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