5 #include "math_deliminset.h"
6 #include "math_parser.h"
8 #include "mathed/support.h"
9 #include "support/LOstream.h"
12 MathDelimInset::MathDelimInset(latexkeys const * l, latexkeys const * r)
13 : MathNestInset(1), left_(l), right_(r)
17 MathInset * MathDelimInset::clone() const
19 return new MathDelimInset(*this);
23 string MathDelimInset::latexName(latexkeys const * l)
25 //static const string vdelim("(){}[]./|");
26 string name = l->name;
41 return "\\" + name + " ";
45 void MathDelimInset::write(std::ostream & os, bool fragile) const
47 os << "\\left" << latexName(left_);
48 cell(0).write(os, fragile);
49 os << "\\right" << latexName(right_);
53 int MathDelimInset::dw() const
64 void MathDelimInset::metrics(MathStyles st) const
68 ascent_ = std::max(xcell(0).ascent(), mathed_char_ascent(LM_TC_VAR, st,'I'));
69 descent_ = xcell(0).descent();
70 width_ = xcell(0).width() + 2 * dw() + 4;
74 void MathDelimInset::draw(Painter & pain, int x, int y) const
80 xcell(0).draw(pain, x + w + 2, y);
82 if (latexName(left_) == ".") {
83 pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
84 LColor::mathcursor, Painter::line_onoffdash);
86 mathed_draw_deco(pain, x, y - ascent_ - 2, w, height() + 4, left_);
90 if (latexName(right_) == ".") {
91 pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
92 LColor::mathcursor, Painter::line_onoffdash);
94 mathed_draw_deco(pain, x - dw(), y - ascent_ - 2, w, height() + 4, right_);