5 #include "math_deliminset.h"
6 #include "math_parser.h"
8 #include "mathed/support.h"
9 #include "support/LOstream.h"
12 MathDelimInset::MathDelimInset(int l, int r)
13 : MathInset(1), left_(l), right_(r)
17 MathInset * MathDelimInset::clone() const
19 return new MathDelimInset(*this);
23 void MathDelimInset::Write(std::ostream & os, bool fragile) const
25 latexkeys const * l = (left_ != '|') ?
26 lm_get_key_by_id(left_, LM_TK_SYM) : 0;
27 latexkeys const * r = (right_ != '|') ?
28 lm_get_key_by_id(right_, LM_TK_SYM) : 0;
32 os << '\\' << l->name << ' ';
34 if (left_ == '{' || left_ == '}')
35 os << '\\' << char(left_) << ' ';
37 os << char(left_) << ' ';
40 cell(0).Write(os, fragile);
44 os << '\\' << r->name << ' ';
46 if (right_ == '{' || right_ == '}')
47 os << '\\' << char(right_) << ' ';
49 os << char(right_) << ' ';
54 void MathDelimInset::draw(Painter & pain, int x, int y)
60 xcell(0).draw(pain, x + w, y);
63 pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
64 LColor::mathcursor, Painter::line_onoffdash);
66 mathed_draw_deco(pain, x, y - ascent_, w, height(), left_);
71 pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
72 LColor::mathcursor, Painter::line_onoffdash);
74 mathed_draw_deco(pain, x, y - ascent_, w, height(), right_);
78 int MathDelimInset::dw() const
89 void MathDelimInset::Metrics(MathStyles st, int, int)
93 ascent_ = xcell(0).ascent() + 2;
94 descent_ = xcell(0).descent() + 2;
95 width_ = xcell(0).width() + 2 * dw() + 4;