]> git.lyx.org Git - lyx.git/blob - src/mathed/math_parboxinset.C
revert Buffer LyxText->InsetText commit
[lyx.git] / src / mathed / math_parboxinset.C
1 /**
2  * \file math_parboxinset.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_parboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17 #include "debug.h"
18
19
20 using std::string;
21 using std::auto_ptr;
22 using std::endl;
23
24
25 MathParboxInset::MathParboxInset()
26         : lyx_width_(0), tex_width_("0mm"), position_('c')
27 {
28         lyxerr << "constructing MathParboxInset" << endl;
29 }
30
31
32 auto_ptr<InsetBase> MathParboxInset::clone() const
33 {
34         return auto_ptr<InsetBase>(new MathParboxInset(*this));
35 }
36
37
38 void MathParboxInset::setPosition(string const & p)
39 {
40         position_ = p.size() > 0 ? p[0] : 'c';
41 }
42
43
44 void MathParboxInset::setWidth(string const & w)
45 {
46         tex_width_ = w;
47         lyx_width_ = LyXLength(w).inBP();
48         lyxerr << "setting " << w << " to " << lyx_width_ << " pixel" << endl;
49 }
50
51
52 void MathParboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
53 {
54         FontSetChanger dummy1(mi.base, "textnormal");
55         WidthChanger dummy2(mi.base, lyx_width_);
56         MathTextInset::metrics(mi, dim);
57         metricsMarkers(dim);
58         dim_ = dim;
59 }
60
61
62 void MathParboxInset::draw(PainterInfo & pi, int x, int y) const
63 {
64         FontSetChanger dummy(pi.base, "textnormal");
65         MathTextInset::draw(pi, x + 1, y);
66         drawMarkers(pi, x, y);
67 }
68
69
70 void MathParboxInset::write(WriteStream & os) const
71 {
72         os << "\\parbox";
73         if (position_ != 'c')
74                 os << '[' << position_ << ']';
75         os << '{' << tex_width_ << "}{" << cell(0) << '}';
76 }
77
78
79 void MathParboxInset::infoize(std::ostream & os) const
80 {
81         os << "Box: Parbox " << tex_width_;
82 }