]> git.lyx.org Git - lyx.git/blob - src/mathed/math_braceinset.C
Fix event loop to no longer eat CPU
[lyx.git] / src / mathed / math_braceinset.C
1 /**
2  * \file math_braceinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_braceinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_support.h"
17 #include "LColor.h"
18 #include "support/std_ostream.h"
19 #include "frontends/Painter.h"
20
21 using std::max;
22 using std::auto_ptr;
23
24
25 MathBraceInset::MathBraceInset()
26         : MathNestInset(1)
27 {}
28
29
30 MathBraceInset::MathBraceInset(MathArray const & ar)
31         : MathNestInset(1)
32 {
33         cell(0) = ar;
34 }
35
36
37 auto_ptr<InsetBase> MathBraceInset::doClone() const
38 {
39         return auto_ptr<InsetBase>(new MathBraceInset(*this));
40 }
41
42
43 void MathBraceInset::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         cell(0).metrics(mi);
46         Dimension t;
47         mathed_char_dim(mi.base.font, '{', t);
48         dim.asc = max(cell(0).ascent(), t.asc);
49         dim.des = max(cell(0).descent(), t.des);
50         dim.wid = cell(0).width() + 2 * t.wid;
51         metricsMarkers(dim);
52         dim_ = dim;
53 }
54
55
56 void MathBraceInset::draw(PainterInfo & pi, int x, int y) const
57 {
58         LyXFont font = pi.base.font;
59         font.setColor(LColor::latex);
60         Dimension t;
61         mathed_char_dim(font, '{', t);
62         pi.pain.text(x, y, '{', font);
63         cell(0).draw(pi, x + t.wid, y);
64         pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
65         drawMarkers(pi, x, y);
66 }
67
68
69 void MathBraceInset::write(WriteStream & os) const
70 {
71         os << '{' << cell(0) << '}';
72 }
73
74
75 void MathBraceInset::normalize(NormalStream & os) const
76 {
77         os << "[block " << cell(0) << ']';
78 }
79
80
81 void MathBraceInset::maple(MapleStream & os) const
82 {
83         os << cell(0);
84 }
85
86
87 void MathBraceInset::octave(OctaveStream & os) const
88 {
89         os << cell(0);
90 }
91
92
93 void MathBraceInset::mathmlize(MathMLStream & os) const
94 {
95         os << MTag("mrow") << cell(0) << ETag("mrow");
96 }
97
98
99 void MathBraceInset::mathematica(MathematicaStream & os) const
100 {
101         os << cell(0);
102 }
103
104
105 void MathBraceInset::infoize(std::ostream & os) const
106 {
107         os << "Nested Block: ";
108 }