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