3 #include "math_amsarrayinset.h"
4 #include "math_mathmlstream.h"
5 #include "metricsinfo.h"
6 #include "math_streamstr.h"
7 #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 auto_ptr<InsetBase> MathAMSArrayInset::clone() const
25 return auto_ptr<InsetBase>(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(MetricsInfo & mi, Dimension & dim) const
64 if (m.base.style == LM_ST_DISPLAY)
65 m.base.style = LM_ST_TEXT;
66 MathGridInset::metrics(m);
72 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
74 MathGridInset::draw(pi, x + 6, y);
75 int const yy = y - dim_.ascent();
76 mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
77 mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
81 void MathAMSArrayInset::write(WriteStream & os) const
83 os << "\\begin{" << name_ << '}';
84 MathGridInset::write(os);
85 os << "\\end{" << name_ << '}';
89 void MathAMSArrayInset::normalize(NormalStream & os) const
91 os << '[' << name_ << ' ';
92 MathGridInset::normalize(os);