]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stackrelinset.C
enable direct input of #1...#9; some whitespace changes
[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 MathStackrelInset::MathStackrelInset()
11 {}
12
13
14 MathInset * MathStackrelInset::clone() const
15 {   
16         return new MathStackrelInset(*this);
17 }
18
19
20 void MathStackrelInset::metrics(MathMetricsInfo const & mi) const
21 {
22         MathMetricsInfo m = mi;
23         smallerStyleFrac(m);
24         xcell(0).metrics(m);
25         xcell(1).metrics(mi);
26         width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
27         ascent_  = xcell(1).ascent() + xcell(0).height() + 4;
28         descent_ = xcell(1).descent();
29 }
30
31
32 void MathStackrelInset::draw(Painter & pain, int x, int y) const
33 {
34         int m  = x + width() / 2;
35         int yo = y - xcell(1).ascent() - xcell(0).descent() - 1;
36         xcell(0).draw(pain, m - xcell(0).width() / 2, yo);
37         xcell(1).draw(pain, m - xcell(1).width() / 2, y);
38 }
39
40
41 void MathStackrelInset::write(WriteStream & os) const
42 {
43         os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
44 }
45
46
47 void MathStackrelInset::normalize(NormalStream & os) const
48 {
49         os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
50 }