]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stackrelinset.C
small up/down tweaking
[lyx.git] / src / mathed / math_stackrelinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_stackrelinset.h"
6 #include "math_mathmlstream.h"
7 #include "math_support.h"
8
9
10 using std::max;
11
12
13 MathStackrelInset::MathStackrelInset()
14 {}
15
16
17 MathInset * MathStackrelInset::clone() const
18 {
19         return new MathStackrelInset(*this);
20 }
21
22
23 void MathStackrelInset::metrics(MathMetricsInfo & mi) const
24 {
25         cell(1).metrics(mi);
26         MathFracChanger dummy(mi.base);
27         cell(0).metrics(mi);
28         dim_.w = max(cell(0).width(), cell(1).width()) + 4;
29         dim_.a = cell(1).ascent() + cell(0).height() + 4;
30         dim_.d = cell(1).descent();
31 }
32
33
34 void MathStackrelInset::draw(MathPainterInfo & pi, int x, int y) const
35 {
36         int m  = x + width() / 2;
37         int yo = y - cell(1).ascent() - cell(0).descent() - 1;
38         cell(1).draw(pi, m - cell(1).width() / 2, y);
39         MathFracChanger dummy(pi.base);
40         cell(0).draw(pi, m - cell(0).width() / 2, yo);
41 }
42
43
44 void MathStackrelInset::write(WriteStream & os) const
45 {
46         os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
47 }
48
49
50 void MathStackrelInset::normalize(NormalStream & os) const
51 {
52         os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
53 }