]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathDFrac.C
Fix comment according to Enricos explanation
[lyx.git] / src / mathed / InsetMathDFrac.C
1 /**
2  * \file InsetMathDFrac.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathDFrac.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "LaTeXFeatures.h"
17 #include "LColor.h"
18 #include "frontends/Painter.h"
19
20
21 namespace lyx {
22
23
24 using std::string;
25 using std::max;
26 using std::auto_ptr;
27
28
29 InsetMathDFrac::InsetMathDFrac()
30         : InsetMathFrac()
31 {}
32
33
34 auto_ptr<InsetBase> InsetMathDFrac::doClone() const
35 {
36         return auto_ptr<InsetBase>(new InsetMathDFrac(*this));
37 }
38
39
40 void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
41 {
42         cell(0).metrics(mi);
43         cell(1).metrics(mi);
44         dim_.wid = max(cell(0).width(), cell(1).width()) + 2;
45         dim_.asc = cell(0).height() + 2 + 5;
46         dim_.des = cell(1).height() + 2 - 5;
47         dim = dim_;
48 }
49
50
51 void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
52 {
53         int m = x + dim_.wid / 2;
54         cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
55         cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 2 - 5);
56         pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math);
57         setPosCache(pi, x, y);
58 }
59
60
61 docstring InsetMathDFrac::name() const
62 {
63         return from_ascii("dfrac");
64 }
65
66
67 void InsetMathDFrac::mathmlize(MathStream & os) const
68 {
69         os << MTag("mdfrac") << cell(0) << cell(1) << ETag("mdfrac");
70 }
71
72
73 void InsetMathDFrac::validate(LaTeXFeatures & features) const
74 {
75         features.require("amsmath");
76         InsetMathNest::validate(features);
77 }
78
79
80 } // namespace lyx