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', a, d, w);
96 int a0 = max(xcell(0).ascent(), a) - h0;
97 int d0 = max(xcell(0).descent(), d) + h0;
98 ascent_ = max(a0, d0) + h0;
99 descent_ = max(a0, d0) - h0;
100 width_ = xcell(0).width() + 2 * dw() + 8;
104 void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
107 int const b = y - ascent_;
108 xcell(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
136 cell(0).size() == 1 && cell(0).begin()->nucleus()
137 && cell(0).begin()->nucleus()->asMatrixInset();
139 os << "linalg[det](" << cell(0) << ")";
141 os << "abs(" << cell(0) << ")";
144 os << left_ << cell(0) << right_;
147 void MathDelimInset::mathematicize(MathematicaStream & os) const
151 cell(0).size() == 1 && cell(0).begin()->nucleus()
152 && cell(0).begin()->nucleus()->asMatrixInset();
154 os << "Det" << cell(0) << ']';
156 os << "Abs[" << cell(0) << ']';
159 os << left_ << cell(0) << right_;
164 void MathDelimInset::mathmlize(MathMLStream & os) const
166 os << "<fenced open=\"" << left_ << "\" close=\""
167 << right_ << "\">" << cell(0) << "</fenced>";
171 void MathDelimInset::octavize(OctaveStream & os) const
174 os << "det(" << cell(0) << ")";
176 os << left_ << cell(0) << right_;