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