]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathTabular.cpp
01d8c9cb653e42383e80d78f78969426303c84ba
[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 namespace lyx {
22
23 InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n)
24         : InsetMathGrid(m, n), name_(name)
25 {}
26
27
28 InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
29                 char valign, docstring const & halign)
30         : InsetMathGrid(m, n, valign, halign), name_(name)
31 {}
32
33
34
35 Inset * InsetMathTabular::clone() const
36 {
37         return new InsetMathTabular(*this);
38 }
39
40
41 void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const
42 {
43         FontSetChanger dummy(mi.base, "textnormal");
44         InsetMathGrid::metrics(mi, dim);
45         dim.wid += 6;
46 }
47
48
49 Dimension const InsetMathTabular::dimension(BufferView const & bv) const
50 {
51         Dimension dim = InsetMathGrid::dimension(bv);
52         dim.wid += 6;
53         return dim;
54 }
55
56
57 void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const
58 {
59         FontSetChanger dummy(pi.base, "textnormal");
60         InsetMathGrid::drawWithMargin(pi, x, y, 4, 2);
61 }
62
63
64 void InsetMathTabular::write(WriteStream & os) const
65 {
66         if (os.fragile())
67                 os << "\\protect";
68         os << "\\begin{" << name_ << '}';
69
70         char const v = verticalAlignment();
71         if (v == 't' || v == 'b')
72                 os << '[' << v << ']';
73         os << '{' << horizontalAlignments() << "}\n";
74
75         InsetMathGrid::write(os);
76
77         if (os.fragile())
78                 os << "\\protect";
79         os << "\\end{" << name_ << '}';
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