2 * \file InsetMathDFrac.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 "InsetMathDFrac.h"
15 #include "MathStream.h"
16 #include "LaTeXFeatures.h"
17 #include "frontends/Painter.h"
22 InsetMathDFrac::InsetMathDFrac()
27 Inset * InsetMathDFrac::clone() const
29 return new InsetMathDFrac(*this);
33 void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
36 cell(0).metrics(mi, dim0);
37 cell(1).metrics(mi, dim1);
38 dim.wid = std::max(dim0.wid, dim1.wid) + 2;
39 dim.asc = dim0.height() + 2 + 5;
40 dim.des = dim1.height() + 2 - 5;
41 // Cache the inset dimension.
46 void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
48 Dimension const dim = dimension(*pi.base.bv);
49 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
50 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
51 int m = x + dim.wid / 2;
52 cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
53 cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
54 pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
55 setPosCache(pi, x, y);
59 docstring InsetMathDFrac::name() const
61 return from_ascii("dfrac");
65 void InsetMathDFrac::mathmlize(MathStream & os) const
67 os << MTag("mdfrac") << cell(0) << cell(1) << ETag("mdfrac");
71 void InsetMathDFrac::validate(LaTeXFeatures & features) const
73 features.require("amsmath");
74 InsetMathNest::validate(features);