]> git.lyx.org Git - lyx.git/blob - src/mathed/math_frameboxinset.C
IU of drawing phase one without 'semantic changes' as requested by John
[lyx.git] / src / mathed / math_frameboxinset.C
1 #include <config.h>
2
3 #include "math_frameboxinset.h"
4 #include "math_support.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7 #include "frontends/Painter.h"
8
9
10 MathFrameboxInset::MathFrameboxInset()
11         : MathNestInset(3)
12 {}
13
14
15 MathInset * MathFrameboxInset::clone() const
16 {
17         return new MathFrameboxInset(*this);
18 }
19
20
21 void MathFrameboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
22 {
23         FontSetChanger dummy(mi.base, "textnormal");
24         w_ = mathed_char_width(mi.base.font, '[');
25         MathNestInset::metrics(mi);
26         dim_  = cell(0).dim();
27         dim_ += cell(1).dim();
28         dim_ += cell(2).dim();
29         metricsMarkers();
30         dim = dim_;
31 }
32
33
34 void MathFrameboxInset::draw(PainterInfo & pi, int x, int y) const
35 {
36         FontSetChanger dummy(pi.base, "textnormal");
37         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
38                 dim_.width() - 2, dim_.height() - 2, LColor::foreground);
39         x += 5;
40
41         drawStrBlack(pi, x, y, "[");
42         x += w_;
43         cell(0).draw(pi, x, y);
44         x += cell(0).width();
45         drawStrBlack(pi, x, y, "]");
46         x += w_ + 4;
47
48         drawStrBlack(pi, x, y, "[");
49         x += w_;
50         cell(1).draw(pi, x, y);
51         x += cell(1).width();
52         drawStrBlack(pi, x, y, "]");
53         x += w_ + 4;
54
55         cell(2).draw(pi, x, y);
56 }
57
58
59 void MathFrameboxInset::write(WriteStream & os) const
60 {
61         os << "\\framebox";
62         os << '[' << cell(0) << ']';
63         if (cell(1).size())
64                 os << '[' << cell(1) << ']';
65         os << '{' << cell(2) << '}';
66 }
67
68
69 void MathFrameboxInset::normalize(NormalStream & os) const
70 {
71         os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
72 }