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