]> git.lyx.org Git - lyx.git/blob - src/mathed/math_makeboxinset.C
architectural changes to tex2lyx
[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 using std::auto_ptr;
14
15
16 MathMakeboxInset::MathMakeboxInset()
17         : MathNestInset(3)
18 {}
19
20
21 auto_ptr<InsetBase> MathMakeboxInset::clone() const
22 {
23         return auto_ptr<InsetBase>(new MathMakeboxInset(*this));
24 }
25
26
27 void MathMakeboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
28 {
29         FontSetChanger dummy(mi.base, "textnormal");
30         w_ = mathed_char_width(mi.base.font, '[');
31         MathNestInset::metrics(mi);
32         dim_   = cell(0).dim();
33         dim_  += cell(1).dim();
34         dim_  += cell(2).dim();
35         dim_.wid += 4 * w_ + 4;
36         metricsMarkers();
37         dim = dim_;
38 }
39
40
41 void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
42 {
43         FontSetChanger dummy(pi.base, "textnormal");
44         drawMarkers(pi, x, y);
45
46         drawStrBlack(pi, x, y, "[");
47         x += w_;
48         cell(0).draw(pi, x, y);
49         x += cell(0).width();
50         drawStrBlack(pi, x, y, "]");
51         x += w_ + 2;
52
53         drawStrBlack(pi, x, y, "[");
54         x += w_;
55         cell(1).draw(pi, x, y);
56         x += cell(1).width();
57         drawStrBlack(pi, x, y, "]");
58         x += w_ + 2;
59
60         cell(2).draw(pi, x, y);
61 }
62
63
64 void MathMakeboxInset::write(WriteStream & os) const
65 {
66         os << "\\makebox";
67         os << '[' << cell(0) << ']';
68         if (cell(1).size())
69                 os << '[' << cell(1) << ']';
70         os << '{' << cell(2) << '}';
71 }
72
73
74 void MathMakeboxInset::normalize(NormalStream & os) const
75 {
76         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
77 }