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