5 #include "math_boxinset.h"
6 #include "support/LOstream.h"
10 #include "math_cursor.h"
11 #include "insets/insettext.h"
12 #include "math_mathmlstream.h"
15 MathBoxInset::MathBoxInset(string const & name)
16 : MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
20 MathBoxInset::MathBoxInset(MathBoxInset const & m)
21 : MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
24 lyxerr << "no buffer\n";
26 text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
30 MathBoxInset::~MathBoxInset()
36 MathInset * MathBoxInset::clone() const
38 return new MathBoxInset(*this);
42 UpdatableInset * MathBoxInset::asHyperActiveInset() const
48 void MathBoxInset::write(WriteStream & os) const
50 os << "\\" << name_.c_str() << "{" << cell(0) << "}";
54 void MathBoxInset::normalize(NormalStream & os) const
57 //text_->write(buffer(), os);
62 void MathBoxInset::metrics(MathMetricsInfo const & st) const
65 if (text_ && mi_.view) {
66 ascent_ = text_->ascent(mi_.view, mi_.font) + 2;
67 descent_ = text_->descent(mi_.view, mi_.font) + 2;
68 width_ = text_->width(mi_.view, mi_.font) + 4;
77 void MathBoxInset::draw(Painter & pain, int x, int y) const
80 if (text_ && mi_.view)
81 text_->draw(mi_.view, mi_.font, y, fx, false);
82 if (mathcursor && mathcursor->isInside(this))
83 pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
88 void MathBoxInset::edit(BufferView * bv, int x, int y, unsigned int button)
91 text_->edit(bv, x, y, button);