]> git.lyx.org Git - lyx.git/blobdiff - src/dispatchresult.h
more cursor dispatch
[lyx.git] / src / dispatchresult.h
index be994a94cb308fe46d90d7fc0cea08876baaa0fa..70760b33d0b1f045b7915e93d990c38323922f43 100644 (file)
 #define DISPATCH_RESULT_H
 
 /** 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
+       DISPATCHED          = the inset caught the action
+       DISPATCHED_NOUPDATE = the inset caught the action and no update
+                       is needed 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
+       FINISHED_RIGHT      = FINISHED, but move the cursor RIGHT from
                        the inset.
-       FINISHED_UP         = FINISHED, but put the cursor UP of
+       FINISHED_UP         = FINISHED, but move the cursor UP from
                        the inset.
-       FINISHED_DOWN       = FINISHED, but put the cursor DOWN of
+       FINISHED_DOWN       = FINISHED, but move the cursor DOWN from
                        the inset.
-       UNDISPATCHED        = the action was not catched, it should be
+       FINISHED_POP       = FINISHED, but move the cursor out the inset
+                       (possibly more than one level)
+       UNDISPATCHED        = the action was not caught, it should be
                        dispatched by lower level insets
 */
 enum dispatch_result_t {
-       UNDISPATCHED = 0,
-       DISPATCHED,
-       DISPATCHED_NOUPDATE,
+       NONE = 0,
        FINISHED,
        FINISHED_RIGHT,
        FINISHED_UP,
-       FINISHED_DOWN,
-       DISPATCHED_POP
+       FINISHED_DOWN
 };
 
+
 /** \c DispatchResult is a wrapper for dispatch_result_t.
  *  It can be forward-declared and passed as a function argument without
  *  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_; }
+               : dispatched_(false), val_(NONE) {}
+       explicit
+       DispatchResult(bool dis)
+               : dispatched_(dis), update_(false), val_(NONE) {}
+       DispatchResult(bool dis, bool update)
+               : dispatched_(dis), update_(update), val_(NONE) {}
+       DispatchResult(bool dis, dispatch_result_t val)
+               : dispatched_(dis), update_(true), val_(val) {}
+       dispatch_result_t val() const { return val_; }
+       void val(dispatch_result_t drt) {
+               val_ = drt;
+       }
+       bool dispatched() const {
+               return dispatched_;
+       }
+       void dispatched(bool dis) {
+               dispatched_ = dis;
+       }
+       bool update() const {
+               return update_;
+       }
+       void update(bool up) {
+               update_ = up;
+       }
+private:
+       bool dispatched_;
+       bool update_;
+       dispatch_result_t val_;
 };
 
+
+inline
+bool operator==(DispatchResult const & lhs, DispatchResult const & rhs)
+{
+       return lhs.dispatched() == rhs.dispatched() && lhs.val() == rhs.val();
+}
+
+
+inline
+bool operator!=(DispatchResult const & lhs, DispatchResult const & rhs)
+{
+       return !(lhs == rhs);
+}
+
 #endif // DISPATCH_RESULT_H