]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
Merge branch 'master' into biblatex2
[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 private:
97         /// vertical displacement
98         int dy(FontInfo & fi) const;
99         ///
100         Inset * clone() const;
101         ///
102         Kind kind_;
103 };
104
105
106
107 /// Binom like objects
108 class InsetMathBinom : public InsetMathFracBase {
109 public:
110         ///
111         enum Kind {
112                 BINOM,
113                 DBINOM,
114                 TBINOM,
115                 CHOOSE,
116                 BRACE,
117                 BRACK
118         };
119         ///
120         explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
121         ///
122         void write(WriteStream & os) const;
123         ///
124         void normalize(NormalStream &) const;
125         /// Generalized fractions are of inner class (see The TeXbook, p.292)
126         MathClass mathClass() const { return MC_INNER; }
127         ///
128         void metrics(MetricsInfo & mi, Dimension & dim) const;
129         ///
130         void draw(PainterInfo &, int x, int y) const;
131         /// draw decorations.
132         void drawDecoration(PainterInfo & pi, int x, int y) const
133         { drawMarkers2(pi, x, y); }
134         ///
135         bool extraBraces() const;
136         ///
137         void mathmlize(MathStream &) const;
138         ///
139         void htmlize(HtmlStream &) const;
140         ///
141         void validate(LaTeXFeatures & features) const;
142         ///
143         InsetCode lyxCode() const { return MATH_FRAC_CODE; }
144 private:
145         Inset * clone() const;
146         ///
147         int dw(int height) const;
148         ///
149         Kind kind_;
150 };
151
152
153
154 } // namespace lyx
155
156 #endif