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"
12 #include "support/LOstream.h"
15 MathDecorationInset::MathDecorationInset(latexkeys const * key)
16 : MathNestInset(1), key_(key)
20 MathInset * MathDecorationInset::clone() const
22 return new MathDecorationInset(*this);
26 bool MathDecorationInset::upper() const
28 return key_->name.substr(0, 5) != "under";
32 bool MathDecorationInset::isScriptable() const
35 key_->name == "overbrace" ||
36 key_->name == "underbrace" ||
37 key_->name == "overleftarrow" ||
38 key_->name == "overrightarrow" ||
39 key_->name == "overleftrightarrow" ||
40 key_->name == "underleftarrow" ||
41 key_->name == "underrightarrow" ||
42 key_->name == "underleftrightarrow";
46 bool MathDecorationInset::protect() const
49 key_->name == "overbrace" ||
50 key_->name == "underbrace" ||
51 key_->name == "overleftarrow" ||
52 key_->name == "overrightarrow" ||
53 key_->name == "overleftrightarrow" ||
54 key_->name == "underleftarrow" ||
55 key_->name == "underrightarrow" ||
56 key_->name == "underleftrightarrow";
60 bool MathDecorationInset::wide() const
63 key_->name == "overline" ||
64 key_->name == "underline" ||
65 key_->name == "overbrace" ||
66 key_->name == "underbrace" ||
67 key_->name == "overleftarrow" ||
68 key_->name == "overrightarrow" ||
69 key_->name == "overleftrightarrow" ||
70 key_->name == "widehat" ||
71 key_->name == "widetilde" ||
72 key_->name == "underleftarrow" ||
73 key_->name == "underrightarrow" ||
74 key_->name == "underleftrightarrow";
78 void MathDecorationInset::metrics(MathMetricsInfo & mi) const
81 dim_ = xcell(0).dim();
82 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
83 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
97 void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
99 xcell(0).draw(pi, x + 1, y);
101 mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name);
103 mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name);
104 drawMarkers(pi, x, y);
108 void MathDecorationInset::write(WriteStream & os) const
110 if (os.fragile() && protect())
112 os << '\\' << key_->name << '{' << cell(0) << '}';
116 void MathDecorationInset::normalize(NormalStream & os) const
118 os << "[deco " << key_->name << ' ' << cell(0) << ']';
122 void MathDecorationInset::infoize(std::ostream & os) const
124 os << "Deco: " << key_->name;