2003-10-29 10:47:21 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
|
|
|
|
* \file dispatchresult.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author none
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DISPATCH_RESULT_H
|
|
|
|
|
#define DISPATCH_RESULT_H
|
|
|
|
|
|
|
|
|
|
/** Dispatch result codes
|
2003-11-01 15:45:19 +00:00
|
|
|
|
DISPATCHED = the inset caught the action
|
|
|
|
|
DISPATCHED_NOUPDATE = the inset caught the action and no update
|
|
|
|
|
is needed to redraw the inset
|
2003-10-29 10:47:21 +00:00
|
|
|
|
FINISHED = the inset must be unlocked as a result
|
|
|
|
|
of the action
|
2003-11-01 15:45:19 +00:00
|
|
|
|
FINISHED_RIGHT = FINISHED, but move the cursor RIGHT from
|
2003-10-29 10:47:21 +00:00
|
|
|
|
the inset.
|
2003-11-01 15:45:19 +00:00
|
|
|
|
FINISHED_UP = FINISHED, but move the cursor UP from
|
2003-10-29 10:47:21 +00:00
|
|
|
|
the inset.
|
2003-11-01 15:45:19 +00:00
|
|
|
|
FINISHED_DOWN = FINISHED, but move the cursor DOWN from
|
2003-10-29 10:47:21 +00:00
|
|
|
|
the inset.
|
2003-11-10 09:06:48 +00:00
|
|
|
|
FINISHED_POP = FINISHED, but move the cursor DOWN from
|
|
|
|
|
the inset.
|
2003-10-29 10:47:21 +00:00
|
|
|
|
UNDISPATCHED = the action was not catched, it should be
|
|
|
|
|
dispatched by lower level insets
|
|
|
|
|
*/
|
|
|
|
|
enum dispatch_result_t {
|
2003-11-01 15:45:19 +00:00
|
|
|
|
NONE = 0,
|
2003-10-29 10:47:21 +00:00
|
|
|
|
FINISHED,
|
|
|
|
|
FINISHED_RIGHT,
|
|
|
|
|
FINISHED_UP,
|
2003-10-29 13:34:11 +00:00
|
|
|
|
FINISHED_DOWN
|
2003-10-29 10:47:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-11-03 19:52:47 +00:00
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
/** \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 {
|
|
|
|
|
public:
|
|
|
|
|
DispatchResult()
|
2003-11-01 15:45:19 +00:00
|
|
|
|
: dispatched_(false), val_(NONE) {}
|
2003-10-29 19:19:27 +00:00
|
|
|
|
explicit
|
2003-11-01 15:45:19 +00:00
|
|
|
|
DispatchResult(bool dis)
|
2003-11-03 19:52:47 +00:00
|
|
|
|
: dispatched_(dis), update_(false), val_(NONE) {}
|
|
|
|
|
DispatchResult(bool dis, bool update)
|
|
|
|
|
: dispatched_(dis), update_(true), val_(NONE) {}
|
2003-11-01 15:45:19 +00:00
|
|
|
|
DispatchResult(bool dis, dispatch_result_t val)
|
2003-11-03 19:52:47 +00:00
|
|
|
|
: dispatched_(dis), update_(false), val_(val) {}
|
2003-10-29 13:24:57 +00:00
|
|
|
|
dispatch_result_t val() const { return val_; }
|
2003-11-04 08:33:23 +00:00
|
|
|
|
void val(dispatch_result_t drt) {
|
|
|
|
|
val_ = drt;
|
|
|
|
|
}
|
2003-11-01 15:45:19 +00:00
|
|
|
|
bool dispatched() const {
|
|
|
|
|
return dispatched_;
|
|
|
|
|
}
|
2003-11-03 19:52:47 +00:00
|
|
|
|
void dispatched(bool dis) {
|
|
|
|
|
dispatched_ = dis;
|
|
|
|
|
}
|
|
|
|
|
bool update() const {
|
|
|
|
|
return update_;
|
|
|
|
|
}
|
|
|
|
|
void update(bool up) {
|
|
|
|
|
update_ = up;
|
|
|
|
|
}
|
2003-10-29 13:24:57 +00:00
|
|
|
|
private:
|
2003-11-01 15:45:19 +00:00
|
|
|
|
bool dispatched_;
|
2003-11-03 19:52:47 +00:00
|
|
|
|
bool update_;
|
2003-10-29 13:24:57 +00:00
|
|
|
|
dispatch_result_t val_;
|
2003-10-29 10:47:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-10-29 13:24:57 +00:00
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool operator==(DispatchResult const & lhs, DispatchResult const & rhs)
|
|
|
|
|
{
|
2003-11-01 15:45:19 +00:00
|
|
|
|
return lhs.dispatched() == rhs.dispatched() && lhs.val() == rhs.val();
|
2003-10-29 13:24:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool operator!=(DispatchResult const & lhs, DispatchResult const & rhs)
|
|
|
|
|
{
|
|
|
|
|
return !(lhs == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#endif // DISPATCH_RESULT_H
|