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 void MathBoxInset::write(MathWriteInfo & os) const
43 os << "\\" << name_ << "{" << cell(0) << "}";
47 void MathBoxInset::writeNormal(std::ostream & os) const
50 //text_->write(buffer(), os);
55 void MathBoxInset::metrics(MathMetricsInfo const & st) const
58 if (text_ && st.view && st.font) {
59 ascent_ = text_->ascent(st.view, *st.font) + 2;
60 descent_ = text_->descent(st.view, *st.font) + 2;
61 width_ = text_->width(st.view, *st.font) + 4;
70 void MathBoxInset::draw(Painter & pain, int x, int y) const
74 if (text_ && size_.view && size_.font)
75 text_->draw(size_.view, *(size_.font), y, fx, false);
76 if (mathcursor && mathcursor->isInside(this))
77 pain.rectangle(x, y - ascent(), xcell(0).width(), height(),