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