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
28 name_ != "underbar" &&
29 name_ != "underline" &&
30 name_ != "underbrace" &&
31 name_ != "underleftarrow" &&
32 name_ != "underrightarrow";
36 bool MathDecorationInset::isScriptable() const
39 name_ == "overbrace" ||
40 name_ == "underbrace" ||
41 name_ == "overleftarrow" ||
42 name_ == "overrightarrow" ||
43 name_ == "underleftarrow" ||
44 name_ == "underrightarrow";
48 bool MathDecorationInset::protect() const
51 name_ == "overbrace" ||
52 name_ == "underbrace" ||
53 name_ == "overleftarrow" ||
54 name_ == "overrightarrow" ||
55 name_ == "underleftarrow" ||
56 name_ == "underrightarrow";
60 bool MathDecorationInset::wide() const
63 name_ == "overline" ||
64 name_ == "underline" ||
65 name_ == "overbrace" ||
66 name_ == "underbrace" ||
67 name_ == "overleftarrow" ||
68 name_ == "overrightarrow" ||
70 name_ == "widetilde" ||
71 name_ == "underleftarrow" ||
72 name_ == "underrightarrow";
76 void MathDecorationInset::metrics(MathMetricsInfo const & st) const
80 width_ = xcell(0).width();
81 ascent_ = xcell(0).ascent();
82 descent_ = xcell(0).descent();
84 dh_ = 6; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
96 void MathDecorationInset::draw(Painter & pain, int x, int y) const
98 xcell(0).draw(pain, x, y);
100 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
102 int w = mathed_char_width(LM_TC_VAR, size_, 'x');
103 mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
108 void MathDecorationInset::write(WriteStream & os) const
110 if (os.fragile() && protect())
112 os << '\\' << name_ << '{' << cell(0) << '}';
116 void MathDecorationInset::normalize(NormalStream & os) const
118 os << "[deco " << name_ << ' ' << cell(0) << ']';