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