4 #include "math_decorationinset.h"
5 #include "math_support.h"
6 #include "math_parser.h"
7 #include "math_mathmlstream.h"
8 #include "math_streamstr.h"
9 #include "support/LOstream.h"
12 MathDecorationInset::MathDecorationInset(latexkeys const * key)
13 : MathNestInset(1), key_(key)
17 MathInset * MathDecorationInset::clone() const
19 return new MathDecorationInset(*this);
23 bool MathDecorationInset::upper() const
25 return key_->name.substr(0, 5) != "under";
29 bool MathDecorationInset::isScriptable() const
32 key_->name == "overbrace" ||
33 key_->name == "underbrace" ||
34 key_->name == "overleftarrow" ||
35 key_->name == "overrightarrow" ||
36 key_->name == "overleftrightarrow" ||
37 key_->name == "underleftarrow" ||
38 key_->name == "underrightarrow" ||
39 key_->name == "underleftrightarrow";
43 bool MathDecorationInset::protect() const
46 key_->name == "overbrace" ||
47 key_->name == "underbrace" ||
48 key_->name == "overleftarrow" ||
49 key_->name == "overrightarrow" ||
50 key_->name == "overleftrightarrow" ||
51 key_->name == "underleftarrow" ||
52 key_->name == "underrightarrow" ||
53 key_->name == "underleftrightarrow";
57 bool MathDecorationInset::wide() const
60 key_->name == "overline" ||
61 key_->name == "underline" ||
62 key_->name == "overbrace" ||
63 key_->name == "underbrace" ||
64 key_->name == "overleftarrow" ||
65 key_->name == "overrightarrow" ||
66 key_->name == "overleftrightarrow" ||
67 key_->name == "widehat" ||
68 key_->name == "widetilde" ||
69 key_->name == "underleftarrow" ||
70 key_->name == "underrightarrow" ||
71 key_->name == "underleftrightarrow";
75 void MathDecorationInset::metrics(MathMetricsInfo & mi) const
79 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
80 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
94 void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
96 cell(0).draw(pi, x + 1, y);
98 mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name);
100 mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name);
101 drawMarkers(pi, x, y);
105 void MathDecorationInset::write(WriteStream & os) const
107 if (os.fragile() && protect())
109 os << '\\' << key_->name << '{' << cell(0) << '}';
113 void MathDecorationInset::normalize(NormalStream & os) const
115 os << "[deco " << key_->name << ' ' << cell(0) << ']';
119 void MathDecorationInset::infoize(std::ostream & os) const
121 os << "Deco: " << key_->name;