X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmathed%2FInsetMathFrac.h;h=c2427ec76496f59ebc602b1eb69fc7892abbf8a0;hb=e5bb491e2e10a8097284d11eae5501a3673731cb;hp=6668654b7567b688dea22064d0f9e15cf36750f8;hpb=0ea6f2c7f129fc400b6935c4a722a1483583c058;p=lyx.git diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h index 6668654b75..c2427ec764 100644 --- a/src/mathed/InsetMathFrac.h +++ b/src/mathed/InsetMathFrac.h @@ -5,71 +5,146 @@ * Licence details can be found in the file COPYING. * * \author Alejandro Aguilar Sierra - * \author André Pönitz + * \author André Pönitz + * \author Uwe Stöhr * * Full author contact details are available in file CREDITS. */ -#ifndef MATH_FRACINSET_H -#define MATH_FRACINSET_H +#ifndef MATH_FRAC_H +#define MATH_FRAC_H -#include "InsetMathFracBase.h" +#include "InsetMathNest.h" namespace lyx { +class InsetMathFracBase : public InsetMathNest { +public: + /// + InsetMathFracBase(Buffer * buf, idx_type ncells = 2); + /// + marker_type marker(BufferView const *) const override { return marker_type::MARKER2; } + /// + bool idxUpDown(Cursor &, bool up) const override; + /// + bool idxBackward(Cursor &) const override { return false; } + /// + bool idxForward(Cursor &) const override { return false; } + /// + InsetMathFracBase * asFracBaseInset() override { return this; } + /// + InsetMathFracBase const * asFracBaseInset() const override { return this; } +}; + + + /// Fraction like objects (frac, binom) class InsetMathFrac : public InsetMathFracBase { public: /// enum Kind { FRAC, + AASTEX_CASE, + CFRAC, + CFRACLEFT, + CFRACRIGHT, + DFRAC, + TFRAC, OVER, ATOP, NICEFRAC, UNITFRAC, - UNIT, - UNITFRAC3 + UNIT }; - /// - explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2); + explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2); /// - bool idxRight(Cursor &) const; + bool idxForward(Cursor &) const override; /// - bool idxLeft(Cursor &) const; + bool idxBackward(Cursor &) const override; /// - bool metrics(MetricsInfo & mi, Dimension & dim) const; + MathClass mathClass() const override; /// - void draw(PainterInfo &, int x, int y) const; + void metrics(MetricsInfo & mi, Dimension & dim) const override; /// - void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; + void draw(PainterInfo &, int x, int y) const override; /// - void drawT(TextPainter &, int x, int y) const; + void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override; + /// + void drawT(TextPainter &, int x, int y) const override; /// identifies FracInsets - InsetMathFrac * asFracInset(); + InsetMathFrac * asFracInset() override; /// identifies FracInsets - InsetMathFrac const * asFracInset() const; + InsetMathFrac const * asFracInset() const override; /// - docstring name() const; + docstring name() const override; /// - bool extraBraces() const; - + bool extraBraces() const override; /// - void write(WriteStream & os) const; + void write(TeXMathStream & os) const override; /// - void maple(MapleStream &) const; + void maple(MapleStream &) const override; /// - void mathematica(MathematicaStream &) const; + void mathematica(MathematicaStream &) const override; /// - void octave(OctaveStream &) const; + void octave(OctaveStream &) const override; /// - void mathmlize(MathStream &) const; + void mathmlize(MathMLStream &) const override; /// - void validate(LaTeXFeatures & features) const; + void htmlize(HtmlStream &) const override; + /// + void validate(LaTeXFeatures & features) const override; +private: + /// vertical displacement + int dy(FontInfo & fi) const; + /// + Inset * clone() const override; + /// + Kind kind_; +}; + + + +/// Binom like objects +class InsetMathBinom : public InsetMathFracBase { public: - virtual Inset * clone() const; + /// + enum Kind { + BINOM, + DBINOM, + TBINOM, + CHOOSE, + BRACE, + BRACK + }; + /// + explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM); + /// + void write(TeXMathStream & os) const override; + /// + void normalize(NormalStream &) const override; + /// Generalized fractions are of inner class (see The TeXbook, p.292) + MathClass mathClass() const override { return MC_INNER; } + /// + void metrics(MetricsInfo & mi, Dimension & dim) const override; + /// + void draw(PainterInfo &, int x, int y) const override; + /// + bool extraBraces() const override; + /// + void mathmlize(MathMLStream &) const override; + /// + void htmlize(HtmlStream &) const override; + /// + void validate(LaTeXFeatures & features) const override; + /// + InsetCode lyxCode() const override { return MATH_FRAC_CODE; } +private: + Inset * clone() const override; + /// + int dw(int height) const; /// Kind kind_; }; @@ -77,4 +152,5 @@ public: } // namespace lyx + #endif