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 "LaTeXFeatures.h"
14 #include "math_amsarrayinset.h"
15 #include "math_data.h"
16 #include "math_mathmlstream.h"
17 #include "math_streamstr.h"
18 #include "math_support.h"
24 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
25 : MathGridInset(m, n), name_(name)
29 MathAMSArrayInset::MathAMSArrayInset(string const & name)
30 : MathGridInset(1, 1), name_(name)
34 auto_ptr<InsetBase> MathAMSArrayInset::doClone() const
36 return auto_ptr<InsetBase>(new MathAMSArrayInset(*this));
40 char const * MathAMSArrayInset::name_left() const
42 if (name_ == "bmatrix")
44 if (name_ == "Bmatrix")
46 if (name_ == "vmatrix")
48 if (name_ == "Vmatrix")
50 if (name_ == "pmatrix")
56 char const * MathAMSArrayInset::name_right() const
58 if (name_ == "bmatrix")
60 if (name_ == "Bmatrix")
62 if (name_ == "vmatrix")
64 if (name_ == "Vmatrix")
66 if (name_ == "pmatrix")
72 void MathAMSArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
75 if (m.base.style == LM_ST_DISPLAY)
76 m.base.style = LM_ST_TEXT;
77 MathGridInset::metrics(m, dim);
83 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
85 MathGridInset::draw(pi, x + 6, y);
86 int const yy = y - dim_.ascent();
87 mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left());
88 mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right());
89 setPosCache(pi, x, y);
93 void MathAMSArrayInset::write(WriteStream & os) const
95 os << "\\begin{" << name_ << '}';
96 MathGridInset::write(os);
97 os << "\\end{" << name_ << '}';
101 void MathAMSArrayInset::normalize(NormalStream & os) const
103 os << '[' << name_ << ' ';
104 MathGridInset::normalize(os);
109 void MathAMSArrayInset::validate(LaTeXFeatures & features) const
111 features.require("amsmath");
112 MathGridInset::validate(features);