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