Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSBASEEVENTH_H__
00020 #define __CS_CSBASEEVENTH_H__
00021
00022 #include "csextern.h"
00023
00031 #include "csutil/eventhandlers.h"
00032 #include "csutil/ref.h"
00033 #include "csutil/scf_implementation.h"
00034 #include "iutil/event.h"
00035 #include "iutil/eventh.h"
00036 #include "iutil/eventq.h"
00037
00038 #include <limits.h>
00039
00040 struct iEventQueue;
00041 struct iObjectRegistry;
00042
00043
00044 #define _CSBASEEVENT_MAXARRAYINDEX csevFrameStart
00045
00058 class CS_CRYSTALSPACE_EXPORT csBaseEventHandler
00059 {
00060 private:
00061 csRef<iEventQueue> queue;
00062
00063 protected:
00064 iObjectRegistry *object_registry;
00065 csHandlerID self;
00066 csEventID FrameEvent;
00067
00074 class CS_CRYSTALSPACE_EXPORT EventHandlerImpl : public
00075 scfImplementation1<EventHandlerImpl, iEventHandler>
00076 {
00077 friend class csBaseEventHandler;
00078 csBaseEventHandler* parent;
00079 public:
00080 EventHandlerImpl (csBaseEventHandler* parent);
00081 virtual bool HandleEvent (iEvent &event)
00082 {
00083 if (!parent) return false;
00084 return parent->HandleEvent (event);
00085 }
00086 virtual const char *GenericName() const
00087 {
00088 if (!parent) return "application";
00089 return parent->GenericName();
00090 }
00091 virtual csHandlerID GenericID(
00092 csRef<iEventHandlerRegistry>& reg) const
00093 {
00094 if (!parent) return CS_HANDLER_INVALID;
00095 return parent->GenericID (reg);
00096 }
00097 virtual const csHandlerID *GenericPrec (
00098 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg,
00099 csEventID id) const
00100 {
00101 if (!parent) return 0;
00102 return parent->GenericPrec (hreg, nreg, id);
00103 }
00104 virtual const csHandlerID *GenericSucc (
00105 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg,
00106 csEventID id) const
00107 {
00108 if (!parent) return 0;
00109 return parent->GenericSucc (hreg, nreg, id);
00110 }
00111 virtual const csHandlerID *InstancePrec (
00112 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg,
00113 csEventID id) const
00114 {
00115 if (!parent) return 0;
00116 return parent->InstancePrec (hreg, nreg, id);
00117 }
00118 virtual const csHandlerID *InstanceSucc(
00119 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg,
00120 csEventID id) const
00121 {
00122 if (!parent) return 0;
00123 return parent->InstanceSucc (hreg, nreg, id);
00124 }
00125 };
00126 csRef<EventHandlerImpl> eventh;
00127
00137 csBaseEventHandler ();
00138
00139 public:
00141 virtual ~csBaseEventHandler ();
00142
00147 void Initialize (iObjectRegistry *registry);
00148
00157 bool RegisterQueue (iObjectRegistry* registry, csEventID name);
00158
00168 bool RegisterQueue (iObjectRegistry* registry, csEventID names[]);
00169
00177 bool RegisterQueue (iEventQueue* queue, csEventID name);
00186 bool RegisterQueue (iEventQueue* queue, csEventID names[]);
00191 void UnregisterQueue ();
00192
00193 protected:
00214 virtual bool HandleEvent (iEvent &event);
00215
00221 virtual const char *GenericName() const
00222 { return "application"; }
00223
00224 virtual csHandlerID GenericID (
00225 csRef<iEventHandlerRegistry>& reg) const
00226 {
00227 return reg->GetGenericID (GenericName ());
00228 }
00229
00234 virtual const csHandlerID *GenericPrec (
00235 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&,
00236 csEventID) const
00237 { return 0; }
00238
00243 virtual const csHandlerID *GenericSucc (
00244 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&,
00245 csEventID) const
00246 { return 0; }
00247
00252 virtual const csHandlerID *InstancePrec (
00253 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&,
00254 csEventID) const
00255 { return 0; }
00256
00261 virtual const csHandlerID *InstanceSucc (
00262 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&,
00263 csEventID) const
00264 { return 0; }
00265
00267 virtual bool OnJoystickMove (iEvent &event);
00268
00273 virtual bool OnJoystickDown (iEvent &event);
00274
00276 virtual bool OnJoystickUp (iEvent &event);
00277
00279 virtual bool OnKeyboard (iEvent &event);
00280
00282 virtual bool OnMouseMove (iEvent &event);
00283
00285 virtual bool OnMouseDown (iEvent &event);
00286
00288 virtual bool OnMouseUp (iEvent &event);
00289
00291 virtual bool OnMouseClick (iEvent &event);
00292
00297 virtual bool OnMouseDoubleClick (iEvent &event);
00298
00305 virtual bool OnUnhandledEvent (iEvent &event);
00306
00308 virtual void Frame ();
00309
00310
00311 CS_DEPRECATED_METHOD_MSG("Use signpost event handlers for frame preprocessing")
00312 virtual void PreProcessFrame () {}
00313 CS_DEPRECATED_METHOD_MSG("Use Frame() method for main frame processing")
00314 virtual void ProcessFrame () {}
00315 CS_DEPRECATED_METHOD_MSG("Use signpost event handlers for frame postprocessing")
00316 virtual void PostProcessFrame () {}
00317 CS_DEPRECATED_METHOD_MSG("Use FramePrinter for frame finishing or "
00318 "signpost event handlers for frame finalization")
00319 virtual void FinishFrame () {}
00320 };
00321
00324 #endif //__CS_CSBASEEVENTH_H__