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