]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathTabular.cpp
Revert "Fix a number of signedness warnings"
[lyx.git] / src / mathed / InsetMathTabular.cpp
1 /**
2  * \file InsetMathTabular.cpp
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 "InsetMathTabular.h"
14
15 #include "MathData.h"
16 #include "MathStream.h"
17
18 #include "MetricsInfo.h"
19
20 #include "support/lstrings.h"
21
22 #include <ostream>
23
24 namespace lyx {
25
26 InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
27                 int n)
28         : InsetMathGrid(buf, m, n), name_(name)
29 {}
30
31
32 InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
33                 int n, char valign, docstring const & halign)
34         : InsetMathGrid(buf, m, n, valign, halign), name_(name)
35 {}
36
37
38
39 Inset * InsetMathTabular::clone() const
40 {
41         return new InsetMathTabular(*this);
42 }
43
44
45 void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         Changer dummy = mi.base.changeFontSet("textnormal");
48         InsetMathGrid::metrics(mi, dim);
49 }
50
51
52 void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const
53 {
54         Changer dummy = pi.base.changeFontSet("textnormal");
55         InsetMathGrid::draw(pi, x, y);
56 }
57
58
59 void InsetMathTabular::write(WriteStream & os) const
60 {
61         ModeSpecifier specifier(os, TEXT_MODE);
62
63         if (os.fragile())
64                 os << "\\protect";
65         os << "\\begin{" << name_ << '}';
66         bool open = os.startOuterRow();
67
68         char const v = verticalAlignment();
69         if (v == 't' || v == 'b')
70                 os << '[' << v << ']';
71         os << '{' << horizontalAlignments() << "}\n";
72
73         InsetMathGrid::write(os);
74
75         if (os.fragile())
76                 os << "\\protect";
77         os << "\\end{" << name_ << '}';
78         if (open)
79                 os.startOuterRow();
80         // adding a \n here is bad if the tabular is the last item
81         // in an \eqnarray...
82 }
83
84
85 void InsetMathTabular::infoize(odocstream & os) const
86 {
87         docstring name = name_;
88         name[0] = support::uppercase(name[0]);
89         os << name << ' ';
90 }
91
92
93 void InsetMathTabular::normalize(NormalStream & os) const
94 {
95         os << '[' << name_ << ' ';
96         InsetMathGrid::normalize(os);
97         os << ']';
98 }
99
100
101 void InsetMathTabular::maple(MapleStream & os) const
102 {
103         os << "array(";
104         InsetMathGrid::maple(os);
105         os << ')';
106 }
107
108
109 } // namespace lyx