]> git.lyx.org Git - lyx.git/blob - src/mathed/math_frameboxinset.C
Fix.
[lyx.git] / src / mathed / math_frameboxinset.C
1 #include <config.h>
2
3
4 #include "math_frameboxinset.h"
5 #include "math_support.h"
6 #include "math_mathmlstream.h"
7 #include "math_streamstr.h"
8 #include "frontends/Painter.h"
9
10
11
12 MathFrameboxInset::MathFrameboxInset()
13         : MathNestInset(2)
14 {}
15
16
17 MathInset * MathFrameboxInset::clone() const
18 {
19         return new MathFrameboxInset(*this);
20 }
21
22
23 void MathFrameboxInset::metrics(MathMetricsInfo & mi) const
24 {
25         w_ = mathed_char_width(mi.base.font, '[');
26         MathNestInset::metrics(mi);
27         dim_    = cell(0).dim();
28         dim_   += cell(1).dim();
29         dim_.w += 2 * w_ + 4;
30         metricsMarkers2(5); // 5 pixels margin
31 }
32
33
34 void MathFrameboxInset::draw(MathPainterInfo & pi, int x, int y) const
35 {
36         pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
37                         LColor::black);
38         x += 5;
39         drawStrBlack(pi, x, y, "[");
40         x += w_;
41         cell(0).draw(pi, x, y);
42         x += cell(0).width();
43         drawStrBlack(pi, x, y, "]");
44         x += w_ + 4;
45         cell(1).draw(pi, x, y);
46 }
47
48
49 void MathFrameboxInset::write(WriteStream & os) const
50 {
51         os << "\\framebox";
52         if (cell(0).size())
53                 os << '[' << cell(0) << ']';
54         os << '{' << cell(1) << '}';
55 }
56
57
58 void MathFrameboxInset::normalize(NormalStream & os) const
59 {
60         os << "[framebox " << cell(0) << ' ' << cell(1) << ']';
61 }