]> git.lyx.org Git - lyx.git/blob - src/mathed/math_amsarrayinset.C
Strip out redundant #includes
[lyx.git] / src / mathed / math_amsarrayinset.C
1 /**
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.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_amsarrayinset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
16 #include "math_support.h"
17
18 using std::auto_ptr;
19
20
21 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
22         : MathGridInset(m, n), name_(name)
23 {}
24
25
26 MathAMSArrayInset::MathAMSArrayInset(string const & name)
27         : MathGridInset(1, 1), name_(name)
28 {}
29
30
31 auto_ptr<InsetBase> MathAMSArrayInset::clone() const
32 {
33         return auto_ptr<InsetBase>(new MathAMSArrayInset(*this));
34 }
35
36
37 char const * MathAMSArrayInset::name_left() const
38 {
39         if (name_ == "bmatrix")
40                 return "[";
41         if (name_ == "Bmatrix")
42                 return "{";
43         if (name_ == "vmatrix")
44                 return "|";
45         if (name_ == "Vmatrix")
46                 return "Vert";
47         if (name_ == "pmatrix")
48                 return "(";
49         return ".";
50 }
51
52
53 char const * MathAMSArrayInset::name_right() const
54 {
55         if (name_ == "bmatrix")
56                 return "]";
57         if (name_ == "Bmatrix")
58                 return "}";
59         if (name_ == "vmatrix")
60                 return "|";
61         if (name_ == "Vmatrix")
62                 return "Vert";
63         if (name_ == "pmatrix")
64                 return ")";
65         return ".";
66 }
67
68
69 void MathAMSArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
70 {
71         MetricsInfo m = mi;
72         if (m.base.style == LM_ST_DISPLAY)
73                 m.base.style = LM_ST_TEXT;
74         MathGridInset::metrics(m);
75         dim_.wid += 12;
76         dim = dim_;
77 }
78
79
80 void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const
81 {
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());
86 }
87
88
89 void MathAMSArrayInset::write(WriteStream & os) const
90 {
91         os << "\\begin{" << name_ << '}';
92         MathGridInset::write(os);
93         os << "\\end{" << name_ << '}';
94 }
95
96
97 void MathAMSArrayInset::normalize(NormalStream & os) const
98 {
99         os << '[' << name_ << ' ';
100         MathGridInset::normalize(os);
101         os << ']';
102 }