]> git.lyx.org Git - lyx.git/blob - src/mathed/math_makeboxinset.C
Fix event loop to no longer eat CPU
[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 #include "support/std_ostream.h"
19
20 using std::auto_ptr;
21
22
23 MathMakeboxInset::MathMakeboxInset()
24         : MathNestInset(3)
25 {}
26
27
28 auto_ptr<InsetBase> MathMakeboxInset::doClone() const
29 {
30         return auto_ptr<InsetBase>(new MathMakeboxInset(*this));
31 }
32
33
34 void MathMakeboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
35 {
36         FontSetChanger dummy(mi.base, "textnormal");
37         w_ = mathed_char_width(mi.base.font, '[');
38         MathNestInset::metrics(mi);
39         dim   = cell(0).dim();
40         dim  += cell(1).dim();
41         dim  += cell(2).dim();
42         dim.wid += 4 * w_ + 4;
43         metricsMarkers(dim);
44         dim_ = dim;
45 }
46
47
48 void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
49 {
50         FontSetChanger dummy(pi.base, "textnormal");
51         drawMarkers(pi, x, y);
52
53         drawStrBlack(pi, x, y, "[");
54         x += w_;
55         cell(0).draw(pi, x, y);
56         x += cell(0).width();
57         drawStrBlack(pi, x, y, "]");
58         x += w_ + 2;
59
60         drawStrBlack(pi, x, y, "[");
61         x += w_;
62         cell(1).draw(pi, x, y);
63         x += cell(1).width();
64         drawStrBlack(pi, x, y, "]");
65         x += w_ + 2;
66
67         cell(2).draw(pi, x, y);
68         setPosCache(pi, x, y);
69 }
70
71
72 void MathMakeboxInset::write(WriteStream & os) const
73 {
74         os << "\\makebox";
75         os << '[' << cell(0) << ']';
76         if (cell(1).size())
77                 os << '[' << cell(1) << ']';
78         os << '{' << cell(2) << '}';
79 }
80
81
82 void MathMakeboxInset::normalize(NormalStream & os) const
83 {
84         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
85 }
86
87
88 void MathMakeboxInset::infoize(std::ostream & os) const
89 {
90         os << "Makebox (width: " << cell(0)
91             << " pos: " << cell(1) << ")";
92 }