]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMakebox.cpp
* Inset and derivatives: insetName() -> name()
[lyx.git] / src / mathed / InsetMathMakebox.cpp
1 /**
2  * \file InsetMathMakebox.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Ling Li
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathMakebox.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18 #include "support/std_ostream.h"
19
20
21 namespace lyx {
22
23 using std::auto_ptr;
24
25
26 InsetMathMakebox::InsetMathMakebox()
27         : InsetMathNest(3)
28 {}
29
30
31 auto_ptr<Inset> InsetMathMakebox::doClone() const
32 {
33         return auto_ptr<Inset>(new InsetMathMakebox(*this));
34 }
35
36
37 bool InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         FontSetChanger dummy(mi.base, from_ascii("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         dim.wid += 4 * w_ + 4;
46         metricsMarkers(dim);
47         if (dim_ == dim)
48                 return false;
49         dim_ = dim;
50         return true;
51 }
52
53
54 void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const
55 {
56         FontSetChanger dummy(pi.base, from_ascii("textnormal"));
57         drawMarkers(pi, x, y);
58
59         drawStrBlack(pi, x, y, from_ascii("["));
60         x += w_;
61         cell(0).draw(pi, x, y);
62         x += cell(0).width();
63         drawStrBlack(pi, x, y, from_ascii("]"));
64         x += w_ + 2;
65
66         drawStrBlack(pi, x, y, from_ascii("["));
67         x += w_;
68         cell(1).draw(pi, x, y);
69         x += cell(1).width();
70         drawStrBlack(pi, x, y, from_ascii("]"));
71         x += w_ + 2;
72
73         cell(2).draw(pi, x, y);
74         setPosCache(pi, x, y);
75 }
76
77
78 void InsetMathMakebox::write(WriteStream & os) const
79 {
80         os << "\\makebox";
81         os << '[' << cell(0) << ']';
82         if (cell(1).size())
83                 os << '[' << cell(1) << ']';
84         os << '{' << cell(2) << '}';
85 }
86
87
88 void InsetMathMakebox::normalize(NormalStream & os) const
89 {
90         os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
91 }
92
93
94 void InsetMathMakebox::infoize(odocstream & os) const
95 {
96         os << "Makebox (width: " << cell(0)
97             << " pos: " << cell(1) << ")";
98 }
99
100
101 } // namespace lyx