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