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