]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCollapsable.h
fix layout of InsetBox and remove unused InsetCollapsable methods.
[lyx.git] / src / insets / InsetCollapsable.h
index 42160baaf8bd6edd52ef07970885834e5fb2f6c9..fb8e175857b3decb140a40baf690801b459ac9cb 100644 (file)
 
 #include "Inset.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; }
 
@@ -36,25 +38,24 @@ 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 = Open);
+       InsetCollapsable(BufferParams const &, CollapseStatus status = Inset::Open);
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
+       
+       InsetCollapsable * asInsetCollapsable() { return this; }
+       InsetCollapsable const * asInsetCollapsable() const { return this; }
+       docstring name() const { return from_ascii("Collapsable"); }
        ///
-       docstring insetName() const { return from_ascii("Collapsable"); }
+       void setLayout(BufferParams const &);
        ///
        void read(Buffer const &, Lexer &);
        ///
        void write(Buffer const &, std::ostream &) const;
        ///
-       bool metrics(MetricsInfo &, Dimension &) const;
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
-       ///
-       void drawSelection(PainterInfo & pi, int x, int y) const;
+
        /// return x,y of given position relative to the inset's baseline
        void cursorPos(BufferView const & bv, CursorSlice const & sl,
                bool boundary, int & x, int & y) const;
@@ -71,21 +72,73 @@ public:
        ///
        virtual void setButtonLabel() {}
        ///
-       void setLabelFont(Font & f);
-       ///
-       bool isOpen() const { return status_ == Open || status_ == Inlined; }
-       ///
-       bool inlined() const { return status_ == Inlined; }
+       bool isOpen() const { return geometry() != ButtonOnly; }
        ///
        CollapseStatus status() const;
+       /** Of the old CollapseStatus we only keep the values  
+        *  Open and Collapsed.
+        * We define a list of possible inset decoration
+        * styles, and a list of possible (concrete, visual)
+        * inset geometries. Relationships between them
+        * (geometries in body of table):
+        *
+        *               \       CollapseStatus:
+        *   Decoration:  \ Open                Collapsed
+        *   -------------+-------------------------------
+        *   Classic      | *) TopButton, <--x) ButtonOnly
+        *                | LeftButton
+        *   Minimalistic | ButtonOnly          NoButton
+        *   Conglomerate | SubLabel            Corners
+        *   ---------------------------------------------
+        *   *) toggled by openinlined_
+        *   x) toggled by autoOpen_
+        */
+
+       ///
+       enum Decoration {
+               Classic,
+               Minimalistic,
+               Conglomerate
+       };
+       /// Default looks
+       virtual Decoration decoration() const;
+       ///
+       enum Geometry {
+               TopButton,
+               ButtonOnly,
+               NoButton,
+               LeftButton,
+               SubLabel,
+               Corners
+       };
+       /// Returns the geometry based on CollapseStatus
+       /// (status_), autoOpen_ and openinlined_, and of
+       /// course decoration().
+       Geometry geometry() const;
        ///
        bool allowSpellCheck() const { return true; }
        ///
+       bool allowMultiPar() const;
+       ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
        void setStatus(Cursor & cur, CollapseStatus st);
        ///
        bool setMouseHover(bool mouse_hover);
+       ///
+       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; }
 
 protected:
        ///
@@ -99,13 +152,11 @@ protected:
        ///
        Inset * editXY(Cursor & cur, int x, int y);
        ///
-       void setInlined() { status_ = Inlined; }
-       ///
        docstring floatName(std::string const & type, BufferParams const &) const;
+       ///
+       virtual void resetParagraphsFont();
 
 protected:
-       ///
-       Font labelfont_;
        ///
        mutable Box button_dim;
        ///
@@ -113,7 +164,9 @@ protected:
        ///
        mutable int topbaseline;
        ///
-       mutable docstring label;
+       mutable InsetLayout layout_;
+       ///
+       CollapseStatus internalStatus() const { return status_; }
 private:
        ///
        mutable CollapseStatus status_;
@@ -121,8 +174,6 @@ private:
        mutable bool openinlined_;
        /// the inset will automatically open when the cursor is inside
        mutable bool autoOpen_;
-       ///
-       mutable Dimension textdim_;
        /// changes color when mouse enters/leaves this inset
        bool mouse_hover_;
 };