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