]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fboxinset.C
Compile fix gcc 2.95 + stlport
[lyx.git] / src / mathed / math_fboxinset.C
1 /**
2  * \file math_fboxinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_fboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_parser.h"
17 #include "math_streamstr.h"
18 #include "LColor.h"
19 #include "frontends/Painter.h"
20
21 using std::auto_ptr;
22
23
24 MathFboxInset::MathFboxInset(latexkeys const * key)
25         : MathNestInset(1), key_(key)
26 {}
27
28
29 auto_ptr<InsetBase> MathFboxInset::clone() const
30 {
31         return auto_ptr<InsetBase>(new MathFboxInset(*this));
32 }
33
34
35 MathInset::mode_type MathFboxInset::currentMode() const
36 {
37         if (key_->name == "fbox")
38                 return TEXT_MODE;
39         return MATH_MODE;
40 }
41
42
43 void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         if (key_->name == "fbox") {
46                 FontSetChanger dummy(mi.base, "textnormal");
47                 cell(0).metrics(mi, dim);
48         } else {
49                 cell(0).metrics(mi, dim);
50         }
51         metricsMarkers(dim, 5); // 5 pixels margin
52         dim_ = dim;
53 }
54
55
56 void MathFboxInset::draw(PainterInfo & pi, int x, int y) const
57 {
58         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
59                 dim_.width() - 2, dim_.height() - 2, LColor::foreground);
60         if (key_->name == "fbox") {
61                 FontSetChanger dummy(pi.base, "textnormal");
62                 cell(0).draw(pi, x + 5, y);
63         } else {
64                 cell(0).draw(pi, x + 5, y);
65         }
66 }
67
68
69 void MathFboxInset::write(WriteStream & os) const
70 {
71         os << '\\' << key_->name << '{' << cell(0) << '}';
72 }
73
74
75 void MathFboxInset::normalize(NormalStream & os) const
76 {
77         os << '[' << key_->name << ' ' << cell(0) << ']';
78 }