]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCollapsable.h
Fix bug 4037 and related problems. The patch has been cleaned up a bit
[lyx.git] / src / insets / InsetCollapsable.h
index 941d54d2d086535e7a9ac7915e23d77ec7197174..71dba1731524fd9987c0143da0bafa7750a5a3d1 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,26 @@ 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);
+       ///
+       virtual bool useEmptyLayout() { return true; }
        ///
        void read(Buffer const &, Lexer &);
        ///
@@ -76,6 +84,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() {}
@@ -95,7 +105,7 @@ public:
         *   -------------+-------------------------------
         *   Classic      | *) TopButton, <--x) ButtonOnly
         *                | LeftButton
-        *   Minimalistic | ButtonOnly          NoButton
+        *   Minimalistic | NoButton            ButtonOnly
         *   Conglomerate | SubLabel            Corners
         *   ---------------------------------------------
         *   *) toggled by openinlined_
@@ -149,12 +159,15 @@ public:
        virtual bool allowEmpty() const { return layout_->keepempty; }
        /// Force inset into LTR environment if surroundings are RTL?
        virtual bool forceLTR() const { return layout_->forceltr; }
+       ///
+       virtual bool useEmptyLayout() const { return true; }
 
 protected:
        ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
-       void edit(Cursor & cur, bool left);
+       void edit(Cursor & cur, bool front, 
+               EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
        ///
        Inset * editXY(Cursor & cur, int x, int y);
        ///
@@ -162,10 +175,11 @@ protected:
        ///
        virtual void resetParagraphsFont();
 
-protected:
-       ///
-       InsetLayout const * layout_;
 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_;
        ///
        Dimension dimensionCollapsed() const;
        ///