]> git.lyx.org Git - lyx.git/blob - src/mathed/math_braceinset.C
Make Helge happy: no more crash on arrow up/down in math macro
[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
20 using std::max;
21 using std::auto_ptr;
22
23
24 MathBraceInset::MathBraceInset()
25         : MathNestInset(1)
26 {}
27
28
29 MathBraceInset::MathBraceInset(MathArray const & ar)
30         : MathNestInset(1)
31 {
32         cell(0) = ar;
33 }
34
35
36 auto_ptr<InsetBase> MathBraceInset::doClone() const
37 {
38         return auto_ptr<InsetBase>(new MathBraceInset(*this));
39 }
40
41
42 void MathBraceInset::metrics(MetricsInfo & mi, Dimension & dim) const
43 {
44         cell(0).metrics(mi);
45         Dimension t;
46         mathed_char_dim(mi.base.font, '{', t);
47         dim.asc = max(cell(0).ascent(), t.asc);
48         dim.des = max(cell(0).descent(), t.des);
49         dim.wid = cell(0).width() + 2 * t.wid;
50         metricsMarkers(dim);
51         dim_ = dim;
52 }
53
54
55 void MathBraceInset::draw(PainterInfo & pi, int x, int y) const
56 {
57         LyXFont font = pi.base.font;
58         font.setColor(LColor::latex);
59         Dimension t;
60         mathed_char_dim(font, '{', t);
61         drawChar(pi, font, x, y, '{');
62         cell(0).draw(pi, x + t.wid, y);
63         drawChar(pi, font, x + t.wid + cell(0).width(), y, '}');
64         drawMarkers(pi, x, y);
65 }
66
67
68 void MathBraceInset::write(WriteStream & os) const
69 {
70         os << '{' << cell(0) << '}';
71 }
72
73
74 void MathBraceInset::normalize(NormalStream & os) const
75 {
76         os << "[block " << cell(0) << ']';
77 }
78
79
80 void MathBraceInset::maple(MapleStream & os) const
81 {
82         os << cell(0);
83 }
84
85
86 void MathBraceInset::octave(OctaveStream & os) const
87 {
88         os << cell(0);
89 }
90
91
92 void MathBraceInset::mathmlize(MathMLStream & os) const
93 {
94         os << MTag("mrow") << cell(0) << ETag("mrow");
95 }
96
97
98 void MathBraceInset::mathematica(MathematicaStream & os) const
99 {
100         os << cell(0);
101 }
102
103
104 void MathBraceInset::infoize(std::ostream & os) const
105 {
106         os << "Nested Block: ";
107 }