7 #include "math_deliminset.h"
8 #include "math_parser.h"
9 #include "mathed/support.h"
10 #include "support/LOstream.h"
14 MathDelimInset::MathDelimInset(string const & l, string const & r)
15 : MathNestInset(1), left_(l), right_(r)
19 MathInset * MathDelimInset::clone() const
21 return new MathDelimInset(*this);
25 string MathDelimInset::latexName(string const & 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
69 mathed_char_dim(LM_TC_VAR, st,'I', a, d, w);
71 int a0 = std::max(xcell(0).ascent(), a) - h0;
72 int d0 = std::max(xcell(0).descent(), d) + h0;
73 ascent_ = max(a0, d0) + h0;
74 descent_ = max(a0, d0) - h0;
75 width_ = xcell(0).width() + 2 * dw() + 4;
79 void MathDelimInset::draw(Painter & pain, int x, int y) const
85 int const b = y - ascent_ - 2;
86 xcell(0).draw(pain, x + w + 2, y);
87 mathed_draw_deco(pain, x + 1, b, w, height() + 4, left_);
88 mathed_draw_deco(pain, x + width() - w - 1, b, w, height() + 4, right_);