]> git.lyx.org Git - features.git/commitdiff
split inset -> inset + updatableinset
authorAndré Pönitz <poenitz@gmx.net>
Thu, 20 Feb 2003 17:39:48 +0000 (17:39 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 20 Feb 2003 17:39:48 +0000 (17:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6212 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/InsetList.C
src/bufferview_funcs.C
src/insets/Makefile.am
src/insets/inset.C
src/insets/inset.h
src/insets/insettext.h
src/insets/updatableinset.C [new file with mode: 0644]
src/insets/updatableinset.h [new file with mode: 0644]
src/mathed/formulabase.h
src/undo_funcs.C

index e654a63eaca2da582191f011037864509641021e..8459e042f4e45cdf30f2871b4b4754e1d697dd6e 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "insets/insetcommand.h" // ChangeRefs
 #include "insets/inseterror.h"
+#include "insets/updatableinset.h"
 
 #include "support/FileInfo.h"
 #include "support/filetools.h"
index a4f03528254320daabb7af333ba86461ecf31b75..dab5287baf2ead8e0133ea38dbd35c213987b98d 100644 (file)
@@ -3,7 +3,7 @@
 #include "InsetList.h"
 #include "debug.h"
 
-#include "insets/inset.h"
+#include "insets/updatableinset.h"
 
 #include <algorithm>
 
@@ -19,7 +19,8 @@ struct MatchIt {
        /// used by lower_bound and upper_bound
        inline
        int operator()(InsetList::InsetTable const & a,
-                      InsetList::InsetTable const & b) const {
+                      InsetList::InsetTable const & b) const
+       {
                return a.pos < b.pos;
        }
 };
index 249acf9e49e333ce08c4235a1dc2c5b77147e7d4..58ed8fdaf12a05c9201d2f243fcdc6b9f049eb1a 100644 (file)
@@ -11,7 +11,6 @@
 #include <config.h>
 
 #include "bufferview_funcs.h"
-#include "frontends/LyXView.h"
 #include "BufferView.h"
 #include "paragraph.h"
 #include "lyxfont.h"
 #include "author.h"
 #include "changes.h"
 
+#include "frontends/LyXView.h"
 #include "frontends/Alert.h"
 
 #include "support/lstrings.h"
 
+#include "insets/updatableinset.h"
+
 #include "BoostFormat.h"
 
 void emph(BufferView * bv)
@@ -143,11 +145,11 @@ void fontSize(BufferView * bv, string const & size)
 // Returns the current font and depth as a message.
 string const currentState(BufferView * bv)
 {
-       ostringstream state;
-
        if (!bv->available())
                return string();
 
+       ostringstream state;
+
        LyXText * text = bv->getLyXText();
        Buffer * buffer = bv->buffer();
        LyXCursor const & c(text->cursor);
index 562e147f9939a9e24b34c66d384950ba7f3c769a..071957cc6086afd8c4a51a66344db7bda76a5c1c 100644 (file)
@@ -84,7 +84,9 @@ libinsets_la_SOURCES = \
        insettoc.C \
        insettoc.h \
        inseturl.C \
-       inseturl.h
+       inseturl.h \
+       updatableinset.C \
+       updatableinset.h
 #      insetlist.C \
 #      insetlist.h \
 #      insetsection.h \
index b62738a6092eafc798dd1607c9fea1bacf0bc8bb..1025cc7bf1a45d89eca0179b6b7e24ef3532ef48 100644 (file)
 #include "inset.h"
 
 #include "BufferView.h"
-#include "debug.h"
 #include "funcrequest.h"
 #include "gettext.h"
-#include "lyxcursor.h"
 #include "lyxfont.h"
 #include "lyxtext.h"
-#include "WordLangTuple.h"
 
 #include "frontends/Painter.h"
 #include "frontends/mouse_state.h"
 
-#include "support/lstrings.h"
 #include "support/lstrings.h"
 
 using std::endl;
@@ -161,214 +157,3 @@ int Inset::latexTextWidth(BufferView * bv) const
        return bv->workWidth();
 }
 
-// some stuff for inset locking
-
-UpdatableInset::UpdatableInset()
-       : Inset(), cursor_visible_(false), block_drawing_(false)
-{}
-
-
-UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
-       : Inset(in, same_id), cursor_visible_(false), block_drawing_(false)
-{}
-
-
-void UpdatableInset::insetUnlock(BufferView *)
-{
-       lyxerr[Debug::INFO] << "Inset Unlock" << endl;
-}
-
-
-// An updatable inset is highly editable by definition
-Inset::EDITABLE UpdatableInset::editable() const
-{
-       return HIGHLY_EDITABLE;
-}
-
-
-void UpdatableInset::toggleInsetCursor(BufferView *)
-{}
-
-
-void UpdatableInset::showInsetCursor(BufferView *, bool)
-{}
-
-
-void UpdatableInset::hideInsetCursor(BufferView *)
-{}
-
-
-void UpdatableInset::fitInsetCursor(BufferView *) const
-{}
-
-
-void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
-{}
-
-
-void UpdatableInset::edit(BufferView *, bool)
-{}
-
-
-void UpdatableInset::draw(BufferView *, LyXFont const &,
-                         int /* baseline */, float & x,
-                         bool/*cleared*/) const
-{
-       x += float(scx);
-       // ATTENTION: don't do the following here!!!
-       //    top_x = int(x);
-       //    top_baseline = baseline;
-}
-
-
-void UpdatableInset::scroll(BufferView * bv, float s) const
-{
-       LyXFont font;
-
-       if (!s) {
-               scx = 0;
-               return;
-       }
-
-       int const workW = bv->workWidth();
-       int const tmp_top_x = top_x - scx;
-
-       if (tmp_top_x > 0 &&
-           (tmp_top_x + width(bv, font)) < workW)
-               return;
-       if (s > 0 && top_x > 0)
-               return;
-
-       // int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
-       //int const save_scx = scx;
-
-       scx = int(s * workW / 2);
-       // if (!display())
-       // scx += 20;
-
-       if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
-               scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
-       }
-
-       // bv->updateInset(const_cast<UpdatableInset *>(this), false);
-}
-
-void UpdatableInset::scroll(BufferView * bv, int offset) const
-{
-       if (offset > 0) {
-               if (!scx && top_x >= 20)
-                       return;
-               if ((top_x + offset) > 20)
-                       scx = 0;
-               // scx += offset - (top_x - scx + offset - 20);
-               else
-                       scx += offset;
-       } else {
-               LyXFont const font;
-               if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20))
-                       return;
-               if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) {
-                       scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
-               } else {
-                       scx += offset;
-               }
-       }
-//     bv->updateInset(const_cast<UpdatableInset *>(this), false);
-}
-
-
-///  An updatable inset could handle lyx editing commands
-Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
-{
-       if (ev.action == LFUN_MOUSE_RELEASE)
-               return (editable() == IS_EDITABLE) ? DISPATCHED : UNDISPATCHED;
-
-       if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
-               if (ev.argument.find('.') != ev.argument.npos) {
-                       float const xx = static_cast<float>(strToDbl(ev.argument));
-                       scroll(ev.view(), xx);
-               } else {
-                       int const xx = strToInt(ev.argument);
-                       scroll(ev.view(), xx);
-               }
-               ev.view()->updateInset(this, false);
-
-               return DISPATCHED;
-       }
-       return UNDISPATCHED;
-}
-
-
-int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
-{
-       int w;
-       if (owner()) {
-               w = static_cast<UpdatableInset*>
-                       (owner())->getMaxWidth(bv, this);
-       } else {
-               w = bv->text->workWidth(bv, const_cast<UpdatableInset *>(this));
-       }
-       if (w < 0) {
-               return -1;
-       }
-       // check for margins left/right and extra right margin "const 5"
-       if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
-               w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
-       if (topx_set && owner()) {
-               w -= top_x;
-               w += owner()->x();
-       } else if (owner()) {
-               // this is needed as otherwise we might have a too large inset if
-               // its top_x afterwards changes to LeftMargin so we try to put at
-               // least the default margin as top_x
-               w -= 20;
-       }
-       if (w < 10) {
-               w = 10;
-       }
-       return w;
-}
-
-
-LyXCursor const & Inset::cursor(BufferView * bv) const
-{
-       if (owner())
-               return owner()->getLyXText(bv, false)->cursor;
-       return bv->text->cursor;
-}
-
-
-WordLangTuple const
-UpdatableInset::selectNextWordToSpellcheck(BufferView *bv, float & value) const
-{
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<UpdatableInset *>(this));
-       value = 0;
-       return WordLangTuple();
-}
-
-
-bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &)
-{
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<UpdatableInset *>(this));
-       return false;
-}
-
-bool UpdatableInset::searchForward(BufferView * bv, string const &,
-                                  bool, bool)
-{
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<UpdatableInset *>(this));
-       return false;
-}
-
-
-bool UpdatableInset::searchBackward(BufferView * bv, string const &,
-                                   bool, bool)
-{
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<UpdatableInset *>(this));
-       return false;
-}
index e2a01478d693c98b1f98a882696b96b578292990..8cc9fa5df85fcbbda214b11669ef22ebc118e0e3 100644 (file)
@@ -378,158 +378,6 @@ bool Inset::checkInsertChar(LyXFont &)
        return false;
 }
 
