00001 #ifndef COIN_SOEVENTCALLBACK_H
00002 #define COIN_SOEVENTCALLBACK_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <Inventor/nodes/SoSubNode.h>
00028 #include <Inventor/lists/SbList.h>
00029
00030 #ifndef COIN_INTERNAL
00031
00032 #include <Inventor/actions/SoHandleEventAction.h>
00033 #endif // !COIN_INTERNAL
00034
00035 class SoEventCallback;
00036 class SoPath;
00037 class SoEvent;
00038 class SoPickedPoint;
00039 class SoHandleEventAction;
00040
00041 typedef void SoEventCallbackCB(void * userdata, SoEventCallback * node);
00042
00043 class COIN_DLL_API SoEventCallback : public SoNode {
00044 typedef SoNode inherited;
00045
00046 SO_NODE_HEADER(SoEventCallback);
00047
00048 public:
00049 static void initClass(void);
00050 SoEventCallback(void);
00051
00052 void setPath(SoPath * path);
00053 const SoPath * getPath(void);
00054
00055 void addEventCallback(SoType eventtype, SoEventCallbackCB * f,
00056 void * userdata = NULL);
00057 void removeEventCallback(SoType eventtype, SoEventCallbackCB * f,
00058 void * userdata = NULL);
00059
00060 SoHandleEventAction * getAction(void) const;
00061 const SoEvent * getEvent(void) const;
00062 const SoPickedPoint * getPickedPoint(void) const;
00063
00064 void setHandled(void);
00065 SbBool isHandled(void) const;
00066
00067 void grabEvents(void);
00068 void releaseEvents(void);
00069
00070 protected:
00071 virtual ~SoEventCallback();
00072
00073 virtual void handleEvent(SoHandleEventAction * action);
00074
00075 private:
00076
00077 struct CallbackInfo {
00078 SoEventCallbackCB * func;
00079 SoType eventtype;
00080 void * userdata;
00081
00082
00083
00084
00085
00086 SbBool operator==(const CallbackInfo & cbi) {
00087 return this->func == cbi.func && this->eventtype == cbi.eventtype && this->userdata == cbi.userdata;
00088 }
00089 SbBool operator!=(const CallbackInfo & cbi) {
00090 return !(*this == cbi);
00091 }
00092 };
00093
00094 SbList<CallbackInfo> callbacks;
00095 SoHandleEventAction * heaction;
00096 SoPath * path;
00097
00098 };
00099
00100 #endif // !COIN_SOEVENTCALLBACK_H