]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inset.h
Remove #include "LColor.h" from inset.h.
[lyx.git] / src / insets / inset.h
index a1e36f39c857fd0190c54deabee9213bbf1661e9..a9feca8ad4b637d1265a979e63600e3c611c546c 100644 (file)
@@ -9,48 +9,46 @@
  * \author Lars Gullik Bjønnes
  * \author Matthias Ettrich
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
-#ifndef INSET_H
-#define INSET_H
+#ifndef INSETOLD_H
+#define INSETOLD_H
 
-
-#include <vector>
-#include "LString.h"
-#include "LColor.h"
 #include "insetbase.h"
-#include "frontends/mouse_state.h"
-#include "support/types.h"
+#include "dimension.h"
+#include "ParagraphList_fwd.h"
 
-class LyXFont;
 class Buffer;
-class Painter;
-class LyXText;
+class EnumLColor;
+class FuncRequest;
+class LatexRunParams;
+class LyXCursor;
+class LyXFont;
 class LyXLex;
+class LyXText;
+class Painter;
 class Paragraph;
-class ParagraphList;
-class LyXCursor;
-class FuncRequest;
+class UpdatableInset;
 class WordLangTuple;
 
-struct LaTeXFeatures;
-
-namespace grfx {
+namespace lyx {
+namespace graphics {
        class PreviewLoader;
 }
+}
 
 /// Insets
-class Inset : public InsetBase {
+class InsetOld : public InsetBase {
 public:
        /** This is not quite the correct place for this enum. I think
            the correct would be to let each subclass of Inset declare
-           its own enum code. Actually the notion of an Inset::Code
+           its own enum code. Actually the notion of an InsetOld::Code
            should be avoided, but I am not sure how this could be done
            in a cleaner way. */
        enum Code {
                ///
-               NO_CODE,
+               NO_CODE, // 0
                ///
                TOC_CODE,  // do these insets really need a code? (ale)
                ///
@@ -58,9 +56,9 @@ public:
                ///
                MARK_CODE,
                ///
-               REF_CODE, // 5
+               REF_CODE,
                ///
-               URL_CODE,
+               URL_CODE, // 5
                ///
                HTMLURL_CODE,
                ///
@@ -68,9 +66,9 @@ public:
                ///
                ENDING_CODE,
                ///
-               LABEL_CODE, // 10
+               LABEL_CODE,
                ///
-               NOTE_CODE,
+               NOTE_CODE, // 10
                ///
                ACCENT_CODE,
                ///
@@ -78,11 +76,9 @@ public:
                ///
                INDEX_CODE,
                ///
-               INCLUDE_CODE, // 15
+               INCLUDE_CODE,
                ///
-               GRAPHICS_CODE,
-               ///
-               PARENT_CODE,
+               GRAPHICS_CODE, // 15
                ///
                BIBITEM_CODE,
                ///
@@ -90,9 +86,9 @@ public:
                ///
                TEXT_CODE,
                ///
-               ERT_CODE, // 20
+               ERT_CODE,
                ///
-               FOOT_CODE,
+               FOOT_CODE, // 20
                ///
                MARGIN_CODE,
                ///
@@ -102,7 +98,9 @@ public:
                ///
                MINIPAGE_CODE,
                ///
-               SPECIALCHAR_CODE, // 25
+               SPACE_CODE, // 25
+               ///
+               SPECIALCHAR_CODE,
                ///
                TABULAR_CODE,
                ///
@@ -124,13 +122,15 @@ public:
                ///
                INDEX_PRINT_CODE,
                ///
-               OPTARG_CODE,
+               OPTARG_CODE, // 35
                ///
                ENVIRONMENT_CODE,
                ///
                HFILL_CODE,
                ///
-               NEWLINE_CODE
+               NEWLINE_CODE,
+               ///
+               BRANCH_CODE
        };
 
        ///
@@ -153,95 +153,60 @@ public:
        typedef dispatch_result RESULT;
 
        ///
-       Inset();
-       ///
-       Inset(Inset const & in, bool same_id = false);
+       InsetOld();
        ///
-       virtual int ascent(BufferView *, LyXFont const &) const = 0;
+       InsetOld(InsetOld const & in);
        ///
-       virtual int descent(BufferView *, LyXFont const &) const = 0;
+       int ascent() const;
        ///
-       virtual int width(BufferView *, LyXFont const &) const = 0;
+       int descent() const;
        ///
-       virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const = 0;
-       /// update the inset representation
-       virtual void update(BufferView *, bool = false)
-               {}
+       int width() const;
        /// what appears in the minibuffer when opening
        virtual string const editMessage() const;
        ///
-       virtual void edit(BufferView *, int x, int y, mouse_button::state button);
-       ///
-       virtual void edit(BufferView *, bool front = true);
-       ///
        virtual EDITABLE editable() const;
        ///
        virtual bool isTextInset() const { return false; }
        /// return true if the inset should be removed automatically
        virtual bool autoDelete() const;
        /// returns true the inset can hold an inset of given type
-       virtual bool insetAllowed(Inset::Code) const { return false; }
+       virtual bool insetAllowed(InsetOld::Code) const { return false; }
        /// wrapper around the above
-       bool insetAllowed(Inset * in) const;
+       bool insetAllowed(InsetOld * in) const;
        ///
-       virtual void write(Buffer const *, std::ostream &) const = 0;
+       virtual void write(Buffer const &, std::ostream &) const = 0;
        ///
-       virtual void read(Buffer const *, LyXLex & lex) = 0;
-       /** returns the number of rows (\n's) of generated tex code.
-           fragile == true means, that the inset should take care about
-           fragile commands by adding a \protect before.
-           If the free_spc (freespacing) variable is set, then this inset
-           is in a free-spacing paragraph.
-       */
-       virtual int latex(Buffer const *, std::ostream &, bool fragile,
-                         bool free_spc) const = 0;
+       virtual void read(Buffer const &, LyXLex & lex) = 0;
+       /// returns the number of rows (\n's) of generated tex code.
+       virtual int latex(Buffer const &, std::ostream &,
+                         LatexRunParams const &) const = 0;
        ///
-       virtual int ascii(Buffer const *,
+       virtual int ascii(Buffer const &,
                          std::ostream &, int linelen = 0) const = 0;
        ///
-       virtual int linuxdoc(Buffer const *, std::ostream &) const = 0;
+       virtual int linuxdoc(Buffer const &, std::ostream &) const = 0;
        ///
-       virtual int docbook(Buffer const *, std::ostream &, bool) const = 0;
-       /// Updates needed features for this inset.
-       virtual void validate(LaTeXFeatures & features) const;
+       virtual int docbook(Buffer const &, std::ostream &, bool) const = 0;
 
        /// returns LyX code associated with the inset. Used for TOC, ...)
-       virtual Inset::Code lyxCode() const { return NO_CODE; }
-
-       virtual std::vector<string> const getLabelList() const {
-               return std::vector<string>();
-       }
-
-       ///
-       virtual Inset * clone(Buffer const &, bool same_ids = false) const = 0;
+       virtual InsetOld::Code lyxCode() const { return NO_CODE; }
 
        /// returns true to override begin and end inset in file
        virtual bool directWrite() const;
 
-       /// Returns true if the inset should be centered alone
-       virtual bool display() const { return false; }
-       /// Changes the display state of the inset
-       virtual void display(bool) {}
-       ///
-       /// returns true if this inset needs a row on it's own
-       ///
-       virtual bool needFullRow() const { return false; }
        ///
        void setInsetName(string const & s) { name_ = s; }
        ///
        string const & getInsetName() const { return name_; }
        ///
-       void setOwner(Inset * inset) { owner_ = inset; }
+       void setOwner(UpdatableInset * inset) { owner_ = inset; }
        ///
-       Inset * owner() const { return owner_; }
+       UpdatableInset * owner() const { return owner_; }
        ///
-       void parOwner(Paragraph * par) { par_owner_ = par; }
+       void setBackgroundColor(EnumLColor);
        ///
-       Paragraph * parOwner() const { return par_owner_; }
-       ///
-       void setBackgroundColor(LColor::color);
-       ///
-       LColor::color backgroundColor() const;
+       EnumLColor backgroundColor() const;
        ///
        int x() const { return top_x; }
        ///
@@ -251,11 +216,9 @@ public:
        // inside them without cast!!!
        ///
        virtual LyXText * getLyXText(BufferView const *,
-                                    bool const recursive = false) const;
+                                    bool recursive = false) const;
        ///
        virtual void deleteLyXText(BufferView *, bool = true) const {}
-       ///
-       virtual void resizeLyXText(BufferView *, bool /*force*/= false) const {}
        /// returns the actuall scroll-value
        virtual int scroll(bool recursive=true) const {
                if (!recursive || !owner_)
@@ -265,7 +228,7 @@ public:
 
        /// try to get a inset pointer from it's id if we have
        /// an inset to give back!
-       virtual Inset * getInsetFromID(int /*id*/) const { return 0; }
+       virtual InsetOld * getInsetFromID(int /*id*/) const { return 0; }
        /// if this insets owns paragraphs (f.ex. InsetText) then it
        /// should return it's very first one!
        virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
@@ -311,7 +274,7 @@ public:
        virtual bool isLineSeparator() const { return false; }
        // if this inset has paragraphs should they be output all as default
        // paragraphs with "Standard" layout?
-       virtual bool forceDefaultParagraphs(Inset const *) const;
+       virtual bool forceDefaultParagraphs(InsetOld const *) const;
        /** returns true if, when outputing LaTeX, font changes should
            be closed before generating this inset. This is needed for
            insets that may contain several paragraphs */
@@ -333,7 +296,7 @@ public:
         *  Most insets have no interest in this capability, so the method
         *  defaults to empty.
         */
-       virtual void addPreview(grfx::PreviewLoader &) const {}
+       virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
 
        /** Find the PreviewLoader, add a LaTeX snippet to it and
         *  start the loading process.
@@ -350,52 +313,36 @@ protected:
        mutable int top_baseline;
        ///
        mutable int scx;
-       ///
+       /// Used to identify the inset for cursor positioning when undoing
        unsigned int id_;
        ///
        static unsigned int inset_id;
+       ///
+       mutable Dimension dim_;
 
 private:
        ///
-       Inset * owner_;
-       /// the paragraph in which this inset has been inserted
-       Paragraph * par_owner_;
+       UpdatableInset * owner_;
        ///
        string name_;
-       ///
-       LColor::color background_color_;
+       /** We store the LColor::color value as an int to get LColor.h out
+        *  of the header file.
+        */
+       int background_color_;
 };
 
 
-inline
-bool Inset::insetAllowed(Inset * in) const
-{
-       return insetAllowed(in->lyxCode());
-}
-
-
-inline
-bool Inset::checkInsertChar(LyXFont &)
-{
-       return false;
-}
-
 /**
  * returns true if pointer argument is valid
  * and points to an editable inset
  */
-inline bool isEditableInset(Inset const * i)
-{
-       return i && i->editable();
-}
+bool isEditableInset(InsetOld const * i);
+
 
 /**
  * returns true if pointer argument is valid
  * and points to a highly editable inset
  */
-inline bool isHighlyEditableInset(Inset const * i)
-{
-       return i && i->editable() == Inset::HIGHLY_EDITABLE;
-}
+bool isHighlyEditableInset(InsetOld const * i);
 
 #endif