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
37 bool MathDecorationInset::protect() const
40 name_ == "overbrace" ||
41 name_ == "underbrace" ||
42 name_ == "overleftarrow" ||
43 name_ == "overrightarrow";
47 void MathDecorationInset::metrics(MathStyles st) const
51 width_ = xcell(0).width();
52 ascent_ = xcell(0).ascent();
53 descent_ = xcell(0).descent();
55 dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
67 void MathDecorationInset::draw(Painter & pain, int x, int y) const
71 xcell(0).draw(pain, x, y);
72 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
76 void MathDecorationInset::write(ostream & os, bool fragile) const
78 if (fragile && protect())
80 os << '\\' << name_ << '{';
81 cell(0).write(os, fragile);
86 void MathDecorationInset::writeNormal(ostream & os) const
88 os << "[" << name_ << " ";
89 cell(0).writeNormal(os);