2 * \file InsetMathSubstack.cpp
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 "InsetMathSubstack.h"
16 #include "MathStream.h"
18 #include "FuncRequest.h"
19 #include "FuncStatus.h"
20 #include "LaTeXFeatures.h"
21 #include "MetricsInfo.h"
23 #include "support/gettext.h"
24 #include "support/lstrings.h"
32 using support::bformat;
35 InsetMathSubstack::InsetMathSubstack(Buffer * buf)
36 : InsetMathGrid(buf, 1, 1)
40 Inset * InsetMathSubstack::clone() const
42 return new InsetMathSubstack(*this);
46 void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const
48 Changer dummy2 = mi.base.changeEnsureMath();
49 Changer dummy = mi.base.changeArray();
50 InsetMathGrid::metrics(mi, dim);
54 void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
56 Changer dummy2 = pi.base.changeEnsureMath();
57 Changer dummy = pi.base.changeArray();
58 InsetMathGrid::draw(pi, x + 1, y);
62 bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
63 FuncStatus & flag) const
65 switch (cmd.action()) {
66 case LFUN_TABULAR_FEATURE: {
67 string s = cmd.getArg(0);
68 if (s == "add-vline-left" || s == "add-vline-right") {
70 from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
71 from_utf8("substack")));
72 flag.setEnabled(false);
75 // in contrary to \subarray, the columns in \substack
76 // are always centered and this cannot be changed
77 if (s == "align-left" || s == "align-right") {
79 from_utf8(N_("Can't change horizontal alignment in '%1$s'")),
80 from_utf8("substack")));
81 flag.setEnabled(false);
90 return InsetMathGrid::getStatus(cur, cmd, flag);
94 void InsetMathSubstack::infoize(odocstream & os) const
100 void InsetMathSubstack::write(TeXMathStream & os) const
102 MathEnsurer ensurer(os);
106 bool open = os.startOuterRow();
107 InsetMathGrid::write(os);
114 void InsetMathSubstack::normalize(NormalStream & os) const
117 InsetMathGrid::normalize(os);
122 void InsetMathSubstack::maple(MapleStream & os) const
125 InsetMathGrid::maple(os);
130 void InsetMathSubstack::mathmlize(MathMLStream & ms) const
133 row_type const numrows = nrows();
134 for (row_type row = 0; row < nrows(); ++row) {
135 if (row < numrows - 1) {
137 ms << MTag("munder");
139 ms << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
141 for (int i = 1; i <= movers; ++i)
142 ms << ETag("munder");
146 void InsetMathSubstack::htmlize(HtmlStream & os) const
148 os << MTag("span", "class='substack'");
149 for (row_type row = 0; row < nrows(); ++row)
150 os << MTag("span") << cell(index(row, 0)) << ETag("span");
155 void InsetMathSubstack::validate(LaTeXFeatures & features) const
157 if (features.runparams().isLaTeX())
158 features.require("amsmath");
159 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
160 features.addCSSSnippet(
161 "span.substack{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
162 "span.substack span{display: block;}");
164 InsetMathGrid::validate(features);