-//  Updatable Insets. These insets can be locked and receive
-//  directly user interaction. Currently used only for mathed.
-//  Note that all pure methods from Inset class are pure here too.
-//  [Alejandro 080596]
-
-/** Extracted from Matthias notes:
- *
- * An inset can simple call LockInset in it's edit call and *ONLY*
- * in it's edit call.
- *
- * Unlocking is either done by LyX or the inset itself with a
- * UnlockInset-call
- *
- * During the lock, all button and keyboard events will be modified
- * and send to the inset through the following inset-features. Note that
- * Inset::insetUnlock will be called from inside UnlockInset. It is meant
- * to contain the code for restoring the menus and things like this.
- *
- * If a inset wishes any redraw and/or update it just has to call
- * updateInset(this).
- *
- * It's is completly irrelevant, where the inset is. UpdateInset will
- * find it in any paragraph in any buffer.
- * Of course the_locking_inset and the insets in the current paragraph/buffer
- *  are checked first, so no performance problem should occur.
- */
-class UpdatableInset : public Inset {
-public:
-       ///
-       UpdatableInset();
-       ///
-       UpdatableInset(UpdatableInset const & in, bool same_id = false);
-
-       /// check if the font of the char we want inserting is correct
-       /// and modify it if it is not.
-       virtual bool checkInsertChar(LyXFont &);
-       ///
-       virtual EDITABLE editable() const;
-
-       ///
-       virtual void toggleInsetCursor(BufferView *);
-       ///
-       virtual void showInsetCursor(BufferView *, bool show = true);
-       ///
-       virtual void hideInsetCursor(BufferView *);
-       ///
-       virtual void fitInsetCursor(BufferView *) const;
-       ///
-       virtual void getCursorPos(BufferView *, int &, int &) const {}
-       ///
-       virtual void insetUnlock(BufferView *);
-       ///
-       virtual void edit(BufferView *, int x, int y, mouse_button::state button);
-       ///
-       virtual void edit(BufferView *, bool front = true);
-       ///
-       virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x, bool cleared) const;
-       ///
-       virtual bool insertInset(BufferView *, Inset *) { return false; }
-       ///
-       virtual UpdatableInset * getLockingInset() const {
-               return const_cast<UpdatableInset *>(this);
-       }
-       ///
-       virtual UpdatableInset * getFirstLockingInsetOfType(Inset::Code c)
-               { return (c == lyxCode()) ? this : 0; }
-       ///
-       virtual int insetInInsetY() const { return 0; }
-       ///
-       virtual bool updateInsetInInset(BufferView *, Inset *)
-               { return false; }
-       ///
-       virtual bool lockInsetInInset(BufferView *, UpdatableInset *)
-               { return false; }
-       ///
-       virtual bool unlockInsetInInset(BufferView *, UpdatableInset *,
-                                       bool /*lr*/ = false)
-               { return false; }
-       ///  An updatable inset could handle lyx editing commands
-       virtual RESULT localDispatch(FuncRequest const & cmd);
-       ///
-       bool isCursorVisible() const { return cursor_visible_; }
-       ///
-       virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
-       ///
-       int scroll(bool recursive = true) const {
-               // We need this method to not clobber the real method in Inset
-               return Inset::scroll(recursive);
-       }
-       ///
-       virtual bool showInsetDialog(BufferView *) const { return false; }
-       ///
-       virtual void nodraw(bool b) const {
-               block_drawing_ = b;
-       }
-       ///
-       virtual bool nodraw() const {
-               return block_drawing_;
-       }
-       ///
-       // needed for spellchecking text
-       ///
-       virtual bool allowSpellcheck() const { return false; }
-       ///
-       virtual WordLangTuple const
-       selectNextWordToSpellcheck(BufferView *, float & value) const;
-       ///
-       virtual void selectSelectedWord(BufferView *) {}
-       ///
-       virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
-
-       /// find the next change in the inset
-       virtual bool nextChange(BufferView * bv, lyx::pos_type & length);
-       ///
-       // needed for search/replace functionality
-       ///
-       virtual bool searchForward(BufferView *, string const &,
-                                  bool = true, bool = false);
-       ///
-       virtual bool searchBackward(BufferView *, string const &,
-                                   bool = true, bool = false);
-
-
-protected:
-       ///
-       void toggleCursorVisible() const {
-               cursor_visible_ = !cursor_visible_;
-       }
-       ///
-       void setCursorVisible(bool b) const {
-               cursor_visible_ = b;
-       }
-       /// scrolls to absolute position in bufferview-workwidth * sx units
-       void scroll(BufferView *, float sx) const;
-       /// scrolls offset pixels
-       void scroll(BufferView *, int offset) const;
-
-private:
-       ///
-       mutable bool cursor_visible_;
-       ///
-       mutable bool block_drawing_;
-};
-
-inline
-bool UpdatableInset::checkInsertChar(LyXFont &)
-{
-       return true;
-}
-
 /**
  * returns true if pointer argument is valid
  * and points to an editable inset
index 710711b2afaab15e9ee46393d21d27bb29a33573..92e340dc7315c936d2c5cc4cc3b0842feadcd736 100644 (file)
@@ -13,7 +13,7 @@
 #define INSETTEXT_H
 
 
-#include "inset.h"
+#include "updatableinset.h"
 #include "LString.h"
 #include "LColor.h"
 #include "ParagraphList.h"
diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C
new file mode 100644 (file)
index 0000000..7df76d7
--- /dev/null
@@ -0,0 +1,222 @@
+
+#include "updatableinset.h"
+#include "BufferView.h"
+#include "funcrequest.h"
+#include "debug.h"
+#include "lyxfont.h"
+#include "WordLangTuple.h"
+#include "lyxtext.h"
+#include "support/lstrings.h"
+
+
+// some stuff for inset locking
+
+UpdatableInset::UpdatableInset()
+       : Inset(), cursor_visible_(false), block_drawing_(false)
+{}
+
+
+UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
+       : Inset(in, same_id), cursor_visible_(false), block_drawing_(false)
+{}
+
+
+void UpdatableInset::insetUnlock(BufferView *)
+{
+       lyxerr[Debug::INFO] << "Inset Unlock" << endl;
+}
+
+
+// An updatable inset is highly editable by definition
+Inset::EDITABLE UpdatableInset::editable() const
+{
+       return HIGHLY_EDITABLE;
+}
+
+
+void UpdatableInset::toggleInsetCursor(BufferView *)
+{}
+
+
+void UpdatableInset::showInsetCursor(BufferView *, bool)
+{}
+
+
+void UpdatableInset::hideInsetCursor(BufferView *)
+{}
+
+
+void UpdatableInset::fitInsetCursor(BufferView *) const
+{}
+
+
+void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
+{}
+
+
+void UpdatableInset::edit(BufferView *, bool)
+{}
+
+
+void UpdatableInset::draw(BufferView *, LyXFont const &,
+                         int /* baseline */, float & x,
+                         bool/*cleared*/) const
+{
+       x += float(scx);
+       // ATTENTION: don't do the following here!!!
+       //    top_x = int(x);
+       //    top_baseline = baseline;
+}
+
+
+void UpdatableInset::scroll(BufferView * bv, float s) const
+{
+       LyXFont font;
+
+       if (!s) {
+               scx = 0;
+               return;
+       }
+
+       int const workW = bv->workWidth();
+       int const tmp_top_x = top_x - scx;
+
+       if (tmp_top_x > 0 &&
+           (tmp_top_x + width(bv, font)) < workW)
+               return;
+       if (s > 0 && top_x > 0)
+               return;
+
+       // int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
+       //int const save_scx = scx;
+
+       scx = int(s * workW / 2);
+       // if (!display())
+       // scx += 20;
+
+       if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
+               scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
+       }
+
+       // bv->updateInset(const_cast<UpdatableInset *>(this), false);
+}
+
+void UpdatableInset::scroll(BufferView * bv, int offset) const
+{
+       if (offset > 0) {
+               if (!scx && top_x >= 20)
+                       return;
+               if ((top_x + offset) > 20)
+                       scx = 0;
+               // scx += offset - (top_x - scx + offset - 20);
+               else
+                       scx += offset;
+       } else {
+               LyXFont const font;
+               if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20))
+                       return;
+               if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) {
+                       scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
+               } else {
+                       scx += offset;
+               }
+       }
+//     bv->updateInset(const_cast<UpdatableInset *>(this), false);
+}
+
+
+///  An updatable inset could handle lyx editing commands
+Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
+{
+       if (ev.action == LFUN_MOUSE_RELEASE)
+               return (editable() == IS_EDITABLE) ? DISPATCHED : UNDISPATCHED;
+
+       if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
+               if (ev.argument.find('.') != ev.argument.npos) {
+                       float const xx = static_cast<float>(strToDbl(ev.argument));
+                       scroll(ev.view(), xx);
+               } else {
+                       int const xx = strToInt(ev.argument);
+                       scroll(ev.view(), xx);
+               }
+               ev.view()->updateInset(this, false);
+
+               return DISPATCHED;
+       }
+       return UNDISPATCHED;
+}
+
+
+int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
+{
+       int w;
+       if (owner()) {
+               w = static_cast<UpdatableInset*>
+                       (owner())->getMaxWidth(bv, this);
+       } else {
+               w = bv->text->workWidth(bv, const_cast<UpdatableInset *>(this));
+       }
+       if (w < 0) {
+               return -1;
+       }
+       // check for margins left/right and extra right margin "const 5"
+       if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
+               w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
+       if (topx_set && owner()) {
+               w -= top_x;
+               w += owner()->x();
+       } else if (owner()) {
+               // this is needed as otherwise we might have a too large inset if
+               // its top_x afterwards changes to LeftMargin so we try to put at
+               // least the default margin as top_x
+               w -= 20;
+       }
+       if (w < 10) {
+               w = 10;
+       }
+       return w;
+}
+
+
+LyXCursor const & Inset::cursor(BufferView * bv) const
+{
+       if (owner())
+               return owner()->getLyXText(bv, false)->cursor;
+       return bv->text->cursor;
+}
+
+
+WordLangTuple const
+UpdatableInset::selectNextWordToSpellcheck(BufferView *bv, float & value) const
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       value = 0;
+       return WordLangTuple();
+}
+
+
+bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &)
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       return false;
+}
+
+bool UpdatableInset::searchForward(BufferView * bv, string const &,
+                                  bool, bool)
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       return false;
+}
+
+
+bool UpdatableInset::searchBackward(BufferView * bv, string const &,
+                                   bool, bool)
+{
+       // we have to unlock ourself in this function by default!
+       bv->unlockInset(const_cast<UpdatableInset *>(this));
+       return false;
+}
diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h
new file mode 100644 (file)
index 0000000..75681cc
--- /dev/null
@@ -0,0 +1,178 @@
+// -*- C++ -*-
+/**
+ * \file insetupdatable.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef UPDATABLEINSET_H
+#define UPDATABLEINSET_H
+
+//  Updatable Insets. These insets can be locked and receive
+//  directly user interaction. Currently used only for mathed.
+//  Note that all pure methods from Inset class are pure here too.
+//  [Alejandro 080596]
+
+#include "inset.h"
+
+
+/** Extracted from Matthias notes:
+ *
+ * An inset can simple call LockInset in it's edit call and *ONLY*
+ * in it's edit call.
+ *
+ * Unlocking is either done by LyX or the inset itself with a
+ * UnlockInset-call
+ *
+ * During the lock, all button and keyboard events will be modified
+ * and send to the inset through the following inset-features. Note that
+ * Inset::insetUnlock will be called from inside UnlockInset. It is meant
+ * to contain the code for restoring the menus and things like this.
+ *
+ * If a inset wishes any redraw and/or update it just has to call
+ * updateInset(this).
+ *
+ * It's is completly irrelevant, where the inset is. UpdateInset will
+ * find it in any paragraph in any buffer.
+ * Of course the_locking_inset and the insets in the current paragraph/buffer
+ *  are checked first, so no performance problem should occur.
+ */
+class UpdatableInset : public Inset {
+public:
+       ///
+       UpdatableInset();
+       ///
+       UpdatableInset(UpdatableInset const & in, bool same_id = false);
+
+       /// check if the font of the char we want inserting is correct
+       /// and modify it if it is not.
+       virtual bool checkInsertChar(LyXFont &);
+       ///
+       virtual EDITABLE editable() const;
+
+       ///
+       virtual void toggleInsetCursor(BufferView *);
+       ///
+       virtual void showInsetCursor(BufferView *, bool show = true);
+       ///
+       virtual void hideInsetCursor(BufferView *);
+       ///
+       virtual void fitInsetCursor(BufferView *) const;
+       ///
+       virtual void getCursorPos(BufferView *, int &, int &) const {}
+       ///
+       virtual void insetUnlock(BufferView *);
+       ///
+       virtual void edit(BufferView *, int x, int y, mouse_button::state button);
+       ///
+       virtual void edit(BufferView *, bool front = true);
+       ///
+       virtual void draw(BufferView *, LyXFont const &,
+                         int baseline, float & x, bool cleared) const;
+       ///
+       virtual bool insertInset(BufferView *, Inset *) { return false; }
+       ///
+       virtual UpdatableInset * getLockingInset() const {
+               return const_cast<UpdatableInset *>(this);
+       }
+       ///
+       virtual UpdatableInset * getFirstLockingInsetOfType(Inset::Code c)
+               { return (c == lyxCode()) ? this : 0; }
+       ///
+       virtual int insetInInsetY() const { return 0; }
+       ///
+       virtual bool updateInsetInInset(BufferView *, Inset *)
+               { return false; }
+       ///
+       virtual bool lockInsetInInset(BufferView *, UpdatableInset *)
+               { return false; }
+       ///
+       virtual bool unlockInsetInInset(BufferView *, UpdatableInset *,
+                                       bool /*lr*/ = false)
+               { return false; }
+       ///  An updatable inset could handle lyx editing commands
+       virtual RESULT localDispatch(FuncRequest const & cmd);
+       ///
+       bool isCursorVisible() const { return cursor_visible_; }
+       ///
+       virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
+       ///
+       int scroll(bool recursive = true) const {
+               // We need this method to not clobber the real method in Inset
+               return Inset::scroll(recursive);
+       }
+       ///
+       virtual bool showInsetDialog(BufferView *) const { return false; }
+       ///
+       virtual void nodraw(bool b) const {
+               block_drawing_ = b;
+       }
+       ///
+       virtual bool nodraw() const {
+               return block_drawing_;
+       }
+       ///
+       // needed for spellchecking text
+       ///
+       virtual bool allowSpellcheck() const { return false; }
+       ///
+       virtual WordLangTuple const
+       selectNextWordToSpellcheck(BufferView *, float & value) const;
+       ///
+       virtual void selectSelectedWord(BufferView *) {}
+       ///
+       virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
+
+       /// find the next change in the inset
+       virtual bool nextChange(BufferView * bv, lyx::pos_type & length);
+       ///
+       // needed for search/replace functionality
+       ///
+       virtual bool searchForward(BufferView *, string const &,
+                                  bool = true, bool = false);
+       ///
+       virtual bool searchBackward(BufferView *, string const &,
+                                   bool = true, bool = false);
+
+
+       ///
+       BufferView * view() const;
+       ///
+       void setView(BufferView * bv) const;
+
+protected:
+       ///
+       void toggleCursorVisible() const {
+               cursor_visible_ = !cursor_visible_;
+       }
+       ///
+       void setCursorVisible(bool b) const {
+               cursor_visible_ = b;
+       }
+       /// scrolls to absolute position in bufferview-workwidth * sx units
+       void scroll(BufferView *, float sx) const;
+       /// scrolls offset pixels
+       void scroll(BufferView *, int offset) const;
+
+private:
+       ///
+       mutable bool cursor_visible_;
+       ///
+       mutable bool block_drawing_;
+};
+
+inline
+bool UpdatableInset::checkInsertChar(LyXFont &)
+{
+       return true;
+}
+
+#endif
index 8dd68ec3ba00230449c3c8dba096b2bcbdeed1a9..9c53c47c57bb8aabd727eee9afadb9c512a620e3 100644 (file)
@@ -14,7 +14,7 @@
 #define INSET_FORMULABASE_H
 
 
-#include "insets/inset.h"
+#include "insets/updatableinset.h"
 #include "frontends/mouse_state.h"
 #include "lyxfont.h"
 
index 96d5497491b371cf036bd55a3747402be7032184..4501d53b116a3e91cb064c639f9b5642393d1859 100644 (file)
@@ -13,7 +13,7 @@
 #include "lyxtext.h"
 #include "BufferView.h"
 #include "buffer.h"
-#include "insets/inset.h"
+#include "insets/updatableinset.h"
 #include "debug.h"
 #include "support/LAssert.h"