]> git.lyx.org Git - lyx.git/blob - src/mathed/math_tabularinset.C
Fix math cursor positioning bug
[lyx.git] / src / mathed / math_tabularinset.C
1 /**
2  * \file math_tabularinset.C
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 "math_tabularinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17
18 #include <iterator>
19
20
21 using std::string;
22 using std::auto_ptr;
23
24
25 MathTabularInset::MathTabularInset(string const & name, int m, int n)
26         : MathGridInset(m, n), name_(name)
27 {}
28
29
30 MathTabularInset::MathTabularInset(string const & name, int m, int n,
31                 char valign, string const & halign)
32         : MathGridInset(m, n, valign, halign), name_(name)
33 {}
34
35
36 MathTabularInset::MathTabularInset(string const & name, char valign,
37                 string const & halign)
38         : MathGridInset(valign, halign), name_(name)
39 {}
40
41
42 auto_ptr<InsetBase> MathTabularInset::doClone() const
43 {
44         return auto_ptr<InsetBase>(new MathTabularInset(*this));
45 }
46
47
48 void MathTabularInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
49 {
50         FontSetChanger dummy(mi.base, "textnormal");
51         return MathGridInset::metrics(mi);
52 }
53
54
55 void MathTabularInset::draw(PainterInfo & pi, int x, int y) const
56 {
57         FontSetChanger dummy(pi.base, "textnormal");
58         MathGridInset::draw(pi, x, y);
59 }
60
61
62 void MathTabularInset::write(WriteStream & os) const
63 {
64         if (os.fragile())
65                 os << "\\protect";
66         os << "\\begin{" << name_ << '}';
67
68         if (v_align_ == 't' || v_align_ == 'b')
69                 os << '[' << char(v_align_) << ']';
70         os << '{' << halign() << "}\n";
71
72         MathGridInset::write(os);
73
74         if (os.fragile())
75                 os << "\\protect";
76         os << "\\end{" << name_ << '}';
77         // adding a \n here is bad if the tabular is the last item
78         // in an \eqnarray...
79 }
80
81
82 void MathTabularInset::normalize(NormalStream & os) const
83 {
84         os << '[' << name_ << ' ';
85         MathGridInset::normalize(os);
86         os << ']';
87 }
88
89
90 void MathTabularInset::maple(MapleStream & os) const
91 {
92         os << "array(";
93         MathGridInset::maple(os);
94         os << ')';
95 }