]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathBoxed.cpp
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[lyx.git] / src / mathed / InsetMathBoxed.cpp
1 /**
2  * \file InsetMathBoxed.cpp
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 "InsetMathBoxed.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "LaTeXFeatures.h"
17 #include "Color.h"
18
19 #include "support/std_ostream.h"
20 #include "frontends/Painter.h"
21
22
23 namespace lyx {
24
25 InsetMathBoxed::InsetMathBoxed()
26         : InsetMathNest(1)
27 {}
28
29
30 Inset * InsetMathBoxed::clone() const
31 {
32         return new InsetMathBoxed(*this);
33 }
34
35
36 bool InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const
37 {
38         cell(0).metrics(mi, dim);
39         metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space
40         if (dim_ == dim)
41                 return false;
42         dim_ = dim;
43         return true;
44 }
45
46
47 void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const
48 {
49         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
50                 dim_.width() - 2, dim_.height() - 2, Color::foreground);
51         cell(0).draw(pi, x + 3, y);
52         setPosCache(pi, x, y);
53 }
54
55
56 void InsetMathBoxed::write(WriteStream & os) const
57 {
58         os << "\\boxed{" << cell(0) << '}';
59 }
60
61
62 void InsetMathBoxed::normalize(NormalStream & os) const
63 {
64         os << "[boxed " << cell(0) << ']';
65 }
66
67
68 void InsetMathBoxed::infoize(odocstream & os) const
69 {
70         os << "Boxed: ";
71 }
72
73
74 void InsetMathBoxed::validate(LaTeXFeatures & features) const
75 {
76         features.require("amsmath");
77 }
78
79
80 } // namespace lyx