]> git.lyx.org Git - features.git/blob - src/mathed/math_frameboxinset.C
c5b665ddde9b46016860bcdf9fa1e0ef963cccae
[features.git] / src / mathed / math_frameboxinset.C
1 /**
2  * \file math_frameboxinset.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 "math_frameboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_support.h"
17 #include "frontends/Painter.h"
18
19 using std::auto_ptr;
20
21
22 MathFrameboxInset::MathFrameboxInset()
23         : MathNestInset(3)
24 {}
25
26
27 auto_ptr<InsetBase> MathFrameboxInset::clone() const
28 {
29         return auto_ptr<InsetBase>(new MathFrameboxInset(*this));
30 }
31
32
33 void MathFrameboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
34 {
35         FontSetChanger dummy(mi.base, "textnormal");
36         w_ = mathed_char_width(mi.base.font, '[');
37         MathNestInset::metrics(mi);
38         dim_  = cell(0).dim();
39         dim_ += cell(1).dim();
40         dim_ += cell(2).dim();
41         metricsMarkers();
42         dim = dim_;
43 }
44
45
46 void MathFrameboxInset::draw(PainterInfo & pi, int x, int y) const
47 {
48         FontSetChanger dummy(pi.base, "textnormal");
49         pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
50                 dim_.width() - 2, dim_.height() - 2, LColor::foreground);
51         x += 5;
52
53         drawStrBlack(pi, x, y, "[");
54         x += w_;
55         cell(0).draw(pi, x, y);
56         x += cell(0).width();
57         drawStrBlack(pi, x, y, "]");
58         x += w_ + 4;
59
60         drawStrBlack(pi, x, y, "[");
61         x += w_;
62         cell(1).draw(pi, x, y);
63         x += cell(1).width();
64         drawStrBlack(pi, x, y, "]");
65         x += w_ + 4;
66
67         cell(2).draw(pi, x, y);
68 }
69
70
71 void MathFrameboxInset::write(WriteStream & os) const
72 {
73         os << "\\framebox";
74         os << '[' << cell(0) << ']';
75         if (cell(1).size())
76                 os << '[' << cell(1) << ']';
77         os << '{' << cell(2) << '}';
78 }
79
80
81 void MathFrameboxInset::normalize(NormalStream & os) const
82 {
83         os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
84 }