]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inset.h
ws changes only
[lyx.git] / src / insets / inset.h
index 8acdb59699fb9b5586a3e1937d396b064065a748..5e8cd824bebe4164aba96be15b437dad298c9b1a 100644 (file)
@@ -9,31 +9,29 @@
  * \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 INSETOLD_H
 #define INSETOLD_H
 
-#include "LColor.h"
 #include "insetbase.h"
 #include "dimension.h"
-#include "support/types.h"
+#include "ParagraphList_fwd.h"
 
-#include <vector>
 
-class LyXFont;
 class Buffer;
-class Painter;
+class LColor_color;
+class FuncRequest;
 class LatexRunParams;
-class LyXText;
+class LyXCursor;
+class LyXFont;
 class LyXLex;
+class LyXText;
+class Painter;
 class Paragraph;
-class LyXCursor;
-class FuncRequest;
-class WordLangTuple;
-class ParagraphList;
 class UpdatableInset;
+class WordLangTuple;
 
 namespace lyx {
 namespace graphics {
@@ -51,7 +49,7 @@ public:
            in a cleaner way. */
        enum Code {
                ///
-               NO_CODE,
+               NO_CODE, // 0
                ///
                TOC_CODE,  // do these insets really need a code? (ale)
                ///
@@ -59,9 +57,9 @@ public:
                ///
                MARK_CODE,
                ///
-               REF_CODE, // 5
+               REF_CODE,
                ///
-               URL_CODE,
+               URL_CODE, // 5
                ///
                HTMLURL_CODE,
                ///
@@ -69,9 +67,9 @@ public:
                ///
                ENDING_CODE,
                ///
-               LABEL_CODE, // 10
+               LABEL_CODE,
                ///
-               NOTE_CODE,
+               NOTE_CODE, // 10
                ///
                ACCENT_CODE,
                ///
@@ -79,9 +77,9 @@ public:
                ///
                INDEX_CODE,
                ///
-               INCLUDE_CODE, // 15
+               INCLUDE_CODE,
                ///
-               GRAPHICS_CODE,
+               GRAPHICS_CODE, // 15
                ///
                BIBITEM_CODE,
                ///
@@ -89,9 +87,9 @@ public:
                ///
                TEXT_CODE,
                ///
-               ERT_CODE, // 20
+               ERT_CODE,
                ///
-               FOOT_CODE,
+               FOOT_CODE, // 20
                ///
                MARGIN_CODE,
                ///
@@ -101,9 +99,9 @@ public:
                ///
                MINIPAGE_CODE,
                ///
-               SPACE_CODE,
+               SPACE_CODE, // 25
                ///
-               SPECIALCHAR_CODE, // 25
+               SPECIALCHAR_CODE,
                ///
                TABULAR_CODE,
                ///
@@ -125,13 +123,17 @@ public:
                ///
                INDEX_PRINT_CODE,
                ///
-               OPTARG_CODE,
+               OPTARG_CODE, // 35
                ///
                ENVIRONMENT_CODE,
                ///
                HFILL_CODE,
                ///
-               NEWLINE_CODE
+               NEWLINE_CODE,
+               ///
+               BRANCH_CODE,
+               ///
+               BOX_CODE
        };
 
        ///
@@ -150,9 +152,6 @@ public:
                HIGHLY_EDITABLE
        };
 
-       ///
-       typedef dispatch_result RESULT;
-
        ///
        InsetOld();
        ///
@@ -164,7 +163,7 @@ public:
        ///
        int width() const;
        /// what appears in the minibuffer when opening
-       virtual string const editMessage() const;
+       virtual std::string const editMessage() const;
        ///
        virtual EDITABLE editable() const;
        ///
@@ -176,19 +175,19 @@ public:
        /// wrapper around the above
        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;
+       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 &,
+       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;
+       virtual int docbook(Buffer const &, std::ostream &, bool) const = 0;
 
        /// returns LyX code associated with the inset. Used for TOC, ...)
        virtual InsetOld::Code lyxCode() const { return NO_CODE; }
@@ -196,30 +195,18 @@ public:
        /// 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(std::string const & s) { name_ = s; }
        ///
-       void setInsetName(string const & s) { name_ = s; }
-       ///
-       string const & getInsetName() const { return name_; }
+       std::string const & getInsetName() const { return name_; }
        ///
        void setOwner(UpdatableInset * inset) { owner_ = inset; }
        ///
        UpdatableInset * owner() const { return owner_; }
        ///
-       void parOwner(Paragraph * par) { par_owner_ = par; }
-       ///
-       Paragraph * parOwner() const { return par_owner_; }
+       void setBackgroundColor(LColor_color);
        ///
-       void setBackgroundColor(LColor::color);
-       ///
-       LColor::color backgroundColor() const;
+       LColor_color backgroundColor() const;
        ///
        int x() const { return top_x; }
        ///
@@ -232,8 +219,6 @@ public:
                                     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_)
@@ -312,15 +297,6 @@ public:
         *  defaults to empty.
         */
        virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
-
-       /** Find the PreviewLoader, add a LaTeX snippet to it and
-        *  start the loading process.
-        *
-        *  Most insets have no interest in this capability, so the method
-        *  defaults to empty.
-        */
-       virtual void generatePreview() const {}
-
 protected:
        ///
        mutable int top_x;
@@ -338,44 +314,38 @@ protected:
 private:
        ///
        UpdatableInset * owner_;
-       /// the paragraph in which this inset has been inserted
-       Paragraph * par_owner_;
        ///
-       string name_;
-       ///
-       LColor::color background_color_;
+       std::string name_;
+       /** We store the LColor::color value as an int to get LColor.h out
+        *  of the header file.
+        */
+       int background_color_;
 };
 
 
-inline
-bool InsetOld::insetAllowed(InsetOld * in) const
-{
-       return insetAllowed(in->lyxCode());
-}
+/** \c InsetOld_code is a wrapper for InsetOld::Code.
+ *  It can be forward-declared and passed as a function argument without
+ *  having to expose inset.h.
+ */
+class InsetOld_code {
+       InsetOld::Code val_;
+public:
+       InsetOld_code(InsetOld::Code val) : val_(val) {}
+       operator InsetOld::Code() const{ return val_; }
+};
 
 
-inline
-bool InsetOld::checkInsertChar(LyXFont &)
-{
-       return false;
-}
-
 /**
  * returns true if pointer argument is valid
  * and points to an editable inset
  */
-inline bool isEditableInset(InsetOld 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(InsetOld const * i)
-{
-       return i && i->editable() == InsetOld::HIGHLY_EDITABLE;
-}
+bool isHighlyEditableInset(InsetOld const * i);
 
 #endif