7 #include "math_boxinset.h"
8 #include "support/LOstream.h"
12 #include "math_cursor.h"
13 #include "insets/insettext.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
17 MathBoxInset::MathBoxInset(string const & name)
18 : MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
22 MathBoxInset::MathBoxInset(MathBoxInset const & m)
23 : MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
26 lyxerr << "no buffer\n";
28 text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
32 MathBoxInset::~MathBoxInset()
38 MathInset * MathBoxInset::clone() const
40 return new MathBoxInset(*this);
44 UpdatableInset * MathBoxInset::asHyperActiveInset() const
50 void MathBoxInset::write(WriteStream & os) const
52 os << "\\" << name_ << "{" << cell(0) << "}";
56 void MathBoxInset::normalize(NormalStream & os) const
59 //text_->write(buffer(), os);
64 void MathBoxInset::metrics(MathMetricsInfo const & st) const
67 if (text_ && mi_.view) {
68 ascent_ = text_->ascent(mi_.view, mi_.font) + 2;
69 descent_ = text_->descent(mi_.view, mi_.font) + 2;
70 width_ = text_->width(mi_.view, mi_.font) + 4;
79 void MathBoxInset::draw(Painter & pain, int x, int y) const
82 if (text_ && mi_.view)
83 text_->draw(mi_.view, mi_.font, y, fx, false);
84 if (mathcursor && mathcursor->isInside(this))
85 pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
90 void MathBoxInset::edit(BufferView * bv, int x, int y, unsigned int button)
93 text_->edit(bv, x, y, button);