2 * \file InsetMathSplit.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathSplit.h"
15 #include "MathMLStream.h"
16 #include "MathStream.h"
18 #include "funcrequest.h"
19 #include "FuncStatus.h"
21 #include "LaTeXFeatures.h"
23 #include "support/lstrings.h"
24 #include "support/std_ostream.h"
28 using lyx::support::bformat;
33 InsetMathSplit::InsetMathSplit(string const & name, char valign)
34 : InsetMathGrid(1, 1, valign, string()), name_(name)
39 auto_ptr<InsetBase> InsetMathSplit::doClone() const
41 return auto_ptr<InsetBase>(new InsetMathSplit(*this));
45 char InsetMathSplit::defaultColAlign(col_type col)
49 if (name_ == "gathered")
51 if (name_ == "aligned")
52 return (col & 1) ? 'l' : 'r';
53 if (name_ == "alignedat")
54 return (col & 1) ? 'l' : 'r';
59 void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
61 InsetMathGrid::draw(pi, x, y);
62 setPosCache(pi, x, y);
66 bool InsetMathSplit::getStatus(LCursor & cur, FuncRequest const & cmd,
67 FuncStatus & flag) const
70 case LFUN_TABULAR_FEATURE: {
71 docstring const & s = cmd.argument();
72 if (s == "add-vline-left" || s == "add-vline-right") {
74 lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
75 lyx::from_utf8(name_)));
79 return InsetMathGrid::getStatus(cur, cmd, flag);
82 return InsetMathGrid::getStatus(cur, cmd, flag);
87 void InsetMathSplit::write(WriteStream & ws) const
91 ws << "\\begin{" << name_ << '}';
92 if (name_ != "split" && valign() != 'c')
93 ws << '[' << valign() << ']';
94 if (name_ == "alignedat")
95 ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
96 InsetMathGrid::write(ws);
99 ws << "\\end{" << name_ << "}\n";
103 void InsetMathSplit::infoize(std::ostream & os) const
106 name[0] = lyx::support::uppercase(name[0]);
111 void InsetMathSplit::validate(LaTeXFeatures & features) const
113 if (name_ == "split" || name_ == "gathered" || name_ == "aligned" ||
114 name_ == "alignedat")
115 features.require("amsmath");
116 InsetMathGrid::validate(features);