]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
put \frac style stuff into a single unit. -161477.
[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  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_FRAC_H
14 #define MATH_FRAC_H
15
16 #include "InsetMathNest.h"
17
18
19 namespace lyx {
20
21
22 class InsetMathFracBase : public InsetMathNest {
23 public:
24         ///
25         explicit InsetMathFracBase(idx_type ncells = 2);
26         ///
27         bool idxUpDown(Cursor &, bool up) const;
28         ///
29         bool idxLeft(Cursor &) const { return false; }
30         ///
31         bool idxRight(Cursor &) const { return false; }
32 };
33
34
35
36 /// Fraction like objects (frac, binom)
37 class InsetMathFrac : public InsetMathFracBase {
38 public:
39         ///
40         enum Kind {
41                 FRAC,
42                 OVER,
43                 ATOP,
44                 NICEFRAC,
45                 UNITFRAC,
46                 UNIT
47         };
48
49         ///
50         explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
51         ///
52         bool idxRight(Cursor &) const;
53         ///
54         bool idxLeft(Cursor &) const;
55         ///
56         void metrics(MetricsInfo & mi, Dimension & dim) const;
57         ///
58         void draw(PainterInfo &, int x, int y) const;
59         ///
60         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
61         ///
62         void drawT(TextPainter &, int x, int y) const;
63         /// identifies FracInsets
64         InsetMathFrac * asFracInset();
65         /// identifies FracInsets
66         InsetMathFrac const * asFracInset() const;
67         ///
68         docstring name() const;
69         ///
70         bool extraBraces() const;
71
72         ///
73         void write(WriteStream & os) const;
74         ///
75         void maple(MapleStream &) const;
76         ///
77         void mathematica(MathematicaStream &) const;
78         ///
79         void octave(OctaveStream &) const;
80         ///
81         void mathmlize(MathStream &) const;
82         ///
83         void validate(LaTeXFeatures & features) const;
84 public:
85         Inset * clone() const;
86         ///
87         Kind kind_;
88 };
89
90
91 /// \dfrac support
92 class InsetMathDFrac : public InsetMathFrac {
93 public:
94         ///
95         InsetMathDFrac() {}
96         ///
97         void metrics(MetricsInfo & mi, Dimension & dim) const;
98         ///
99         void draw(PainterInfo &, int x, int y) const;
100         ///
101         docstring name() const;
102         ///
103         void mathmlize(MathStream &) const;
104         ///
105         void validate(LaTeXFeatures & features) const;
106 private:
107         Inset * clone() const;
108 };
109
110
111 /// \tfrac support
112 class InsetMathTFrac : public InsetMathFrac {
113 public:
114         ///
115         InsetMathTFrac() {}
116         ///
117         void metrics(MetricsInfo & mi, Dimension & dim) const;
118         ///
119         void draw(PainterInfo &, int x, int y) const;
120         ///
121         docstring name() const;
122         ///
123         void mathmlize(MathStream &) const;
124         ///
125         void validate(LaTeXFeatures & features) const;
126 private:
127         Inset * clone() const;
128 };
129
130
131 /// Binom like objects
132 class InsetMathBinom : public InsetMathFracBase {
133 public:
134         ///
135         explicit InsetMathBinom(bool choose = false);
136         ///
137         void write(WriteStream & os) const;
138         ///
139         void normalize(NormalStream &) const;
140         ///
141         void metrics(MetricsInfo & mi, Dimension & dim) const;
142         ///
143         void draw(PainterInfo &, int x, int y) const;
144         /// draw decorations.
145         void drawDecoration(PainterInfo & pi, int x, int y) const
146         { drawMarkers2(pi, x, y); }
147         ///
148         bool extraBraces() const;
149 private:
150         Inset * clone() const;
151         ///
152         int dw(int height) const;
153         ///
154         bool choose_;
155 };
156
157
158 } // namespace lyx
159
160 #endif