From 1d7a7153298510004eef95e030fe6e3f2a242e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 29 Oct 2003 13:24:57 +0000 Subject: [PATCH] more dispatch work git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8001 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 4 ++++ src/BufferView_pimpl.C | 2 +- src/ChangeLog | 27 +++++++++++++++++++-------- src/cursor.C | 6 +++--- src/dispatchresult.h | 30 +++++++++++++++++++++++++++--- src/insets/ChangeLog | 7 +++++++ src/insets/insettabular.C | 8 ++++---- src/insets/insettext.C | 6 +++--- src/mathed/ChangeLog | 4 ++++ src/mathed/math_cursor.C | 2 +- src/mathed/math_gridinset.C | 10 +++++----- src/mathed/math_hullinset.C | 8 ++++---- 12 files changed, 82 insertions(+), 32 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index ee9faf7add..19447ffb6d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -38,6 +38,9 @@ src/frontends/controllers/helper_funcs.C src/frontends/gnome/GLog.C src/frontends/gtk/Dialogs.C src/frontends/gtk/GBC.h +src/frontends/gtk/GMathPanel.C +src/frontends/gtk/GTableCreate.C +src/frontends/gtk/GUrl.C src/frontends/qt2/Alert_pimpl.C src/frontends/qt2/BulletsModule.C src/frontends/qt2/Dialogs.C @@ -162,6 +165,7 @@ src/insets/insetmarginal.C src/insets/insetminipage.C src/insets/insetnote.C src/insets/insetoptarg.C +src/insets/insetpagebreak.C src/insets/insetref.C src/insets/insettabular.C src/insets/insettext.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ad600d96d1..f76397bc5a 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1279,7 +1279,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) break; default: - return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)); + return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)) >= DISPATCHED; } // end of switch return true; diff --git a/src/ChangeLog b/src/ChangeLog index 9b685fa25a..f727aa2711 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,17 +1,28 @@ 2003-10-29 Lars Gullik Bjønnes - * text3.C: - * text2.C: - * text.C: - * lyxtext.h: - * lyxfunc.C: - * cursor.C: + * dispatchresult.h: rename DISPATCHED_POP to FINISHED_POP, remove + operator dispatch_result_t, and operators for == != and >= + + * cursor.C (dispatch): adjust for operator dispatch_result_t + removal. comment out call to update + + * BufferView_pimpl.C (dispatch): dont implicit covert to bool + +2003-10-29 Lars Gullik Bjønnes + + * text3.C: + * text2.C: + * text.C: + * lyxtext.h: + * lyxfunc.C: + * cursor.C: * BufferView_pimpl.C: dispatch_result -> DispatchResult changes. + (dispatch): * dispatchresult.h: new file, DispatchResult broken out of - insets/insetbase.h + insets/insetbase.h - * Makefile.am (lyx_SOURCES): add dispatchresult.h + * Makefile.am (lyx_SOURCES): add dispatchresult.h 2003-10-28 Alfredo Braunstein diff --git a/src/cursor.C b/src/cursor.C index 874215f7db..7f7e4891e2 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -30,17 +30,17 @@ DispatchResult Cursor::dispatch(FuncRequest const & cmd) for (int i = data_.size() - 1; i >= 0; --i) { lyxerr << "trying to dispatch to inset" << data_[i].inset_ << endl; DispatchResult res = data_[i].inset_->dispatch(cmd); - lyxerr << " result: " << res << endl; + lyxerr << " result: " << res.val() << endl; if (res == DISPATCHED) { //update(); return DISPATCHED; } - + if (res == DISPATCHED_NOUPDATE) return DISPATCHED; - lyxerr << "# unhandled result: " << res << endl; + lyxerr << "# unhandled result: " << res.val() << endl; } return UNDISPATCHED; } diff --git a/src/dispatchresult.h b/src/dispatchresult.h index be994a94cb..0700dd517a 100644 --- a/src/dispatchresult.h +++ b/src/dispatchresult.h @@ -36,7 +36,7 @@ enum dispatch_result_t { FINISHED_RIGHT, FINISHED_UP, FINISHED_DOWN, - DISPATCHED_POP + FINISHED_POP }; /** \c DispatchResult is a wrapper for dispatch_result_t. @@ -44,12 +44,36 @@ enum dispatch_result_t { * having to expose insetbase.h. */ class DispatchResult { - dispatch_result_t val_; public: DispatchResult() : val_(UNDISPATCHED) {} DispatchResult(dispatch_result_t val) : val_(val) {} - operator dispatch_result_t() const{ return val_; } + dispatch_result_t val() const { return val_; } +private: + dispatch_result_t val_; }; + +inline +bool operator==(DispatchResult const & lhs, DispatchResult const & rhs) +{ + return lhs.val() == rhs.val(); +} + + +inline +bool operator!=(DispatchResult const & lhs, DispatchResult const & rhs) +{ + return !(lhs == rhs); +} + + +// This operator is temporary, will be removed with the introduction of +// a status field in DispatchResult. +inline +bool operator>=(DispatchResult const & lhs, DispatchResult const & rhs) +{ + return lhs.val() >= rhs.val(); +} + #endif // DISPATCH_RESULT_H diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f5f207748d..d2fcfbbd09 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,12 @@ 2003-10-29 Lars Gullik Bjønnes + * insettext.C (lfunMouseRelease): dont use implicit conversion to bool + (priv_dispatch): adjust for operator dispatch_result_t removal + + * insettabular.C (lfunMouseRelease): put the result of a dispatch + in a DispatchResult, adjust accordingly. + (priv_dispatch): use strange >= construct... (will be removed later) + * most insets: dispatch_result -> DispatchResult * insetbase.h: move DispatchResult out to dispatchresult.h diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 0a390dc5e2..a9264f94d7 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -598,18 +598,18 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd) bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd) { - bool ret = false; + DispatchResult ret = UNDISPATCHED; if (the_locking_inset) { FuncRequest cmd1 = cmd; cmd1.x -= inset_x; cmd1.y -= inset_y; ret = the_locking_inset->dispatch(cmd1); } - if (cmd.button() == mouse_button::button3 && !ret) { + if (cmd.button() == mouse_button::button3 && ret == UNDISPATCHED) { InsetTabularMailer(*this).showDialog(cmd.view()); return true; } - return ret; + return ret >= DISPATCHED; } @@ -1111,7 +1111,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd, } break; } - if (result < FINISHED) { + if (!(result >= FINISHED)) { if (!the_locking_inset && bv->fitCursor()) updateLocal(bv); } else diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 4551ed3d38..45125ded5f 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -547,7 +547,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) no_selection = true; if (the_locking_inset) - return the_locking_inset->dispatch(cmd1); + return the_locking_inset->dispatch(cmd1) >= DISPATCHED; int tmp_x = cmd.x; int tmp_y = cmd.y + dim_.asc - bv->top_y(); @@ -557,7 +557,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) // We still need to deal properly with the whole relative vs. // absolute mouse co-ords thing in a realiable, sensible way - bool ret = inset->dispatch(cmd1); + bool ret = inset->dispatch(cmd1) >= DISPATCHED; updateLocal(bv, false); return ret; } @@ -687,7 +687,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd, return result; } if (result >= FINISHED) { - switch (result) { + switch (result.val()) { case FINISHED_RIGHT: moveRightIntern(bv, false, false); result = DISPATCHED; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 3d13851000..df03a27f37 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,5 +1,9 @@ 2003-10-29 Lars Gullik Bjønnes + * math_hullinset.C (priv_dispatch): + * math_gridinset.C (priv_dispatch): + * math_cursor.C (dispatch): DISPATCHED_POP -> FINISHED_POP + * math_scriptinset.h: change dispatch to priv_dispatch and make it protected diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 1e4f7a7f0e..bfea72d107 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1439,7 +1439,7 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd) CursorPos & pos = Cursor_[i]; DispatchResult res = pos.inset_->dispatch(cmd, pos.idx_, pos.pos_); if (res != UNDISPATCHED) { - if (res == DISPATCHED_POP) { + if (res == FINISHED_POP) { Cursor_.shrink(i + 1); selClear(); } diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 4636f6562a..ffc31f08e6 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -1072,12 +1072,12 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd, idx = nargs() - 1; if (pos > cell(idx).size()) pos = cell(idx).size(); - return DISPATCHED_POP; + return FINISHED_POP; case LFUN_CELL_SPLIT: //recordUndo(bv, Undo::ATOMIC); splitCell(idx, pos); - return DISPATCHED_POP; + return FINISHED_POP; case LFUN_BREAKLINE: { //recordUndo(bv, Undo::INSERT); @@ -1096,7 +1096,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd, pos = cell(idx).size(); //mathcursor->normalize(); - return DISPATCHED_POP; + return FINISHED_POP; } case LFUN_TABULAR_FEATURE: { @@ -1153,7 +1153,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd, else return UNDISPATCHED; lyxerr << "returning DISPATCHED_POP" << endl; - return DISPATCHED_POP; + return FINISHED_POP; } case LFUN_PASTE: { @@ -1184,7 +1184,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd, for (col_type c = 0; c < grid.ncols(); ++c) cell(i).append(grid.cell(grid.index(r, c))); } - return DISPATCHED_POP; + return FINISHED_POP; } default: diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 3bfaf6a9c6..dd55c413d6 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -782,7 +782,7 @@ DispatchResult MathHullInset::priv_dispatch mutate("eqnarray"); idx = 1; pos = 0; - return DISPATCHED_POP; + return FINISHED_POP; } return MathGridInset::priv_dispatch(cmd, idx, pos); @@ -837,7 +837,7 @@ DispatchResult MathHullInset::priv_dispatch case LFUN_MATH_EXTERN: doExtern(cmd, idx, pos); - return DISPATCHED_POP; + return FINISHED_POP; case LFUN_MATH_MUTATE: { lyxerr << "Hull: MUTATE: " << cmd.argument << endl; @@ -849,14 +849,14 @@ DispatchResult MathHullInset::priv_dispatch idx = nargs() - 1; if (pos > cell(idx).size()) pos = cell(idx).size(); - return DISPATCHED_POP; + return FINISHED_POP; } case LFUN_MATH_DISPLAY: { mutate(type_ == "simple" ? "equation" : "simple"); idx = 0; pos = cell(idx).size(); - return DISPATCHED_POP; + return FINISHED_POP; } default: