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