]> git.lyx.org Git - lyx.git/blob - src/mathed/math_dfracinset.C
Make Helge happy: no more crash on arrow up/down in math macro
[lyx.git] / src / mathed / math_dfracinset.C
1 /**
2  * \file math_dfracinset.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 "math_dfracinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "LaTeXFeatures.h"
17 #include "LColor.h"
18 #include "frontends/Painter.h"
19
20
21 using std::string;
22 using std::max;
23 using std::auto_ptr;
24
25
26 MathDfracInset::MathDfracInset()
27         : MathFracInset(false)
28 {}
29
30
31 auto_ptr<InsetBase> MathDfracInset::doClone() const
32 {
33         return auto_ptr<InsetBase>(new MathDfracInset(*this));
34 }
35
36
37 void MathDfracInset::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         cell(0).metrics(mi);
40         cell(1).metrics(mi);
41         dim_.wid = max(cell(0).width(), cell(1).width()) + 2;
42         dim_.asc = cell(0).height() + 2 + 5;
43         dim_.des = cell(1).height() + 2 - 5;
44         dim = dim_;
45 }
46
47
48 void MathDfracInset::draw(PainterInfo & pi, int x, int y) const
49 {
50         int m = x + dim_.wid / 2;
51         cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
52         cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 2 - 5);
53         pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math);
54         setPosCache(pi, x, y);
55 }
56
57
58 string MathDfracInset::name() const
59 {
60         return "dfrac";
61 }
62
63
64 void MathDfracInset::mathmlize(MathMLStream & os) const
65 {
66         os << MTag("mdfrac") << cell(0) << cell(1) << ETag("mdfrac");
67 }
68
69
70 void MathDfracInset::validate(LaTeXFeatures & features) const
71 {
72         features.require("amsmath");
73         MathNestInset::validate(features);
74 }