]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
Merge branch 'master' of git.lyx.org:lyx
[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         void metrics(MetricsInfo & mi, Dimension & dim) const;
66         ///
67         void draw(PainterInfo &, int x, int y) const;
68         ///
69         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
70         ///
71         void drawT(TextPainter &, int x, int y) const;
72         /// identifies FracInsets
73         InsetMathFrac * asFracInset();
74         /// identifies FracInsets
75         InsetMathFrac const * asFracInset() const;
76         ///
77         docstring name() const;
78         ///
79         bool extraBraces() const;
80         ///
81         void write(WriteStream & os) const;
82         ///
83         void maple(MapleStream &) const;
84         ///
85         void mathematica(MathematicaStream &) const;
86         ///
87         void octave(OctaveStream &) const;
88         ///
89         void mathmlize(MathStream &) const;
90         ///
91         void htmlize(HtmlStream &) const;
92         ///
93         void validate(LaTeXFeatures & features) const;
94 public:
95         Inset * clone() const;
96         ///
97         Kind kind_;
98 };
99
100
101
102 /// Binom like objects
103 class InsetMathBinom : public InsetMathFracBase {
104 public:
105         ///
106         enum Kind {
107                 BINOM,
108                 DBINOM,
109                 TBINOM,
110                 CHOOSE,
111                 BRACE,
112                 BRACK
113         };
114         ///
115         explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
116         ///
117         void write(WriteStream & os) const;
118         ///
119         void normalize(NormalStream &) const;
120         ///
121         void metrics(MetricsInfo & mi, Dimension & dim) const;
122         ///
123         void draw(PainterInfo &, int x, int y) const;
124         /// draw decorations.
125         void drawDecoration(PainterInfo & pi, int x, int y) const
126         { drawMarkers2(pi, x, y); }
127         ///
128         bool extraBraces() const;
129         ///
130         void mathmlize(MathStream &) const;
131         ///
132         void htmlize(HtmlStream &) const;
133         ///
134         void validate(LaTeXFeatures & features) const;
135         ///
136         InsetCode lyxCode() const { return MATH_FRAC_CODE; }
137 private:
138         Inset * clone() const;
139         ///
140         int dw(int height) const;
141         ///
142         Kind kind_;
143 };
144
145
146
147 } // namespace lyx
148
149 #endif