]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binominset.C
use stream-like syntax for LaTeX output
[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(MathMetricsInfo const & st) const
32 {
33         MathMetricsInfo m = st;
34         m.size   = smallerStyleFrac(m.size);
35         xcell(0).metrics(m);
36         xcell(1).metrics(m);
37         ascent_  = xcell(0).height() + 4 + 5;
38         descent_ = xcell(1).height() + 4 - 5; 
39         width_   = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4; 
40 }
41
42
43 void MathBinomInset::draw(Painter & pain, int x, int y) const
44 {
45         xo(x);
46         yo(y);
47         int m = x + width() / 2;
48         xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
49         xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 3 - 5);
50         mathed_draw_deco(pain, x, y - ascent_, dw(), height(), "(");
51         mathed_draw_deco(pain, x + width() - dw(), y - ascent_, dw(), height(), ")");
52 }
53
54
55 void MathBinomInset::write(MathWriteInfo & os) const
56 {
57         os << '{' << cell(0) << " \\choose " << cell(1) << '}';
58 }
59
60
61 void MathBinomInset::writeNormal(std::ostream & os) const
62 {
63         os << "[binom ";
64         cell(0).writeNormal(os);
65         os << " ";
66         cell(1).writeNormal(os);
67         os << "] ";
68 }