]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFrac.h
typo
[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         marker_type marker(BufferView const *) const override { return marker_type::MARKER2; }
29         ///
30         bool idxUpDown(Cursor &, bool up) const override;
31         ///
32         bool idxBackward(Cursor &) const override { return false; }
33         ///
34         bool idxForward(Cursor &) const override { return false; }
35         ///
36         InsetMathFracBase * asFracBaseInset() override { return this; }
37         ///
38         InsetMathFracBase const * asFracBaseInset() const override { return this; }
39 };
40
41
42
43 /// Fraction like objects (frac, binom)
44 class InsetMathFrac : public InsetMathFracBase {
45 public:
46         ///
47         enum Kind {
48                 FRAC,
49                 AASTEX_CASE,
50                 CFRAC,
51                 CFRACLEFT,
52                 CFRACRIGHT,
53                 DFRAC,
54                 TFRAC,
55                 OVER,
56                 ATOP,
57                 NICEFRAC,
58                 UNITFRAC,
59                 UNIT
60         };
61         ///
62         explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
63         ///
64         bool idxForward(Cursor &) const override;
65         ///
66         bool idxBackward(Cursor &) const override;
67         ///
68         MathClass mathClass() const override;
69         ///
70         void metrics(MetricsInfo & mi, Dimension & dim) const override;
71         ///
72         void draw(PainterInfo &, int x, int y) const override;
73         ///
74         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
75         ///
76         void drawT(TextPainter &, int x, int y) const override;
77         /// identifies FracInsets
78         InsetMathFrac * asFracInset() override;
79         /// identifies FracInsets
80         InsetMathFrac const * asFracInset() const override;
81         ///
82         docstring name() const override;
83         ///
84         bool extraBraces() const override;
85         ///
86         void write(TeXMathStream & os) const override;
87         ///
88         void maple(MapleStream &) const override;
89         ///
90         void mathematica(MathematicaStream &) const override;
91         ///
92         void octave(OctaveStream &) const override;
93         ///
94         void mathmlize(MathMLStream &) const override;
95         ///
96         void htmlize(HtmlStream &) const override;
97         ///
98         void validate(LaTeXFeatures & features) const override;
99 private:
100         /// vertical displacement
101         int dy(FontInfo & fi) const;
102         ///
103         Inset * clone() const override;
104         ///
105         Kind kind_;
106 };
107
108
109
110 /// Binom like objects
111 class InsetMathBinom : public InsetMathFracBase {
112 public:
113         ///
114         enum Kind {
115                 BINOM,
116                 DBINOM,
117                 TBINOM,
118                 CHOOSE,
119                 BRACE,
120                 BRACK
121         };
122         ///
123         explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
124         ///
125         void write(TeXMathStream & os) const override;
126         ///
127         void normalize(NormalStream &) const override;
128         /// Generalized fractions are of inner class (see The TeXbook, p.292)
129         MathClass mathClass() const override { return MC_INNER; }
130         ///
131         void metrics(MetricsInfo & mi, Dimension & dim) const override;
132         ///
133         void draw(PainterInfo &, int x, int y) const override;
134         ///
135         bool extraBraces() const override;
136         ///
137         void mathmlize(MathMLStream &) const override;
138         ///
139         void htmlize(HtmlStream &) const override;
140         ///
141         void validate(LaTeXFeatures & features) const override;
142         ///
143         InsetCode lyxCode() const override { return MATH_FRAC_CODE; }
144 private:
145         Inset * clone() const override;
146         ///
147         int dw(int height) const;
148         ///
149         Kind kind_;
150 };
151
152
153
154 } // namespace lyx
155
156 #endif