]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathBrace.cpp
Get rid of Inset::setPosCache
[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 #include <algorithm>
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         FontInfo font = mi.base.font;
53         augmentFont(font, "mathnormal");
54         Dimension t = theFontMetrics(font).dimension('{');
55         dim.asc = max(dim0.asc, t.asc);
56         dim.des = max(dim0.des, t.des);
57         dim.wid = dim0.width() + 2 * t.wid;
58         metricsMarkers(mi, dim);
59 }
60
61
62 void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
63 {
64         FontInfo font = pi.base.font;
65         augmentFont(font, "mathnormal");
66         font.setShape(UP_SHAPE);
67         font.setColor(Color_latex);
68         Dimension t = theFontMetrics(font).dimension('{');
69         pi.pain.text(x, y, '{', font);
70         cell(0).draw(pi, x + t.wid, y);
71         Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
72         pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
73         drawMarkers(pi, x, y);
74 }
75
76
77 void InsetMathBrace::write(WriteStream & os) const
78 {
79         os << '{' << cell(0) << '}';
80 }
81
82
83 void InsetMathBrace::normalize(NormalStream & os) const
84 {
85         os << "[block " << cell(0) << ']';
86 }
87
88
89 void InsetMathBrace::maple(MapleStream & os) const
90 {
91         os << cell(0);
92 }
93
94
95 void InsetMathBrace::octave(OctaveStream & os) const
96 {
97         os << cell(0);
98 }
99
100
101 void InsetMathBrace::mathmlize(MathStream & os) const
102 {
103         os << MTag("mrow") << cell(0) << ETag("mrow");
104 }
105
106
107 void InsetMathBrace::htmlize(HtmlStream & os) const
108 {
109         os << cell(0);
110 }
111
112
113 void InsetMathBrace::mathematica(MathematicaStream & os) const
114 {
115         os << cell(0);
116 }
117
118
119 void InsetMathBrace::infoize(odocstream & os) const
120 {
121         os << "Nested Block: ";
122 }
123
124
125 } // namespace lyx