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