2 * \file InsetMathStackrel.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 "InsetMathStackrel.h"
15 #include "LaTeXFeatures.h"
17 #include "MathStream.h"
23 InsetMathStackrel::InsetMathStackrel(Buffer * buf) : InsetMathFracBase(buf)
27 Inset * InsetMathStackrel::clone() const
29 return new InsetMathStackrel(*this);
33 void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const
36 cell(1).metrics(mi, dim1);
37 FracChanger dummy(mi.base);
39 cell(0).metrics(mi, dim0);
40 dim.wid = max(dim0.width(), dim1.width()) + 4;
41 dim.asc = dim1.ascent() + dim0.height() + 4;
42 dim.des = dim1.descent();
47 void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) const
49 Dimension const dim = dimension(*pi.base.bv);
50 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
51 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
52 int m = x + dim.width() / 2;
53 int yo = y - dim1.ascent() - dim0.descent() - 1;
54 cell(1).draw(pi, m - dim1.width() / 2, y);
55 FracChanger dummy(pi.base);
56 cell(0).draw(pi, m - dim0.width() / 2, yo);
57 drawMarkers(pi, x, y);
61 void InsetMathStackrel::write(WriteStream & os) const
63 MathEnsurer ensurer(os);
64 os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
68 void InsetMathStackrel::normalize(NormalStream & os) const
70 os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
74 void InsetMathStackrel::mathmlize(MathStream & ms) const
76 ms << "<mover accent='false'>" << cell(1) << cell(0) << "</mover>";
80 void InsetMathStackrel::htmlize(HtmlStream & os) const
82 // at the moment, this is exactly the same as overset
83 os << MTag("span", "class='overset'")
84 << MTag("span", "class='top'") << cell(0) << ETag("span")
85 << MTag("span") << cell(1) << ETag("span")
90 void InsetMathStackrel::validate(LaTeXFeatures & features) const
93 if (features.runparams().math_flavor == OutputParams::MathAsHTML)
94 features.addCSSSnippet(
95 "span.overset{display: inline-block; vertical-align: bottom; text-align:center;}\n"
96 "span.overset span {display: block;}\n"
97 "span.top{font-size: 66%;}");
99 InsetMathNest::validate(features);