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