Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HEventListener.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: 0341c015a3045ba9366a45b6212bebf36aa45b21 $
13 //
14 
19 #ifndef _HEVENTLISTENER_H
20 #define _HEVENTLISTENER_H
21 
22 #ifdef H_PACK_8
23 #pragma pack(push)
24 #pragma pack(8)
25 #endif
26 
27 #include "HTools.h"
28 #include "HEventInfo.h"
29 
30 #include "HDB.h"
31 
32 class HBhvAnimation;
33 class HBhvTargetObject;
34 class HEventListener;
35 class HBhvSensor;
36 
37 #define HLISTENER_PASS_EVENT 0
38 #define HLISTENER_CONSUME_EVENT 999
39 
41 #define HLISTENER_PRIORITY_NORMAL 5
42 
43 #define HLISTENER_PRIORITY_HIGH 10
44 
45 #define HLISTENER_PRIORITY_LOW 0
46 
59 };
60 
61 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 
63 #define HLISTENER_EVENT(listenertype, manager, function) { listenertype *el = (listenertype *)manager->GetEventListenerManager(listenertype::GetType()); \
64  if (el) \
65  el->function; }
66 #define HLISTENER_EVENT_STRING(listenertype, manager, function) { listenertype *el = (listenertype *)manager->GetEventListenerManager(listenertype::GetStringType()); \
67  if (el) \
68  el->function; }
69 
70 #define HLISTENER_FUNCTION_0(classname, method) \
71  virtual int method() { \
72  if (!m_pEventListenerManager) \
73  return 0; \
74  m_pEventListenerManager->StartQuery(); \
75  classname* listener; \
76  while ((listener = (classname*)m_pEventListenerManager->GetEventListener())) \
77  if (listener->method() == HLISTENER_CONSUME_EVENT) \
78  break; \
79  return 1; }
80 
81 
82 #define HLISTENER_FUNCTION_1(classname, method, param_type_1, param_1) \
83  virtual int method( param_type_1 param_1 ) { \
84  if (!m_pEventListenerManager) \
85  return 0; \
86  m_pEventListenerManager->StartQuery(); \
87  classname* listener; \
88  while ((listener = (classname*)m_pEventListenerManager->GetEventListener())) \
89  if (listener->method( param_1 ) == HLISTENER_CONSUME_EVENT) \
90  break; \
91  return 1; }
92 
93 #define HLISTENER_FUNCTION_2(classname, method, param_type_1, param_1, param_type_2, param_2) \
94  virtual int method( param_type_1 param_1 , param_type_2 param_2) { \
95  if (!m_pEventListenerManager) \
96  return 0; \
97  m_pEventListenerManager->StartQuery(); \
98  classname* listener; \
99  while ((listener = (classname*)m_pEventListenerManager->GetEventListener())) \
100  if (listener->method( param_1, param_2) == HLISTENER_CONSUME_EVENT) \
101  break; \
102  return 1; }
103 
104 #define HLISTENER_FUNCTION_3(classname, method, param_type_1, param_1, param_type_2, param_2, param_type_3, param_3) \
105  virtual int method( param_type_1 param_1 , param_type_2 param_2, param_type_3 param_3) { \
106  if (!m_pEventListenerManager) \
107  return 0; \
108  m_pEventListenerManager->StartQuery(); \
109  classname* listener; \
110  while ((listener = (classname*)m_pEventListenerManager->GetEventListener())) \
111  if (listener->method( param_1, param_2, param_3) == HLISTENER_CONSUME_EVENT) \
112  break; \
113  return 1; }
114 
115 #define HLISTENER_SETUP_FUNCTIONS(listenertype) \
116  static HEventListenerType GetType() { return listenertype##Type; } \
117  virtual HEventListener *CreateListenerManager() \
118  { HEventListener *temp = (HEventListener *)new listenertype(); \
119  temp->ConvertToManager(); \
120  return temp; \
121  }
122 
123 #define HLISTENER_SETUP_FUNCTIONS_STRING(listenertype, stringtype) \
124 static HEventListenerType GetType() { return HUserdefinerListenerType; } \
125  static const char * GetStringType() { return stringtype; } \
126  virtual HEventListener *CreateListenerManager() \
127  { HEventListener *temp = (HEventListener *)new listenertype(); \
128  temp->ConvertToManager(); \
129  return temp; \
130  }
131 
132 #endif //DOXYGEN_SHOULD_SKIP_THIS
133 
134 class HMouseListenerManager;
135 class HUpdateListenerManager;
136 
137 
138 
139 
140 
143 {
144 public:
149  virtual ~HEventListenerManager();
150 
151 
158  void AddEventListener(HEventListener *eventlistener, int priority);
159 
164  void Reset();
168  void StartQuery();
169 
176  HEventListener * GetEventListener();
177 
183  bool RemoveEventListener(HEventListener *eventlistener);
184 
185 protected:
186  struct vlist_s * m_pEventListenerList;
188 };
189 
190 
191 
192 
193 
195 
199 class MVO_API HEventListener
200 {
201 public:
205  HEventListener() { m_pEventListenerManager = 0; m_RequestedPriority = -1; }
206  virtual ~HEventListener() {
207  if (m_pEventListenerManager)
208  delete m_pEventListenerManager;
209  };
214  if (m_pEventListenerManager == 0)
215  m_pEventListenerManager = new HEventListenerManager;
216 
217  }
222  virtual HEventListener *CreateListenerManager() { return 0;}
226  HEventListenerManager * GetEventListenerManager() {return m_pEventListenerManager; }
231  void SetRequestedPriority(int v) { m_RequestedPriority = v; }
232 
236  int GetRequestedPriority() { return m_RequestedPriority; }
237 protected:
240 };
241 
242 
243 
244 #ifndef DOXYGEN_SHOULD_SKIP_THIS
245 
246 
248 class MVO_API HUpdateListener : public HEventListener
249 {
250 public:
254  HLISTENER_SETUP_FUNCTIONS(HUpdateListener);
255  HLISTENER_FUNCTION_1(HUpdateListener, CameraChangedEvent, HBaseView *, view);
256  HLISTENER_FUNCTION_2(HUpdateListener, UpdateEvent, bool, antialias, bool, forceUpdate);
257  HLISTENER_FUNCTION_1(HUpdateListener, ViewDestroyedEvent, HBaseView *, view);
258  HLISTENER_FUNCTION_1(HUpdateListener, SmoothTransitionFinishedEvent, HBaseView *, view);
259 
260 
261 };
262 
264 class MVO_API HFitWorldListener : public HEventListener
265 {
266 public:
270  HLISTENER_SETUP_FUNCTIONS(HFitWorldListener);
271  HLISTENER_FUNCTION_1(HFitWorldListener, PreFitWorldEvent, HBaseView *, view);
272  HLISTENER_FUNCTION_1(HFitWorldListener, PostFitWorldEvent, HBaseView *, view);
273 
274 };
275 
277 class MVO_API HObjectManipulationListener : public HEventListener
278 {
279 public:
283  HLISTENER_SETUP_FUNCTIONS(HObjectManipulationListener);
284  HLISTENER_FUNCTION_3(HObjectManipulationListener, SetupHandlesEvent, HBaseView *, view, HC_KEY, key, bool, complex);
285  HLISTENER_FUNCTION_3(HObjectManipulationListener, ObjectBeforeMoveEvent, HBaseView *, view, HC_KEY, key, HPoint *, p);
286  HLISTENER_FUNCTION_3(HObjectManipulationListener, ObjectMovedEvent, HBaseView *, view, HC_KEY, key, HPoint *, p);
287  HLISTENER_FUNCTION_3(HObjectManipulationListener, ObjectScaledEvent, HBaseView *, view, HC_KEY, key, HPoint &, p);
288 
289 };
290 
291 
293 class MVO_API HAnimationListener : public HEventListener
294 {
295 public:
299  HLISTENER_SETUP_FUNCTIONS(HAnimationListener)
300 
301  HLISTENER_FUNCTION_1(HAnimationListener, AnimationFinishedEvent, HBhvAnimation *, ainst)
302  HLISTENER_FUNCTION_1(HAnimationListener, KeyframeEditorExistsQuery, bool &, res)
303  HLISTENER_FUNCTION_0(HAnimationListener, KeyframeAddedEvent)
304  HLISTENER_FUNCTION_1(HAnimationListener, ObjectCollisionEvent, HBhvTargetObject *, tob)
305  HLISTENER_FUNCTION_1(HAnimationListener, ObjectNoCollisionEvent, HBhvTargetObject *, tob)
306 
307 
308 };
309 
311 class MVO_API HSensorListener : public HEventListener
312 {
313 public:
317  HLISTENER_SETUP_FUNCTIONS(HSensorListener)
318  HLISTENER_FUNCTION_1(HSensorListener, SensorActivatedEvent, HBhvSensor *, sensor)
319  HLISTENER_FUNCTION_1(HSensorListener, SensorActionEvent, const char *, action)
320 
321 };
322 
323 
324 
326 class MVO_API HMouseListener : public HEventListener
327 {
328 public:
332  HLISTENER_SETUP_FUNCTIONS(HMouseListener)
333 
334  HLISTENER_FUNCTION_1(HMouseListener, OnLButtonDown, HEventInfo &, hevent)
335  HLISTENER_FUNCTION_1(HMouseListener, OnMouseMove, HEventInfo &, hevent)
336  HLISTENER_FUNCTION_1(HMouseListener, OnLButtonUp, HEventInfo &, hevent)
337  HLISTENER_FUNCTION_1(HMouseListener, OnLButtonDblClk, HEventInfo &, hevent)
338  HLISTENER_FUNCTION_1(HMouseListener, OnMButtonDown, HEventInfo &, hevent)
339  HLISTENER_FUNCTION_1(HMouseListener, OnMButtonUp, HEventInfo &, hevent)
340  HLISTENER_FUNCTION_1(HMouseListener, OnMButtonDblClk, HEventInfo &, hevent)
341  HLISTENER_FUNCTION_1(HMouseListener, OnRButtonDown, HEventInfo &, hevent)
342  HLISTENER_FUNCTION_1(HMouseListener, OnRButtonUp, HEventInfo &, hevent)
343  HLISTENER_FUNCTION_1(HMouseListener, OnRButtonDblClk, HEventInfo &, hevent)
344  HLISTENER_FUNCTION_1(HMouseListener, OnMouseWheel, HEventInfo &, hevent)
345  HLISTENER_FUNCTION_1(HMouseListener, OnKeyDown, HEventInfo &, hevent)
346  HLISTENER_FUNCTION_1(HMouseListener, OnKeyUp, HEventInfo &, hevent)
347  HLISTENER_FUNCTION_1(HMouseListener, OnTouchesDown, HEventInfo &, hevent)
348  HLISTENER_FUNCTION_1(HMouseListener, OnTouchesMove, HEventInfo &, hevent)
349  HLISTENER_FUNCTION_1(HMouseListener, OnTouchesUp, HEventInfo &, hevent)
350 
351 };
352 
354 class MVO_API HJoyStickListener : public HEventListener
355 {
356 public:
360  HLISTENER_SETUP_FUNCTIONS(HJoyStickListener)
361 
362  HLISTENER_FUNCTION_1(HJoyStickListener, OnJoyStickRotation, HEventInfo &, hevent)
363  HLISTENER_FUNCTION_1(HJoyStickListener, OnJoyStickTranslation, HEventInfo &, hevent)
364  HLISTENER_FUNCTION_1(HJoyStickListener, OnJoyStickButton, HEventInfo &, hevent)
365 };
366 
367 #endif //DOXYGEN_SHOULD_SKIP_THIS
368 
369 
370 #ifdef H_PACK_8
371 #pragma pack(pop)
372 #endif
373 
374 #endif
375 
376 
377 
378 
void ConvertToManager()
Definition: HEventListener.h:213
self-explanatory
Definition: HEventListener.h:51
bool m_bQueryInProgress
Definition: HEventListener.h:187
virtual HEventListener * CreateListenerManager()
Definition: HEventListener.h:222
int m_RequestedPriority
Definition: HEventListener.h:239
HEventListenerManager * m_pEventListenerManager
Definition: HEventListener.h:238
HEventListener()
Definition: HEventListener.h:205
The HEventListener class is the base class for all event types.
Definition: HEventListener.h:199
The HBhvTargetObject class encapsulates various target types for animations and sensors.
Definition: HBhvBehaviorManager.h:86
Listens for mouse events like mouse moves and double clicks.
Definition: HEventListener.h:53
The HBhvSensor class encapsulates an animation sensor.
Definition: HBhvSensor.h:38
Listens when sensors are activated.
Definition: HEventListener.h:55
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:337
int GetRequestedPriority()
Definition: HEventListener.h:236
Listens for animation events like when key frames are added or when objects collide.
Definition: HEventListener.h:54
HEventListenerType
Definition: HEventListener.h:50
The HBhvAnimation class defines an animation.
Definition: HBhvAnimation.h:47
void SetRequestedPriority(int v)
Definition: HEventListener.h:231
HEventListenerManager * GetEventListenerManager()
Definition: HEventListener.h:226
The HEventInfo class stores and manages event information.
Definition: HEventInfo.h:214
Listens for 3DMouse/Joystick translation and rotation events.
Definition: HEventListener.h:58
The HEventListenerManager class is used to dispatch event for a specific type.
Definition: HEventListener.h:142
Listens for when fit world event will happen.
Definition: HEventListener.h:56
Listens for object manipulation events like when objects are moved or scaled.
Definition: HEventListener.h:57
Listens for update events like camera changed or view destroyed.
Definition: HEventListener.h:52
Interface of the HEventInfo class.
struct vlist_s * m_pEventListenerList
Definition: HEventListener.h:186