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