]> git.lyx.org Git - lyx.git/blob - src/mathed/math_frameboxinset.C
fix #1073
[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(3)
14 {}
15
16
17 MathInset * MathFrameboxInset::clone() const
18 {
19         return new MathFrameboxInset(*this);
20 }
21
22
23 void MathFrameboxInset::metrics(MetricsInfo & mi) const
24 {
25         FontSetChanger dummy(mi.base, "textnormal");
26         w_ = mathed_char_width(mi.base.font, '[');
27         MathNestInset::metrics(mi);
28         dim_    = cell(0).dim();
29         dim_   += cell(1).dim();
30         dim_   += cell(2).dim();
31         dim_.w += 4 * w_ + 4;
32         metricsMarkers2(5); // 5 pixels margin
33 }
34
35
36 void MathFrameboxInset::draw(PainterInfo & pi, int x, int y) const
37 {
38         FontSetChanger dummy(pi.base, "textnormal");
39         pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
40                         LColor::foreground);
41         x += 5;
42
43         drawStrBlack(pi, x, y, "[");
44         x += w_;
45         cell(0).draw(pi, x, y);
46         x += cell(0).width();
47         drawStrBlack(pi, x, y, "]");
48         x += w_ + 4;
49
50         drawStrBlack(pi, x, y, "[");
51         x += w_;
52         cell(1).draw(pi, x, y);
53         x += cell(1).width();
54         drawStrBlack(pi, x, y, "]");
55         x += w_ + 4;
56
57         cell(2).draw(pi, x, y);
58 }
59
60
61 void MathFrameboxInset::write(WriteStream & os) const
62 {
63         os << "\\framebox";
64         os << '[' << cell(0) << ']';
65         if (cell(1).size())
66                 os << '[' << cell(1) << ']';
67         os << '{' << cell(2) << '}';
68 }
69
70
71 void MathFrameboxInset::normalize(NormalStream & os) const
72 {
73         os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
74 }