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