]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stackrelinset.C
further code uglification to make Jean-Marc's compiler happy
[lyx.git] / src / mathed / math_stackrelinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_stackrelinset.h"
6 #include "mathed/support.h"
7 #include "support/LOstream.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(MathStyles st) const
21 {
22         size_    = smallerStyleFrac(st);
23         xcell(0).metrics(size_);
24         xcell(1).metrics(st);
25         width_   = std::max(xcell(0).width(), xcell(1).width()) + 4; 
26         ascent_  = xcell(1).ascent() + xcell(0).height() + 4;
27         descent_ = xcell(1).descent();
28 }
29
30
31 void MathStackrelInset::draw(Painter & pain, int x, int y) const
32 {
33         xo(x);
34         yo(y);
35         int m = x + width() / 2;
36         xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).height() - 4);
37         xcell(1).draw(pain, m - xcell(1).width() / 2, y);
38 }
39
40
41 void MathStackrelInset::write(std::ostream & os, bool fragile) const
42 {
43         os << "\\stackrel{";
44         cell(0).write(os, fragile);
45         os << "}{";
46         cell(1).write(os, fragile);
47         os << '}';
48 }
49
50
51 void MathStackrelInset::writeNormal(std::ostream & os) const
52 {
53         os << "[stackrel ";
54         cell(0).writeNormal(os);
55         os << " ";
56         cell(1).writeNormal(os);
57         os << "] ";
58 }