]> git.lyx.org Git - lyx.git/blob - src/mathed/math_makeboxinset.C
rename the members of Dimension
[lyx.git] / src / mathed / math_makeboxinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_makeboxinset.h"
8 #include "math_support.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "frontends/Painter.h"
12
13
14
15 MathMakeboxInset::MathMakeboxInset()
16         : MathNestInset(3)
17 {}
18
19
20 MathInset * MathMakeboxInset::clone() const
21 {
22         return new MathMakeboxInset(*this);
23 }
24
25
26 void MathMakeboxInset::metrics(MetricsInfo & mi) const
27 {
28         FontSetChanger dummy(mi.base, "textnormal");
29         w_ = mathed_char_width(mi.base.font, '[');
30         MathNestInset::metrics(mi);
31         dim_    = cell(0).dim();
32         dim_   += cell(1).dim();
33         dim_   += cell(2).dim();
34         dim_.wid += 4 * w_ + 4;
35         metricsMarkers2();
36 }
37
38
39 void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
40 {
41         FontSetChanger dummy(pi.base, "textnormal");
42         drawMarkers2(pi, x, y);
43
44         drawStrBlack(pi, x, y, "[");
45         x += w_;
46         cell(0).draw(pi, x, y);
47         x += cell(0).width();
48         drawStrBlack(pi, x, y, "]");
49         x += w_ + 2;
50
51         drawStrBlack(pi, x, y, "[");
52         x += w_;
53         cell(1).draw(pi, x, y);
54         x += cell(1).width();
55         drawStrBlack(pi, x, y, "]");
56         x += w_ + 2;
57
58         cell(2).draw(pi, x, y);
59 }
60
61
62 void MathMakeboxInset::write(WriteStream & os) const
63 {
64         os << "\\makebox";
65         os << '[' << cell(0) << ']';
66         if (cell(1).size())
67                 os << '[' << cell(1) << ']';
68         os << '{' << cell(2) << '}';
69 }
70
71
72 void MathMakeboxInset::normalize(NormalStream & os) const
73 {
74         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
75 }