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"
19 string convertDelimToLatexName(string const & name)
35 return "\\" + name + " ";
42 MathDelimInset::MathDelimInset(string const & l, string const & r)
43 : MathNestInset(1), left_(l), right_(r)
47 MathDelimInset::MathDelimInset
48 (string const & l, string const & r, MathArray const & ar)
49 : MathNestInset(1), left_(l), right_(r)
55 MathInset * MathDelimInset::clone() const
57 return new MathDelimInset(*this);
61 void MathDelimInset::write(WriteStream & os) const
63 os << "\\left" << convertDelimToLatexName(left_) << cell(0)
64 << "\\right" << convertDelimToLatexName(right_);
68 void MathDelimInset::normalize(NormalStream & os) const
70 os << "[delim " << convertDelimToLatexName(left_) << ' '
71 << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
75 int MathDelimInset::dw() const
86 void MathDelimInset::metrics(MathMetricsInfo & mi) const
90 mathed_char_dim(mi.base.font, 'I', a, d, w);
92 int a0 = max(xcell(0).ascent(), a) - h0;
93 int d0 = max(xcell(0).descent(), d) + h0;
94 ascent_ = max(a0, d0) + h0;
95 descent_ = max(a0, d0) - h0;
96 width_ = xcell(0).width() + 2 * dw() + 8;
100 void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
103 int const b = y - ascent_;
104 xcell(0).draw(pi, x + w + 4, y);
105 mathed_draw_deco(pi, x + 4, b, w, height(), left_);
106 mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
110 bool MathDelimInset::isParanthesis() const
112 return left_ == "(" && right_ == ")";
116 bool MathDelimInset::isBrackets() const
118 return left_ == "[" && right_ == "]";
122 bool MathDelimInset::isAbs() const
124 return left_ == "|" && right_ == "|";
128 void MathDelimInset::maplize(MapleStream & os) const
132 cell(0).size() == 1 && cell(0).begin()->nucleus()
133 && cell(0).begin()->nucleus()->asMatrixInset();
135 os << "linalg[det](" << cell(0) << ")";
137 os << "abs(" << cell(0) << ")";
140 os << left_ << cell(0) << right_;
144 void MathDelimInset::mathmlize(MathMLStream & os) const
146 os << "<fenced open=\"" << left_ << "\" close=\""
147 << right_ << "\">" << cell(0) << "</fenced>";
151 void MathDelimInset::octavize(OctaveStream & os) const
154 os << "det(" << cell(0) << ")";
156 os << left_ << cell(0) << right_;