7 #include "math_deliminset.h"
8 #include "math_parser.h"
9 #include "mathed/support.h"
10 #include "support/LOstream.h"
15 MathDelimInset::MathDelimInset(string const & l, string const & r)
16 : MathNestInset(1), left_(l), right_(r)
20 MathInset * MathDelimInset::clone() const
22 return new MathDelimInset(*this);
26 string MathDelimInset::latexName(string const & name)
42 return "\\" + name + " ";
46 void MathDelimInset::write(MathWriteInfo & os) const
48 os << "\\left" << latexName(left_) << cell(0)
49 << "\\right" << latexName(right_);
53 void MathDelimInset::writeNormal(std::ostream & os) const
55 os << "[delim " << latexName(left_) << ' ' << latexName(right_) << ' ';
56 cell(0).writeNormal(os);
61 int MathDelimInset::dw() const
72 void MathDelimInset::metrics(MathMetricsInfo const & mi) const
76 mathed_char_dim(LM_TC_VAR, mi, 'I', a, d, w);
78 int a0 = std::max(xcell(0).ascent(), a) - h0;
79 int d0 = std::max(xcell(0).descent(), d) + h0;
80 ascent_ = max(a0, d0) + h0;
81 descent_ = max(a0, d0) - h0;
82 width_ = xcell(0).width() + 2 * dw() + 4;
86 void MathDelimInset::draw(Painter & pain, int x, int y) const
89 int const b = y - ascent_;
90 xcell(0).draw(pain, x + w + 2, y);
91 mathed_draw_deco(pain, x + 1, b, w, height(), left_);
92 mathed_draw_deco(pain, x + width() - w - 1, b, w, height(), right_);