2 * \file math_amsarrayinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_amsarrayinset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
16 #include "math_support.h"
21 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
22 : MathGridInset(m, n), name_(name)
26 MathAMSArrayInset::MathAMSArrayInset(string const & name)
27 : MathGridInset(1, 1), name_(name)
31 auto_ptr<InsetBase> MathAMSArrayInset::clone() const
33 return auto_ptr<InsetBase>(new MathAMSArrayInset(*this));
37 char const * MathAMSArrayInset::name_left() const
39 if (name_ == "bmatrix")
41 if (name_ == "Bmatrix")
43 if (name_ == "vmatrix")
45 if (name_ == "Vmatrix")
47 if (name_ == "pmatrix")
53 char const * MathAMSArrayInset::name_right() const
55 if (name_ == "bmatrix")
57 if (name_ == "Bmatrix")
59 if (name_ == "vmatrix")
61 if (name_ == "Vmatrix")
63 if (name_ == "pmatrix")
69 void MathAMSArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
72 if (m.base.style == LM_ST_DISPLAY)
73 m.base.style = LM_ST_TEXT;
74 MathGridInset::metrics(m);
80 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
82 MathGridInset::draw(pi, x + 6, y);
83 int const yy = y - dim_.ascent();
84 mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
85 mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
89 void MathAMSArrayInset::write(WriteStream & os) const
91 os << "\\begin{" << name_ << '}';
92 MathGridInset::write(os);
93 os << "\\end{" << name_ << '}';
97 void MathAMSArrayInset::normalize(NormalStream & os) const
99 os << '[' << name_ << ' ';
100 MathGridInset::normalize(os);