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