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 string MathDelimInset::latexName(string const & name)
42 return "\\" + name + " ";
46 void MathDelimInset::write(WriteStream & os) const
48 os << "\\left" << latexName(left_) << cell(0)
49 << "\\right" << latexName(right_);
53 void MathDelimInset::normalize(NormalStream & os) const
55 os << "[delim " << latexName(left_) << ' '
56 << latexName(right_) << ' ' << cell(0) << ']';
60 int MathDelimInset::dw() const
71 void MathDelimInset::metrics(MathMetricsInfo const & mi) const
75 mathed_char_dim(LM_TC_VAR, mi, 'I', a, d, w);
77 int a0 = std::max(xcell(0).ascent(), a) - h0;
78 int d0 = std::max(xcell(0).descent(), d) + h0;
79 ascent_ = std::max(a0, d0) + h0;
80 descent_ = std::max(a0, d0) - h0;
81 width_ = xcell(0).width() + 2 * dw() + 4;
85 void MathDelimInset::draw(Painter & pain, int x, int y) const
88 int const b = y - ascent_;
89 xcell(0).draw(pain, x + w + 2, y);
90 mathed_draw_deco(pain, x + 1, b, w, height(), left_);
91 mathed_draw_deco(pain, x + width() - w - 1, b, w, height(), right_);
95 bool MathDelimInset::isParanthesis() const
97 return left_ == "(" && right_ == ")";
101 bool MathDelimInset::isBrackets() const
103 return left_ == "[" && right_ == "]";
107 bool MathDelimInset::isAbs() const
109 return left_ == "|" && right_ == "|";
113 void MathDelimInset::maplize(MapleStream & os) const
117 cell(0).size() == 1 && cell(0).begin()->nucleus()
118 && cell(0).begin()->nucleus()->asMatrixInset();
120 os << "linalg[det](" << cell(0) << ")";
122 os << "abs(" << cell(0) << ")";
125 os << left_ << cell(0) << right_;
129 void MathDelimInset::mathmlize(MathMLStream & os) const
131 os << "<fenced open=\"" << left_ << "\" close=\""
132 << right_ << "\">" << cell(0) << "</fenced>";
136 void MathDelimInset::octavize(OctaveStream & os) const
139 os << "det(" << cell(0) << ")";
141 os << left_ << cell(0) << right_;