]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrameBox.cpp
remove unneeded header.
[lyx.git] / src / mathed / InsetMathFrameBox.cpp
1 /**
2  * \file InsetMathFrameBox.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 "InsetMathFrameBox.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "Color.h"
18 #include "frontends/Painter.h"
19
20
21 namespace lyx {
22
23 using std::auto_ptr;
24
25
26 InsetMathFrameBox::InsetMathFrameBox()
27         : InsetMathNest(3)
28 {}
29
30
31 auto_ptr<Inset> InsetMathFrameBox::doClone() const
32 {
33         return auto_ptr<Inset>(new InsetMathFrameBox(*this));
34 }
35
36
37 bool InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         FontSetChanger dummy(mi.base, "textnormal");
40         w_ = mathed_char_width(mi.base.font, '[');
41         InsetMathNest::metrics(mi);
42         dim  = cell(0).dim();
43         dim += cell(1).dim();
44         dim += cell(2).dim();
45         metricsMarkers(dim);
46         if (dim_ == dim)
47                 return false;
48         dim_ = dim;
49         return true;
50 }
51
52
53 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
54 {
55         FontSetChanger dummy(pi.base, "textnormal");
56         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
57                 dim_.width() - 2, dim_.height() - 2, Color::foreground);
58         x += 5;
59
60         drawStrBlack(pi, x, y, from_ascii("["));
61         x += w_;
62         cell(0).draw(pi, x, y);
63         x += cell(0).width();
64         drawStrBlack(pi, x, y, from_ascii("]"));
65         x += w_ + 4;
66
67         drawStrBlack(pi, x, y, from_ascii("["));
68         x += w_;
69         cell(1).draw(pi, x, y);
70         x += cell(1).width();
71         drawStrBlack(pi, x, y, from_ascii("]"));
72         x += w_ + 4;
73
74         cell(2).draw(pi, x, y);
75         drawMarkers(pi, x, y);
76 }
77
78
79 void InsetMathFrameBox::write(WriteStream & os) const
80 {
81         os << "\\framebox";
82         os << '[' << cell(0) << ']';
83         if (cell(1).size())
84                 os << '[' << cell(1) << ']';
85         os << '{' << cell(2) << '}';
86 }
87
88
89 void InsetMathFrameBox::normalize(NormalStream & os) const
90 {
91         os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
92 }
93
94
95 } // namespace lyx