3 #include "LaTeXFeatures.h"
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 bool MathDecorationInset::ams() const
78 key_->name == "overleftrightarrow" ||
79 key_->name == "underleftarrow" ||
80 key_->name == "underrightarrow" ||
81 key_->name == "underleftrightarrow";
85 void MathDecorationInset::metrics(MathMetricsInfo & mi) const
89 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
90 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
104 void MathDecorationInset::draw(MathPainterInfo & pi, int x, int y) const
106 cell(0).draw(pi, x + 1, y);
108 mathed_draw_deco(pi, x + 1, y + dy_, width(), dh_, key_->name);
110 mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, key_->name);
111 drawMarkers(pi, x, y);
115 void MathDecorationInset::validate(LaTeXFeatures & features) const
118 features.require("amsmath");
119 MathNestInset::validate(features);
123 void MathDecorationInset::write(WriteStream & os) const
125 if (os.fragile() && protect())
127 os << '\\' << key_->name << '{' << cell(0) << '}';
131 void MathDecorationInset::normalize(NormalStream & os) const
133 os << "[deco " << key_->name << ' ' << cell(0) << ']';
137 void MathDecorationInset::infoize(std::ostream & os) const
139 os << "Deco: " << key_->name;