]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathBrace.cpp
d74136b4844e5d4f75ec6ff03b7e1ed5617674f3
[lyx.git] / src / mathed / InsetMathBrace.cpp
1 /**
2  * \file InsetMathBrace.cpp
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 "InsetMathBrace.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "Color.h"
18
19 #include "frontends/FontMetrics.h"
20 #include "frontends/Painter.h"
21
22 #include "support/std_ostream.h"
23
24 namespace lyx {
25
26 InsetMathBrace::InsetMathBrace()
27         : InsetMathNest(1)
28 {}
29
30
31 InsetMathBrace::InsetMathBrace(MathData const & ar)
32         : InsetMathNest(1)
33 {
34         cell(0) = ar;
35 }
36
37
38 Inset * InsetMathBrace::clone() const
39 {
40         return new InsetMathBrace(*this);
41 }
42
43
44 bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         cell(0).metrics(mi);
47         Dimension t = theFontMetrics(mi.base.font).dimension('{');
48         dim.asc = std::max(cell(0).ascent(), t.asc);
49         dim.des = std::max(cell(0).descent(), t.des);
50         dim.wid = cell(0).width() + 2 * t.wid;
51         metricsMarkers(dim);
52         if (dim_ == dim)
53                 return false;
54         dim_ = dim;
55         return true;
56 }
57
58
59 void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
60 {
61         Font font = pi.base.font;
62         font.setColor(Color::latex);
63         Dimension t = theFontMetrics(font).dimension('{');
64         pi.pain.text(x, y, '{', font);
65         cell(0).draw(pi, x + t.wid, y);
66         pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
67         drawMarkers(pi, x, y);
68 }
69
70
71 void InsetMathBrace::write(WriteStream & os) const
72 {
73         os << '{' << cell(0) << '}';
74 }
75
76
77 void InsetMathBrace::normalize(NormalStream & os) const
78 {
79         os << "[block " << cell(0) << ']';
80 }
81
82
83 void InsetMathBrace::maple(MapleStream & os) const
84 {
85         os << cell(0);
86 }
87
88
89 void InsetMathBrace::octave(OctaveStream & os) const
90 {
91         os << cell(0);
92 }
93
94
95 void InsetMathBrace::mathmlize(MathStream & os) const
96 {
97         os << MTag("mrow") << cell(0) << ETag("mrow");
98 }
99
100
101 void InsetMathBrace::mathematica(MathematicaStream & os) const
102 {
103         os << cell(0);
104 }
105
106
107 void InsetMathBrace::infoize(odocstream & os) const
108 {
109         os << "Nested Block: ";
110 }
111
112
113 } // namespace lyx