]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacroTemplate.h
revert last patch. there's something wrong, possibly unrelated to this
[lyx.git] / src / mathed / MathMacroTemplate.h
index c14bfcb3ebade4af9ebeb024efc737c91634ced1..0af0975144ff8460b98ef672cbfdace65cbb9e1f 100644 (file)
@@ -38,17 +38,20 @@ public:
        ///
        EDITABLE editable() const { return HIGHLY_EDITABLE; }
        ///
-       void read(Buffer const &, Lexer & lex);
+       void edit(Cursor & cur, bool front, EntryDirection entry_from);
        ///
-       void write(Buffer const &, std::ostream & os) const;
+       bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
+       ///
+       void read(Lexer & lex);
+       ///
+       void write(std::ostream & os) const;
        ///
        void write(WriteStream & os) const;
        /// Output LaTeX code, but assume that the macro is not definied yet
        /// if overwriteRedefinition is true
        void write(WriteStream & os, bool overwriteRedefinition) const;
        ///
-       int plaintext(Buffer const &, odocstream &,
-               OutputParams const &) const;
+       int plaintext(odocstream &, OutputParams const &) const;
        ///
        bool noFontChange() const { return true; }
 
@@ -76,6 +79,9 @@ public:
        /// Remove everything from the name which makes it invalid 
        /// and return true iff it is valid.
        bool fixNameAndCheckIfValid();
+       
+       /// request "external features"
+       virtual void validate(LaTeXFeatures &) const;
 
        /// decide whether its a redefinition
        void updateToContext(MacroContext const & mc) const;
@@ -90,6 +96,10 @@ public:
        MathMacroTemplate const * asMacroTemplate() const { return this; }
        ///
        InsetCode lyxCode() const { return MATHMACRO_CODE; }
+       ///
+       void infoize(odocstream & os) const;
+       ///
+       docstring contextMenu(BufferView const &, int, int) const;
 
 protected:
        ///
@@ -99,6 +109,10 @@ protected:
                FuncStatus & status) const;
 
 private:
+       friend class InsetLabelBox;
+       friend class DisplayLabelBox;
+       
+       ///
        virtual Inset * clone() const;
 
        /// remove #n with from<=n<=to
@@ -106,9 +120,9 @@ private:
        /// shift every #n with from<=n, i.e. #n -> #(n-by)
        void shiftArguments(size_t from, int by);
        ///
-       void insertParameter(Cursor & cur, int pos, bool greedy = false);
+       void insertParameter(Cursor & cur, int pos, bool greedy = false, bool addarg = true);
        ///
-       void removeParameter(Cursor & cur, int pos, bool greedy = false );
+       void removeParameter(Cursor & cur, int pos, bool greedy = false);
        ///
        void makeOptional(Cursor & cur);
        ///
@@ -119,11 +133,23 @@ private:
        idx_type optIdx(idx_type n) const { return n + 1; }
        ///
        idx_type displayIdx() const { return optionals_ + 2; }
-       /// The label with some holes to edit
-       mutable MathData label_;
+       ///
+       void updateLook() const;
+       /// look through the macro for #n arguments
+       int maxArgumentInDefinition() const;
+       /// add missing #n arguments up to \c maxArg
+       void insertMissingArguments(int maxArg);
+       /// change the arity
+       void changeArity(Cursor & cur, int newNumArg);
+       /// find arguments in definition and adapt the arity accordingly
+       void commitEditChanges(Cursor & cur);
+       /// The representation of the macro template, with some holes to edit
+       mutable MathData look_;
        ///
        mutable int numargs_;
        ///
+       mutable int argsInLook_;
+       ///
        int optionals_;
        /// keeps the old optional default value when an 
        /// optional argument is disabled
@@ -133,6 +159,22 @@ private:
        mutable MacroType type_;
        /// defined before already?
        mutable bool redefinition_;
+       ///
+       void createLook(int args) const;
+       ///
+       mutable bool lookOutdated_;
+       /// true if in pre-calculations of metrics to get height of boxes
+       mutable bool premetrics_;
+       ///
+       mutable int labelBoxAscent_;
+       ///
+       mutable int labelBoxDescent_;
+       ///
+       bool premetrics() const { return premetrics_; }
+       ///
+       int commonLabelBoxAscent() const { return labelBoxAscent_; }
+       ///
+       int commonLabelBoxDescent() const { return labelBoxDescent_; }
 };