7 #include "math_decorationinset.h"
8 #include "math_support.h"
9 #include "math_parser.h"
10 #include "math_mathmlstream.h"
11 #include "math_streamstr.h"
14 MathDecorationInset::MathDecorationInset(string const & name)
15 : MathNestInset(1), name_(name)
19 MathInset * MathDecorationInset::clone() const
21 return new MathDecorationInset(*this);
25 bool MathDecorationInset::upper() const
27 return name_ != "underline" && name_ != "underbrace";
31 bool MathDecorationInset::isScriptable() const
34 name_ == "overbrace" ||
35 name_ == "underbrace" ||
36 name_ == "overleftarrow" ||
37 name_ == "overrightarrow";
41 bool MathDecorationInset::protect() const
44 name_ == "overbrace" ||
45 name_ == "underbrace" ||
46 name_ == "overleftarrow" ||
47 name_ == "overrightarrow";
51 bool MathDecorationInset::wide() const
54 name_ == "overline" ||
55 name_ == "underline" ||
56 name_ == "overbrace" ||
57 name_ == "underbrace" ||
58 name_ == "overleftarrow" ||
59 name_ == "overrightarrow" ||
65 void MathDecorationInset::metrics(MathMetricsInfo const & st) const
69 width_ = xcell(0).width();
70 ascent_ = xcell(0).ascent();
71 descent_ = xcell(0).descent();
73 dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
85 void MathDecorationInset::draw(Painter & pain, int x, int y) const
87 xcell(0).draw(pain, x, y);
89 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
91 int w = 2 + mathed_char_width(LM_TC_VAR, size_, 'x');
92 mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
97 void MathDecorationInset::write(WriteStream & os) const
99 if (os.fragile() && protect())
101 os << '\\' << name_ << '{' << cell(0) << '}';
105 void MathDecorationInset::normalize(NormalStream & os) const
107 os << "[deco " << name_ << ' ' << cell(0) << ']';