]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binominset.C
further code uglification to make Jean-Marc's compiler happy
[lyx.git] / src / mathed / math_binominset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_binominset.h"
6 #include "support.h"
7 #include "support/LOstream.h"
8
9
10 MathBinomInset::MathBinomInset()
11 {}
12
13
14 MathInset * MathBinomInset::clone() const
15 {   
16         return new MathBinomInset(*this);
17 }
18
19
20 int MathBinomInset::dw() const
21 {
22         int w = height()/5;
23         if (w > 15)
24                 w = 15;
25         if (w < 6)
26                 w = 6;
27         return w;
28 }
29
30
31 void MathBinomInset::metrics(MathStyles st) const
32 {
33         size_    = smallerStyleFrac(st);
34         xcell(0).metrics(size_);
35         xcell(1).metrics(size_);
36         ascent_  = xcell(0).height() + 4 + 5;
37         descent_ = xcell(1).height() + 4 - 5; 
38         width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
39 }
40
41
42 void MathBinomInset::draw(Painter & pain, int x, int y) const
43 {
44         xo(x);
45         yo(y);
46         int m = x + width() / 2;
47         xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
48         xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 3 - 5);
49         mathed_draw_deco(pain, x, y - ascent_, dw(), height(), "(");
50         mathed_draw_deco(pain, x + width() - dw(), y - ascent_, dw(), height(), ")");
51 }
52
53
54 void MathBinomInset::write(std::ostream & os, bool fragile) const
55 {
56         os << '{';
57         cell(0).write(os, fragile);
58         os << " \\choose ";
59         cell(1).write(os, fragile);
60         os << '}';
61 }
62
63
64 void MathBinomInset::writeNormal(std::ostream & os) const
65 {
66         os << "[binom ";
67         cell(0).writeNormal(os);
68         os << " ";
69         cell(1).writeNormal(os);
70         os << "] ";
71 }