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"
23 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
24 : MathGridInset(m, n), name_(name)
28 MathAMSArrayInset::MathAMSArrayInset(string const & name)
29 : MathGridInset(1, 1), name_(name)
33 auto_ptr<InsetBase> MathAMSArrayInset::clone() const
35 return auto_ptr<InsetBase>(new MathAMSArrayInset(*this));
39 char const * MathAMSArrayInset::name_left() const
41 if (name_ == "bmatrix")
43 if (name_ == "Bmatrix")
45 if (name_ == "vmatrix")
47 if (name_ == "Vmatrix")
49 if (name_ == "pmatrix")
55 char const * MathAMSArrayInset::name_right() const
57 if (name_ == "bmatrix")
59 if (name_ == "Bmatrix")
61 if (name_ == "vmatrix")
63 if (name_ == "Vmatrix")
65 if (name_ == "pmatrix")
71 void MathAMSArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
74 if (m.base.style == LM_ST_DISPLAY)
75 m.base.style = LM_ST_TEXT;
76 MathGridInset::metrics(m);
82 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
84 MathGridInset::draw(pi, x + 6, y);
85 int const yy = y - dim_.ascent();
86 mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
87 mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
91 void MathAMSArrayInset::write(WriteStream & os) const
93 os << "\\begin{" << name_ << '}';
94 MathGridInset::write(os);
95 os << "\\end{" << name_ << '}';
99 void MathAMSArrayInset::normalize(NormalStream & os) const
101 os << '[' << name_ << ' ';
102 MathGridInset::normalize(os);