16#ifndef OSGWIDGET_EVENT_INTERFACE
17#define OSGWIDGET_EVENT_INTERFACE
164 virtual const char*
className()
const {
return "osgWidget::CallbackInterface"; }
178 _callback (callback) {}
181 return (_object->*_callback)(ev);
212 virtual const char*
className()
const {
return "osgWidget::Callback"; }
273 _eventMask (ei._eventMask),
274 _callbacks (ei._callbacks) {}
323 _callbacks.push_back(cb);
329 for(CallbackList::iterator i = _callbacks.begin(); i != _callbacks.end(); i++) {
333 if(i->get()->getType() & ev.
type) {
334 ev.
setData(i->get()->getData());
336 if((*i->get())(ev))
return true;
346 bool handled =
false;
409 unsigned int _eventMask;
410 CallbackList _callbacks;
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgWidget library is a NodeKit that extends the core scene graph to support a 2D (and eventually ...
Definition Box:21
EventType
Definition EventInterface:33
@ EVENT_UNFOCUS
Definition EventInterface:36
@ EVENT_MOUSE_SCROLL
Definition EventInterface:43
@ EVENT_MOUSE_ENTER
Definition EventInterface:37
@ EVENT_MOUSE_RELEASE
Definition EventInterface:42
@ EVENT_MOUSE_OVER
Definition EventInterface:38
@ EVENT_FOCUS
Definition EventInterface:35
@ EVENT_ALL
Definition EventInterface:46
@ EVENT_KEY_UP
Definition EventInterface:45
@ EVENT_NONE
Definition EventInterface:34
@ EVENT_MOUSE_DRAG
Definition EventInterface:40
@ EVENT_MOUSE_LEAVE
Definition EventInterface:39
@ EVENT_MOUSE_PUSH
Definition EventInterface:41
@ EVENT_KEY_DOWN
Definition EventInterface:44
EventMask
Definition EventInterface:52
@ EVENT_MASK_MOUSE_CLICK
Definition EventInterface:55
@ EVENT_MASK_MOUSE_DRAG
Definition EventInterface:56
@ EVENT_MASK_FOCUS
Definition EventInterface:53
@ EVENT_MASK_MOUSE_MOVE
Definition EventInterface:54
@ EVENT_MASK_KEY
Definition EventInterface:57
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Definition EventInterface:61
Event & makeType(EventType _type)
Definition EventInterface:81
double x
Definition EventInterface:64
void * _data
Definition EventInterface:147
WindowManager * getWindowManager()
Definition EventInterface:105
Window * _window
Definition EventInterface:145
Event(WindowManager *wm, EventType _type=EVENT_NONE)
Definition EventInterface:69
Event & makeMouse(double _x, double _y, EventType _type=EVENT_NONE)
Definition EventInterface:87
void setData(void *data)
Definition EventInterface:135
EventType type
Definition EventInterface:63
int keyMask
Definition EventInterface:67
void * getData()
Definition EventInterface:127
friend class Window
Definition EventInterface:142
int key
Definition EventInterface:66
Widget * getWidget()
Definition EventInterface:119
double y
Definition EventInterface:65
friend class WindowManager
Definition EventInterface:141
Widget * _widget
Definition EventInterface:146
WindowManager * _wm
Definition EventInterface:144
const void * getData() const
Definition EventInterface:131
Window * getWindow()
Definition EventInterface:111
const Window * getWindow() const
Definition EventInterface:115
Event & makeKey(int _key, int _keyMask, EventType _type=EVENT_NONE)
Definition EventInterface:96
const WindowManager * getWindowManager() const
Definition EventInterface:107
const Widget * getWidget() const
Definition EventInterface:123
Definition EventInterface:161
virtual const char * className() const
Definition EventInterface:164
virtual bool operator()(Event &)=0
virtual ~CallbackInterface()
Definition EventInterface:162
Definition EventInterface:172
bool(T::* ObjectCallbackType)(Event &)
Definition EventInterface:174
virtual bool operator()(Event &ev)
Definition EventInterface:180
ObjectCallback(ObjectCallbackType callback, T *obj)
Definition EventInterface:176
Definition EventInterface:192
FunctionCallback(T *callback)
Definition EventInterface:194
virtual bool operator()(Event &ev)
Definition EventInterface:198
T * _callback
Definition EventInterface:202
Definition EventInterface:207
void * getData()
Definition EventInterface:249
virtual const char * className() const
Definition EventInterface:212
Callback(bool(T::*function)(Event &), T *obj, EventType type, void *data=0)
Definition EventInterface:223
void * _data
Definition EventInterface:259
virtual bool operator()(Event &ev)
Definition EventInterface:239
Callback()
Definition EventInterface:209
osg::ref_ptr< CallbackInterface > _callback
Definition EventInterface:262
Callback(EventType type, void *data=0)
Definition EventInterface:215
Callback(T *functor, EventType type, void *data=0)
Definition EventInterface:231
const void * getData() const
Definition EventInterface:253
Callback(const Callback &rhs)
Definition EventInterface:210
EventType _type
Definition EventInterface:258
virtual ~Callback()
Definition EventInterface:237
EventType getType() const
Definition EventInterface:245
void addCallback(Callback *cb)
Definition EventInterface:322
const CallbackList & getCallbacks() const
Definition EventInterface:320
virtual bool keyUp(int, int, const WindowManager *)
Definition EventInterface:299
bool canMousePush() const
Definition EventInterface:400
std::list< osg::ref_ptr< Callback > > CallbackList
Definition EventInterface:317
void addEventMask(unsigned int mask)
Definition EventInterface:305
EventInterface(const EventInterface &ei)
Definition EventInterface:272
bool canKeyDown() const
Definition EventInterface:404
EventInterface()
Definition EventInterface:270
bool canUnfocus() const
Definition EventInterface:394
bool canMouseEnter() const
Definition EventInterface:396
unsigned int getEventMask() const
Definition EventInterface:313
virtual bool mouseScroll(double, double, const WindowManager *)
Definition EventInterface:294
virtual bool mouseOver(double, double, const WindowManager *)
Definition EventInterface:289
virtual bool unfocus(const WindowManager *)
Definition EventInterface:285
virtual bool mousePush(double, double, const WindowManager *)
Definition EventInterface:292
void setEventMask(unsigned int mask)
Definition EventInterface:301
virtual bool mouseEnter(double, double, const WindowManager *)
Definition EventInterface:288
bool canFocus() const
Definition EventInterface:393
virtual ~EventInterface()
Definition EventInterface:276
CallbackList & getCallbacks()
Definition EventInterface:319
virtual bool focus(const WindowManager *)
Definition EventInterface:284
virtual bool mouseDrag(double, double, const WindowManager *)
Definition EventInterface:291
virtual bool mouseRelease(double, double, const WindowManager *)
Definition EventInterface:293
bool canMouseScroll() const
Definition EventInterface:402
void removeEventMask(unsigned int mask)
Definition EventInterface:309
bool canMouseLeave() const
Definition EventInterface:398
bool canMouseDrag() const
Definition EventInterface:399
bool canMouseRelease() const
Definition EventInterface:401
bool callCallbacks(Event &ev)
Definition EventInterface:326
virtual bool mouseLeave(double, double, const WindowManager *)
Definition EventInterface:290
virtual bool keyDown(int, int, const WindowManager *)
Definition EventInterface:298
bool canMouseOver() const
Definition EventInterface:397
bool canKeyUp() const
Definition EventInterface:405
bool callMethodAndCallbacks(Event &ev)
Definition EventInterface:343
Definition WindowManager:39
#define OSGWIDGET_EXPORT
Definition Export:42