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