MathDecorationInset::MathDecorationInset(latexkeys const * key)
: MathNestInset(1), key_(key)
{
- upper_ = key_->id != LM_underline && key_->id != LM_underbrace;
}
}
+bool MathDecorationInset::upper() const
+{
+ return key_->id != LM_underline && key_->id != LM_underbrace;
+}
+
+
+bool MathDecorationInset::protect() const
+{
+ return
+ key_->name == "overbrace" ||
+ key_->name == "underbrace" ||
+ key_->name == "overleftarrow" ||
+ key_->name == "overrightarrow";
+}
+
void MathDecorationInset::metrics(MathStyles st) const
{
dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
- if (upper_) {
+ if (upper()) {
dy_ = -ascent_ - dh_;
ascent_ += dh_ + 1;
} else {
void MathDecorationInset::write(ostream & os, bool fragile) const
{
string name = key_->name;
- if (fragile &&
- (name == "overbrace" ||
- name == "underbrace" ||
- name == "overleftarrow" ||
- name == "overrightarrow"))
+ if (fragile && protect())
os << "\\protect";
os << '\\' << name;
os << '}';
}
+
void MathDecorationInset::writeNormal(ostream & os) const
{
os << "[" << key_->name << " ";
}
+int MathDelimInset::dw() const
+{
+ int w = height() / 5;
+ if (w > 15)
+ w = 15;
+ if (w < 4)
+ w = 4;
+ return w;
+}
+
+
+void MathDelimInset::metrics(MathStyles st) const
+{
+ xcell(0).metrics(st);
+ size_ = st;
+ ascent_ = std::max(xcell(0).ascent(), mathed_char_ascent(LM_TC_VAR, st,'I'));
+ descent_ = xcell(0).descent();
+ width_ = xcell(0).width() + 2 * dw() + 4;
+}
+
+
void MathDelimInset::draw(Painter & pain, int x, int y) const
{
xo(x);
yo(y);
int w = dw();
- xcell(0).draw(pain, x + w, y);
+ xcell(0).draw(pain, x + w + 2, y);
if (latexName(left_) == ".") {
- pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
+ pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
LColor::mathcursor, Painter::line_onoffdash);
} else
- mathed_draw_deco(pain, x, y - ascent_, w, height(), left_);
+ mathed_draw_deco(pain, x, y - ascent_ - 2, w, height() + 4, left_);
- x += width() - w - 2;
+ x += width();
if (latexName(right_) == ".") {
- pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
+ pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
LColor::mathcursor, Painter::line_onoffdash);
} else
- mathed_draw_deco(pain, x, y - ascent_, w, height(), right_);
-}
-
-
-int MathDelimInset::dw() const
-{
- int w = height()/5;
- if (w > 15)
- w = 15;
- if (w < 6)
- w = 6;
- return w;
-}
-
-
-void MathDelimInset::metrics(MathStyles st) const
-{
- xcell(0).metrics(st);
- size_ = st;
- ascent_ = xcell(0).ascent() + 2;
- descent_ = xcell(0).descent() + 2;
- width_ = xcell(0).width() + 2 * dw() + 4;
+ mathed_draw_deco(pain, x - dw(), y - ascent_ - 2, w, height() + 4, right_);
}