5 #include "math_decorationinset.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8 #include "math_mathmlstream.h"
11 MathDecorationInset::MathDecorationInset(string const & name)
12 : MathNestInset(1), name_(name)
16 MathInset * MathDecorationInset::clone() const
18 return new MathDecorationInset(*this);
22 bool MathDecorationInset::upper() const
24 return name_ != "underline" && name_ != "underbrace";
28 bool MathDecorationInset::isScriptable() const
31 name_ == "overbrace" ||
32 name_ == "underbrace" ||
33 name_ == "overleftarrow" ||
34 name_ == "overrightarrow";
38 bool MathDecorationInset::protect() const
41 name_ == "overbrace" ||
42 name_ == "underbrace" ||
43 name_ == "overleftarrow" ||
44 name_ == "overrightarrow";
48 bool MathDecorationInset::wide() const
51 name_ == "overline" ||
52 name_ == "underline" ||
53 name_ == "overbrace" ||
54 name_ == "underbrace" ||
55 name_ == "overleftarrow" ||
56 name_ == "overrightarrow" ||
62 void MathDecorationInset::metrics(MathMetricsInfo const & st) const
66 width_ = xcell(0).width();
67 ascent_ = xcell(0).ascent();
68 descent_ = xcell(0).descent();
70 dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
82 void MathDecorationInset::draw(Painter & pain, int x, int y) const
84 xcell(0).draw(pain, x, y);
86 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
88 int w = 2 + mathed_char_width(LM_TC_VAR, size_, 'x');
89 mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
94 void MathDecorationInset::write(WriteStream & os) const
96 if (os.fragile && protect())
98 os << '\\' << name_.c_str() << '{' << cell(0) << '}';
102 void MathDecorationInset::normalize(NormalStream & os) const
104 os << "[deco " << name_.c_str() << ' ' << cell(0) << ']';