]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathScript.h
Rm dup "Float" in "Insert>Float>Figure Wrap Float"
[features.git] / src / mathed / InsetMathScript.h
index 32abf34fa4bfb8a7445ac79c79226c7bbbfee3e1..31955dd84c4dbb40a8aa27486c3204cba6f6b493 100644 (file)
@@ -4,7 +4,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -13,6 +13,7 @@
 #define MATH_SCRIPTINSET_H
 
 #include "InsetMathNest.h"
+#include "FontEnums.h"
 
 
 namespace lyx {
@@ -25,55 +26,57 @@ namespace lyx {
 class InsetMathScript : public InsetMathNest {
 public:
        /// create inset without scripts
-       InsetMathScript();
+       explicit InsetMathScript(Buffer * buf);
        /// create inset with single script
-       explicit InsetMathScript(bool up);
+       explicit InsetMathScript(Buffer * buf, bool up);
        /// create inset with single script and given nucleus
-       InsetMathScript(MathAtom const & at, bool up);
+       InsetMathScript(Buffer * buf, MathAtom const & at, bool up);
        ///
-       mode_type currentMode() const { return MATH_MODE; }
+       mode_type currentMode() const override { return MATH_MODE; }
+       /// whether the inset has limit-like sub/superscript
+       Limits limits() const override;
+       /// sets types of sub/superscripts
+       void limits(Limits lim) override;
        ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       MathClass mathClass() const override;
        ///
-       void draw(PainterInfo & pi, int x, int y) const;
+       void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
-       void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
+       void draw(PainterInfo & pi, int x, int y) const override;
        ///
-       void drawT(TextPainter & pi, int x, int y) const;
+       void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
+       ///
+       void drawT(TextPainter & pi, int x, int y) const override;
 
-       /// move cursor left
-       bool idxLeft(Cursor & cur) const;
-       /// move cursor right
-       bool idxRight(Cursor & cur) const;
+       /// move cursor backwards
+       bool idxBackward(Cursor & cur) const override;
+       /// move cursor forward
+       bool idxForward(Cursor & cur) const override;
        /// move cursor up or down
-       bool idxUpDown(Cursor & cur, bool up) const;
-       /// Target pos when we enter the inset from the left by pressing "Right"
-       bool idxFirst(Cursor & cur) const;
-       /// Target pos when we enter the inset from the right by pressing "Left"
-       bool idxLast(Cursor & cur) const;
+       bool idxUpDown(Cursor & cur, bool up) const override;
+       /// The index of the cell entered while moving backward
+       size_type lastIdx() const override { return 0; }
 
        /// write LaTeX and Lyx code
-       void write(WriteStream & os) const;
+       void write(TeXMathStream & os) const override;
        /// write normalized content
-       void normalize(NormalStream &) const;
+       void normalize(NormalStream &) const override;
        /// write content as something readable by Maple
-       void maple(MapleStream &) const;
+       void maple(MapleStream &) const override;
        /// write content as something readable by Mathematica
-       void mathematica(MathematicaStream &) const;
-       /// write content as something resembling MathML
-       void mathmlize(MathStream &) const;
+       void mathematica(MathematicaStream &) const override;
+       /// write content as MathML
+       void mathmlize(MathMLStream &) const override;
+       /// write content as HTML
+       void htmlize(HtmlStream &) const override;
        /// write content as something readable by Octave
-       void octave(OctaveStream &) const;
+       void octave(OctaveStream &) const override;
 
        /// identifies scriptinsets
-       InsetMathScript const * asScriptInset() const;
+       InsetMathScript const * asScriptInset() const override;
        ///
-       InsetMathScript * asScriptInset();
+       InsetMathScript * asScriptInset() override;
 
-       /// set limits
-       void limits(int lim) { limits_ = lim; }
-       /// get limits
-       int limits() const { return limits_; }
        /// returns subscript. Always run 'hasDown' or 'has(false)' before!
        MathData const & down() const;
        /// returns subscript. Always run 'hasDown' or 'has(false)' before!
@@ -99,45 +102,50 @@ public:
        /// make sure a script is accessible
        void ensure(bool up);
        /// say that we have scripts
-       void infoize(odocstream & os) const;
+       void infoize(odocstream & os) const override;
        /// say whether we have displayed limits
-       void infoize2(odocstream & os) const;
-protected:
-       virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+       void infoize2(odocstream & os) const override;
+       ///
+       InsetCode lyxCode() const override { return MATH_SCRIPT_CODE; }
+       ///
+       void validate(LaTeXFeatures &features) const override;
 private:
-       virtual Inset * clone() const;
+       Inset * clone() const override;
        /// returns x offset for main part
-       int dxx() const;
+       int dxx(BufferView const & bv) const;
        /// returns width of nucleus if any
-       int nwid() const;
+       int nwid(BufferView const &) const;
        /// returns y offset for either superscript or subscript
-       int dy01(int asc, int des, int what) const;
+       int dy01(BufferView const &, int asc, int des, int what) const;
        /// returns y offset for superscript
-       int dy0() const;
+       int dy0(BufferView const &) const;
        /// returns y offset for subscript
-       int dy1() const;
+       int dy1(BufferView const &) const;
        /// returns x offset for superscript
-       int dx0() const;
+       int dx0(BufferView const & bv) const;
        /// returns x offset for subscript
-       int dx1() const;
+       int dx1(BufferView const & bv) const;
        /// returns ascent of nucleus if any
-       int nasc() const;
+       int nasc(BufferView const &) const;
        /// returns descent of nucleus if any
-       int ndes() const;
-       /// returns superscript kerning of nucleus if any
-       int nker() const;
-       /// where do we have to draw the scripts?
-       bool hasLimits() const;
+       int ndes(BufferView const &) const;
+       /// Italic correction: amount of displacement between subscript and
+       /// superscript in math mode as per Appendix G, rule 18f.  A positive value
+       /// shifts the superscript to the right, and a negative value shifts the
+       /// subscript to the left.
+       int nker(BufferView const * bv) const;
+       /// do we we have to draw the scripts above/below nucleus?
+       bool hasLimits(MathStyle const &) const;
        /// clean up empty cells and return true if a cell has been deleted.
-       bool notifyCursorLeaves(Cursor & cur);
+       bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
 
        /// possible subscript (index 0) and superscript (index 1)
        bool cell_1_is_up_;
-       /// 1 - "limits", -1 - "nolimits", 0 - "default"
-       int limits_;
+       /// remember whether we are in display mode (used by mathml output)
+       mutable bool has_limits_ = false;
 };
 
 
-
 } // namespace lyx
+
 #endif