]> git.lyx.org Git - lyx.git/blob - src/mathed/math_undersetinset.C
introduce namespace lyx::support
[lyx.git] / src / mathed / math_undersetinset.C
1
2 #include "math_undersetinset.h"
3 #include "math_mathmlstream.h"
4 #include "math_support.h"
5
6
7 using std::max;
8
9
10 MathUndersetInset::MathUndersetInset()
11 {}
12
13
14 InsetBase * MathUndersetInset::clone() const
15 {
16         return new MathUndersetInset(*this);
17 }
18
19
20 void MathUndersetInset::metrics(MetricsInfo & mi, Dimension & dim) const
21 {
22         cell(1).metrics(mi);
23         FracChanger dummy(mi.base);
24         cell(0).metrics(mi);
25         dim_.wid = max(cell(0).width(), cell(1).width()) + 4;
26         dim_.asc = cell(1).ascent();
27         dim_.des = cell(1).descent() + cell(0).height() + 4;
28         dim = dim_;
29 }
30
31
32 void MathUndersetInset::draw(PainterInfo & pi, int x, int y) const
33 {
34         int m  = x + pi.width / 2;
35         int yo = y + cell(1).descent() + cell(0).ascent() + 1;
36         cell(1).draw(pi, m - cell(1).width() / 2, y);
37         FracChanger dummy(pi.base);
38         cell(0).draw(pi, m - cell(0).width() / 2, yo);
39 }
40
41
42 void MathUndersetInset::write(WriteStream & os) const
43 {
44         os << "\\underset{" << cell(0) << "}{" << cell(1) << '}';
45 }
46
47
48 void MathUndersetInset::normalize(NormalStream & os) const
49 {
50         os << "[underset " << cell(0) << ' ' << cell(1) << ']';
51 }