4 #include "math_deliminset.h"
5 #include "math_parser.h"
6 #include "math_support.h"
7 #include "math_mathmlstream.h"
8 #include "math_streamstr.h"
9 #include "math_extern.h"
16 string convertDelimToLatexName(string const & name)
36 return '\\' + name + ' ';
43 MathDelimInset::MathDelimInset(string const & l, string const & r)
44 : MathNestInset(1), left_(l), right_(r)
48 MathDelimInset::MathDelimInset
49 (string const & l, string const & r, MathArray const & ar)
50 : MathNestInset(1), left_(l), right_(r)
56 MathInset * MathDelimInset::clone() const
58 return new MathDelimInset(*this);
62 void MathDelimInset::write(WriteStream & os) const
64 os << "\\left" << convertDelimToLatexName(left_) << cell(0)
65 << "\\right" << convertDelimToLatexName(right_);
69 void MathDelimInset::normalize(NormalStream & os) const
71 os << "[delim " << convertDelimToLatexName(left_) << ' '
72 << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
76 int MathDelimInset::dw() const
87 void MathDelimInset::metrics(MetricsInfo & mi) const
91 mathed_char_dim(mi.base.font, 'I', t);
92 int h0 = (t.a + t.d) / 2;
93 int a0 = max(cell(0).ascent(), t.a) - h0;
94 int d0 = max(cell(0).descent(), t.d) + h0;
95 dim_.a = max(a0, d0) + h0;
96 dim_.d = max(a0, d0) - h0;
97 dim_.w = cell(0).width() + 2 * dw() + 8;
101 void MathDelimInset::draw(PainterInfo & pi, int x, int y) const
104 int const b = y - ascent();
105 cell(0).draw(pi, x + w + 4, y);
106 mathed_draw_deco(pi, x + 4, b, w, height(), left_);
107 mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
111 bool MathDelimInset::isParanthesis() const
113 return left_ == "(" && right_ == ")";
117 bool MathDelimInset::isBrackets() const
119 return left_ == "[" && right_ == "]";
123 bool MathDelimInset::isAbs() const
125 return left_ == "|" && right_ == "|";
129 void MathDelimInset::maple(MapleStream & os) const
132 if (cell(0).size() == 1 && cell(0).front()->asMatrixInset())
133 os << "linalg[det](" << cell(0) << ')';
135 os << "abs(" << cell(0) << ')';
138 os << left_ << cell(0) << right_;
141 void MathDelimInset::maxima(MaximaStream & os) const
144 if (cell(0).size() == 1 && cell(0).front()->asMatrixInset())
145 os << "determinant(" << cell(0) << ')';
147 os << "abs(" << cell(0) << ')';
150 os << left_ << cell(0) << right_;
154 void MathDelimInset::mathematica(MathematicaStream & os) const
157 if (cell(0).size() == 1 && cell(0).front()->asMatrixInset())
158 os << "Det" << cell(0) << ']';
160 os << "Abs[" << cell(0) << ']';
163 os << left_ << cell(0) << right_;
167 void MathDelimInset::mathmlize(MathMLStream & os) const
169 os << "<fenced open=\"" << left_ << "\" close=\""
170 << right_ << "\">" << cell(0) << "</fenced>";
174 void MathDelimInset::octave(OctaveStream & os) const
177 os << "det(" << cell(0) << ')';
179 os << left_ << cell(0) << right_;