7 #include "math_deliminset.h"
8 #include "math_parser.h"
9 #include "math_support.h"
10 #include "math_mathmlstream.h"
11 #include "math_streamstr.h"
12 #include "math_extern.h"
18 MathDelimInset::MathDelimInset(string const & l, string const & r)
19 : MathNestInset(1), left_(l), right_(r)
23 MathInset * MathDelimInset::clone() const
25 return new MathDelimInset(*this);
29 void MathDelimInset::write(WriteStream & os) const
31 os << "\\left" << convertDelimToLatexName(left_) << cell(0)
32 << "\\right" << convertDelimToLatexName(right_);
36 void MathDelimInset::normalize(NormalStream & os) const
38 os << "[delim " << convertDelimToLatexName(left_) << ' '
39 << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
43 int MathDelimInset::dw() const
54 void MathDelimInset::metrics(MathMetricsInfo const & mi) const
59 whichFont(font, LM_TC_VAR, mi);
60 mathed_char_dim(font, 'I', a, d, w);
62 int a0 = max(xcell(0).ascent(), a) - h0;
63 int d0 = max(xcell(0).descent(), d) + h0;
64 ascent_ = max(a0, d0) + h0;
65 descent_ = max(a0, d0) - h0;
66 width_ = xcell(0).width() + 2 * dw() + 8;
70 void MathDelimInset::draw(Painter & pain, int x, int y) const
73 int const b = y - ascent_;
74 xcell(0).draw(pain, x + w + 4, y);
75 mathed_draw_deco(pain, x + 4, b, w, height(), left_);
76 mathed_draw_deco(pain, x + width() - w - 4, b, w, height(), right_);
80 bool MathDelimInset::isParanthesis() const
82 return left_ == "(" && right_ == ")";
86 bool MathDelimInset::isBrackets() const
88 return left_ == "[" && right_ == "]";
92 bool MathDelimInset::isAbs() const
94 return left_ == "|" && right_ == "|";
98 void MathDelimInset::maplize(MapleStream & os) const
102 cell(0).size() == 1 && cell(0).begin()->nucleus()
103 && cell(0).begin()->nucleus()->asMatrixInset();
105 os << "linalg[det](" << cell(0) << ")";
107 os << "abs(" << cell(0) << ")";
110 os << left_ << cell(0) << right_;
114 void MathDelimInset::mathmlize(MathMLStream & os) const
116 os << "<fenced open=\"" << left_ << "\" close=\""
117 << right_ << "\">" << cell(0) << "</fenced>";
121 void MathDelimInset::octavize(OctaveStream & os) const
124 os << "det(" << cell(0) << ")";
126 os << left_ << cell(0) << right_;