]> git.lyx.org Git - lyx.git/blobdiff - src/insets/Inset.h
Fix text frame drawing.
[lyx.git] / src / insets / Inset.h
index a326a49ed88f8d0c6caa7c437f0214c708f21db1..6b2b14a7310c12f99beecbb4fbfd210dfff44cb1 100644 (file)
@@ -5,8 +5,8 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author Jürgen Vigna
- * \author Lars Gullik Bjønnes
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  * \author Matthias Ettrich
  *
  * Full author contact details are available in file CREDITS.
 #ifndef INSETBASE_H
 #define INSETBASE_H
 
-#include "Changes.h"
 #include "Dimension.h"
 
 #include "support/docstream.h"
 
-#include <boost/signal.hpp>
-
 #include <memory>
 #include <vector>
 
 namespace lyx {
 
+class BiblioInfo;
 class Buffer;
 class BufferParams;
 class BufferView;
+class Change;
+class Color_color;
+class Cursor;
 class CursorSlice;
 class FuncRequest;
 class FuncStatus;
+class InsetIterator;
+class InsetLayout;
 class InsetMath;
 class InsetText;
 class LaTeXFeatures;
-class Color_color;
-class Cursor;
 class Lexer;
-class Text;
+class MathAtom;
 class MetricsInfo;
-class Dimension;
-class PainterInfo;
 class OutputParams;
+class PainterInfo;
+class Paragraph;
+class ParConstIterator;
+class ParIterator;
+class Text;
 class TocList;
+class EmbeddedFiles;
 
 
 namespace graphics { class PreviewLoader; }
@@ -56,7 +61,7 @@ namespace graphics { class PreviewLoader; }
 // everything storing large quantities of insets. Mathed e.g. would
 // suffer.
 
-class Inset : public boost::noncopyable {
+class Inset {
 public:
        ///
        typedef ptrdiff_t  difference_type;
@@ -72,15 +77,17 @@ public:
        typedef size_t     col_type;
 
        /// virtual base class destructor
-       virtual ~Inset() { destroyed();}
-       /// replicate ourselves
-       std::auto_ptr<Inset> clone() const;
+       virtual ~Inset() {}
 
        /// identification as math inset
        virtual InsetMath * asInsetMath() { return 0; }
        /// true for 'math' math inset, but not for e.g. mbox
        virtual bool inMathed() const { return false; }
-
+       /// is this inset based on the TextInset class?
+       virtual InsetText * asTextInset() { return 0; }
+       /// is this inset based on the TextInset class?
+       virtual InsetText const * asTextInset() const { return 0; }
+       
        /// the real dispatcher
        void dispatch(Cursor & cur, FuncRequest & cmd);
        /**
@@ -146,6 +153,7 @@ public:
                CursorSlice const & sl, bool boundary, int & x, int & y) const;
 
        /// is this an inset that can be moved into?
+       /// FIXME: merge with editable()
        virtual bool isActive() const { return nargs() > 0; }
        /// Where should we go when we press the up or down cursor key?
        virtual bool idxUpDown(Cursor & cur, bool up) const;
@@ -194,6 +202,12 @@ public:
        /// is called when the mouse enter or leave this inset
        /// return true if this inset needs repaint
        virtual bool setMouseHover(bool) { return false; }
+       /// return true if this inset is hovered (under mouse)
+       /// This is by now only used by mathed to draw corners 
+       /// (Inset::drawMarkers() and Inset::drawMarkers2()).
+       /// Other insets do not have to redefine this function to 
+       /// return the correct status of mouseHovered.
+       virtual bool mouseHovered() const { return false; }
 
        /// request "external features"
        virtual void validate(LaTeXFeatures &) const {}
@@ -214,10 +228,10 @@ public:
        /// return the number of characters; in case of multiple lines of
        /// output, add PLAINTEXT_NEWLINE to the number of chars in the last line
        virtual int plaintext(Buffer const &, odocstream &,
-                             OutputParams const &) const = 0;
+                             OutputParams const &) const = 0;
        /// docbook output
        virtual int docbook(Buffer const &, odocstream & os,
-                           OutputParams const &) const;
+                           OutputParams const &) const;
        /// the string that is passed to the TOC
        virtual void textString(Buffer const &, odocstream &) const {}
 
@@ -244,8 +258,6 @@ public:
        virtual bool descendable() const { return false; }
        /// does this contain text that can be change track marked in DVI?
        virtual bool canTrackChanges() const { return false; }
-       /// is this inset based on the TextInset class?
-       virtual InsetText const * asTextInset() const { return 0; }
        /// return true if the inset should be removed automatically
        virtual bool autoDelete() const;
 
@@ -370,6 +382,8 @@ public:
 
        ///
        virtual docstring name() const { return from_ascii("unknown"); }
+       ///
+       virtual InsetLayout const & getLayout(BufferParams const & bp) const;
        /// used to toggle insets
        /// is the inset open?
        /// should this inset be handled like a normal charater
@@ -386,7 +400,7 @@ public:
                AlignCenter,
                AlignRight
        };
-       
+
        /// should we have a non-filled line before this inset?
        virtual DisplayType display() const { return Inline; }
        /// should we break lines after this inset?
@@ -423,7 +437,17 @@ public:
         */
        virtual void addPreview(graphics::PreviewLoader &) const {}
        /// Add an entry to the TocList
-       virtual void addToToc(TocList &, Buffer const &) const {}
+       /// pit is the ParConstIterator of the paragraph containing the inset
+       virtual void addToToc(TocList &, Buffer const &, ParConstIterator const &) const {}
+       /// report files that can be embedded with the lyx file
+       virtual void registerEmbeddedFiles(Buffer const &, EmbeddedFiles &,
+                       ParConstIterator const &) const {};
+       /// Fill keys with BibTeX information
+       virtual void fillWithBibKeys(Buffer const &,
+               BiblioInfo &, InsetIterator const &) const { return; }
+       /// Update the counters of this inset and of its contents
+       virtual void updateLabels(Buffer const &, ParIterator const &) {}
+
 
 public:
        /// returns LyX code associated with the inset. Used for TOC, ...)
@@ -452,6 +476,8 @@ public:
        /// reject the changes within the inset
        virtual void rejectChanges(BufferParams const &) {};
 
+       /// FIXME: move dim_ out of Inset!
+       Dimension const & dimension() { return dim_; }
        /// inset width.
        int width() const { return dim_.wid; }
        /// inset ascent.
@@ -461,13 +487,10 @@ public:
        ///
        int scroll() const { return 0; }
        ///
-       void setBackgroundColor(Color_color);
-       ///
-       Color_color backgroundColor() const;
+       virtual Color_color backgroundColor() const;
        ///
        enum CollapseStatus {
                Collapsed,
-               Inlined,
                Open
        };
        ///
@@ -475,14 +498,14 @@ public:
        //
        enum { TEXT_TO_INSET_OFFSET = 4 };
 
-       /// This signal is emitted when the inset is destroyed.
-       boost::signal<void()> destroyed;
-
 protected:
        Inset();
-       Inset(Inset const & i);
-       ///
-       Inset & operator=(Inset const &);
+
+       /// replicate ourselves
+       friend class Paragraph;
+       friend class MathAtom;
+       virtual Inset * clone() const = 0;
+
        /** The real dispatcher.
         *  Gets normally called from Cursor::dispatch(). Cursor::dispatch()
         *  assumes the common case of 'LFUN handled, need update'.
@@ -498,12 +521,6 @@ protected:
 
        /// Cached dimensions of the inset.
        mutable Dimension dim_;
-private:
-       virtual std::auto_ptr<Inset> doClone() const = 0;
-       /** We store the Color::color value as an int to get Color.h out
-        *  of the header file.
-        */
-       int background_color_;
 };
 
 
@@ -524,7 +541,6 @@ bool isHighlyEditableInset(Inset const * inset);
  *  It can be forward-declared and passed as a function argument without
  *  having to expose Inset.h.
  */
-
 class Inset_code {
        Inset::Code val_;
 public: