2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathSplit.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathSplit.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathStream.h"
|
2001-09-05 12:57:13 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "FuncRequest.h"
|
2005-04-03 12:07:49 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2006-04-13 10:31:32 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2005-04-03 12:07:49 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
|
|
|
|
|
#include <ostream>
|
2005-04-03 12:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::bformat;
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2001-09-05 12:57:13 +00:00
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
InsetMathSplit::InsetMathSplit(docstring const & name, char valign)
|
|
|
|
|
: InsetMathGrid(1, 1, valign, docstring()), name_(name)
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * InsetMathSplit::clone() const
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
|
return new InsetMathSplit(*this);
|
2001-09-05 12:57:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
char InsetMathSplit::defaultColAlign(col_type col)
|
2002-02-15 14:50:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (name_ == "split")
|
|
|
|
|
return 'l';
|
|
|
|
|
if (name_ == "gathered")
|
|
|
|
|
return 'c';
|
|
|
|
|
if (name_ == "aligned")
|
|
|
|
|
return (col & 1) ? 'l' : 'r';
|
2004-08-14 14:03:42 +00:00
|
|
|
|
if (name_ == "alignedat")
|
|
|
|
|
return (col & 1) ? 'l' : 'r';
|
2002-02-15 14:50:40 +00:00
|
|
|
|
return 'l';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
|
2005-04-04 13:40:27 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::draw(pi, x, y);
|
2005-04-04 13:40:27 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool InsetMathSplit::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2005-04-03 12:07:49 +00:00
|
|
|
|
FuncStatus & flag) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
case LFUN_TABULAR_FEATURE: {
|
2006-09-01 15:41:38 +00:00
|
|
|
|
docstring const & s = cmd.argument();
|
2005-04-03 12:07:49 +00:00
|
|
|
|
if (s == "add-vline-left" || s == "add-vline-right") {
|
|
|
|
|
flag.message(bformat(
|
2006-10-22 10:15:23 +00:00
|
|
|
|
from_utf8(N_("Can't add vertical grid lines in '%1$s'")), name_));
|
2005-04-03 12:07:49 +00:00
|
|
|
|
flag.enabled(false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return InsetMathGrid::getStatus(cur, cmd, flag);
|
2005-04-03 12:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
default:
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return InsetMathGrid::getStatus(cur, cmd, flag);
|
2005-04-03 12:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSplit::write(WriteStream & ws) const
|
2001-09-05 12:57:13 +00:00
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
|
if (ws.fragile())
|
|
|
|
|
ws << "\\protect";
|
2002-11-27 10:30:28 +00:00
|
|
|
|
ws << "\\begin{" << name_ << '}';
|
2006-10-02 20:01:30 +00:00
|
|
|
|
if (name_ != "split" && valign() != 'c')
|
|
|
|
|
ws << '[' << valign() << ']';
|
2005-10-14 10:50:23 +00:00
|
|
|
|
if (name_ == "alignedat")
|
|
|
|
|
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::write(ws);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
if (ws.fragile())
|
|
|
|
|
ws << "\\protect";
|
2002-02-15 14:50:40 +00:00
|
|
|
|
ws << "\\end{" << name_ << "}\n";
|
2001-09-05 12:57:13 +00:00
|
|
|
|
}
|
2005-04-03 12:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathSplit::infoize(odocstream & os) const
|
2005-04-03 12:07:49 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring name = name_;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
name[0] = support::uppercase(name[0]);
|
2005-04-03 12:07:49 +00:00
|
|
|
|
os << name << ' ';
|
|
|
|
|
}
|
2006-04-13 10:31:32 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSplit::validate(LaTeXFeatures & features) const
|
2006-04-13 10:31:32 +00:00
|
|
|
|
{
|
2006-10-03 19:45:43 +00:00
|
|
|
|
if (name_ == "split" || name_ == "gathered" || name_ == "aligned" ||
|
|
|
|
|
name_ == "alignedat")
|
|
|
|
|
features.require("amsmath");
|
|
|
|
|
InsetMathGrid::validate(features);
|
2006-04-13 10:31:32 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|