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
58 mathed_char_dim(LM_TC_VAR, mi, 'I', a, d, w);
60 int a0 = max(xcell(0).ascent(), a) - h0;
61 int d0 = max(xcell(0).descent(), d) + h0;
62 ascent_ = max(a0, d0) + h0;
63 descent_ = max(a0, d0) - h0;
64 width_ = xcell(0).width() + 2 * dw() + 8;
68 void MathDelimInset::draw(Painter & pain, int x, int y) const
71 int const b = y - ascent_;
72 xcell(0).draw(pain, x + w + 4, y);
73 mathed_draw_deco(pain, x + 4, b, w, height(), left_);
74 mathed_draw_deco(pain, x + width() - w - 4, b, w, height(), right_);
78 bool MathDelimInset::isParanthesis() const
80 return left_ == "(" && right_ == ")";
84 bool MathDelimInset::isBrackets() const
86 return left_ == "[" && right_ == "]";
90 bool MathDelimInset::isAbs() const
92 return left_ == "|" && right_ == "|";
96 void MathDelimInset::maplize(MapleStream & os) const
100 cell(0).size() == 1 && cell(0).begin()->nucleus()
101 && cell(0).begin()->nucleus()->asMatrixInset();
103 os << "linalg[det](" << cell(0) << ")";
105 os << "abs(" << cell(0) << ")";
108 os << left_ << cell(0) << right_;
112 void MathDelimInset::mathmlize(MathMLStream & os) const
114 os << "<fenced open=\"" << left_ << "\" close=\""
115 << right_ << "\">" << cell(0) << "</fenced>";
119 void MathDelimInset::octavize(OctaveStream & os) const
122 os << "det(" << cell(0) << ")";
124 os << left_ << cell(0) << right_;