3 * \file InsetMathFrac.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alejandro Aguilar Sierra
11 * Full author contact details are available in file CREDITS.
17 #include "InsetMathNest.h"
23 class InsetMathFracBase : public InsetMathNest {
26 InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
28 marker_type marker(BufferView const *) const override { return marker_type::MARKER2; }
30 bool idxUpDown(Cursor &, bool up) const override;
32 bool idxBackward(Cursor &) const override { return false; }
34 bool idxForward(Cursor &) const override { return false; }
36 InsetMathFracBase * asFracBaseInset() override { return this; }
38 InsetMathFracBase const * asFracBaseInset() const override { return this; }
43 /// Fraction like objects (frac, binom)
44 class InsetMathFrac : public InsetMathFracBase {
62 explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
64 bool idxForward(Cursor &) const override;
66 bool idxBackward(Cursor &) const override;
68 MathClass mathClass() const override;
70 void metrics(MetricsInfo & mi, Dimension & dim) const override;
72 void draw(PainterInfo &, int x, int y) const override;
74 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
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;
82 docstring name() const override;
84 bool extraBraces() const override;
86 void write(TeXMathStream & os) const override;
88 void maple(MapleStream &) const override;
90 void mathematica(MathematicaStream &) const override;
92 void octave(OctaveStream &) const override;
94 void mathmlize(MathMLStream &) const override;
96 void htmlize(HtmlStream &) const override;
98 void validate(LaTeXFeatures & features) const override;
100 /// vertical displacement
101 int dy(FontInfo & fi) const;
103 Inset * clone() const override;
110 /// Binom like objects
111 class InsetMathBinom : public InsetMathFracBase {
123 explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
125 void write(TeXMathStream & os) const override;
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; }
131 void metrics(MetricsInfo & mi, Dimension & dim) const override;
133 void draw(PainterInfo &, int x, int y) const override;
135 bool extraBraces() const override;
137 void mathmlize(MathMLStream &) const override;
139 void htmlize(HtmlStream &) const override;
141 void validate(LaTeXFeatures & features) const override;
143 InsetCode lyxCode() const override { return MATH_FRAC_CODE; }
145 Inset * clone() const override;
147 int dw(int height) const;