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