]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCollapsable.h
* Do not keep pointers to data structures around if you don't know
[lyx.git] / src / insets / InsetCollapsable.h
index 8be193e00ccff5b7a4a34672766daa33b751c0d6..c507cda475f0030d862d9c877b6be800982ad826 100644 (file)
 #define INSETCOLLAPSABLE_H
 
 #include "Inset.h"
+#include "InsetLayout.h"
 #include "InsetText.h"
-#include "TextClass.h"
 
 #include "Box.h"
+#include "TextClass.h"
+#include "TextClassPtr.h"
 
 #include <string>
 
@@ -41,20 +43,24 @@ public:
        InsetCollapsable(
                BufferParams const &,
                CollapseStatus status = Inset::Open,
-               InsetLayout const * il = 0
+               TextClassPtr tc = TextClassPtr((TextClass *)0)
                );
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
        
        InsetCollapsable * asInsetCollapsable() { return this; }
        InsetCollapsable const * asInsetCollapsable() const { return this; }
+       docstring toolTip(BufferView const & bv, int x, int y) const;
        docstring name() const { return from_ascii("Collapsable"); }
        InsetLayout const & getLayout(BufferParams const &) const
        { return *layout_; } 
+       InsetLayout const & getLayout() const
+       { return *layout_; } 
        ///
        void setLayout(BufferParams const &);
-       /// (Re-)set the character style parameters from \p il
-       void setLayout(InsetLayout const & il);
+       /// (Re-)set the character style parameters from \p tc according
+       /// to name()
+       void setLayout(TextClassPtr tc);
        ///
        void read(Buffer const &, Lexer &);
        ///
@@ -76,6 +82,8 @@ public:
        /// can we go further down on mouse click?
        bool descendable() const;
        ///
+       bool isMacroScope(Buffer const & buf) const;
+       ///
        void setLabel(docstring const & l);
        ///
        virtual void setButtonLabel() {}
@@ -154,10 +162,6 @@ protected:
        ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
-       Dimension dimensionCollapsed() const;
-       ///
-       Box const & buttonDim() const;
-       ///
        void edit(Cursor & cur, bool left);
        ///
        Inset * editXY(Cursor & cur, int x, int y);
@@ -166,21 +170,18 @@ protected:
        ///
        virtual void resetParagraphsFont();
 
-protected:
-       ///
-       mutable Box button_dim;
-       ///
-       mutable int topx;
-       ///
-       mutable int topbaseline;
-       ///
+private:
+       /// text class to keep the InsetLayout above in memory
+       TextClassPtr textClass_;
+       /// cache for the layout_. Make sure it is in sync with the text class!
        InsetLayout const * layout_;
        ///
-       CollapseStatus internalStatus() const { return status_; }
-private:
+       Dimension dimensionCollapsed() const;
        ///
        docstring labelstring_;
        ///
+       mutable Box button_dim;
+       ///
        mutable CollapseStatus status_;
        /// a substatus of the Open status, determined automatically in metrics
        mutable bool openinlined_;
@@ -190,9 +191,6 @@ private:
        bool mouse_hover_;
 };
 
-// A helper function that pushes the cursor out of the inset.
-void leaveInset(Cursor & cur, Inset const & in);
-
 } // namespace lyx
 
 #endif