X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMath.h;h=c872316abfbf5bc38613f991d9c0a562b8f9699b;hb=d9082639080b9de993742bd352f92e5183058cf5;hp=421cd162b99d6be92c7e529404bd3a64f4edda79;hpb=decd2c74f105a11a21de08097649f9bc102a1b5c;p=lyx.git diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index 421cd162b9..c872316abf 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -39,6 +39,26 @@ 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 +}; + + +/// The possible marker types for math insets +enum class marker_type : int { + NO_MARKER, + MARKER2, + MARKER, + BOX_MARKER +}; + + /** Abstract base class for all math objects. A math insets is for use of the @@ -53,7 +73,6 @@ inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset. */ -class Cursor; class OutputParams; class MetricsInfo; @@ -61,6 +80,7 @@ class InsetMathArray; class InsetMathAMSArray; class InsetMathBrace; class InsetMathChar; +class InsetMathClass; class InsetMathDelim; class InsetMathFracBase; class InsetMathFrac; @@ -84,8 +104,8 @@ class OctaveStream; class MapleStream; class MaximaStream; class MathematicaStream; -class MathStream; -class WriteStream; +class MathMLStream; +class TeXMathStream; class MathData; class InsetMathMacroTemplate; @@ -95,28 +115,23 @@ class TextPainter; class TextMetricsInfo; class ReplaceData; -/// Type of unique identifiers for math insets (used in TexRow) -typedef void const * uid_type; - class InsetMath : public Inset { public: /// explicit InsetMath(Buffer * buf = 0) : Inset(buf) {} /// identification as math inset - InsetMath * asInsetMath() { return this; } + InsetMath * asInsetMath() override { return this; } /// identification as math inset - InsetMath const * asInsetMath() const { return this; } + InsetMath const * asInsetMath() const override { return this; } /// this is overridden in math text insets (i.e. mbox) - bool inMathed() const { return true; } + bool inMathed() const override { return true; } /// virtual docstring name() const; /// this is overridden by specific insets - virtual mode_type currentMode() const { return MATH_MODE; } + mode_type currentMode() const override { 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(BufferView const *) const; @@ -139,6 +154,7 @@ public: 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; } @@ -173,7 +189,7 @@ public: 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 @@ -185,15 +201,22 @@ public: /// 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 depending on whether display mode is on + virtual Limits defaultLimits(bool /* display */) 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(TeXMathStream & os) const; /// replace things by other things virtual void replace(ReplaceData &) {} @@ -208,7 +231,7 @@ public: // write(). This is to shut off a clang warning. using Inset::write; /// write LaTeX and LyX code - virtual void write(WriteStream & os) const; + virtual void write(TeXMathStream & os) const; /// write normalized content virtual void normalize(NormalStream &) const; /// write content as something readable by Maple @@ -218,7 +241,7 @@ public: /// write content as something readable by Mathematica virtual void mathematica(MathematicaStream &) const; /// write content as MathML - virtual void mathmlize(MathStream &) const; + virtual void mathmlize(MathMLStream &) const; /// write content as HTML, best we can. /// the idea for this, and some of the details, come from /// eLyXer, written by Alex Fernandez. no code is borrowed. rather, @@ -228,10 +251,10 @@ public: virtual void octave(OctaveStream &) const; /// plain text output in ucs4 encoding - int plaintext(odocstringstream &, OutputParams const &, size_t) const; + int plaintext(odocstringstream &, OutputParams const &, size_t) const override; /// dump content to stderr for debugging - virtual void dump() const; + void dump() const override; /// LyXInset stuff virtual bool numberedType() const { return false; } @@ -241,14 +264,14 @@ public: virtual void mutate(HullType /*newtype*/) {} /// math stuff usually isn't allowed in text mode - virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; } + bool allowedIn(mode_type mode) const override { return mode == MATH_MODE; } /// Italic correction as described in InsetMathScript.h virtual int kerning(BufferView const *) const { return 0; } /// - bool isInToc() const { return true; } + bool isInToc() const override { return true; } /// - InsetCode lyxCode() const { return MATH_CODE; } + InsetCode lyxCode() const override { return MATH_CODE; } /// uid_type id() const { return this; } };