]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathTabular.cpp
cosmetics
[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
24 namespace lyx {
25
26 InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n)
27         : InsetMathGrid(m, n), name_(name)
28 {}
29
30
31 InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
32                 char valign, docstring const & halign)
33         : InsetMathGrid(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         if (os.fragile())
70                 os << "\\protect";
71         os << "\\begin{" << name_ << '}';
72
73         char const v = verticalAlignment();
74         if (v == 't' || v == 'b')
75                 os << '[' << v << ']';
76         os << '{' << horizontalAlignments() << "}\n";
77
78         InsetMathGrid::write(os);
79
80         if (os.fragile())
81                 os << "\\protect";
82         os << "\\end{" << name_ << '}';
83         // adding a \n here is bad if the tabular is the last item
84         // in an \eqnarray...
85 }
86
87
88 void InsetMathTabular::infoize(odocstream & os) const
89 {
90         docstring name = name_;
91         name[0] = support::uppercase(name[0]);
92         os << name << ' ';
93 }
94
95
96 void InsetMathTabular::normalize(NormalStream & os) const
97 {
98         os << '[' << name_ << ' ';
99         InsetMathGrid::normalize(os);
100         os << ']';
101 }
102
103
104 void InsetMathTabular::maple(MapleStream & os) const
105 {
106         os << "array(";
107         InsetMathGrid::maple(os);
108         os << ')';
109 }
110
111
112 } // namespace lyx