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