]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetcollapsable.h
fix #832
[lyx.git] / src / insets / insetcollapsable.h
index 8ae7d2a593f52c327621516b0530fe389892969c..577111f21a285c4b0d9eb41e0b44c3629b6fc7fb 100644 (file)
@@ -1,27 +1,27 @@
 // -*- C++ -*-
-/* This file is part of
- * ======================================================
+/**
+ * \file insetcollapsable.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  *
- *           Copyright 2000-2001 The LyX Team.
- *
- *======================================================
+ * Full author contact details are available in file CREDITS
  */
 
-
 #ifndef INSETCOLLAPSABLE_H
 #define INSETCOLLAPSABLE_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
 #include "inset.h"
 #include "insettext.h"
 #include "lyxfont.h"
+#include "funcrequest.h" // for adjustCommand
 #include "LColor.h"
 
+#include <boost/weak_ptr.hpp>
+
 class Painter;
 class LyXText;
 class Paragraph;
@@ -32,11 +32,6 @@ class LyXCursor;
 */
 class InsetCollapsable : public UpdatableInset {
 public:
-       ///
-       enum UpdateCodes {
-               NONE = 0,
-               FULL
-       };
        ///
        static int const TEXT_TO_TOP_OFFSET = 2;
        ///
@@ -56,13 +51,12 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
-       ///
-       void update(BufferView *, LyXFont const &, bool =false);
+       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 edit(BufferView *, int, int, mouse_button::state);
-       ///
-       void edit(BufferView *, bool front = true);
+       void update(BufferView *, bool =false);
        ///
        EDITABLE editable() const;
        ///
@@ -74,8 +68,6 @@ public:
        ///
        bool isTextInset() const { return true; }
        ///
-       bool doClearArea() const;
-       ///
        void insetUnlock(BufferView *);
        ///
        bool needFullRow() const { return isOpen(); }
@@ -89,14 +81,7 @@ public:
        ///
        int insetInInsetY() const;
        ///
-       bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
-       ///
-       void insetButtonPress(BufferView *, int, int, mouse_button::state);
-       ///
-       void insetMotionNotify(BufferView *, int, int, mouse_button::state);
-       ///
-       UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
-                                            string const &);
+       RESULT localDispatch(FuncRequest const &);
        ///
        int latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
@@ -108,14 +93,10 @@ public:
        int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures & features) const;
-       ///
+       /// FIXME, document
        void getCursorPos(BufferView *, int & x, int & y) const;
-       ///
-       void toggleInsetCursor(BufferView *);
-       ///
-       void showInsetCursor(BufferView *, bool show = true);
-       ///
-       void hideInsetCursor(BufferView *);
+       /// Get the absolute document x,y of the cursor
+       virtual void getCursor(BufferView &, int &, int &) const;
        ///
        void fitInsetCursor(BufferView * bv) const {
                inset.fitInsetCursor(bv);
@@ -133,10 +114,6 @@ public:
 #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;
@@ -159,13 +136,9 @@ public:
                UpdatableInset::scroll(bv, offset);
        }
        ///
-       Paragraph * getParFromID(int id) const;
-       ///
        Inset * getInsetFromID(int id) const;
        ///
-       Paragraph * firstParagraph() const;
-       ///
-       Paragraph * getFirstParagraph(int) const;
+       ParagraphList * getParagraphs(int) const;
        ///
        LyXCursor const & cursor(BufferView *) const;
        ///
@@ -175,16 +148,23 @@ public:
        ///
        void close(BufferView *) const;
        ///
-       bool allowSpellcheck() { return inset.allowSpellcheck(); }
-
-       WordLangTuple selectNextWordToSpellcheck(BufferView *, float &) const;
-
+       bool allowSpellcheck() const { return inset.allowSpellcheck(); }
+       ///
+       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);
@@ -195,6 +175,11 @@ public:
        void addPreview(grfx::PreviewLoader &) const;
 
 protected:
+       ///
+       virtual void cache(BufferView *) const;
+       ///
+       virtual BufferView * view() const;
+
        ///
        int ascent_collapsed() const;
        ///
@@ -225,9 +210,13 @@ protected:
        ///
        mutable int topx;
        mutable int topbaseline;
-       mutable UpdateCodes need_update;
 
 private:
+       ///
+       void lfunMouseRelease(FuncRequest const &);
+       ///
+       FuncRequest adjustCommand(FuncRequest const &);
+
        ///
        mutable string label;
 #if 0
@@ -240,6 +229,8 @@ private:
        bool in_update;
        ///
        mutable bool first_after_edit;
+       ///
+       mutable boost::weak_ptr<BufferView> view_;
 };
 
 #endif