]> git.lyx.org Git - features.git/commitdiff
iu2: move localDispatch() to InsetBase
authorAndré Pönitz <poenitz@gmx.net>
Tue, 18 Feb 2003 11:47:16 +0000 (11:47 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 18 Feb 2003 11:47:16 +0000 (11:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6194 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
src/insets/Makefile.am
src/insets/inset.C
src/insets/inset.h
src/insets/insetbase.C
src/insets/insetbase.h
src/lyxfunc.C
src/mathed/command_inset.C
src/mathed/command_inset.h
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/ref_inset.C
src/mathed/ref_inset.h
src/text3.C

index d888b6942a87b857d34816736962dbecab37e670..562e147f9939a9e24b34c66d384950ba7f3c769a 100644 (file)
@@ -18,6 +18,7 @@ libinsets_la_SOURCES = \
        inset.C \
        inset.h \
        insetbase.h \
+       insetbase.C \
        insetbib.C \
        insetbib.h \
        insetbutton.C \
index 21ca38df6c5f569c926d1714fdae411304a1423b..b62738a6092eafc798dd1607c9fea1bacf0bc8bb 100644 (file)
@@ -88,12 +88,6 @@ void Inset::edit(BufferView *, bool)
 {}
 
 
-Inset::RESULT Inset::localDispatch(FuncRequest const &)
-{
-       return UNDISPATCHED;
-}
-
-
 #if 0
 LyXFont const Inset::convertFont(LyXFont const & font) const
 {
index 7df0f29e04a623eaf1fa5b867245c9ae04f25d4b..0f66e29c6ce0b0fcd58b36cd4930b11ff447774d 100644 (file)
@@ -142,15 +142,13 @@ public:
        };
 
        ///
-       typedef InsetBase::dispatch_result RESULT;
+       typedef dispatch_result RESULT;
 
        ///
        Inset();
        ///
        Inset(Inset const & in, bool same_id = false);
        ///
-       virtual ~Inset() {}
-       ///
        virtual int ascent(BufferView *, LyXFont const &) const = 0;
        ///
        virtual int descent(BufferView *, LyXFont const &) const = 0;
@@ -171,8 +169,6 @@ public:
        ///
        virtual EDITABLE editable() const;
        ///
-       virtual RESULT localDispatch(FuncRequest const & cmd);
-       ///
        virtual bool isTextInset() const { return false; }
        ///
        virtual bool doClearArea() const { return true; }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..58371411a25def39273b100b302be85732e856e3 100644 (file)
@@ -0,0 +1,17 @@
+
+#include "insetbase.h"
+
+
+dispatch_result InsetBase::dispatch(FuncRequest const &, idx_type &, pos_type &)
+{
+       return UNDISPATCHED;
+}
+
+
+dispatch_result InsetBase::localDispatch(FuncRequest const & cmd)
+{
+       idx_type idx = 0;
+       pos_type pos = 0;
+       return dispatch(cmd, idx, pos);
+}
+
index d09874d6ab7c10a86d8d1e13a3ad9b5a37a38551..79933fcc62d3598fa7219354cfa260c5e45d58e2 100644 (file)
 #ifndef INSETBASE_H
 #define INSETBASE_H
 
+#include <vector>
+
+class FuncRequest;
+
+/** Dispatch result codes
+               DISPATCHED          = the inset catched the action
+               DISPATCHED_NOUPDATE = the inset catched the action and no update
+                               is needed here to redraw the inset
+               FINISHED            = the inset must be unlocked as a result
+                               of the action
+               FINISHED_RIGHT      = FINISHED, but put the cursor to the RIGHT of
+                               the inset.
+               FINISHED_UP         = FINISHED, but put the cursor UP of
+                               the inset.
+               FINISHED_DOWN       = FINISHED, but put the cursor DOWN of
+                               the inset.
+               UNDISPATCHED        = the action was not catched, it should be
+                               dispatched by lower level insets
+*/
+enum dispatch_result {
+       UNDISPATCHED = 0,
+       DISPATCHED,
+       DISPATCHED_NOUPDATE,
+       FINISHED,
+       FINISHED_RIGHT,
+       FINISHED_UP,
+       FINISHED_DOWN,
+       DISPATCHED_POP
+};
+
 
 /// Common base class to all insets
 class InsetBase {
 public:
-       /** Dispatch result codes
-           DISPATCHED          = the inset catched the action
-           DISPATCHED_NOUPDATE = the inset catched the action and no update
-                                 is needed here to redraw the inset
-           FINISHED            = the inset must be unlocked as a result
-                                 of the action
-           FINISHED_RIGHT      = FINISHED, but put the cursor to the RIGHT of
-                                 the inset.
-           FINISHED_UP         = FINISHED, but put the cursor UP of
-                                 the inset.
-           FINISHED_DOWN       = FINISHED, but put the cursor DOWN of
-                                 the inset.
-           UNDISPATCHED        = the action was not catched, it should be
-                                 dispatched by lower level insets
-       */
-       enum dispatch_result {
-               UNDISPATCHED = 0,
-               DISPATCHED,
-               DISPATCHED_NOUPDATE,
-               FINISHED,
-               FINISHED_RIGHT,
-               FINISHED_UP,
-               FINISHED_DOWN,
-               DISPATCHED_POP
-       };
+       /// type for cell indices
+       typedef size_t                   idx_type;
+       /// type for cursor positions
+       typedef size_t                   pos_type;
+       /// type for row numbers
+       typedef size_t                   row_type;
+       /// type for column numbers
+       typedef size_t                   col_type;
+
+       // the real dispatcher
+       virtual dispatch_result dispatch
+               (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+
+       /// small wrapper for the time being
+       virtual dispatch_result localDispatch(FuncRequest const & cmd);
 
        ///
        virtual ~InsetBase() {}
index 99a61ed8e2bf4f32ececb8969370756565171987..9cdd982fab168cd1bbe1b17b3f894ccfa7f40d21 100644 (file)
@@ -789,21 +789,21 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                        } else if (((result=inset->
                                     // Hand-over to inset's own dispatch:
                                     localDispatch(FuncRequest(view(), action, argument))) ==
-                                   UpdatableInset::DISPATCHED) ||
-                                  (result == UpdatableInset::DISPATCHED_NOUPDATE))
+                                   DISPATCHED) ||
+                                  (result == DISPATCHED_NOUPDATE))
                                goto exit_with_message;
                                        // If UNDISPATCHED, just soldier on
-                       else if (result == UpdatableInset::FINISHED) {
+                       else if (result == FINISHED) {
                                goto exit_with_message;
                                // We do not need special RTL handling here:
                                // FINISHED means that the cursor should be
                                // one position after the inset.
-                       } else if (result == UpdatableInset::FINISHED_RIGHT) {
+                       } else if (result == FINISHED_RIGHT) {
                                TEXT()->cursorRight(view());
                                moveCursorUpdate(true, false);
                                owner->view_state_changed();
                                goto exit_with_message;
-                       } else if (result == UpdatableInset::FINISHED_UP) {
+                       } else if (result == FINISHED_UP) {
                                if (TEXT()->cursor.irow()->previous()) {
 #if 1
                                        TEXT()->setCursorFromCoordinates(
@@ -820,7 +820,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                                        view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
                                }
                                goto exit_with_message;
-                       } else if (result == UpdatableInset::FINISHED_DOWN) {
+                       } else if (result == FINISHED_DOWN) {
                                if (TEXT()->cursor.irow()->next()) {
 #if 1
                                        TEXT()->setCursorFromCoordinates(
index dcb256f47816131501f389d6a430397362e66257..22e56af1736a242820d2de35ebed88adb711e4c7 100644 (file)
@@ -27,7 +27,7 @@ MathInset * CommandInset::clone() const
 }
 
 
-MathInset::result_type
+dispatch_result
 CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
index 3fb4258e63048991eceb477ddd13a50d86c7649c..df5981f71ed9311d87555ac355ed2ab3ff0e8fd1 100644 (file)
@@ -29,7 +29,7 @@ public:
        ///
        //void infoize(std::ostream & os) const;
        ///
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
        ///
        string screenLabel() const;
 public:
index 1ab3bf9c90d704652d9e7bc204718d22ab788c53..316ea479bf31fbe5c3b159c0ffde1c75e538fb87 100644 (file)
@@ -303,7 +303,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 }
 
 
-Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
 {
        if (!mathcursor)
                return UNDISPATCHED;
@@ -316,7 +316,7 @@ Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
 
        if (cmd.button() == mouse_button::button3) {
                // try to dispatch to enclosed insets first
-               if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) {
+               if (mathcursor->dispatch(cmd) == UNDISPATCHED) {
                        // launch math panel for right mouse button
                        bv->owner()->getDialogs().showMathPanel();
                }
@@ -347,7 +347,7 @@ Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
 }
 
 
-Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
 {
        BufferView * bv = cmd.view();
        //lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
@@ -379,12 +379,12 @@ Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
 }
 
 
-Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
 {
        if (!mathcursor)
                return DISPATCHED;
 
-       if (mathcursor->dispatch(FuncRequest(cmd)) != MathInset::UNDISPATCHED)
+       if (mathcursor->dispatch(FuncRequest(cmd)) != UNDISPATCHED)
                return DISPATCHED;
 
        // only select with button 1
@@ -409,7 +409,7 @@ Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
 }
 
 
-Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
 {
        //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
        //      << " arg: '" << cmd.argument
index 49d48a4bcdb0d94ece4b5cc961825d79c8509722..8dd68ec3ba00230449c3c8dba096b2bcbdeed1a9 100644 (file)
@@ -76,7 +76,7 @@ public:
        virtual void insetUnlock(BufferView *);
 
        /// To allow transparent use of math editing functions
-       virtual RESULT localDispatch(FuncRequest const &);
+       virtual dispatch_result localDispatch(FuncRequest const &);
        /// To allow transparent use of math editing functions
        //virtual void status(FuncRequest const &);
 
@@ -116,11 +116,11 @@ private:
        /// common base for handling accents
        void handleAccent(BufferView * bv, string const & arg, string const & name);
        /// lfun handler
-       RESULT lfunMousePress(FuncRequest const &);
+       dispatch_result lfunMousePress(FuncRequest const &);
        ///
-       RESULT lfunMouseRelease(FuncRequest const &);
+       dispatch_result lfunMouseRelease(FuncRequest const &);
        ///
-       RESULT lfunMouseMotion(FuncRequest const &);
+       dispatch_result lfunMouseMotion(FuncRequest const &);
 
 protected:
        ///
index 5e89cc4b87dcac47d4ef45afeda15ffc1a9f23eb..7efecbba79247f1a5792088912619a679d16828e 100644 (file)
@@ -1409,21 +1409,20 @@ MathCursorPos MathCursor::normalAnchor() const
 }
 
 
-MathInset::result_type MathCursor::dispatch(FuncRequest const & cmd)
+dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
 {
        for (int i = Cursor_.size() - 1; i >= 0; --i) {
                MathCursorPos & pos = Cursor_[i];
-               MathInset::result_type
-                       res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
-               if (res != MathInset::UNDISPATCHED) {
-                       if (res == MathInset::DISPATCHED_POP) {
+               dispatch_result res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
+               if (res != UNDISPATCHED) {
+                       if (res == DISPATCHED_POP) {
                                Cursor_.shrink(i + 1);
                                selClear();
                        }
                        return res;
                }
        }
-       return MathInset::UNDISPATCHED;
+       return UNDISPATCHED;
 }
 
 
index b0d3a240d63320e3e634e26e2ad805c049737e9d..8043f3b7d9c032441f99ca14366b63b39857a818 100644 (file)
@@ -218,7 +218,7 @@ public:
        unsigned depth() const;
 
        /// local dispatcher
-       MathInset::result_type dispatch(FuncRequest const & cmd);
+       dispatch_result dispatch(FuncRequest const & cmd);
        /// describe the situation
        string info() const;
        /// dump selection information for debugging
index 7cfd702c9adea05ff876d428b66898619f4f06c7..8e3c61838d00b21732966f8843d7f4d0f8c87107 100644 (file)
@@ -967,7 +967,7 @@ void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
 }
 
 
-MathInset::result_type MathGridInset::dispatch
+dispatch_result MathGridInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
index 29e8c9afc72ed7c9415929c5b8c01e6f2ca1ab10..a7df3eb5853802478547a856c1ae4e8e61061aa2 100644 (file)
@@ -128,7 +128,7 @@ public:
        /// identifies GridInset
        MathGridInset const * asGridInset() const { return this; }
        /// local dispatcher
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
 
        ///
        col_type ncols() const;
index 52044b8ef0cf8bbe45f5fb458f2f069caa37b568..5d52dfd0bafd282e66a72c1d75dca9ea29bfb344 100644 (file)
@@ -743,7 +743,7 @@ void MathHullInset::doExtern
 }
 
 
-MathInset::result_type MathHullInset::dispatch
+dispatch_result MathHullInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
index f0911dd926df67736a66a4184d254df00c024ce4..63e580f1052c497820f1464104e4b4e3cfd43478 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        bool ams() const;
        /// local dispatcher
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
        ///
        void getLabelList(std::vector<string> &) const;
        ///
index 47a1c3d82c6b52f15ec7250d2c7618498c3e662f..065408881be4c724c456001a489c8c67b86bc039 100644 (file)
@@ -260,13 +260,6 @@ int MathInset::docbook(std::ostream &, bool) const
 }
 
 
-MathInset::result_type
-       MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
-{
-       return UNDISPATCHED;
-}
-
-
 string const & MathInset::getType() const
 {
        static string t("none");
index 2b0719621c782973324ad9d4d0164eaaf0eed7ba..c95540085882ea3749f7445545743d98fffe2e53 100644 (file)
@@ -97,13 +97,9 @@ public:
        typedef size_type                   row_type;
        /// type for column numbers
        typedef size_type                   col_type;
-       ///
-       typedef InsetBase::dispatch_result  result_type;
 
        /// our members behave nicely...
        MathInset() {}
-       /// the virtual base destructor
-       virtual ~MathInset() {}
 
        /// reproduce itself
        virtual MathInset * clone() const = 0;
@@ -289,9 +285,6 @@ public:
 
        /// dump content to stderr for debugging
        virtual void dump() const;
-       /// local dispatcher
-       virtual result_type dispatch
-               (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
 
        /// LyXInset stuff
        /// write labels into a list
index 3ed34a0277cd1e44f00fa1ac32bd03cedd644076..890fe5c017bd9c53ed0c9fc062837fcfa1143ca5 100644 (file)
@@ -315,7 +315,7 @@ void MathNestInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-MathInset::result_type MathNestInset::dispatch
+dispatch_result MathNestInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        BufferView * bv = cmd.view();
index 4abaa95fea57914e4bf6a2169d600781316d5c2f..42dad7d97757bdef22a9dc84b87a581e95348b2d 100644 (file)
@@ -99,7 +99,8 @@ public:
        void normalize(NormalStream & os) const;
 
        /// local dispatcher
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result
+               dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
 
 protected:
        /// we store the cells in a vector
index 201916eabf9f7063065e6eda64580c7ba11b796a..3892ba88328da383d71a7d4ec6411e56dfc5d699 100644 (file)
@@ -493,7 +493,7 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-MathInset::result_type MathScriptInset::dispatch
+dispatch_result MathScriptInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        if (cmd.action == LFUN_MATH_LIMITS) {
index 6b7688d4b82e53c939deb4dd9c84c6de16f4ef12..fa5dc7653fc92d2a3d7ea3132cc63375e99559c0 100644 (file)
@@ -91,7 +91,7 @@ public:
        /// say whether we have displayed limits
        void infoize2(std::ostream & os) const;
        /// local dispatcher
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
 
 private:
        /// returns x offset for main part
index 5002cb5eea95b7b09fca2e289413dd8dec480cbd..520b6a0c867ecd129f65ba20fa96270aa92aeb04 100644 (file)
@@ -36,7 +36,7 @@ void RefInset::infoize(std::ostream & os) const
 }
 
 
-MathInset::result_type
+dispatch_result
 RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
index c8ff0347afd711328460951128a22eb2a8c13ed8..bb9a6c25da9af7a4521bddbd78557c3d78904478 100644 (file)
@@ -18,7 +18,7 @@ public:
        ///
        void infoize(std::ostream & os) const;
        ///
-       result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
        ///
        string screenLabel() const;
        ///
index 5dacb94186039d614e0cf6f8c0f7bc7546a25b63..3fcc37dfa4e714157ba4b4f5c303fe5362067853 100644 (file)
@@ -375,6 +375,7 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
                bv->updateInset(new_inset, true);
 }
 
+
 void doInsertInset(LyXText * lt, FuncRequest const & cmd,
                   bool edit, bool pastesel)
 {
@@ -396,7 +397,6 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd,
                else
                        delete inset;
        }
-
 }
 
 }
@@ -1055,7 +1055,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_BEGINNINGBUFSEL:
                if (inset_owner)
-                       return Inset::UNDISPATCHED;
+                       return UNDISPATCHED;
                update(bv, false);
                cursorTop(bv);
                finishChange(bv, true);
@@ -1063,7 +1063,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
        case LFUN_ENDBUFSEL:
                if (inset_owner)
-                       return Inset::UNDISPATCHED;
+                       return UNDISPATCHED;
                update(bv, false);
                cursorBottom(bv);
                finishChange(bv, true);
@@ -1640,8 +1640,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                break;
 
        default:
-               return Inset::UNDISPATCHED;
+               return UNDISPATCHED;
        }
 
-       return Inset::DISPATCHED;
+       return DISPATCHED;
 }