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