7 #include "math_deliminset.h"
8 #include "math_parser.h"
11 #include "mathed/support.h"
12 #include "support/LOstream.h"
15 MathDelimInset::MathDelimInset(int l, int r)
16 : MathInset("", LM_OT_DELIM, 1), left_(l), right_(r)
20 MathInset * MathDelimInset::Clone() const
22 return new MathDelimInset(*this);
26 void MathDelimInset::Write(std::ostream & os, bool fragile) const
28 latexkeys const * l = (left_ != '|') ?
29 lm_get_key_by_id(left_, LM_TK_SYM) : 0;
30 latexkeys const * r = (right_ != '|') ?
31 lm_get_key_by_id(right_, LM_TK_SYM) : 0;
35 os << '\\' << l->name << ' ';
37 if (left_ == '{' || left_ == '}')
38 os << '\\' << char(left_) << ' ';
40 os << char(left_) << ' ';
43 cell(0).Write(os, fragile);
47 os << '\\' << r->name << ' ';
49 if (right_ == '{' || right_ == '}')
50 os << '\\' << char(right_) << ' ';
52 os << char(right_) << ' ';
57 void MathDelimInset::draw(Painter & pain, int x, int y)
63 xcell(0).draw(pain, x + w, y);
66 pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
67 LColor::mathcursor, Painter::line_onoffdash);
69 mathed_draw_deco(pain, x, y - ascent_, w, height(), left_);
74 pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
75 LColor::mathcursor, Painter::line_onoffdash);
77 mathed_draw_deco(pain, x, y - ascent_, w, height(), right_);
81 int MathDelimInset::dw() const
92 void MathDelimInset::Metrics(MathStyles st)
96 ascent_ = xcell(0).ascent() + 2;
97 descent_ = xcell(0).descent() + 2;
98 width_ = xcell(0).width() + 2 * dw() + 4;