]> git.lyx.org Git - lyx.git/blob - src/mathed/math_tabularinset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_tabularinset.C
1 #include <config.h>
2
3
4 #include "math_tabularinset.h"
5 #include "math_parser.h"
6 #include "math_mathmlstream.h"
7 #include "math_metricsinfo.h"
8 #include "math_streamstr.h"
9 #include "Lsstream.h"
10
11 #include <iterator>
12
13 using std::vector;
14 using std::istringstream;
15 using std::getline;
16 using std::istream_iterator;
17
18
19 MathTabularInset::MathTabularInset(string const & name, int m, int n)
20         : MathGridInset(m, n), name_(name)
21 {}
22
23
24 MathTabularInset::MathTabularInset(string const & name, int m, int n,
25                 char valign, string const & halign)
26         : MathGridInset(m, n, valign, halign), name_(name)
27 {}
28
29
30 MathTabularInset::MathTabularInset(string const & name, char valign,
31                 string const & halign)
32         : MathGridInset(valign, halign), name_(name)
33 {}
34
35
36 MathInset * MathTabularInset::clone() const
37 {
38         return new MathTabularInset(*this);
39 }
40
41
42 void MathTabularInset::metrics(MathMetricsInfo & mi) const
43 {
44         MathFontSetChanger dummy(mi.base, "textnormal");
45         MathGridInset::metrics(mi);
46 }
47
48
49 void MathTabularInset::draw(MathPainterInfo & pi, int x, int y) const
50 {
51         MathFontSetChanger dummy(pi.base, "textnormal");
52         MathGridInset::draw(pi, x, y);
53 }
54
55
56 void MathTabularInset::write(WriteStream & os) const
57 {
58         if (os.fragile())
59                 os << "\\protect";
60         os << "\\begin{" << name_ << '}';
61
62         if (v_align_ == 't' || v_align_ == 'b')
63                 os << '[' << char(v_align_) << ']';
64         os << '{' << halign() << "}\n";
65
66         MathGridInset::write(os);
67
68         if (os.fragile())
69                 os << "\\protect";
70         os << "\\end{" << name_ << '}';
71         // adding a \n here is bad if the tabular is the last item
72         // in an \eqnarray...
73 }
74
75
76 void MathTabularInset::normalize(NormalStream & os) const
77 {
78         os << '[' << name_ << ' ';
79         MathGridInset::normalize(os);
80         os << ']';
81 }
82
83
84 void MathTabularInset::maple(MapleStream & os) const
85 {
86         os << "array(";
87         MathGridInset::maple(os);
88         os << ')';
89 }