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 InsetBase * 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(MetricsInfo & mi, Dimension & dim) const
80 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
81 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
84 dy_ = -dim_.asc - dh_;
96 void MathDecorationInset::draw(PainterInfo & pi, int x, int y) const
98 cell(0).draw(pi, x + 1, y);
100 mathed_draw_deco(pi, x + 1, y + dy_, cell(0).width(), dh_, key_->name);
102 mathed_draw_deco(pi, x + 1 + (pi.width - dw_) / 2,
103 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;