X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathScript.h;h=31955dd84c4dbb40a8aa27486c3204cba6f6b493;hb=ffff88e7fcd46afaa3b1823e9fcdc4aad4e2114b;hp=e9be1fda6a16088c8f8c7eb0f537bccdfdd0e936;hpb=89e4055189e6ded9561f6e365822d7597f99590e;p=features.git diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index e9be1fda6a..31955dd84c 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -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 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; - /// 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,13 +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; -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(BufferView const & bv) const; /// returns width of nucleus if any @@ -124,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; };