]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrameBox.C
Fix comment according to Enricos explanation
[lyx.git] / src / mathed / InsetMathFrameBox.C
1 /**
2  * \file InsetMathFrameBox.C
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 "LColor.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<InsetBase> InsetMathFrameBox::doClone() const
32 {
33         return auto_ptr<InsetBase>(new InsetMathFrameBox(*this));
34 }
35
36
37 void 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         dim_ = dim;
47 }
48
49
50 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
51 {
52         FontSetChanger dummy(pi.base, "textnormal");
53         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
54                 dim_.width() - 2, dim_.height() - 2, LColor::foreground);
55         x += 5;
56
57         drawStrBlack(pi, x, y, from_ascii("["));
58         x += w_;
59         cell(0).draw(pi, x, y);
60         x += cell(0).width();
61         drawStrBlack(pi, x, y, from_ascii("]"));
62         x += w_ + 4;
63
64         drawStrBlack(pi, x, y, from_ascii("["));
65         x += w_;
66         cell(1).draw(pi, x, y);
67         x += cell(1).width();
68         drawStrBlack(pi, x, y, from_ascii("]"));
69         x += w_ + 4;
70
71         cell(2).draw(pi, x, y);
72         drawMarkers(pi, x, y);
73 }
74
75
76 void InsetMathFrameBox::write(WriteStream & os) const
77 {
78         os << "\\framebox";
79         os << '[' << cell(0) << ']';
80         if (cell(1).size())
81                 os << '[' << cell(1) << ']';
82         os << '{' << cell(2) << '}';
83 }
84
85
86 void InsetMathFrameBox::normalize(NormalStream & os) const
87 {
88         os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
89 }
90
91
92 } // namespace lyx