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"
15 MathDelimInset::MathDelimInset(string const & l, string const & r)
16 : MathNestInset(1), left_(l), right_(r)
20 MathInset * MathDelimInset::clone() const
22 return new MathDelimInset(*this);
26 void MathDelimInset::write(WriteStream & os) const
28 os << "\\left" << convertDelimToLatexName(left_) << cell(0)
29 << "\\right" << convertDelimToLatexName(right_);
33 void MathDelimInset::normalize(NormalStream & os) const
35 os << "[delim " << convertDelimToLatexName(left_) << ' '
36 << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
40 int MathDelimInset::dw() const
51 void MathDelimInset::metrics(MathMetricsInfo const & mi) const
55 mathed_char_dim(LM_TC_VAR, mi, 'I', a, d, w);
57 int a0 = std::max(xcell(0).ascent(), a) - h0;
58 int d0 = std::max(xcell(0).descent(), d) + h0;
59 ascent_ = std::max(a0, d0) + h0;
60 descent_ = std::max(a0, d0) - h0;
61 width_ = xcell(0).width() + 2 * dw() + 8;
65 void MathDelimInset::draw(Painter & pain, int x, int y) const
68 int const b = y - ascent_;
69 xcell(0).draw(pain, x + w + 4, y);
70 mathed_draw_deco(pain, x + 4, b, w, height(), left_);
71 mathed_draw_deco(pain, x + width() - w - 4, b, w, height(), right_);
75 bool MathDelimInset::isParanthesis() const
77 return left_ == "(" && right_ == ")";
81 bool MathDelimInset::isBrackets() const
83 return left_ == "[" && right_ == "]";
87 bool MathDelimInset::isAbs() const
89 return left_ == "|" && right_ == "|";
93 void MathDelimInset::maplize(MapleStream & os) const
97 cell(0).size() == 1 && cell(0).begin()->nucleus()
98 && cell(0).begin()->nucleus()->asMatrixInset();
100 os << "linalg[det](" << cell(0) << ")";
102 os << "abs(" << cell(0) << ")";
105 os << left_ << cell(0) << right_;
109 void MathDelimInset::mathmlize(MathMLStream & os) const
111 os << "<fenced open=\"" << left_ << "\" close=\""
112 << right_ << "\">" << cell(0) << "</fenced>";
116 void MathDelimInset::octavize(OctaveStream & os) const
119 os << "det(" << cell(0) << ")";
121 os << left_ << cell(0) << right_;