]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacroTemplate.h
simplify GuiToc / TocWidget interaction. Much can still be simplified...
[lyx.git] / src / mathed / MathMacroTemplate.h
index 36eb7fbab3e61090439f744a4d0a87fe3c6877bd..6f2fa1d3b7e03b7696760bdf4f3390a82fb948a1 100644 (file)
@@ -29,7 +29,7 @@ public:
        MathMacroTemplate();
        ///
        MathMacroTemplate(docstring const & name, int nargs, int optional, 
-               docstring const & type, 
+               MacroType type,
                std::vector<MathData> const & optionalValues = std::vector<MathData>(),
                MathData const & def = MathData(),
                MathData const & display = MathData());
@@ -38,23 +38,55 @@ public:
        ///
        EDITABLE editable() const { return HIGHLY_EDITABLE; }
        ///
+       void edit(Cursor & cur, bool front, EntryDirection entry_from);
+       ///
+       bool notifyCursorLeaves(Cursor & cur);
+       ///
        void read(Buffer const &, Lexer & lex);
        ///
        void write(Buffer const &, 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;
+       ///
+       bool noFontChange() const { return true; }
 
        ///
        docstring name() const;
+       ///
+       void getDefaults(std::vector<docstring> & defaults) const;
+       ///
+       docstring definition() const;
+       ///
+       docstring displayDefinition() const;
+       ///
+       size_t numArgs() const;
+       ///
+       size_t numOptionals() const;
+       ///
+       bool redefinition() const { return redefinition_; }
+       ///
+       MacroType type() const { return type_; }
+
        /// check name and possible other formal properties
        bool validMacro() const;
        ///
        bool validName() const;
-       ///
-       MacroData asMacroData() const;
+       /// 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;
+
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
@@ -65,6 +97,8 @@ public:
        MathMacroTemplate const * asMacroTemplate() const { return this; }
        ///
        InsetCode lyxCode() const { return MATHMACRO_CODE; }
+       ///
+       void infoize(odocstream & os) const;
 
 protected:
        ///
@@ -74,6 +108,10 @@ protected:
                FuncStatus & status) const;
 
 private:
+       friend class InsetLabelBox;
+       friend class DisplayLabelBox;
+       
+       ///
        virtual Inset * clone() const;
 
        /// remove #n with from<=n<=to
@@ -89,21 +127,43 @@ private:
        ///
        void makeNonOptional(Cursor & cur);
        ///
-       pos_type defIdx() const { return optionals_ + 1; }
+       idx_type defIdx() const { return optionals_ + 1; }
        /// index of default value cell of optional parameter (#1 -> n=0)
-       pos_type optIdx(int n) const { return n + 1; }
+       idx_type optIdx(idx_type n) const { return n + 1; }
        ///
-       pos_type displayIdx() const { return optionals_ + 2; }
-       /// The label with some holes to edit
-       mutable MathData label_;
+       idx_type displayIdx() const { return optionals_ + 2; }
+       ///
+       void updateLook() const;
+       /// The representation of the macro tempalte, with some holes to edit
+       mutable MathData look_;
        ///
        mutable int numargs_;
        ///
        int optionals_;
-       /// keeps the old optional default value when an optional argument is disabled
+       /// keeps the old optional default value when an 
+       /// optional argument is disabled
        std::vector<MathData> optionalValues_;
-       /// newcommand or renewcommand or def
-       mutable docstring type_;
+
+       /// (re)newcommand or def
+       mutable MacroType type_;
+       /// defined before already?
+       mutable bool redefinition_;
+       ///
+       void createLook() 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_; }
 };