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