csutil/csbaseeventh.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2003 by Odes B. Boatwright. 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 // Max event type (in event type enumeration) that will be handled. 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 CS_DEPRECATED_VAR(csEventID PreProcess); 00068 CS_DEPRECATED_VAR(csEventID Process); 00069 CS_DEPRECATED_VAR(csEventID PostProcess); 00070 CS_DEPRECATED_VAR(csEventID FinalProcess); 00071 00078 class CS_CRYSTALSPACE_EXPORT EventHandlerImpl : public 00079 scfImplementation1<EventHandlerImpl, iEventHandler> 00080 { 00081 friend class csBaseEventHandler; 00082 csBaseEventHandler* parent; 00083 public: 00084 EventHandlerImpl (csBaseEventHandler* parent); 00085 virtual bool HandleEvent (iEvent &event) 00086 { 00087 if (!parent) return false; 00088 return parent->HandleEvent (event); 00089 } 00090 virtual const char *GenericName() const 00091 { 00092 if (!parent) return "application"; 00093 return parent->GenericName(); 00094 } 00095 virtual csHandlerID GenericID( 00096 csRef<iEventHandlerRegistry>& reg) const 00097 { 00098 if (!parent) return CS_HANDLER_INVALID; 00099 return parent->GenericID (reg); 00100 } 00101 virtual const csHandlerID *GenericPrec ( 00102 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00103 csEventID id) const 00104 { 00105 if (!parent) return 0; 00106 return parent->GenericPrec (hreg, nreg, id); 00107 } 00108 virtual const csHandlerID *GenericSucc ( 00109 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00110 csEventID id) const 00111 { 00112 if (!parent) return 0; 00113 return parent->GenericSucc (hreg, nreg, id); 00114 } 00115 virtual const csHandlerID *InstancePrec ( 00116 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00117 csEventID id) const 00118 { 00119 if (!parent) return 0; 00120 return parent->InstancePrec (hreg, nreg, id); 00121 } 00122 virtual const csHandlerID *InstanceSucc( 00123 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00124 csEventID id) const 00125 { 00126 if (!parent) return 0; 00127 return parent->InstanceSucc (hreg, nreg, id); 00128 } 00129 }; 00130 csRef<EventHandlerImpl> eventh; 00131 00141 csBaseEventHandler (); 00142 00143 public: 00145 virtual ~csBaseEventHandler (); 00146 00151 void Initialize (iObjectRegistry *registry); 00152 00161 bool RegisterQueue (iObjectRegistry* registry, csEventID name); 00162 00172 bool RegisterQueue (iObjectRegistry* registry, csEventID names[]); 00173 00181 bool RegisterQueue (iEventQueue* queue, csEventID name); 00190 bool RegisterQueue (iEventQueue* queue, csEventID names[]); 00195 void UnregisterQueue (); 00196 00197 protected: 00218 virtual bool HandleEvent (iEvent &event); 00219 00225 virtual const char *GenericName() const 00226 { return "application"; } 00227 00228 virtual csHandlerID GenericID ( 00229 csRef<iEventHandlerRegistry>& reg) const 00230 { 00231 return reg->GetGenericID (GenericName ()); 00232 } 00233 00238 virtual const csHandlerID *GenericPrec ( 00239 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00240 csEventID) const 00241 { return 0; } 00242 00247 virtual const csHandlerID *GenericSucc ( 00248 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00249 csEventID) const 00250 { return 0; } 00251 00256 virtual const csHandlerID *InstancePrec ( 00257 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00258 csEventID) const 00259 { return 0; } 00260 00265 virtual const csHandlerID *InstanceSucc ( 00266 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00267 csEventID) const 00268 { return 0; } 00269 00271 virtual bool OnJoystickMove (iEvent &event); 00272 00277 virtual bool OnJoystickDown (iEvent &event); 00278 00280 virtual bool OnJoystickUp (iEvent &event); 00281 00283 virtual bool OnKeyboard (iEvent &event); 00284 00286 virtual bool OnMouseMove (iEvent &event); 00287 00289 virtual bool OnMouseDown (iEvent &event); 00290 00292 virtual bool OnMouseUp (iEvent &event); 00293 00295 virtual bool OnMouseClick (iEvent &event); 00296 00301 virtual bool OnMouseDoubleClick (iEvent &event); 00302 00309 virtual bool OnUnhandledEvent (iEvent &event); 00310 00312 virtual void Frame (); 00313 00315 CS_DEPRECATED_METHOD virtual void PreProcessFrame (); 00316 00318 CS_DEPRECATED_METHOD virtual void ProcessFrame (); 00319 00321 CS_DEPRECATED_METHOD virtual void PostProcessFrame (); 00322 00324 CS_DEPRECATED_METHOD virtual void FinishFrame (); 00325 }; 00326 00329 #endif //__CS_CSBASEEVENTH_H__
Generated for Crystal Space 1.4.1 by doxygen 1.7.1