]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binominset.C
Strip out redundant #includes
[lyx.git] / src / mathed / math_binominset.C
1 /**
2  * \file math_binominset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_binominset.h"
14 #include "math_support.h"
15 #include "math_mathmlstream.h"
16
17
18 using std::max;
19 using std::auto_ptr;
20
21
22 MathBinomInset::MathBinomInset(bool choose)
23         : choose_(choose)
24 {}
25
26
27 auto_ptr<InsetBase> MathBinomInset::clone() const
28 {
29         return auto_ptr<InsetBase>(new MathBinomInset(*this));
30 }
31
32
33 int MathBinomInset::dw() const
34 {
35         int w = dim_.height() / 5;
36         if (w > 15)
37                 w = 15;
38         if (w < 6)
39                 w = 6;
40         return w;
41 }
42
43
44 void MathBinomInset::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         ScriptChanger dummy(mi.base);
47         cell(0).metrics(mi);
48         cell(1).metrics(mi);
49         dim_.asc = cell(0).height() + 4 + 5;
50         dim_.des = cell(1).height() + 4 - 5;
51         dim_.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
52         dim = dim_;
53 }
54
55
56 void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
57 {
58         int m = x + dim_.width() / 2;
59         ScriptChanger dummy(pi.base);
60         cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
61         cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 3 - 5);
62         mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), "(");
63         mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
64                 dw(), dim_.height(), ")");
65 }
66
67
68 void MathBinomInset::write(WriteStream & os) const
69 {
70         if (choose_)
71                 os << '{' << cell(0) << " \\choose " << cell(1) << '}';
72         else
73                 os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
74 }
75
76
77 void MathBinomInset::normalize(NormalStream & os) const
78 {
79         os << "[binom " << cell(0) << ' ' << cell(1) << ']';
80 }