]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binominset.C
don't #include too much stuff in .h
[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 #include "math_mathmlstream.h"
9
10
11 MathBinomInset::MathBinomInset()
12 {}
13
14
15 MathInset * MathBinomInset::clone() const
16 {   
17         return new MathBinomInset(*this);
18 }
19
20
21 int MathBinomInset::dw() const
22 {
23         int w = height()/5;
24         if (w > 15)
25                 w = 15;
26         if (w < 6)
27                 w = 6;
28         return w;
29 }
30
31
32 void MathBinomInset::metrics(MathMetricsInfo const & st) const
33 {
34         MathMetricsInfo mi = st;
35         smallerStyleFrac(mi);
36         xcell(0).metrics(mi);
37         xcell(1).metrics(mi);
38         ascent_  = xcell(0).height() + 4 + 5;
39         descent_ = xcell(1).height() + 4 - 5; 
40         width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
41 }
42
43
44 void MathBinomInset::draw(Painter & pain, int x, int y) const
45 {
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(MathWriteInfo & os) const
55 {
56         os << '{' << cell(0) << " \\choose " << cell(1) << '}';
57 }
58
59
60 void MathBinomInset::writeNormal(NormalStream & os) const
61 {
62         os << "[binom ";
63         cell(0).writeNormal(os);
64         os << " ";
65         cell(1).writeNormal(os);
66         os << "] ";
67 }