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(string const & name)
16 : MathNestInset(1), name_(name)
20 MathInset * MathDecorationInset::clone() const
22 return new MathDecorationInset(*this);
26 bool MathDecorationInset::upper() const
28 return name_.substr(0, 5) != "under";
32 bool MathDecorationInset::isScriptable() const
35 name_ == "overbrace" ||
36 name_ == "underbrace" ||
37 name_ == "overleftarrow" ||
38 name_ == "overrightarrow" ||
39 name_ == "overleftrightarrow" ||
40 name_ == "underleftarrow" ||
41 name_ == "underrightarrow" ||
42 name_ == "underleftrightarrow";
46 bool MathDecorationInset::protect() const
49 name_ == "overbrace" ||
50 name_ == "underbrace" ||
51 name_ == "overleftarrow" ||
52 name_ == "overrightarrow" ||
53 name_ == "overleftrightarrow" ||
54 name_ == "underleftarrow" ||
55 name_ == "underrightarrow" ||
56 name_ == "underleftrightarrow";
60 bool MathDecorationInset::wide() const
63 name_ == "overline" ||
64 name_ == "underline" ||
65 name_ == "overbrace" ||
66 name_ == "underbrace" ||
67 name_ == "overleftarrow" ||
68 name_ == "overrightarrow" ||
69 name_ == "overleftrightarrow" ||
71 name_ == "widetilde" ||
72 name_ == "underleftarrow" ||
73 name_ == "underrightarrow" ||
74 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_, name_);
103 mathed_draw_deco(pi, x + 1 + (width() - dw_) / 2, y + dy_, dw_, dh_, name_);
104 drawMarkers(pi, x, y);
108 void MathDecorationInset::write(WriteStream & os) const
110 if (os.fragile() && protect())
112 os << '\\' << name_ << '{' << cell(0) << '}';
116 void MathDecorationInset::normalize(NormalStream & os) const
118 os << "[deco " << name_ << ' ' << cell(0) << ']';
122 void MathDecorationInset::infoize(std::ostream & os) const
124 os << "Deco: " << name_;