]> git.lyx.org Git - lyx.git/blob - src/mathed/math_makeboxinset.C
IU of clone() and getLabelList()
[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 InsetBase * MathMakeboxInset::clone() const
21 {
22         return new MathMakeboxInset(*this);
23 }
24
25
26 void MathMakeboxInset::metrics(MetricsInfo & mi, Dimension & dim) 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         metricsMarkers();
36         dim = dim_;
37 }
38
39
40 void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
41 {
42         FontSetChanger dummy(pi.base, "textnormal");
43         drawMarkers(pi, x, y);
44
45         drawStrBlack(pi, x, y, "[");
46         x += w_;
47         cell(0).draw(pi, x, y);
48         x += cell(0).width();
49         drawStrBlack(pi, x, y, "]");
50         x += w_ + 2;
51
52         drawStrBlack(pi, x, y, "[");
53         x += w_;
54         cell(1).draw(pi, x, y);
55         x += cell(1).width();
56         drawStrBlack(pi, x, y, "]");
57         x += w_ + 2;
58
59         cell(2).draw(pi, x, y);
60 }
61
62
63 void MathMakeboxInset::write(WriteStream & os) const
64 {
65         os << "\\makebox";
66         os << '[' << cell(0) << ']';
67         if (cell(1).size())
68                 os << '[' << cell(1) << ']';
69         os << '{' << cell(2) << '}';
70 }
71
72
73 void MathMakeboxInset::normalize(NormalStream & os) const
74 {
75         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
76 }