]> git.lyx.org Git - lyx.git/blob - src/mathed/math_amsarrayinset.C
inactive new stuff to re-sync my tree before going on holyday
[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         return "(";
36 }
37
38
39 char const * MathAMSArrayInset::name_right() const
40 {
41         if (name_ == "bmatrix")
42                 return "]";
43         return ")";
44 }
45
46
47 void MathAMSArrayInset::metrics(MathMetricsInfo const & st) const
48 {
49         MathMetricsInfo mi = st;
50         if (mi.style == LM_ST_DISPLAY)
51                 mi.style = LM_ST_TEXT;
52         MathGridInset::metrics(mi);
53         width_ += 12;
54 }
55
56
57 void MathAMSArrayInset::draw(Painter & pain, int x, int y) const
58
59         MathGridInset::draw(pain, x + 6, y);
60         int yy = y - ascent_;
61         mathed_draw_deco(pain, x + 1, yy, 5, height(), name_left());
62         mathed_draw_deco(pain, x + width_ - 6, yy, 5, height(), name_right());
63 }
64
65
66 void MathAMSArrayInset::write(WriteStream & os) const
67 {
68         os << "\\begin{" << name_ << "}";
69         MathGridInset::write(os);
70         os << "\\end{" << name_ << "}\n";
71 }
72
73
74 void MathAMSArrayInset::normalize(NormalStream & os) const
75 {
76         os << "[" << name_ << " ";
77         MathGridInset::normalize(os);
78         os << "]";
79 }
80
81
82 void MathAMSArrayInset::maplize(MapleStream & os) const
83 {
84         os << name_ << "(";
85         MathGridInset::maplize(os);
86         os << ")";
87 }