]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.h
Part of IU.
[lyx.git] / src / insets / insetcollapsable.h
index 4b89a1684ed646eca63a8d75e5751714437a947a..c237e73ced912a408a3a0ebe7f934f7b67637df8 100644 (file)
@@ -8,24 +8,22 @@
  * \author Jürgen Vigna
  * \author Lars Gullik Bjønnes
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef INSETCOLLAPSABLE_H
 #define INSETCOLLAPSABLE_H
 
-
 #include "inset.h"
 #include "insettext.h"
-#include "lyxfont.h"
-#include "LColor.h"
 
-#include <boost/weak_ptr.hpp>
+#include "box.h"
+#include "lyxfont.h"
 
 class Painter;
 class LyXText;
 class Paragraph;
-class LyXCursor;
+class CursorSlice;
 
 /** A collapsable text inset
 
@@ -36,217 +34,132 @@ public:
        static int const TEXT_TO_TOP_OFFSET = 2;
        ///
        static int const TEXT_TO_BOTTOM_OFFSET = 2;
-       /// inset is initially collapsed if bool = true
-       InsetCollapsable(BufferParams const &, bool = false);
-       ///
-       InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
        ///
-       void read(Buffer const *, LyXLex &);
+       enum CollapseStatus {
+               Open,
+               Collapsed,
+               Inlined
+       };
        ///
-       void write(Buffer const *, std::ostream &) const;
+       InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
        ///
-       int ascent(BufferView *, LyXFont const &) const;
+       InsetCollapsable(InsetCollapsable const & in);
        ///
-       int descent(BufferView *, LyXFont const &) const;
+       void read(Buffer const &, LyXLex &);
        ///
-       int width(BufferView *, LyXFont const &) const;
+       void write(Buffer const &, std::ostream &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &) const;
-       /// draw, either inlined (no button) or collapsed/open
-       void draw(BufferView * bv, LyXFont const & f,
-                 int baseline, float & x, bool inlined) const;
+       void metrics(MetricsInfo &, Dimension &) const;
        ///
-       void update(BufferView *, bool =false);
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
-       void edit(BufferView *, int, int, mouse_button::state);
+       bool hitButton(FuncRequest const &) const;
        ///
-       void edit(BufferView *, bool front = true);
+       std::string const getNewLabel(std::string const & l) const;
        ///
        EDITABLE editable() const;
+       /// can we go further down on mouse click?
+       bool descendable() const;
        ///
-       bool insertInset(BufferView *, Inset * inset);
-       ///
-       virtual bool insetAllowed(Inset::Code code) const {
-               return inset.insetAllowed(code);
-       }
+       bool insetAllowed(InsetOld::Code code) const;
        ///
        bool isTextInset() const { return true; }
        ///
-       void insetUnlock(BufferView *);
-       ///
-       bool needFullRow() const { return isOpen(); }
-       ///
-       bool lockInsetInInset(BufferView *, UpdatableInset *);
-       ///
-       bool unlockInsetInInset(BufferView *, UpdatableInset *,
-                               bool lr = false);
+       int latex(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       bool updateInsetInInset(BufferView *, Inset *);
+       int plaintext(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       int insetInInsetY() const;
+       int linuxdoc(Buffer const &, std::ostream &,
+                    OutputParams const &) const;
        ///
-       RESULT localDispatch(FuncRequest const &);
-       ///
-       int latex(Buffer const *, std::ostream &,
-                 bool fragile, bool free_spc) const;
-       ///
-       int ascii(Buffer const *, std::ostream &, int) const;
-       ///
-       int linuxdoc(Buffer const *, std::ostream &) const;
-       ///
-       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+       int docbook(Buffer const &, std::ostream &,
+                   OutputParams const & runparams) const;
        ///
        void validate(LaTeXFeatures & features) const;
+       /// get the screen x,y of the cursor
+       void getCursorPos(int cell, int & x, int & y) const;
        ///
-       void getCursorPos(BufferView *, int & x, int & y) const;
-       ///
-       void toggleInsetCursor(BufferView *);
-       ///
-       void showInsetCursor(BufferView *, bool show = true);
-       ///
-       void hideInsetCursor(BufferView *);
+       void setLabel(std::string const & l);
        ///
-       void fitInsetCursor(BufferView * bv) const {
-               inset.fitInsetCursor(bv);
-       }
-       UpdatableInset * getLockingInset() const;
-       ///
-       UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
-       ///
-       void setFont(BufferView *, LyXFont const &, bool toggleall = false,
-                bool selectall = false);
-       ///
-       void setLabel(string const & l) const;
-       ///
-       void setLabelFont(LyXFont & f) { labelfont = f; }
-#if 0
-       ///
-       void setAutoCollapse(bool f) { autocollapse = f; }
-#endif
-#if 0
-       ///
-       int getMaxWidth(BufferView *, UpdatableInset const *) const;
-#endif
-       ///
-       LyXText * getLyXText(BufferView const *, bool const recursive) const;
-       ///
-       void deleteLyXText(BufferView *, bool recursive=true) const;
-       ///
-       void resizeLyXText(BufferView *, bool force = false) const;
-       ///
-       std::vector<string> const getLabelList() const;
-       ///
-       bool nodraw() const;
+       virtual void setButtonLabel() {};
+       ///
+       void setLabelFont(LyXFont & f);
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &, std::vector<std::string> & list) const;
        ///
        int scroll(bool recursive=true) const;
        ///
-       void scroll(BufferView *bv, float sx) const {
-               UpdatableInset::scroll(bv, sx);
-       }
-       ///
-       void scroll(BufferView *bv, int offset) const {
-               UpdatableInset::scroll(bv, offset);
-       }
+       void scroll(BufferView & bv, float sx) const;
        ///
-       Inset * getInsetFromID(int id) const;
+       void scroll(BufferView & bv, int offset) const;
        ///
-       Paragraph * firstParagraph() const;
+       int numParagraphs() const;
        ///
-       Paragraph * getFirstParagraph(int) const;
+       LyXText * getText(int) const;
        ///
-       LyXCursor const & cursor(BufferView *) const;
+       bool isOpen() const { return status_ == Open || status_ == Inlined; }
        ///
-       bool isOpen() const { return !collapsed_; }
+       bool inlined() const { return status_ == Inlined; }
        ///
-       void open(BufferView *);
+       CollapseStatus status() const { return status_; }
        ///
-       void close(BufferView *) const;
+       void open();
        ///
-       bool allowSpellcheck() const { return inset.allowSpellcheck(); }
+       void close();
        ///
-       WordLangTuple const
-       selectNextWordToSpellcheck(BufferView *, float &) const;
-       ///
-       void selectSelectedWord(BufferView * bv) {
-               inset.selectSelectedWord(bv);
-       }
-       ///
-       void toggleSelection(BufferView * bv, bool kill_selection) {
-               inset.toggleSelection(bv, kill_selection);
-       }
        void markErased();
-       bool nextChange(BufferView * bv, lyx::pos_type & length);
-
        ///
-       bool searchForward(BufferView * bv, string const & str,
-                          bool = true, bool = false);
-       bool searchBackward(BufferView * bv, string const & str,
-                           bool = true, bool = false);
-
-       ///
-       void addPreview(grfx::PreviewLoader &) const;
-
-protected:
+       void addPreview(lyx::graphics::PreviewLoader &) const;
        ///
-       virtual void cache(BufferView *) const;
+       void setBackgroundColor(LColor_color);
        ///
-       virtual BufferView * view() const;
+       void setStatus(CollapseStatus st);
 
+protected:
        ///
-       int ascent_collapsed() const;
+       virtual
+       DispatchResult
+       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
-       int descent_collapsed() const;
+       void dimension_collapsed(Dimension &) const;
        ///
-       int width_collapsed() const;
+       int height_collapsed() const;
        ///
-       void draw_collapsed(Painter & pain, int , float &) const;
+       void draw_collapsed(PainterInfo & pi, int x, int y) const;
        ///
        int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
-
-       ///
-       mutable bool collapsed_;
-       ///
-       LColor::color framecolor;
-       ///
-       LyXFont labelfont;
-public:
-       ///
-       mutable InsetText inset;
-protected:
        ///
-       mutable int button_length;
+       Box const & buttonDim() const;
        ///
-       mutable int button_top_y;
+       void edit(LCursor & cur, bool left);
        ///
-       mutable int button_bottom_y;
-       ///
-       mutable int topx;
-       mutable int topbaseline;
+       void edit(LCursor & cur, int x, int y);
 
 private:
        ///
-       void lfunMousePress(FuncRequest const &);
-       ///
-       bool lfunMouseRelease(FuncRequest const &);
+       DispatchResult lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
        ///
-       void lfunMouseMotion(FuncRequest const &);
+       FuncRequest adjustCommand(FuncRequest const &);
 
+public:
        ///
-       mutable string label;
-#if 0
+       mutable InsetText inset;
+private:
        ///
-       bool autocollapse;
-#endif
+       mutable CollapseStatus status_;
+protected:
        ///
-       mutable int oldWidth;
+       LyXFont labelfont_;
        ///
-       bool in_update;
+       mutable Box button_dim;
        ///
-       mutable bool first_after_edit;
+       mutable int topx;
+       ///
+       mutable int topbaseline;
        ///
-       mutable boost::weak_ptr<BufferView> view_;
+       mutable std::string label;
 };
 
 #endif