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