]> git.lyx.org Git - lyx.git/blob - src/mathed/math_amsarrayinset.C
fix typo that put too many include paths for most people
[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_support.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "Lsstream.h"
13
14
15 MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n)
16         : MathGridInset(m, n), name_(name)
17 {}
18
19
20 MathAMSArrayInset::MathAMSArrayInset(string const & name)
21         : MathGridInset(1, 1), name_(name)
22 {}
23
24
25 MathInset * MathAMSArrayInset::clone() const
26 {
27         return new MathAMSArrayInset(*this);
28 }
29
30
31 char const * MathAMSArrayInset::name_left() const
32 {
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_ == "vmatrix")
50                 return "|";
51         if (name_ == "Vmatrix")
52                 return "Vert";
53         if (name_ == "pmatrix")
54                 return ")";
55         return ".";
56 }
57
58
59 void MathAMSArrayInset::metrics(MathMetricsInfo const & st) const
60 {
61         MathMetricsInfo mi = st;
62         if (mi.style == LM_ST_DISPLAY)
63                 mi.style = LM_ST_TEXT;
64         MathGridInset::metrics(mi);
65         width_ += 12;
66 }
67
68
69 void MathAMSArrayInset::draw(Painter & pain, int x, int y) const
70 {
71         MathGridInset::draw(pain, x + 6, y);
72         int yy = y - ascent_;
73         mathed_draw_deco(pain, x + 1, yy, 5, height(), name_left());
74         mathed_draw_deco(pain, x + width_ - 6, yy, 5, height(), name_right());
75 }
76
77
78 void MathAMSArrayInset::write(WriteStream & os) const
79 {
80         os << "\\begin{" << name_ << "}";
81         MathGridInset::write(os);
82         os << "\\end{" << name_ << "}";
83 }
84
85
86 void MathAMSArrayInset::normalize(NormalStream & os) const
87 {
88         os << "[" << name_ << " ";
89         MathGridInset::normalize(os);
90         os << "]";
91 }
92
93
94 void MathAMSArrayInset::maplize(MapleStream & os) const
95 {
96         os << name_ << "(";
97         MathGridInset::maplize(os);
98         os << ")";
99 }