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_.substr(0, 5) != "under";
31 bool MathDecorationInset::isScriptable() const
34 name_ == "overbrace" ||
35 name_ == "underbrace" ||
36 name_ == "overleftarrow" ||
37 name_ == "overrightarrow" ||
38 name_ == "overleftrightarrow" ||
39 name_ == "underleftarrow" ||
40 name_ == "underrightarrow" ||
41 name_ == "underleftrightarrow";
45 bool MathDecorationInset::protect() const
48 name_ == "overbrace" ||
49 name_ == "underbrace" ||
50 name_ == "overleftarrow" ||
51 name_ == "overrightarrow" ||
52 name_ == "overleftrightarrow" ||
53 name_ == "underleftarrow" ||
54 name_ == "underrightarrow" ||
55 name_ == "underleftrightarrow";
59 bool MathDecorationInset::wide() const
62 name_ == "overline" ||
63 name_ == "underline" ||
64 name_ == "overbrace" ||
65 name_ == "underbrace" ||
66 name_ == "overleftarrow" ||
67 name_ == "overrightarrow" ||
68 name_ == "overleftrightarrow" ||
70 name_ == "widetilde" ||
71 name_ == "underleftarrow" ||
72 name_ == "underrightarrow" ||
73 name_ == "underleftrightarrow";
77 void MathDecorationInset::metrics(MathMetricsInfo const & mi) 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, mi(), 'I', ascent_, descent_);
85 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
97 void MathDecorationInset::draw(Painter & pain, int x, int y) const
99 xcell(0).draw(pain, x, y);
101 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
103 mathed_draw_deco(pain, x + (width_ - dw_) / 2, y + dy_, dw_, dh_, name_);
107 void MathDecorationInset::write(WriteStream & os) const
109 if (os.fragile() && protect())
111 os << '\\' << name_ << '{' << cell(0) << '}';
115 void MathDecorationInset::normalize(NormalStream & os) const
117 os << "[deco " << name_ << ' ' << cell(0) << ']';