]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFrac.h
Reduce the number of accesses to coord cache when drawing a math row
[lyx.git] / src / mathed / InsetMathFrac.h
index ffcab063530cf09a9b9db27a5f16f3e5820a8b26..c2427ec76496f59ebc602b1eb69fc7892abbf8a0 100644 (file)
@@ -5,7 +5,8 @@
  * 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.
  */
@@ -22,13 +23,19 @@ namespace lyx {
 class InsetMathFracBase : public InsetMathNest {
 public:
        ///
-       explicit InsetMathFracBase(idx_type ncells = 2);
+       InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
        ///
-       bool idxUpDown(Cursor &, bool up) const;
+       marker_type marker(BufferView const *) const override { return marker_type::MARKER2; }
        ///
-       bool idxBackward(Cursor &) const { return false; }
+       bool idxUpDown(Cursor &, bool up) const override;
        ///
-       bool idxForward(Cursor &) const { return false; }
+       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; }
 };
 
 
@@ -39,166 +46,111 @@ public:
        ///
        enum Kind {
                FRAC,
+               AASTEX_CASE,
+               CFRAC,
+               CFRACLEFT,
+               CFRACRIGHT,
+               DFRAC,
+               TFRAC,
                OVER,
                ATOP,
                NICEFRAC,
                UNITFRAC,
                UNIT
        };
-
        ///
-       explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
+       explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
        ///
-       bool idxForward(Cursor &) const;
+       bool idxForward(Cursor &) const override;
        ///
-       bool idxBackward(Cursor &) const;
+       bool idxBackward(Cursor &) const override;
        ///
-       void 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;
-       ///
-       docstring name() const;
-       ///
-       bool extraBraces() const;
-
+       InsetMathFrac const * asFracInset() const override;
        ///
-       void write(WriteStream & os) const;
+       docstring name() const override;
        ///
-       void maple(MapleStream &) const;
+       bool extraBraces() const override;
        ///
-       void mathematica(MathematicaStream &) const;
+       void write(TeXMathStream & os) const override;
        ///
-       void octave(OctaveStream &) const;
+       void maple(MapleStream &) const override;
        ///
-       void mathmlize(MathStream &) const;
+       void mathematica(MathematicaStream &) const override;
        ///
-       void validate(LaTeXFeatures & features) const;
-public:
-       Inset * clone() const;
+       void octave(OctaveStream &) const override;
        ///
-       Kind kind_;
-};
-
-
-/// \dfrac support
-class InsetMathDFrac : public InsetMathFrac {
-public:
+       void mathmlize(MathMLStream &) const override;
        ///
-       InsetMathDFrac() {}
+       void htmlize(HtmlStream &) const override;
        ///
-       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;
+       void validate(LaTeXFeatures & features) const override;
 private:
-       Inset * clone() const;
-};
-
-
-/// \tfrac support
-class InsetMathTFrac : public InsetMathFrac {
-public:
-       ///
-       InsetMathTFrac() {}
-       ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       /// vertical displacement
+       int dy(FontInfo & fi) const;
        ///
-       void draw(PainterInfo &, int x, int y) const;
+       Inset * clone() const override;
        ///
-       docstring name() const;
-       ///
-       void mathmlize(MathStream &) const;
-       ///
-       void validate(LaTeXFeatures & features) const;
-private:
-       Inset * clone() const;
+       Kind kind_;
 };
 
 
+
 /// Binom like objects
 class InsetMathBinom : public InsetMathFracBase {
 public:
        ///
-       explicit InsetMathBinom(bool choose = false);
-       ///
-       void write(WriteStream & os) const;
-       ///
-       void normalize(NormalStream &) const;
-       ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       enum Kind {
+               BINOM,
+               DBINOM,
+               TBINOM,
+               CHOOSE,
+               BRACE,
+               BRACK
+       };
        ///
-       void draw(PainterInfo &, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers2(pi, x, y); }
+       explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
        ///
-       bool extraBraces() const;
-private:
-       Inset * clone() const;
+       void write(TeXMathStream & os) const override;
        ///
-       int dw(int height) const;
+       void normalize(NormalStream &) const override;
+       /// Generalized fractions are of inner class (see The TeXbook, p.292)
+       MathClass mathClass() const override { return MC_INNER; }
        ///
-       bool choose_;
-};
-
-
-/// \dbinom support
-class InsetMathDBinom : public InsetMathFracBase {
-public:
+       void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
-       InsetMathDBinom() {}
+       void draw(PainterInfo &, int x, int y) const override;
        ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       bool extraBraces() const override;
        ///
-       void draw(PainterInfo &, int x, int y) const;
+       void mathmlize(MathMLStream &) const override;
        ///
-       docstring name() const;
+       void htmlize(HtmlStream &) const override;
        ///
-       void mathmlize(MathStream &) const;
+       void validate(LaTeXFeatures & features) const override;
        ///
-       void validate(LaTeXFeatures & features) const;
+       InsetCode lyxCode() const override { return MATH_FRAC_CODE; }
 private:
-       Inset * clone() const;
+       Inset * clone() const override;
        ///
        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;
+       Kind kind_;
 };
 
 
+
 } // namespace lyx
 
 #endif