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