]> git.lyx.org Git - lyx.git/blob - src/mathed/math_tabularinset.C
Finish the task of removing all cruft from the header files.
[lyx.git] / src / mathed / math_tabularinset.C
1 /**
2  * \file math_tabularinset.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_tabularinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17
18 #include <iterator>
19
20 using std::vector;
21 using std::istringstream;
22 using std::getline;
23 using std::istream_iterator;
24 using std::auto_ptr;
25
26
27 MathTabularInset::MathTabularInset(string const & name, int m, int n)
28         : MathGridInset(m, n), name_(name)
29 {}
30
31
32 MathTabularInset::MathTabularInset(string const & name, int m, int n,
33                 char valign, string const & halign)
34         : MathGridInset(m, n, valign, halign), name_(name)
35 {}
36
37
38 MathTabularInset::MathTabularInset(string const & name, char valign,
39                 string const & halign)
40         : MathGridInset(valign, halign), name_(name)
41 {}
42
43
44 auto_ptr<InsetBase> MathTabularInset::clone() const
45 {
46         return auto_ptr<InsetBase>(new MathTabularInset(*this));
47 }
48
49
50 void MathTabularInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
51 {
52         FontSetChanger dummy(mi.base, "textnormal");
53         return MathGridInset::metrics(mi);
54 }
55
56
57 void MathTabularInset::draw(PainterInfo & pi, int x, int y) const
58 {
59         FontSetChanger dummy(pi.base, "textnormal");
60         MathGridInset::draw(pi, x, y);
61 }
62
63
64 void MathTabularInset::write(WriteStream & os) const
65 {
66         if (os.fragile())
67                 os << "\\protect";
68         os << "\\begin{" << name_ << '}';
69
70         if (v_align_ == 't' || v_align_ == 'b')
71                 os << '[' << char(v_align_) << ']';
72         os << '{' << halign() << "}\n";
73
74         MathGridInset::write(os);
75
76         if (os.fragile())
77                 os << "\\protect";
78         os << "\\end{" << name_ << '}';
79         // adding a \n here is bad if the tabular is the last item
80         // in an \eqnarray...
81 }
82
83
84 void MathTabularInset::normalize(NormalStream & os) const
85 {
86         os << '[' << name_ << ' ';
87         MathGridInset::normalize(os);
88         os << ']';
89 }
90
91
92 void MathTabularInset::maple(MapleStream & os) const
93 {
94         os << "array(";
95         MathGridInset::maple(os);
96         os << ')';
97 }