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_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17 #include "math_support.h"
22 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
23 : MathGridInset(m, n), name_(name)
27 MathAMSArrayInset::MathAMSArrayInset(string const & name)
28 : MathGridInset(1, 1), name_(name)
32 auto_ptr<InsetBase> MathAMSArrayInset::clone() const
34 return auto_ptr<InsetBase>(new MathAMSArrayInset(*this));
38 char const * MathAMSArrayInset::name_left() const
40 if (name_ == "bmatrix")
42 if (name_ == "Bmatrix")
44 if (name_ == "vmatrix")
46 if (name_ == "Vmatrix")
48 if (name_ == "pmatrix")
54 char const * MathAMSArrayInset::name_right() const
56 if (name_ == "bmatrix")
58 if (name_ == "Bmatrix")
60 if (name_ == "vmatrix")
62 if (name_ == "Vmatrix")
64 if (name_ == "pmatrix")
70 void MathAMSArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
73 if (m.base.style == LM_ST_DISPLAY)
74 m.base.style = LM_ST_TEXT;
75 MathGridInset::metrics(m);
81 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
83 MathGridInset::draw(pi, x + 6, y);
84 int const yy = y - dim_.ascent();
85 mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
86 mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
90 void MathAMSArrayInset::write(WriteStream & os) const
92 os << "\\begin{" << name_ << '}';
93 MathGridInset::write(os);
94 os << "\\end{" << name_ << '}';
98 void MathAMSArrayInset::normalize(NormalStream & os) const
100 os << '[' << name_ << ' ';
101 MathGridInset::normalize(os);