]> git.lyx.org Git - lyx.git/blob - src/mathed/math_braceinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_braceinset.C
1 #include <config.h>
2
3 #include "math_braceinset.h"
4 #include "math_parser.h"
5 #include "math_support.h"
6 #include "math_mathmlstream.h"
7 #include "support/LOstream.h"
8
9 using std::max;
10 using std::auto_ptr;
11
12
13 MathBraceInset::MathBraceInset()
14         : MathNestInset(1)
15 {}
16
17
18 MathBraceInset::MathBraceInset(MathArray const & ar)
19         : MathNestInset(1)
20 {
21         cell(0) = ar;
22 }
23
24
25 auto_ptr<InsetBase> MathBraceInset::clone() const
26 {
27         return auto_ptr<InsetBase>(new MathBraceInset(*this));
28 }
29
30
31 void MathBraceInset::metrics(MetricsInfo & mi, Dimension & dim) const
32 {
33         cell(0).metrics(mi);
34         Dimension t;
35         mathed_char_dim(mi.base.font, '{', t);
36         wid_ = t.wid;
37         dim_.asc = max(cell(0).ascent(), t.asc);
38         dim_.des = max(cell(0).descent(), t.des);
39         dim_.wid = cell(0).width() + 2 * wid_;
40         dim = dim_;
41 }
42
43
44 void MathBraceInset::draw(PainterInfo & pi, int x, int y) const
45 {
46         LyXFont font = pi.base.font;
47         font.setColor(LColor::latex);
48         drawChar(pi, font, x, y, '{');
49         cell(0).draw(pi, x + wid_, y);
50         drawChar(pi, font, x + dim_.width() - wid_, y, '}');
51 }
52
53
54 void MathBraceInset::write(WriteStream & os) const
55 {
56         os << '{' << cell(0) << '}';
57 }
58
59
60 void MathBraceInset::normalize(NormalStream & os) const
61 {
62         os << "[block " << cell(0) << ']';
63 }
64
65
66 void MathBraceInset::maple(MapleStream & os) const
67 {
68         os << cell(0);
69 }
70
71
72 void MathBraceInset::octave(OctaveStream & os) const
73 {
74         os << cell(0);
75 }
76
77
78 void MathBraceInset::mathmlize(MathMLStream & os) const
79 {
80         os << MTag("mrow") << cell(0) << ETag("mrow");
81 }
82
83
84 void MathBraceInset::mathematica(MathematicaStream & os) const
85 {
86         os << cell(0);
87 }
88
89
90 void MathBraceInset::infoize(std::ostream & os) const
91 {
92         os << "Nested Block: ";
93 }