]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathFrac.h
1 // -*- C++ -*-
2 /**
3  * \file InsetMathFrac.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author André Pönitz
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_FRAC_H
14 #define MATH_FRAC_H
15
16 #include "InsetMathNest.h"
17
18
19 namespace lyx {
20
21
22 class InsetMathFracBase : public InsetMathNest {
23 public:
24         ///
25         explicit InsetMathFracBase(idx_type ncells = 2);
26         ///
27         bool idxUpDown(Cursor &, bool up) const;
28         ///
29         bool idxBackward(Cursor &) const { return false; }
30         ///
31         bool idxForward(Cursor &) const { return false; }
32 };
33
34
35
36 /// Fraction like objects (frac, binom)
37 class InsetMathFrac : public InsetMathFracBase {
38 public:
39         ///
40         enum Kind {
41                 FRAC,
42                 OVER,
43                 ATOP,
44                 NICEFRAC,
45                 UNITFRAC,
46                 UNIT
47         };
48
49         ///
50         explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
51         ///
52         bool idxForward(Cursor &) const;
53         ///
54         bool idxBackward(Cursor &) const;
55         ///
56         void metrics(MetricsInfo & mi, Dimension & dim) const;
57         ///
58         void draw(PainterInfo &, int x, int y) const;
59         ///
60         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
61         ///
62         void drawT(TextPainter &, int x, int y) const;
63         /// identifies FracInsets
64         InsetMathFrac * asFracInset();
65         /// identifies FracInsets
66         InsetMathFrac const * asFracInset() const;
67         ///
68         docstring name() const;
69         ///
70         bool extraBraces() const;
71
72         ///
73         void write(WriteStream & os) const;
74         ///
75         void maple(MapleStream &) const;
76         ///
77         void mathematica(MathematicaStream &) const;
78         ///
79         void octave(OctaveStream &) const;
80         ///
81         void mathmlize(MathStream &) const;
82         ///
83         void validate(LaTeXFeatures & features) const;
84 public:
85         Inset * clone() const;
86         ///
87         Kind kind_;
88 };
89
90
91 /// \dfrac support
92 class InsetMathDFrac : public InsetMathFrac {
93 public:
94         ///
95         InsetMathDFrac() {}
96         ///
97         void metrics(MetricsInfo & mi, Dimension & dim) const;
98         ///
99         void draw(PainterInfo &, int x, int y) const;
100         ///
101         docstring name() const;
102         ///
103         void mathmlize(MathStream &) const;
104         ///
105         void validate(LaTeXFeatures & features) const;
106 private:
107         Inset * clone() const;
108 };
109
110
111 /// \tfrac support
112 class InsetMathTFrac : public InsetMathFrac {
113 public:
114         ///
115         InsetMathTFrac() {}
116         ///
117         void metrics(MetricsInfo & mi, Dimension & dim) const;
118         ///
119         void draw(PainterInfo &, int x, int y) const;
120         ///
121         docstring name() const;
122         ///
123         void mathmlize(MathStream &) const;
124         ///
125         void validate(LaTeXFeatures & features) const;
126 private:
127         Inset * clone() const;
128 };
129
130
131 /// \cfrac support
132 class InsetMathCFrac : public InsetMathFrac {
133 public:
134         ///
135         InsetMathCFrac() {}
136         ///
137         void metrics(MetricsInfo & mi, Dimension & dim) const;
138         ///
139         void draw(PainterInfo &, int x, int y) const;
140         ///
141         docstring name() const;
142         ///
143         void mathmlize(MathStream &) const;
144         ///
145         void validate(LaTeXFeatures & features) const;
146 private:
147         Inset * clone() const;
148 };
149
150
151 /// Binom like objects
152 class InsetMathBinom : public InsetMathFracBase {
153 public:
154         ///
155         enum Kind {
156                 BINOM,
157                 CHOOSE,
158                 BRACE,
159                 BRACK
160         };
161
162         ///
163         explicit InsetMathBinom(Kind kind = BINOM);
164         ///
165         void write(WriteStream & os) const;
166         ///
167         void normalize(NormalStream &) const;
168         ///
169         void metrics(MetricsInfo & mi, Dimension & dim) const;
170         ///
171         void draw(PainterInfo &, int x, int y) const;
172         /// draw decorations.
173         void drawDecoration(PainterInfo & pi, int x, int y) const
174         { drawMarkers2(pi, x, y); }
175         ///
176         bool extraBraces() const;
177         ///
178         void validate(LaTeXFeatures & features) const;
179 private:
180         Inset * clone() const;
181         ///
182         int dw(int height) const;
183         ///
184         Kind kind_;
185 };
186
187
188 /// \dbinom support
189 class InsetMathDBinom : public InsetMathFracBase {
190 public:
191         ///
192         InsetMathDBinom() {}
193         ///
194         void metrics(MetricsInfo & mi, Dimension & dim) const;
195         ///
196         void draw(PainterInfo &, int x, int y) const;
197         ///
198         docstring name() const;
199         ///
200         void mathmlize(MathStream &) const;
201         ///
202         void validate(LaTeXFeatures & features) const;
203 private:
204         Inset * clone() const;
205         ///
206         int dw(int height) const;
207 };
208
209
210 /// \tbinom support
211 class InsetMathTBinom : public InsetMathFracBase {
212 public:
213         ///
214         InsetMathTBinom() {}
215         ///
216         void metrics(MetricsInfo & mi, Dimension & dim) const;
217         ///
218         void draw(PainterInfo &, int x, int y) const;
219         ///
220         docstring name() const;
221         ///
222         void mathmlize(MathStream &) const;
223         ///
224         void validate(LaTeXFeatures & features) const;
225 private:
226         Inset * clone() const;
227         ///
228         int dw(int height) const;
229 };
230
231
232 } // namespace lyx
233
234 #endif