]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFrac.h
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathFrac.h
index c03157bdaacbbee2cc674e7fee838d902a2bc428..49d131d25a596948e270fbd35df3118f0f761931 100644 (file)
@@ -5,20 +5,34 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author André Pönitz
+ * \author André Pönitz
  *
  * 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:
+       ///
+       explicit InsetMathFracBase(idx_type ncells = 2);
+       ///
+       bool idxUpDown(Cursor &, bool up) const;
+       ///
+       bool idxBackward(Cursor &) const { return false; }
+       ///
+       bool idxForward(Cursor &) const { return false; }
+};
+
+
+
 /// Fraction like objects (frac, binom)
 class InsetMathFrac : public InsetMathFracBase {
 public:
@@ -27,13 +41,19 @@ public:
                FRAC,
                OVER,
                ATOP,
-               NICEFRAC
+               NICEFRAC,
+               UNITFRAC,
+               UNIT
        };
 
        ///
-       explicit InsetMathFrac(Kind kind = FRAC);
+       explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
+       ///
+       bool idxForward(Cursor &) const;
+       ///
+       bool idxBackward(Cursor &) const;
        ///
-       bool metrics(MetricsInfo & mi, Dimension & dim) const;
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo &, int x, int y) const;
        ///
@@ -62,12 +82,153 @@ public:
        ///
        void validate(LaTeXFeatures & features) const;
 public:
-       virtual Inset * clone() const;
+       Inset * clone() const;
        ///
        Kind kind_;
 };
 
 
+/// \dfrac support
+class InsetMathDFrac : public InsetMathFrac {
+public:
+       ///
+       InsetMathDFrac() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+};
+
+
+/// \tfrac support
+class InsetMathTFrac : public InsetMathFrac {
+public:
+       ///
+       InsetMathTFrac() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+};
+
+
+/// \cfrac support
+class InsetMathCFrac : public InsetMathFrac {
+public:
+       ///
+       InsetMathCFrac() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+};
+
+
+/// Binom like objects
+class InsetMathBinom : public InsetMathFracBase {
+public:
+       ///
+       enum Kind {
+               BINOM,
+               CHOOSE,
+               BRACE,
+               BRACK
+       };
+
+       ///
+       explicit InsetMathBinom(Kind kind = BINOM);
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       /// draw decorations.
+       void drawDecoration(PainterInfo & pi, int x, int y) const
+       { drawMarkers2(pi, x, y); }
+       ///
+       bool extraBraces() const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+       ///
+       int dw(int height) const;
+       ///
+       Kind kind_;
+};
+
+
+/// \dbinom support
+class InsetMathDBinom : public InsetMathFracBase {
+public:
+       ///
+       InsetMathDBinom() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+       ///
+       int dw(int height) const;
+};
+
+
+/// \tbinom support
+class InsetMathTBinom : public InsetMathFracBase {
+public:
+       ///
+       InsetMathTBinom() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+       ///
+       int dw(int height) const;
+};
+
 
 } // namespace lyx
+
 #endif