7 #include "math_deliminset.h"
9 #include "math_parser.h"
12 #include "mathed/support.h"
13 #include "support/LOstream.h"
18 MathDelimInset::MathDelimInset(int l, int r, short st)
19 : MathParInset(st, "", LM_OT_DELIM), left_(l), right_(r) {}
22 MathedInset * MathDelimInset::Clone()
24 return new MathDelimInset(*this);
28 void MathDelimInset::Write(ostream & os, bool fragile)
30 latexkeys const * l = (left_ != '|') ?
31 lm_get_key_by_id(left_, LM_TK_SYM) : 0;
32 latexkeys const * r = (right_ != '|') ?
33 lm_get_key_by_id(right_, LM_TK_SYM) : 0;
36 os << '\\' << l->name << ' ';
38 if (left_ == '{' || left_ == '}') {
39 os << '\\' << char(left_) << ' ';
41 os << char(left_) << ' ';
44 MathParInset::Write(os, fragile);
47 os << '\\' << r->name << ' ';
49 if (right_ == '{' || right_ == '}') {
50 os << '\\' << char(right_) << ' ';
52 os << char(right_) << ' ';
58 void MathDelimInset::draw(Painter & pain, int x, int y)
62 MathParInset::draw(pain, x + dw_ + 2, y - dh_);
65 pain.line(x + 4, yo() - ascent,
66 x + 4, yo() + descent,
67 LColor::mathcursor, Painter::line_onoffdash);
69 mathed_draw_deco(pain, x, y - ascent, dw_, Height(), left_);
70 x += Width() - dw_ - 2;
72 pain.line(x + 4, yo() - ascent,
73 x + 4, yo() + descent,
74 LColor::mathcursor, Painter::line_onoffdash);
76 mathed_draw_deco(pain, x, y - ascent, dw_, Height(), right_);
80 void MathDelimInset::Metrics()
82 MathParInset::Metrics();
85 mathed_char_height(LM_TC_CONST, size(), 'I', d, dh_);
90 if (dw_ > 15) dw_ = 15;