]> 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 e84886b7d3bf922a8d42cae1e0beff345cc5de53..31955dd84c4dbb40a8aa27486c3204cba6f6b493 100644 (file)
@@ -13,6 +13,7 @@
 #define MATH_SCRIPTINSET_H
 
 #include "InsetMathNest.h"
+#include "FontEnums.h"
 
 
 namespace lyx {
@@ -25,57 +26,57 @@ namespace lyx {
 class InsetMathScript : public InsetMathNest {
 public:
        /// create inset without scripts
-       InsetMathScript(Buffer * buf);
+       explicit InsetMathScript(Buffer * buf);
        /// create inset with single script
        explicit InsetMathScript(Buffer * buf, bool up);
        /// create inset with single script and given nucleus
        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 backwards
-       bool idxBackward(Cursor & cur) const;
+       bool idxBackward(Cursor & cur) const override;
        /// move cursor forward
-       bool idxForward(Cursor & cur) const;
+       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 while moving forward
-       bool idxFirst(Cursor & cur) const;
-       /// Target pos when we enter the inset while moving backwards
-       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;
+       void mathematica(MathematicaStream &) const override;
        /// write content as MathML
-       void mathmlize(MathStream &) const;
+       void mathmlize(MathMLStream &) const override;
        /// write content as HTML
-       void htmlize(HtmlStream &) const;
+       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!
@@ -101,20 +102,15 @@ 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;
+       void infoize2(odocstream & os) const override;
        ///
-       InsetCode lyxCode() const { return MATH_SCRIPT_CODE; }
+       InsetCode lyxCode() const override { return MATH_SCRIPT_CODE; }
        ///
-       void validate(LaTeXFeatures &features) const;
-protected:
-       virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
-       /// do we want to handle this event?
-       bool getStatus(Cursor & cur, FuncRequest const & cmd,
-               FuncStatus & status) const;
+       void validate(LaTeXFeatures &features) const override;
 private:
-       virtual Inset * clone() const;
+       Inset * clone() const override;
        /// returns x offset for main part
        int dxx(BufferView const & bv) const;
        /// returns width of nucleus if any
@@ -133,17 +129,20 @@ private:
        int nasc(BufferView const &) const;
        /// returns descent of nucleus if any
        int ndes(BufferView const &) const;
-       /// returns superscript kerning of nucleus if any
+       /// 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;
-       /// where do we have to draw the scripts?
-       bool hasLimits() 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 const & old, 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;
 };