]> git.lyx.org Git - lyx.git/blob - src/mathed/math_casesinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_casesinset.C
1 #include <config.h>
2
3
4 #include "math_casesinset.h"
5 #include "math_parser.h"
6 #include "math_mathmlstream.h"
7 #include "math_support.h"
8 #include "LaTeXFeatures.h"
9 #include "support/LOstream.h"
10
11 using std::auto_ptr;
12
13
14 MathCasesInset::MathCasesInset(row_type n)
15         : MathGridInset(2, n, 'c', "ll")
16 {}
17
18
19 auto_ptr<InsetBase> MathCasesInset::clone() const
20 {
21         return auto_ptr<InsetBase>(new MathCasesInset(*this));
22 }
23
24
25 void MathCasesInset::metrics(MetricsInfo & mi, Dimension & dim) const
26 {
27         MathGridInset::metrics(mi);
28         dim_.wid += 8;
29         dim = dim_;
30 }
31
32
33 void MathCasesInset::draw(PainterInfo & pain, int x, int y) const
34 {
35         mathed_draw_deco(pain, x + 1, y - dim_.ascent(), 6, dim_.height(), "{");
36         MathGridInset::draw(pain, x + 8, y);
37 }
38
39
40 void MathCasesInset::write(WriteStream & os) const
41 {
42         if (os.fragile())
43                 os << "\\protect";
44         os << "\\begin{cases}\n";
45         MathGridInset::write(os);
46         if (os.fragile())
47                 os << "\\protect";
48         os << "\\end{cases}";
49 }
50
51
52 void MathCasesInset::normalize(NormalStream & os) const
53 {
54         os << "[cases ";
55         MathGridInset::normalize(os);
56         os << ']';
57 }
58
59
60 void MathCasesInset::maple(MapleStream & os) const
61 {
62         os << "cases(";
63         MathGridInset::maple(os);
64         os << ')';
65 }
66
67
68 void MathCasesInset::infoize(std::ostream & os) const
69 {
70         os << "Cases ";
71 }
72
73
74 void MathCasesInset::validate(LaTeXFeatures & features) const
75 {
76         features.require("amsmath");
77         MathGridInset::validate(features);
78 }