]> git.lyx.org Git - lyx.git/blob - src/mathed/math_amsarrayinset.C
rename commandtags.h to lfuns.h and renumber/cleanup. Rebuild the tree !
[lyx.git] / src / mathed / math_amsarrayinset.C
1 #include <config.h>
2
3
4 #include "math_amsarrayinset.h"
5 #include "math_mathmlstream.h"
6 #include "math_metricsinfo.h"
7 #include "math_support.h"
8 #include "math_streamstr.h"
9 #include "math_support.h"
10 #include "Lsstream.h"
11
12
13 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
14         : MathGridInset(m, n), name_(name)
15 {}
16
17
18 MathAMSArrayInset::MathAMSArrayInset(string const & name)
19         : MathGridInset(1, 1), name_(name)
20 {}
21
22
23 MathInset * MathAMSArrayInset::clone() const
24 {
25         return new MathAMSArrayInset(*this);
26 }
27
28
29 char const * MathAMSArrayInset::name_left() const
30 {
31         if (name_ == "bmatrix")
32                 return "[";
33         if (name_ == "Bmatrix")
34                 return "{";
35         if (name_ == "vmatrix")
36                 return "|";
37         if (name_ == "Vmatrix")
38                 return "Vert";
39         if (name_ == "pmatrix")
40                 return "(";
41         return ".";
42 }
43
44
45 char const * MathAMSArrayInset::name_right() const
46 {
47         if (name_ == "bmatrix")
48                 return "]";
49         if (name_ == "Bmatrix")
50                 return "}";
51         if (name_ == "vmatrix")
52                 return "|";
53         if (name_ == "Vmatrix")
54                 return "Vert";
55         if (name_ == "pmatrix")
56                 return ")";
57         return ".";
58 }
59
60
61 void MathAMSArrayInset::metrics(MathMetricsInfo & mi) const
62 {
63         MathMetricsInfo m = mi;
64         if (m.base.style == LM_ST_DISPLAY)
65                 m.base.style = LM_ST_TEXT;
66         MathGridInset::metrics(m);
67         dim_.w += 12;
68 }
69
70
71 void MathAMSArrayInset::draw(MathPainterInfo & pi, int x, int y) const
72 {
73         MathGridInset::draw(pi, x + 6, y);
74         int const yy = y - ascent();
75         mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left());
76         mathed_draw_deco(pi, x + width() - 6, yy, 5, height(), name_right());
77 }
78
79
80 void MathAMSArrayInset::write(WriteStream & os) const
81 {
82         os << "\\begin{" << name_ << '}';
83         MathGridInset::write(os);
84         os << "\\end{" << name_ << '}';
85 }
86
87
88 void MathAMSArrayInset::normalize(NormalStream & os) const
89 {
90         os << '[' << name_ << ' ';
91         MathGridInset::normalize(os);
92         os << ']';
93 }