]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.h
Generalise the deletion protection mechanism from math to text (#9540)
[lyx.git] / src / mathed / MathMacro.h
index 9c6fdb1ce9e5b4041873c579825431791b2604c7..893c011a4141bdc05e3e1ddd250f160c751ec4ae 100644 (file)
@@ -37,21 +37,28 @@ public:
        ///
        virtual MathMacro const * asMacro() const { return this; }
        ///
+       marker_type marker(BufferView const *) const;
        /// If the macro is in normal edit mode, dissolve its contents in
        /// the row. Otherwise, just insert the inset.
-       bool addToMathRow(MathRow &, MetricsInfo const & mi) const;
+       bool addToMathRow(MathRow &, MetricsInfo & mi) const;
        ///
-       void draw(PainterInfo & pi, int x, int y) const;
-       /// draw selection background
-       void drawSelection(PainterInfo & pi, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers2(pi, x, y); }
+       void beforeMetrics() const;
+       ///
+       void afterMetrics() const;
+       ///
+       void beforeDraw(PainterInfo const &) const;
+       ///
+       void afterDraw(PainterInfo const &) const;
+
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        /// was the macro in edit mode when computing metrics?
        bool editMetrics(BufferView const * bv) const;
        ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       /// draw selection background
+       void drawSelection(PainterInfo & pi, int x, int y) const;
+       ///
        int kerning(BufferView const * bv) const;
        /// get cursor position
        void cursorPos(BufferView const & bv, CursorSlice const & sl,
@@ -122,10 +129,12 @@ public:
 
        ///
        docstring name() const;
-       ///
+       /// FIXME: Often dangling.
        MacroData const * macro() const;
        ///
        docstring macroName() const;
+       /// Level of nesting in macros (including this one)
+       int nesting() const;
        ///
        bool validName() const;
        ///
@@ -139,6 +148,9 @@ public:
        size_t appetite() const;
        ///
        InsetCode lyxCode() const { return MATH_MACRO_CODE; }
+       /// This is not used for display; however whether it is mathrel determines
+       /// how to split equations intelligently.
+       MathClass mathClass() const; //override
 
 protected:
        friend class MathData;
@@ -152,7 +164,8 @@ protected:
        /// update macro definition
        void updateMacro(MacroContext const & mc);
        /// check if macro definition changed, argument changed etc. and adapt
-       void updateRepresentation(Cursor * cur, MacroContext const & mc, UpdateType);
+       void updateRepresentation(Cursor * cur, MacroContext const & mc,
+                                 UpdateType, int nesting);
        /// empty macro, put arguments into args, possibly strip arity-attachedArgsNum_ empty ones.
        /// Includes the optional arguments.
        void detachArguments(std::vector<MathData> & args, bool strip);
@@ -161,6 +174,14 @@ protected:
        void attachArguments(std::vector<MathData> const & args, size_t arity, int optionals);
 
 private:
+       /// Math mode for output and display. UNDECIDED for user macros: they could
+       /// be either.
+       mode_type modeToEnsure() const;
+       /// This function is needed for now because of two shortfalls of the current
+       /// implementation: the macro() pointer is often dangling, in which case we
+       /// fall back to a backup copy, and the macro is not known at inset
+       /// creation, in which case we fall back to the global macro with this name.
+       MacroData const * macroBackup() const;
        ///
        virtual Inset * clone() const;
        ///