2002-11-16 02:11:44 +00:00
|
|
|
#ifndef __eventdispatcher
|
|
|
|
#define __eventdispatcher
|
|
|
|
|
|
|
|
#include "eventhandler.hh"
|
|
|
|
#include <map>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace otk {
|
|
|
|
|
|
|
|
typedef std::map<unsigned int, OtkEventHandler *> OtkEventMap;
|
|
|
|
|
|
|
|
class OtkEventDispatcher {
|
|
|
|
public:
|
|
|
|
|
|
|
|
OtkEventDispatcher();
|
|
|
|
virtual ~OtkEventDispatcher();
|
|
|
|
|
|
|
|
virtual void clearAllHandlers(void);
|
2002-12-24 21:27:16 +00:00
|
|
|
virtual void registerHandler(Window id, otk::OtkEventHandler *handler);
|
2002-11-16 02:11:44 +00:00
|
|
|
virtual void clearHandler(Window id);
|
|
|
|
virtual void dispatchEvents(void);
|
|
|
|
|
2002-12-24 21:27:16 +00:00
|
|
|
inline void setFallbackHandler(otk::OtkEventHandler *fallback)
|
2002-11-16 02:11:44 +00:00
|
|
|
{ _fallback = fallback; }
|
2002-12-24 21:27:16 +00:00
|
|
|
otk::OtkEventHandler *getFallbackHandler(void) const { return _fallback; }
|
2002-11-16 02:11:44 +00:00
|
|
|
|
2002-12-04 07:55:52 +00:00
|
|
|
//! Sets an event handler that gets all events for all handlers after
|
|
|
|
//! any specific handlers have received them
|
2002-12-24 21:27:16 +00:00
|
|
|
inline void setMasterHandler(otk::OtkEventHandler *master)
|
2002-12-04 07:55:52 +00:00
|
|
|
{ _master = master; }
|
2002-12-24 21:27:16 +00:00
|
|
|
otk::OtkEventHandler *getMasterHandler(void) const { return _master; }
|
2002-12-18 11:34:29 +00:00
|
|
|
|
2002-12-24 21:27:16 +00:00
|
|
|
otk::OtkEventHandler *findHandler(Window win);
|
2003-01-04 01:18:24 +00:00
|
|
|
|
|
|
|
inline Time lastTime() const { return _lasttime; }
|
2002-12-04 07:55:52 +00:00
|
|
|
|
2002-11-16 02:11:44 +00:00
|
|
|
private:
|
|
|
|
OtkEventMap _map;
|
|
|
|
OtkEventHandler *_fallback;
|
2002-12-04 07:55:52 +00:00
|
|
|
OtkEventHandler *_master;
|
2002-11-16 02:11:44 +00:00
|
|
|
|
2002-11-17 09:41:58 +00:00
|
|
|
//! The time at which the last XEvent with a time was received
|
2003-01-04 01:18:24 +00:00
|
|
|
Time _lasttime;
|
2002-12-25 22:02:34 +00:00
|
|
|
|
2003-01-07 09:30:00 +00:00
|
|
|
void dispatch(Window win, const XEvent &e);
|
2002-11-16 02:11:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|