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