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"
15 #include "MathStream.h"
18 #include "LaTeXFeatures.h"
23 Inset * InsetMathOverset::clone() const
25 return new InsetMathOverset(*this);
29 void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const
32 cell(1).metrics(mi, dim1);
33 FracChanger dummy(mi.base);
35 cell(0).metrics(mi, dim0);
36 dim.wid = std::max(dim0.width(), dim1.wid) + 4;
37 dim.asc = dim1.asc + dim0.height() + 4;
40 // Cache the inset dimension.
45 void InsetMathOverset::draw(PainterInfo & pi, int x, int y) const
47 Dimension const dim = dimension(*pi.base.bv);
48 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
49 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
50 int m = x + dim.wid / 2;
51 int yo = y - dim1.asc - dim0.des - 1;
52 cell(1).draw(pi, m - dim1.wid / 2, y);
53 FracChanger dummy(pi.base);
54 cell(0).draw(pi, m - dim0.width() / 2, yo);
55 drawMarkers(pi, x, y);
59 bool InsetMathOverset::idxFirst(Cursor & cur) const
67 bool InsetMathOverset::idxLast(Cursor & cur) const
70 cur.pos() = cur.lastpos();
75 void InsetMathOverset::write(WriteStream & os) const
77 os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
81 void InsetMathOverset::normalize(NormalStream & os) const
83 os << "[overset " << cell(0) << ' ' << cell(1) << ']';
87 void InsetMathOverset::validate(LaTeXFeatures & features) const
89 features.require("amsmath");
90 InsetMathNest::validate(features);