]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stackrelinset.C
use stream-like syntax for LaTeX output
[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(MathMetricsInfo const & st) const
21 {
22         size_    = st;
23         size_.size = smallerStyleFrac(size_.size);
24         xcell(0).metrics(size_);
25         xcell(1).metrics(st);
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         xo(x);
35         yo(y);
36         int m = x + width() / 2;
37         xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).height() - 4);
38         xcell(1).draw(pain, m - xcell(1).width() / 2, y);
39 }
40
41
42 void MathStackrelInset::write(MathWriteInfo & os) const
43 {
44         os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
45 }
46
47
48 void MathStackrelInset::writeNormal(std::ostream & os) const
49 {
50         os << "[stackrel ";
51         cell(0).writeNormal(os);
52         os << " ";
53         cell(1).writeNormal(os);
54         os << "] ";
55 }