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)
39 return "\\" + name + " ";
46 MathDelimInset::MathDelimInset(string const & l, string const & r)
47 : MathNestInset(1), left_(l), right_(r)
51 MathDelimInset::MathDelimInset
52 (string const & l, string const & r, MathArray const & ar)
53 : MathNestInset(1), left_(l), right_(r)
59 MathInset * MathDelimInset::clone() const
61 return new MathDelimInset(*this);
65 void MathDelimInset::write(WriteStream & os) const
67 os << "\\left" << convertDelimToLatexName(left_) << cell(0)
68 << "\\right" << convertDelimToLatexName(right_);
72 void MathDelimInset::normalize(NormalStream & os) const
74 os << "[delim " << convertDelimToLatexName(left_) << ' '
75 << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
79 int MathDelimInset::dw() const
90 void MathDelimInset::metrics(MathMetricsInfo & mi) const
94 mathed_char_dim(mi.base.font, 'I', t);
95 int h0 = (t.a + t.d) / 2;
96 int a0 = max(cell(0).ascent(), t.a) - h0;
97 int d0 = max(cell(0).descent(), t.d) + h0;
98 dim_.a = max(a0, d0) + h0;
99 dim_.d = max(a0, d0) - h0;
100 dim_.w = cell(0).width() + 2 * dw() + 8;
104 void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
107 int const b = y - ascent();
108 cell(0).draw(pi, x + w + 4, y);
109 mathed_draw_deco(pi, x + 4, b, w, height(), left_);
110 mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
114 bool MathDelimInset::isParanthesis() const
116 return left_ == "(" && right_ == ")";
120 bool MathDelimInset::isBrackets() const
122 return left_ == "[" && right_ == "]";
126 bool MathDelimInset::isAbs() const
128 return left_ == "|" && right_ == "|";
132 void MathDelimInset::maplize(MapleStream & os) const
135 if (cell(0).size() == 1 && cell(0).front()->asMatrixInset())
136 os << "linalg[det](" << cell(0) << ")";
138 os << "abs(" << cell(0) << ")";
141 os << left_ << cell(0) << right_;
144 void MathDelimInset::mathematicize(MathematicaStream & os) const
147 if (cell(0).size() == 1 && cell(0).front()->asMatrixInset())
148 os << "Det" << cell(0) << ']';
150 os << "Abs[" << cell(0) << ']';
153 os << left_ << cell(0) << right_;
158 void MathDelimInset::mathmlize(MathMLStream & os) const
160 os << "<fenced open=\"" << left_ << "\" close=\""
161 << right_ << "\">" << cell(0) << "</fenced>";
165 void MathDelimInset::octavize(OctaveStream & os) const
168 os << "det(" << cell(0) << ")";
170 os << left_ << cell(0) << right_;