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