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)
17 lyxerr << "creating new " << name << endl;
21 MathBoxInset::MathBoxInset(MathBoxInset const & m)
22 : MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
25 cerr << "no buffer\n";
27 text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
31 MathBoxInset::~MathBoxInset()
37 MathInset * MathBoxInset::clone() const
39 return new MathBoxInset(*this);
43 void MathBoxInset::write(MathWriteInfo & os) const
45 os << "\\" << name_ << "{" << cell(0) << "}";
49 void MathBoxInset::writeNormal(std::ostream & os) const
52 //text_->write(buffer(), os);
57 void MathBoxInset::metrics(MathMetricsInfo const & st) const
60 if (text_ && st.view && st.font) {
61 ascent_ = text_->ascent(st.view, *st.font) + 2;
62 descent_ = text_->descent(st.view, *st.font) + 2;
63 width_ = text_->width(st.view, *st.font) + 4;
72 void MathBoxInset::draw(Painter & pain, int x, int y) const
76 if (text_ && size_.view && size_.font)
77 text_->draw(size_.view, *(size_.font), y, fx, false);
78 if (mathcursor && mathcursor->isInside(this))
79 pain.rectangle(x, y - ascent(), xcell(0).width(), height(),