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 {
61 explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
63 bool idxForward(Cursor &) const override;
65 bool idxBackward(Cursor &) const override;
67 MathClass mathClass() const override;
69 void metrics(MetricsInfo & mi, Dimension & dim) const override;
71 void draw(PainterInfo &, int x, int y) const override;
73 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
75 void drawT(TextPainter &, int x, int y) const override;
76 /// identifies FracInsets
77 InsetMathFrac * asFracInset() override;
78 /// identifies FracInsets
79 InsetMathFrac const * asFracInset() const override;
81 docstring name() const override;
83 bool extraBraces() const override;
85 void write(WriteStream & os) const override;
87 void maple(MapleStream &) const override;
89 void mathematica(MathematicaStream &) const override;
91 void octave(OctaveStream &) const override;
93 void mathmlize(MathStream &) const override;
95 void htmlize(HtmlStream &) const override;
97 void validate(LaTeXFeatures & features) const override;
99 /// vertical displacement
100 int dy(FontInfo & fi) const;
102 Inset * clone() const override;
109 /// Binom like objects
110 class InsetMathBinom : public InsetMathFracBase {
122 explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
124 void write(WriteStream & os) const override;
126 void normalize(NormalStream &) const override;
127 /// Generalized fractions are of inner class (see The TeXbook, p.292)
128 MathClass mathClass() const override { return MC_INNER; }
130 void metrics(MetricsInfo & mi, Dimension & dim) const override;
132 void draw(PainterInfo &, int x, int y) const override;
134 bool extraBraces() const override;
136 void mathmlize(MathStream &) const override;
138 void htmlize(HtmlStream &) const override;
140 void validate(LaTeXFeatures & features) const override;
142 InsetCode lyxCode() const override { return MATH_FRAC_CODE; }
144 Inset * clone() const override;
146 int dw(int height) const;