]> 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 6ac7ca4bcf60afc70b9174a98495871bca5c5236..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>
 
@@ -38,13 +40,27 @@ namespace frontend { class Painter; }
 class InsetCollapsable : public InsetText {
 public:
        ///
-       InsetCollapsable(BufferParams const &, CollapseStatus status = Inset::Open);
+       InsetCollapsable(
+               BufferParams const &,
+               CollapseStatus status = Inset::Open,
+               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 tc according
+       /// to name()
+       void setLayout(TextClassPtr tc);
        ///
        void read(Buffer const &, Lexer &);
        ///
@@ -66,12 +82,12 @@ 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() {}
        ///
-       void setLabelFont(FontInfo const & f);
-       ///
        bool isOpen() const { return geometry() != ButtonOnly; }
        ///
        CollapseStatus status() const;
@@ -126,7 +142,7 @@ public:
        ///
        bool setMouseHover(bool mouse_hover);
        ///
-       virtual ColorCode backgroundColor() const {return layout_.bgcolor; }
+       virtual ColorCode backgroundColor() const {return layout_->bgcolor; }
 
        int latex(Buffer const &, odocstream &,
                  OutputParams const &) const;
@@ -136,18 +152,16 @@ public:
        virtual InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
 
        /// Allow multiple blanks
-       virtual bool isFreeSpacing() const { return layout_.freespacing; }
+       virtual bool isFreeSpacing() const { return layout_->freespacing; }
        /// Don't eliminate empty paragraphs
-       virtual bool allowEmpty() const { return layout_.keepempty; }
+       virtual bool allowEmpty() const { return layout_->keepempty; }
+       /// Force inset into LTR environment if surroundings are RTL?
+       virtual bool forceLTR() const { return layout_->forceltr; }
 
 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);
@@ -155,21 +169,18 @@ protected:
        docstring floatName(std::string const & type, BufferParams const &) const;
        ///
        virtual void resetParagraphsFont();
-       ///
-       virtual void getDrawFont(FontInfo &) const;
 
-protected:
-       ///
-       mutable Box button_dim;
-       ///
-       mutable int topx;
+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_;
        ///
-       mutable int topbaseline;
+       Dimension dimensionCollapsed() const;
        ///
-       mutable InsetLayout layout_;
+       docstring labelstring_;
        ///
-       CollapseStatus internalStatus() const { return status_; }
-private:
+       mutable Box button_dim;
        ///
        mutable CollapseStatus status_;
        /// a substatus of the Open status, determined automatically in metrics
@@ -180,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