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