2 * \file InsetMathOverset.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 "InsetMathOverset.h"
16 #include "MathStream.h"
19 #include "LaTeXFeatures.h"
20 #include "MetricsInfo.h"
26 Inset * InsetMathOverset::clone() const
28 return new InsetMathOverset(*this);
32 void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const
34 Changer dummy2 = mi.base.changeEnsureMath();
36 cell(1).metrics(mi, dim1);
37 Changer dummy = mi.base.changeScript();
39 cell(0).metrics(mi, dim0);
40 dim.wid = max(dim0.width(), dim1.wid) + 4;
41 dim.asc = dim1.asc + dim0.height() + 4;
46 void InsetMathOverset::draw(PainterInfo & pi, int x, int y) const
48 Changer dummy2 = pi.base.changeEnsureMath();
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.wid / 2;
53 int yo = y - dim1.asc - dim0.des - 1;
54 cell(1).draw(pi, m - dim1.wid / 2, y);
55 Changer dummy = pi.base.changeScript();
56 cell(0).draw(pi, m - dim0.width() / 2, yo);
60 bool InsetMathOverset::idxFirst(Cursor & cur) const
68 bool InsetMathOverset::idxLast(Cursor & cur) const
71 cur.pos() = cur.lastpos();
76 void InsetMathOverset::write(WriteStream & os) const
78 MathEnsurer ensurer(os);
81 os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
85 void InsetMathOverset::normalize(NormalStream & os) const
87 os << "[overset " << cell(0) << ' ' << cell(1) << ']';
91 void InsetMathOverset::mathmlize(MathStream & ms) const
93 ms << "<mover accent='false'>" << cell(1) << cell(0) << "</mover>";
97 void InsetMathOverset::htmlize(HtmlStream & os) const
99 os << MTag("span", "class='overset'")
100 << MTag("span", "class='top'") << cell(0) << ETag("span")
101 << MTag("span") << cell(1) << ETag("span")
106 void InsetMathOverset::validate(LaTeXFeatures & features) const
108 if (features.runparams().isLaTeX())
109 features.require("amsmath");
110 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
111 features.addCSSSnippet(
112 "span.overset{display: inline-block; vertical-align: bottom; text-align:center;}\n"
113 "span.overset span {display: block;}\n"
114 "span.top{font-size: 66%;}");
116 InsetMathNest::validate(features);