]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetCollapsable.h
* Lazy MathData to avoid unneeded interpretation of macro definitions
[features.git] / src / insets / InsetCollapsable.h
index 71264ade2ba59bf91281a4389df899575ef117a3..1b6cbc3c45edf1ea30dba459d737ba19781795ef 100644 (file)
 #define INSETCOLLAPSABLE_H
 
 #include "Inset.h"
+#include "InsetLayout.h"
 #include "InsetText.h"
-#include "TextClass.h"
 
 #include "Box.h"
-#include "Font.h"
 
 #include <string>
 
 namespace lyx {
 
-class Text;
-class Paragraph;
 class CursorSlice;
+class FontInfo;
 class InsetLayout;
+class Paragraph;
+class Text;
 
 namespace frontend { class Painter; }
 
@@ -38,17 +38,23 @@ namespace frontend { class Painter; }
 class InsetCollapsable : public InsetText {
 public:
        ///
-       static int const TEXT_TO_TOP_OFFSET = 2;
-       ///
-       static int const TEXT_TO_BOTTOM_OFFSET = 2;
-       ///
-       InsetCollapsable(BufferParams const &, CollapseStatus status = Inset::Open);
+       InsetCollapsable(
+               BufferParams const &,
+               CollapseStatus status = Inset::Open,
+               InsetLayout const * il = 0
+               );
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
-       ///
+       
+       InsetCollapsable * asInsetCollapsable() { return this; }
+       InsetCollapsable const * asInsetCollapsable() const { return this; }
        docstring name() const { return from_ascii("Collapsable"); }
+       InsetLayout const & getLayout(BufferParams const &) const
+       { return *layout_; } 
        ///
        void setLayout(BufferParams const &);
+       /// (Re-)set the character style parameters from \p il
+       void setLayout(InsetLayout const & il);
        ///
        void read(Buffer const &, Lexer &);
        ///
@@ -70,12 +76,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(Font const & f);
-       ///
        bool isOpen() const { return geometry() != ButtonOnly; }
        ///
        CollapseStatus status() const;
@@ -130,39 +136,44 @@ public:
        ///
        bool setMouseHover(bool mouse_hover);
        ///
-       virtual Color_color backgroundColor() const {return layout_.bgcolor; }
+       virtual ColorCode backgroundColor() const {return layout_->bgcolor; }
 
        int latex(Buffer const &, odocstream &,
                  OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
+       ///
+       virtual InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
+
+       /// Allow multiple blanks
+       virtual bool isFreeSpacing() const { return layout_->freespacing; }
+       /// Don't eliminate empty paragraphs
+       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);
        ///
        docstring floatName(std::string const & type, BufferParams const &) const;
+       ///
+       virtual void resetParagraphsFont();
 
 protected:
        ///
-       mutable Box button_dim;
-       ///
-       mutable int topx;
+       InsetLayout const * layout_;
+private:
        ///
-       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
@@ -173,9 +184,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