2 * \file math_splitinset.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 "math_splitinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.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 MathSplitInset::MathSplitInset(string const & name)
34 : MathGridInset(1, 1), name_(name)
40 auto_ptr<InsetBase> MathSplitInset::doClone() const
42 return auto_ptr<InsetBase>(new MathSplitInset(*this));
46 char MathSplitInset::defaultColAlign(col_type col)
50 if (name_ == "gathered")
52 if (name_ == "aligned")
53 return (col & 1) ? 'l' : 'r';
54 if (name_ == "alignedat")
55 return (col & 1) ? 'l' : 'r';
60 void MathSplitInset::draw(PainterInfo & pi, int x, int y) const
62 MathGridInset::draw(pi, x, y);
63 setPosCache(pi, x, y);
67 bool MathSplitInset::getStatus(LCursor & cur, FuncRequest const & cmd,
68 FuncStatus & flag) const
71 case LFUN_TABULAR_FEATURE: {
72 docstring const & s = cmd.argument();
73 if (s == "add-vline-left" || s == "add-vline-right") {
75 N_("Can't add vertical grid lines in '%1$s'"),
80 return MathGridInset::getStatus(cur, cmd, flag);
83 return MathGridInset::getStatus(cur, cmd, flag);
88 void MathSplitInset::write(WriteStream & ws) const
92 ws << "\\begin{" << name_ << '}';
93 if (name_ == "alignedat")
94 ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
95 MathGridInset::write(ws);
98 ws << "\\end{" << name_ << "}\n";
102 void MathSplitInset::infoize(std::ostream & os) const
105 name[0] = lyx::support::uppercase(name[0]);
110 void MathSplitInset::validate(LaTeXFeatures & features) const
112 features.require("amsmath");
113 MathNestInset::validate(features);