2 * \file InsetMathUnderset.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 "InsetMathUnderset.h"
16 #include "MathStream.h"
19 #include "LaTeXFeatures.h"
20 #include "MetricsInfo.h"
27 Inset * InsetMathUnderset::clone() const
29 return new InsetMathUnderset(*this);
33 void InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & dim) const
35 Changer dummy2 = mi.base.changeEnsureMath();
37 cell(0).metrics(mi, dim0);
38 Changer dummy = mi.base.changeFrac();
40 cell(1).metrics(mi, dim1);
41 dim.wid = max(dim1.width(), dim0.width()) + 4;
42 dim.asc = dim0.ascent();
43 dim.des = dim0.descent() + dim1.height() + 4;
47 void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) const
49 Changer dummy2 = pi.base.changeEnsureMath();
50 Dimension const dim = dimension(*pi.base.bv);
51 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
52 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
53 int m = x + dim.wid / 2;
54 int yo = y + dim0.descent() + dim1.ascent() + 1;
55 cell(0).draw(pi, m - dim0.width() / 2, y);
56 Changer dummy = pi.base.changeFrac();
57 cell(1).draw(pi, m - dim1.width() / 2, yo);
61 void InsetMathUnderset::write(WriteStream & os) const
63 MathEnsurer ensurer(os);
66 os << "\\underset{" << cell(1) << "}{" << cell(0) << '}';
70 void InsetMathUnderset::normalize(NormalStream & os) const
72 os << "[underset " << cell(1) << ' ' << cell(0) << ']';
76 void InsetMathUnderset::mathmlize(MathStream & ms) const
78 ms << "<munder accent='false'>" << cell(0) << cell(1) << "</munder>";
82 void InsetMathUnderset::htmlize(HtmlStream & os) const
84 os << MTag("span", "class='underset'")
85 << MTag("span") << cell(1) << ETag("span")
86 << MTag("span", "class='bottom'") << cell(0) << ETag("span")
91 void InsetMathUnderset::validate(LaTeXFeatures & features) const
93 if (features.runparams().isLaTeX())
94 features.require("amsmath");
95 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
96 features.addCSSSnippet(
97 "span.underset{display: inline-block; vertical-align: top; text-align:center;}\n"
98 "span.underset span {display: block;}\n"
99 "span.bottom{font-size: 66%;}");
101 InsetMathNest::validate(features);