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