X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fdispatchresult.h;h=7b53ec1c85d3ba2d28a1174b6ca4761892c39cd5;hb=c68f3da771a54ef78bd309b8f1a81c374d2fea4c;hp=1e4d801eef52fb2bdc2160c49cb64708ffb0f272;hpb=c1319d2c6738ff3e72283917ea903f4878298d41;p=lyx.git diff --git a/src/dispatchresult.h b/src/dispatchresult.h index 1e4d801eef..7b53ec1c85 100644 --- a/src/dispatchresult.h +++ b/src/dispatchresult.h @@ -13,76 +13,33 @@ #ifndef DISPATCH_RESULT_H #define DISPATCH_RESULT_H -/** Dispatch result codes - 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 move the cursor RIGHT from - the inset. - FINISHED_UP = FINISHED, but move the cursor UP from - the inset. - FINISHED_DOWN = FINISHED, but move the cursor DOWN from - the inset. - UNDISPATCHED = the action was not catched, it should be - dispatched by lower level insets -*/ -enum dispatch_result_t { - NONE = 0, - FINISHED, - FINISHED_RIGHT, - FINISHED_UP, - FINISHED_DOWN -}; +#include "UpdateFlags.h" +namespace lyx { -/** \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. - */ +/// Maybe this can go entirely class DispatchResult { public: - DispatchResult() - : dispatched_(false), val_(NONE) {} - explicit - DispatchResult(bool dis) - : dispatched_(dis), update_(false), val_(NONE) {} - DispatchResult(bool dis, bool update) - : dispatched_(dis), update_(true), val_(NONE) {} - DispatchResult(bool dis, dispatch_result_t val) - : dispatched_(dis), update_(false), val_(val) {} - dispatch_result_t val() const { return val_; } - bool dispatched() const { - return dispatched_; - } - void dispatched(bool dis) { - dispatched_ = dis; - } - bool update() const { - return update_; - } - void update(bool up) { - update_ = up; - } + /// + DispatchResult() : dispatched_(false), update_(Update::None) {} + /// + DispatchResult(bool disp, Update::flags f) : dispatched_(disp), update_(f) {} + // + bool dispatched() const { return dispatched_; } + /// + void dispatched(bool disp) { dispatched_ = disp; } + /// + Update::flags update() const { return update_; } + /// + void update(Update::flags f) { update_ = f; } private: + /// was the event fully dispatched? bool dispatched_; - bool update_; - dispatch_result_t val_; + /// do we need to redraw the screen afterwards? + Update::flags update_; }; -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); -} +} // namespace lyx #endif // DISPATCH_RESULT_H