5 #include "math_boxinset.h"
6 #include "support/LOstream.h"
10 #include "math_cursor.h"
11 #include "insets/insettext.h"
14 MathBoxInset::MathBoxInset(string const & name)
15 : MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
19 MathBoxInset::MathBoxInset(MathBoxInset const & m)
20 : MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
23 lyxerr << "no buffer\n";
25 text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
29 MathBoxInset::~MathBoxInset()
35 MathInset * MathBoxInset::clone() const
37 return new MathBoxInset(*this);
41 UpdatableInset * MathBoxInset::asHyperActiveInset() const
47 void MathBoxInset::write(MathWriteInfo & os) const
49 os << "\\" << name_ << "{" << cell(0) << "}";
53 void MathBoxInset::writeNormal(std::ostream & os) const
56 //text_->write(buffer(), os);
61 void MathBoxInset::metrics(MathMetricsInfo const & st) const
64 if (text_ && mi_.view) {
65 ascent_ = text_->ascent(mi_.view, mi_.font) + 2;
66 descent_ = text_->descent(mi_.view, mi_.font) + 2;
67 width_ = text_->width(mi_.view, mi_.font) + 4;
76 void MathBoxInset::draw(Painter & pain, int x, int y) const
79 if (text_ && mi_.view)
80 text_->draw(mi_.view, mi_.font, y, fx, false);
81 if (mathcursor && mathcursor->isInside(this))
82 pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
87 void MathBoxInset::edit(BufferView * bv, int x, int y, unsigned int button)
90 text_->edit(bv, x, y, button);