]> 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 8be193e00ccff5b7a4a34672766daa33b751c0d6..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,16 +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);
        ///
-       Dimension dimensionCollapsed() const;
-       ///
-       Box const & buttonDim() const;
-       ///
-       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);
        ///
@@ -166,21 +175,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 +196,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