X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMath.h;h=067bf6e876a2d0b7e46ee7f596fc37a89e44341a;hb=7441172d4d9a26eb4824bb8bee003f457ef34f1c;hp=9c65fafe4d307dadf77772f544f978d74e7a8187;hpb=03a4b8c93281f9081dc56673f408d32ecddc2470;p=features.git diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index 9c65fafe4d..067bf6e876 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -39,6 +39,17 @@ enum HullType { HullType hullType(docstring const & name); docstring hullName(HullType type); + +enum Limits { + // what is obtained with \c \\nolimits + NO_LIMITS = -1, + // the default + AUTO_LIMITS = 0, + // what is obtained with \c \\limits + LIMITS = 1 +}; + + /** Abstract base class for all math objects. A math insets is for use of the @@ -61,6 +72,7 @@ class InsetMathArray; class InsetMathAMSArray; class InsetMathBrace; class InsetMathChar; +class InsetMathClass; class InsetMathDelim; class InsetMathFracBase; class InsetMathFrac; @@ -74,6 +86,7 @@ class InsetMathString; class InsetMathSpace; class InsetMathSpecialChar; class InsetMathSymbol; +class InsetMathSubstack; class InsetMathUnknown; class InsetMathRef; @@ -87,8 +100,8 @@ class MathStream; class WriteStream; class MathData; -class MathMacroTemplate; -class MathMacro; +class InsetMathMacroTemplate; +class InsetMathMacro; class MathRow; class TextPainter; class TextMetricsInfo; @@ -101,7 +114,7 @@ typedef void const * uid_type; class InsetMath : public Inset { public: /// - InsetMath(Buffer * buf = 0) : Inset(buf) {} + explicit InsetMath(Buffer * buf = 0) : Inset(buf) {} /// identification as math inset InsetMath * asInsetMath() { return this; } /// identification as math inset @@ -114,8 +127,10 @@ public: /// this is overridden by specific insets virtual mode_type currentMode() const { return MATH_MODE; } + // The possible marker types for math insets + enum marker_type { NO_MARKER, MARKER2, MARKER, BOX_MARKER }; /// this is overridden by insets with specific edit marker type - virtual marker_type marker() const; + virtual marker_type marker(BufferView const *) const; /// the ascent of the inset above the baseline /// compute the size of the object for text based drawing @@ -129,58 +144,76 @@ public: virtual MathData const & cell(idx_type) const; /// identifies certain types of insets - virtual InsetMathAMSArray * asAMSArrayInset() { return 0; } - virtual InsetMathAMSArray const * asAMSArrayInset() const { return 0; } - virtual InsetMathArray * asArrayInset() { return 0; } - virtual InsetMathArray const * asArrayInset() const { return 0; } - virtual InsetMathBrace * asBraceInset() { return 0; } - virtual InsetMathBrace const * asBraceInset() const { return 0; } - virtual InsetMathChar const * asCharInset() const { return 0; } - virtual InsetMathDelim * asDelimInset() { return 0; } - virtual InsetMathDelim const * asDelimInset() const { return 0; } - virtual InsetMathFracBase * asFracBaseInset() { return 0; } - virtual InsetMathFracBase const * asFracBaseInset() const { return 0; } - virtual InsetMathFrac * asFracInset() { return 0; } - virtual InsetMathFrac const * asFracInset() const { return 0; } - virtual InsetMathFont * asFontInset() { return 0; } - virtual InsetMathFont const * asFontInset() const { return 0; } - virtual InsetMathGrid * asGridInset() { return 0; } - virtual InsetMathGrid const * asGridInset() const { return 0; } - virtual InsetMathHull * asHullInset() { return 0; } - virtual InsetMathHull const * asHullInset() const { return 0; } - virtual MathMacro * asMacro() { return 0; } - virtual MathMacro const * asMacro() const { return 0; } - virtual MathMacroTemplate * asMacroTemplate() { return 0; } - virtual MathMacroTemplate const * asMacroTemplate() const { return 0; } - virtual InsetMathMatrix const * asMatrixInset() const { return 0; } - virtual InsetMathNest * asNestInset() { return 0; } - virtual InsetMathNest const * asNestInset() const { return 0; } - virtual InsetMathScript * asScriptInset() { return 0; } - virtual InsetMathScript const * asScriptInset() const { return 0; } - virtual InsetMathSpace * asSpaceInset() { return 0; } - virtual InsetMathSpace const * asSpaceInset() const { return 0; } - virtual InsetMathString * asStringInset() { return 0; } - virtual InsetMathString const * asStringInset() const { return 0; } - virtual InsetMathSymbol const * asSymbolInset() const { return 0; } - virtual InsetMathUnknown * asUnknownInset() { return 0; } - virtual InsetMathUnknown const * asUnknownInset() const { return 0; } - virtual InsetMathRef * asRefInset() { return 0; } - virtual InsetMathSpecialChar const * asSpecialCharInset() const { return 0; } + virtual InsetMathAMSArray * asAMSArrayInset() { return nullptr; } + virtual InsetMathAMSArray const * asAMSArrayInset() const { return nullptr; } + virtual InsetMathArray * asArrayInset() { return nullptr; } + virtual InsetMathArray const * asArrayInset() const { return nullptr; } + virtual InsetMathBrace * asBraceInset() { return nullptr; } + virtual InsetMathBrace const * asBraceInset() const { return nullptr; } + virtual InsetMathChar const * asCharInset() const { return nullptr; } + virtual InsetMathClass const * asClassInset() const { return nullptr; } + virtual InsetMathDelim * asDelimInset() { return nullptr; } + virtual InsetMathDelim const * asDelimInset() const { return nullptr; } + virtual InsetMathFracBase * asFracBaseInset() { return nullptr; } + virtual InsetMathFracBase const * asFracBaseInset() const { return nullptr; } + virtual InsetMathFrac * asFracInset() { return nullptr; } + virtual InsetMathFrac const * asFracInset() const { return nullptr; } + virtual InsetMathFont * asFontInset() { return nullptr; } + virtual InsetMathFont const * asFontInset() const { return nullptr; } + virtual InsetMathGrid * asGridInset() { return nullptr; } + virtual InsetMathGrid const * asGridInset() const { return nullptr; } + virtual InsetMathHull * asHullInset() { return nullptr; } + virtual InsetMathHull const * asHullInset() const { return nullptr; } + virtual InsetMathMacro * asMacro() { return nullptr; } + virtual InsetMathMacro const * asMacro() const { return nullptr; } + virtual InsetMathMacroTemplate * asMacroTemplate() { return nullptr; } + virtual InsetMathMacroTemplate const * asMacroTemplate() const { return nullptr; } + virtual InsetMathMatrix const * asMatrixInset() const { return nullptr; } + virtual InsetMathNest * asNestInset() { return nullptr; } + virtual InsetMathNest const * asNestInset() const { return nullptr; } + virtual InsetMathScript * asScriptInset() { return nullptr; } + virtual InsetMathScript const * asScriptInset() const { return nullptr; } + virtual InsetMathSpace * asSpaceInset() { return nullptr; } + virtual InsetMathSpace const * asSpaceInset() const { return nullptr; } + virtual InsetMathString * asStringInset() { return nullptr; } + virtual InsetMathString const * asStringInset() const { return nullptr; } + virtual InsetMathSubstack * asSubstackInset() { return nullptr; } + virtual InsetMathSubstack const * asSubstackInset() const { return nullptr; } + virtual InsetMathSymbol const * asSymbolInset() const { return nullptr; } + virtual InsetMathUnknown * asUnknownInset() { return nullptr; } + virtual InsetMathUnknown const * asUnknownInset() const { return nullptr; } + virtual InsetMathRef * asRefInset() { return nullptr; } + virtual InsetMathSpecialChar const * asSpecialCharInset() const { return nullptr; } /// The class of the math object (used primarily for spacing) - virtual MathClass mathClass() const; + virtual MathClass mathClass() const { return MC_ORD; } /// Add this inset to a math row. Return true if contents got added virtual bool addToMathRow(MathRow &, MetricsInfo & mi) const; + /// Hook that is run before metrics computation starts + virtual void beforeMetrics() const {} + /// Hook that is run after metrics computation + virtual void afterMetrics() const {} + /// Hook that is run before actual drawing + virtual void beforeDraw(PainterInfo const &) const {} + /// Hook that is run after drawing + virtual void afterDraw(PainterInfo const &) const {} - /// identifies things that can get scripts - virtual bool isScriptable() const { return false; } /// will this get written as a single block in {..} virtual bool extraBraces() const { return false; } /// return the content as char if the inset is able to do so virtual char_type getChar() const { return 0; } - /// identifies things that can get \limits or \nolimits - virtual bool takesLimits() const { return false; } + + /// Whether the inset allows \(no)limits + bool allowsLimitsChange() const { return mathClass() == MC_OP; } + /// The default limits value + virtual Limits defaultLimits() const { return NO_LIMITS; } + /// whether the inset has limit-like sub/superscript + virtual Limits limits() const { return AUTO_LIMITS; } + /// sets types of sub/superscripts + virtual void limits(Limits) {} + /// write limits status for LaTeX and LyX code + void writeLimits(WriteStream & os) const; /// replace things by other things virtual void replace(ReplaceData &) {}