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::protect() const
34 name_ == "overbrace" ||
35 name_ == "underbrace" ||
36 name_ == "overleftarrow" ||
37 name_ == "overrightarrow";
41 void MathDecorationInset::metrics(MathStyles st) const
45 width_ = xcell(0).width();
46 ascent_ = xcell(0).ascent();
47 descent_ = xcell(0).descent();
49 dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
61 void MathDecorationInset::draw(Painter & pain, int x, int y) const
65 xcell(0).draw(pain, x, y);
66 mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
70 void MathDecorationInset::write(ostream & os, bool fragile) const
72 if (fragile && protect())
74 os << '\\' << name_ << '{';
75 cell(0).write(os, fragile);
80 void MathDecorationInset::writeNormal(ostream & os) const
82 os << "[" << name_ << " ";
83 cell(0).writeNormal(os);