Open Inventor Reference
SoEventCallback.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | SoEventCallback node class - invokes callbacks when the handle
48  | event action is applied to this node.
49  |
50  | Author(s): David Mott
51  |
52  ______________ S I L I C O N G R A P H I C S I N C . ____________
53  _______________________________________________________________________
54  */
55 
56 #ifndef _SO_EVENT_CALLBACK_
57 #define _SO_EVENT_CALLBACK_
58 
60 #include <Inventor/SoPath.h>
63 
64 class SoEvent;
65 class SoEventCallback;
66 
68 typedef void INVENTOR_API SoEventCallbackCB(void *userData, SoEventCallback *node);
69 
70 
73 
96 
98 
100 
101  public:
102 
106 
108  void setPath(SoPath *path);
116  const SoPath * getPath() { return pathOfInterest; }
117 
129  void addEventCallback(SoType eventType,
131  void *userData = NULL);
133  void removeEventCallback(SoType eventType,
135  void *userData = NULL);
136 
138  //
139  // These all provide information to callback functions. They
140  // return NULL when called from anywhere but a callback function.
141  //
142 
146  SoHandleEventAction * getAction() const { return eventAction; }
147 
151  const SoEvent * getEvent() const
152  { return (eventAction != NULL ? eventAction->getEvent() : NULL); }
153 
158  { return (eventAction != NULL ? eventAction->getPickedPoint() : NULL);}
159 
161 
169  void setHandled()
170  { if (eventAction != NULL) eventAction->setHandled(); }
171 
174  bool isHandled() const
175  { return (eventAction != NULL) ? eventAction->isHandled() : FALSE; }
176 
181  void grabEvents()
182  { if (eventAction != NULL) eventAction->setGrabber(this); }
183 
187  { if (eventAction != NULL) eventAction->releaseGrabber(); }
188 
189  SoINTERNAL public:
190  static void initClass();
191 
192  protected:
194  virtual ~SoEventCallback();
195 
197  virtual void handleEvent(SoHandleEventAction *ha);
198 
199  private:
202  SoPath *pathOfInterest;
203 
205  SbPList * cblist;
206 
209  SoHandleEventAction *eventAction;
210 
213  void invokeCallbacks(const SoEvent *e);
214 };
215 
216 #endif /* _SO_EVENT_CALLBACK_ */
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
void INVENTOR_API SoEventCallbackCB(void *userData, SoEventCallback *node)
callback function prototypes
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition: SoSubNode.h:170
List of generic (void *) pointers.
Definition: SbPList.h:78
Node which invokes callbacks for events.
const SoPath * getPath()
Set and get the path which must be picked in order for the callbacks to be invoked.
void removeEventCallback(SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
Removes the given callback function.
bool isHandled() const
Returns whether the event has been handled.
void releaseEvents()
Release the grabbing of events.
SoEventCallback()
Constructor creates an event callback node with no event interest and a NULL path.
SoHandleEventAction * getAction() const
Returns the SoHandleEventAction currently traversing this node, or NULL if traversal is not taking pl...
const SoPickedPoint * getPickedPoint() const
Returns pick information during SoHandleEventAction traversal, or NULL if traversal is not taking pla...
virtual ~SoEventCallback()
Destructor - protected since ref/unref is what should destroy this.
const SoEvent * getEvent() const
Returns the event currently being handled, or NULL if traversal is not taking place.
static void initClass()
initialize the class
void grabEvents()
Tells the event callback node to grab events or release the grab.
virtual void handleEvent(SoHandleEventAction *ha)
This will be called during handleEventAction traversal.
void setHandled()
Tells the node the event was handled.
void addEventCallback(SoType eventType, SoEventCallbackCB *f, void *userData=NULL)
Specifies the callback functions to be invoked for different event types.
void setPath(SoPath *path)
Base class for all events.
Definition: SoEvent.h:84
Allows nodes in a graph to receive input events.
Abstract base class for all database nodes.
Definition: SoNode.h:103
Path that points to a list of hierarchical nodes.
Definition: SoPath.h:109
Represents point on surface of picked object.
Definition: SoPickedPoint.h:89
SoType has no virtual functions to keep it small...
Definition: SoType.h:103