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(WriteStream & os) const
102 MathEnsurer ensurer(os);
104 bool open = os.startOuterRow();
105 InsetMathGrid::write(os);
112 void InsetMathSubstack::normalize(NormalStream & os) const
115 InsetMathGrid::normalize(os);
120 void InsetMathSubstack::maple(MapleStream & os) const
123 InsetMathGrid::maple(os);
128 void InsetMathSubstack::mathmlize(MathStream & os) const
131 row_type const numrows = nrows();
132 for (row_type row = 0; row < nrows(); ++row) {
133 if (row < numrows - 1) {
135 os << MTag("munder");
137 os << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
139 for (int i = 1; i <= movers; ++i)
140 os << ETag("munder");
144 void InsetMathSubstack::htmlize(HtmlStream & os) const
146 os << MTag("span", "class='substack'");
147 for (row_type row = 0; row < nrows(); ++row)
148 os << MTag("span") << cell(index(row, 0)) << ETag("span");
153 void InsetMathSubstack::validate(LaTeXFeatures & features) const
155 if (features.runparams().isLaTeX())
156 features.require("amsmath");
157 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
158 features.addCSSSnippet(
159 "span.substack{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
160 "span.substack span{display: block;}");
162 InsetMathGrid::validate(features);