]> git.lyx.org Git - lyx.git/blob - src/mathed/math_makeboxinset.C
lyxfont.h no longer #includes LColor.h.
[lyx.git] / src / mathed / math_makeboxinset.C
1 /**
2  * \file math_makeboxinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Ling Li
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_makeboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_support.h"
17
18 using std::auto_ptr;
19
20
21 MathMakeboxInset::MathMakeboxInset()
22         : MathNestInset(3)
23 {}
24
25
26 auto_ptr<InsetBase> MathMakeboxInset::clone() const
27 {
28         return auto_ptr<InsetBase>(new MathMakeboxInset(*this));
29 }
30
31
32 void MathMakeboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
33 {
34         FontSetChanger dummy(mi.base, "textnormal");
35         w_ = mathed_char_width(mi.base.font, '[');
36         MathNestInset::metrics(mi);
37         dim_   = cell(0).dim();
38         dim_  += cell(1).dim();
39         dim_  += cell(2).dim();
40         dim_.wid += 4 * w_ + 4;
41         metricsMarkers();
42         dim = dim_;
43 }
44
45
46 void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
47 {
48         FontSetChanger dummy(pi.base, "textnormal");
49         drawMarkers(pi, x, y);
50
51         drawStrBlack(pi, x, y, "[");
52         x += w_;
53         cell(0).draw(pi, x, y);
54         x += cell(0).width();
55         drawStrBlack(pi, x, y, "]");
56         x += w_ + 2;
57
58         drawStrBlack(pi, x, y, "[");
59         x += w_;
60         cell(1).draw(pi, x, y);
61         x += cell(1).width();
62         drawStrBlack(pi, x, y, "]");
63         x += w_ + 2;
64
65         cell(2).draw(pi, x, y);
66 }
67
68
69 void MathMakeboxInset::write(WriteStream & os) const
70 {
71         os << "\\makebox";
72         os << '[' << cell(0) << ']';
73         if (cell(1).size())
74                 os << '[' << cell(1) << ']';
75         os << '{' << cell(2) << '}';
76 }
77
78
79 void MathMakeboxInset::normalize(NormalStream & os) const
80 {
81         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
82 }