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"
14 MathDecorationInset::MathDecorationInset(latexkeys const * key)
15 : MathNestInset(1), key_(key)
19 auto_ptr<InsetBase> MathDecorationInset::clone() const
21 return auto_ptr<InsetBase>(new MathDecorationInset(*this));
25 bool MathDecorationInset::upper() const
27 return key_->name.substr(0, 5) != "under";
31 bool MathDecorationInset::isScriptable() const
34 key_->name == "overbrace" ||
35 key_->name == "underbrace" ||
36 key_->name == "overleftarrow" ||
37 key_->name == "overrightarrow" ||
38 key_->name == "overleftrightarrow" ||
39 key_->name == "underleftarrow" ||
40 key_->name == "underrightarrow" ||
41 key_->name == "underleftrightarrow";
45 bool MathDecorationInset::protect() const
48 key_->name == "overbrace" ||
49 key_->name == "underbrace" ||
50 key_->name == "overleftarrow" ||
51 key_->name == "overrightarrow" ||
52 key_->name == "overleftrightarrow" ||
53 key_->name == "underleftarrow" ||
54 key_->name == "underrightarrow" ||
55 key_->name == "underleftrightarrow";
59 bool MathDecorationInset::wide() const
62 key_->name == "overline" ||
63 key_->name == "underline" ||
64 key_->name == "overbrace" ||
65 key_->name == "underbrace" ||
66 key_->name == "overleftarrow" ||
67 key_->name == "overrightarrow" ||
68 key_->name == "overleftrightarrow" ||
69 key_->name == "widehat" ||
70 key_->name == "widetilde" ||
71 key_->name == "underleftarrow" ||
72 key_->name == "underrightarrow" ||
73 key_->name == "underleftrightarrow";
77 void MathDecorationInset::metrics(MetricsInfo & mi, Dimension & dim) const
82 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
83 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
86 dy_ = -dim_.asc - dh_;
98 void MathDecorationInset::draw(PainterInfo & pi, int x, int y) const
100 cell(0).draw(pi, x + 1, y);
102 mathed_draw_deco(pi, x + 1, y + dy_, cell(0).width(), dh_, key_->name);
104 mathed_draw_deco(pi, x + 1 + (pi.width - dw_) / 2,
105 y + dy_, dw_, dh_, key_->name);
106 drawMarkers(pi, x, y);
110 void MathDecorationInset::write(WriteStream & os) const
112 if (os.fragile() && protect())
114 os << '\\' << key_->name << '{' << cell(0) << '}';
118 void MathDecorationInset::normalize(NormalStream & os) const
120 os << "[deco " << key_->name << ' ' << cell(0) << ']';
124 void MathDecorationInset::infoize(std::ostream & os) const
126 os << "Deco: " << key_->name;