]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
Simplify Changers interface
[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         InsetMathFracBase(Buffer * buf, 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         InsetMathFracBase * asFracBaseInset() { return this; }
35         ///
36         InsetMathFracBase const * asFracBaseInset() const { return this; }
37 };
38
39
40
41 /// Fraction like objects (frac, binom)
42 class InsetMathFrac : public InsetMathFracBase {
43 public:
44         ///
45         enum Kind {
46                 FRAC,
47                 CFRAC,
48                 CFRACLEFT,
49                 CFRACRIGHT,
50                 DFRAC,
51                 TFRAC,
52                 OVER,
53                 ATOP,
54                 NICEFRAC,
55                 UNITFRAC,
56                 UNIT
57         };
58         ///
59         explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
60         ///
61         bool idxForward(Cursor &) const;
62         ///
63         bool idxBackward(Cursor &) const;
64         ///
65         MathClass mathClass() const;
66         ///
67         void metrics(MetricsInfo & mi, Dimension & dim) const;
68         ///
69         void draw(PainterInfo &, int x, int y) const;
70         ///
71         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
72         ///
73         void drawT(TextPainter &, int x, int y) const;
74         /// identifies FracInsets
75         InsetMathFrac * asFracInset();
76         /// identifies FracInsets
77         InsetMathFrac const * asFracInset() const;
78         ///
79         docstring name() const;
80         ///
81         bool extraBraces() const;
82         ///
83         void write(WriteStream & os) const;
84         ///
85         void maple(MapleStream &) const;
86         ///
87         void mathematica(MathematicaStream &) const;
88         ///
89         void octave(OctaveStream &) const;
90         ///
91         void mathmlize(MathStream &) const;
92         ///
93         void htmlize(HtmlStream &) const;
94         ///
95         void validate(LaTeXFeatures & features) const;
96 public:
97         Inset * clone() const;
98         ///
99         Kind kind_;
100 };
101
102
103
104 /// Binom like objects
105 class InsetMathBinom : public InsetMathFracBase {
106 public:
107         ///
108         enum Kind {
109                 BINOM,
110                 DBINOM,
111                 TBINOM,
112                 CHOOSE,
113                 BRACE,
114                 BRACK
115         };
116         ///
117         explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
118         ///
119         void write(WriteStream & os) const;
120         ///
121         void normalize(NormalStream &) const;
122         /// Generalized fractions are of inner class (see The TeXbook, p.292)
123         MathClass mathClass() const { return MC_INNER; }
124         ///
125         void metrics(MetricsInfo & mi, Dimension & dim) const;
126         ///
127         void draw(PainterInfo &, int x, int y) const;
128         /// draw decorations.
129         void drawDecoration(PainterInfo & pi, int x, int y) const
130         { drawMarkers2(pi, x, y); }
131         ///
132         bool extraBraces() const;
133         ///
134         void mathmlize(MathStream &) const;
135         ///
136         void htmlize(HtmlStream &) const;
137         ///
138         void validate(LaTeXFeatures & features) const;
139         ///
140         InsetCode lyxCode() const { return MATH_FRAC_CODE; }
141 private:
142         Inset * clone() const;
143         ///
144         int dw(int height) const;
145         ///
146         Kind kind_;
147 };
148
149
150
151 } // namespace lyx
152
153 #endif