4 #include "math_amsarrayinset.h"
5 #include "math_mathmlstream.h"
6 #include "math_metricsinfo.h"
7 #include "math_support.h"
8 #include "math_streamstr.h"
9 #include "math_support.h"
13 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
14 : MathGridInset(m, n), name_(name)
18 MathAMSArrayInset::MathAMSArrayInset(string const & name)
19 : MathGridInset(1, 1), name_(name)
23 MathInset * MathAMSArrayInset::clone() const
25 return new MathAMSArrayInset(*this);
29 char const * MathAMSArrayInset::name_left() const
31 if (name_ == "bmatrix")
33 if (name_ == "Bmatrix")
35 if (name_ == "vmatrix")
37 if (name_ == "Vmatrix")
39 if (name_ == "pmatrix")
45 char const * MathAMSArrayInset::name_right() const
47 if (name_ == "bmatrix")
49 if (name_ == "Bmatrix")
51 if (name_ == "vmatrix")
53 if (name_ == "Vmatrix")
55 if (name_ == "pmatrix")
61 void MathAMSArrayInset::metrics(MathMetricsInfo & mi) const
63 MathMetricsInfo m = mi;
64 if (m.base.style == LM_ST_DISPLAY)
65 m.base.style = LM_ST_TEXT;
66 MathGridInset::metrics(m);
71 void MathAMSArrayInset::draw(MathPainterInfo & pi, int x, int y) const
73 MathGridInset::draw(pi, x + 6, y);
74 int const yy = y - ascent();
75 mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left());
76 mathed_draw_deco(pi, x + width() - 6, yy, 5, height(), name_right());
80 void MathAMSArrayInset::write(WriteStream & os) const
82 os << "\\begin{" << name_ << '}';
83 MathGridInset::write(os);
84 os << "\\end{" << name_ << '}';
88 void MathAMSArrayInset::normalize(NormalStream & os) const
90 os << '[' << name_ << ' ';
91 MathGridInset::normalize(os);