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"
15 #include "LaTeXFeatures.h"
17 #include "MathStream.h"
19 #include "FuncRequest.h"
20 #include "FuncStatus.h"
21 #include "support/gettext.h"
23 #include "support/lstrings.h"
31 using support::bformat;
34 InsetMathSubstack::InsetMathSubstack(Buffer * buf)
35 : InsetMathGrid(buf, 1, 1)
39 Inset * InsetMathSubstack::clone() const
41 return new InsetMathSubstack(*this);
45 void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const
47 if (mi.base.style == LM_ST_DISPLAY) {
48 StyleChanger dummy(mi.base, LM_ST_TEXT);
49 InsetMathGrid::metrics(mi, dim);
51 InsetMathGrid::metrics(mi, dim);
56 void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
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_INSET_MODIFY: {
67 istringstream is(to_utf8(cmd.argument()));
73 string const name = "substack";
74 if (s == "add-vline-left" || s == "add-vline-right") {
76 from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
78 flag.setEnabled(false);
81 // in contrary to \subaray, the columns in \substack
82 // are always centered and this cannot be changed
83 if (s == "align-left" || s == "align-right") {
85 from_utf8(N_("Can't change horizontal alignment in '%1$s'")),
87 flag.setEnabled(false);
96 return InsetMathGrid::getStatus(cur, cmd, flag);
100 void InsetMathSubstack::infoize(odocstream & os) const
106 void InsetMathSubstack::write(WriteStream & os) const
108 MathEnsurer ensurer(os);
110 InsetMathGrid::write(os);
115 void InsetMathSubstack::normalize(NormalStream & os) const
118 InsetMathGrid::normalize(os);
123 void InsetMathSubstack::maple(MapleStream & os) const
126 InsetMathGrid::maple(os);
131 void InsetMathSubstack::htmlize(HtmlStream & os) const
133 os << MTag("span", "class='substack'");
134 for (row_type row = 0; row < nrows(); ++row)
135 os << MTag("span") << cell(index(row, 0)) << ETag("span");
140 void InsetMathSubstack::validate(LaTeXFeatures & features) const
142 if (features.runparams().isLaTeX())
143 features.require("amsmath");
144 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
145 features.addPreambleSnippet("<style type=\"text/css\">\n"
146 "span.substack{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
147 "span.substack span{display: block;}\n"
150 InsetMathGrid::validate(features);