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.changeFrac();
39 cell(0).metrics(mi, dim0);
40 dim.wid = max(dim0.width(), dim1.wid) + 4;
41 dim.asc = dim1.asc + dim0.height() + 4;
43 metricsMarkers(mi, dim);
47 void InsetMathOverset::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 & dim0 = cell(0).dimension(*pi.base.bv);
52 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
53 int m = x + dim.wid / 2;
54 int yo = y - dim1.asc - dim0.des - 1;
55 cell(1).draw(pi, m - dim1.wid / 2, y);
56 Changer dummy = pi.base.changeFrac();
57 cell(0).draw(pi, m - dim0.width() / 2, yo);
58 drawMarkers(pi, x, y);
62 bool InsetMathOverset::idxFirst(Cursor & cur) const
70 bool InsetMathOverset::idxLast(Cursor & cur) const
73 cur.pos() = cur.lastpos();
78 void InsetMathOverset::write(WriteStream & os) const
80 MathEnsurer ensurer(os);
83 os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
87 void InsetMathOverset::normalize(NormalStream & os) const
89 os << "[overset " << cell(0) << ' ' << cell(1) << ']';
93 void InsetMathOverset::mathmlize(MathStream & ms) const
95 ms << "<mover accent='false'>" << cell(1) << cell(0) << "</mover>";
99 void InsetMathOverset::htmlize(HtmlStream & os) const
101 os << MTag("span", "class='overset'")
102 << MTag("span", "class='top'") << cell(0) << ETag("span")
103 << MTag("span") << cell(1) << ETag("span")
108 void InsetMathOverset::validate(LaTeXFeatures & features) const
110 if (features.runparams().isLaTeX())
111 features.require("amsmath");
112 else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
113 features.addCSSSnippet(
114 "span.overset{display: inline-block; vertical-align: bottom; text-align:center;}\n"
115 "span.overset span {display: block;}\n"
116 "span.top{font-size: 66%;}");
118 InsetMathNest::validate(features);