5 #include "math_decorationinset.h"
6 #include "mathed/support.h"
7 #include "math_parser.h"
8 #include "support/LOstream.h"
14 MathDecorationInset::MathDecorationInset(string const & name)
15 : MathNestInset(1), name_(name)
19 MathInset * MathDecorationInset::clone() const
21 return new MathDecorationInset(*this);
25 bool MathDecorationInset::upper() const
27 return name_ != "underline" && name_ != "underbrace";
31 bool MathDecorationInset::isScriptable() const
34 name_ == "overbrace" ||
35 name_ == "underbrace" ||
36 name_ == "overleftarrow" ||
37 name_ == "overrightarrow";
41 bool MathDecorationInset::protect() const
44 name_ == "overbrace" ||
45 name_ == "underbrace" ||
46 name_ == "overleftarrow" ||
47 name_ == "overrightarrow";
51 void MathDecorationInset::metrics(MathStyles st) const
55 width_ = xcell(0).width();
56 ascent_ = xcell(0).ascent();
57 descent_ = xcell(0).descent();
59 dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
71 void MathDecorationInset::draw(Painter & pain, int x, int y) const
75 xcell(0).draw(pain, x, y);
76 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
80 void MathDecorationInset::write(ostream & os, bool fragile) const
82 if (fragile && protect())
84 os << '\\' << name_ << '{';
85 cell(0).write(os, fragile);
90 void MathDecorationInset::writeNormal(ostream & os) const
92 os << "[" << name_ << " ";
93 cell(0).writeNormal(os);