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 00037 #include <limits.h> 00038 00039 struct iEventQueue; 00040 struct iObjectRegistry; 00041 00042 // Max event type (in event type enumeration) that will be handled. 00043 #define _CSBASEEVENT_MAXARRAYINDEX csevFrameStart 00044 00057 class CS_CRYSTALSPACE_EXPORT csBaseEventHandler 00058 { 00059 private: 00060 csRef<iEventQueue> queue; 00061 00062 protected: 00063 iObjectRegistry *object_registry; 00064 csHandlerID self; 00065 csEventID FrameEvent; 00066 csEventID PreProcess; 00067 csEventID Process; 00068 csEventID PostProcess; 00069 csEventID FinalProcess; 00070 00077 class CS_CRYSTALSPACE_EXPORT EventHandlerImpl : public 00078 scfImplementation1<EventHandlerImpl, iEventHandler> 00079 { 00080 friend class csBaseEventHandler; 00081 csBaseEventHandler* parent; 00082 public: 00083 EventHandlerImpl (csBaseEventHandler* parent); 00084 virtual bool HandleEvent (iEvent &event) 00085 { 00086 if (!parent) return false; 00087 return parent->HandleEvent (event); 00088 } 00089 CS_CONST_METHOD virtual const char *GenericName() const 00090 { 00091 if (!parent) return "application"; 00092 return parent->GenericName(); 00093 } 00094 CS_CONST_METHOD virtual csHandlerID GenericID( 00095 csRef<iEventHandlerRegistry>& reg) const 00096 { 00097 if (!parent) return CS_HANDLER_INVALID; 00098 return parent->GenericID (reg); 00099 } 00100 CS_CONST_METHOD virtual const csHandlerID *GenericPrec ( 00101 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00102 csEventID id) const 00103 { 00104 if (!parent) return 0; 00105 return parent->GenericPrec (hreg, nreg, id); 00106 } 00107 CS_CONST_METHOD virtual const csHandlerID *GenericSucc ( 00108 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00109 csEventID id) const 00110 { 00111 if (!parent) return 0; 00112 return parent->GenericSucc (hreg, nreg, id); 00113 } 00114 CS_CONST_METHOD virtual const csHandlerID *InstancePrec ( 00115 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00116 csEventID id) const 00117 { 00118 if (!parent) return 0; 00119 return parent->InstancePrec (hreg, nreg, id); 00120 } 00121 CS_CONST_METHOD virtual const csHandlerID *InstanceSucc( 00122 csRef<iEventHandlerRegistry>& hreg, csRef<iEventNameRegistry>& nreg, 00123 csEventID id) const 00124 { 00125 if (!parent) return 0; 00126 return parent->InstanceSucc (hreg, nreg, id); 00127 } 00128 }; 00129 csRef<EventHandlerImpl> eventh; 00130 00140 csBaseEventHandler (); 00141 00142 public: 00144 virtual ~csBaseEventHandler (); 00145 00150 void Initialize (iObjectRegistry *registry); 00151 00160 bool RegisterQueue (iObjectRegistry* registry, csEventID name); 00161 00171 bool RegisterQueue (iObjectRegistry* registry, csEventID names[]); 00172 00180 bool RegisterQueue (iEventQueue* queue, csEventID name); 00189 bool RegisterQueue (iEventQueue* queue, csEventID names[]); 00190 00191 protected: 00212 virtual bool HandleEvent (iEvent &event); 00213 00219 CS_CONST_METHOD virtual const char *GenericName() const 00220 { return "application"; } 00221 00222 CS_CONST_METHOD virtual csHandlerID GenericID ( 00223 csRef<iEventHandlerRegistry>& reg) const 00224 { 00225 return reg->GetGenericID (GenericName ()); 00226 } 00227 00232 CS_CONST_METHOD virtual const csHandlerID *GenericPrec ( 00233 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00234 csEventID) const 00235 { return 0; } 00236 00241 CS_CONST_METHOD virtual const csHandlerID *GenericSucc ( 00242 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00243 csEventID) const 00244 { return 0; } 00245 00250 CS_CONST_METHOD virtual const csHandlerID *InstancePrec ( 00251 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00252 csEventID) const 00253 { return 0; } 00254 00259 CS_CONST_METHOD virtual const csHandlerID *InstanceSucc ( 00260 csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 00261 csEventID) const 00262 { return 0; } 00263 00265 virtual bool OnJoystickMove (iEvent &event); 00266 00271 virtual bool OnJoystickDown (iEvent &event); 00272 00274 virtual bool OnJoystickUp (iEvent &event); 00275 00277 virtual bool OnKeyboard (iEvent &event); 00278 00280 virtual bool OnMouseMove (iEvent &event); 00281 00283 virtual bool OnMouseDown (iEvent &event); 00284 00286 virtual bool OnMouseUp (iEvent &event); 00287 00289 virtual bool OnMouseClick (iEvent &event); 00290 00295 virtual bool OnMouseDoubleClick (iEvent &event); 00296 00303 virtual bool OnUnhandledEvent (iEvent &event); 00304 00306 virtual void Frame (); 00307 00309 virtual void PreProcessFrame (); 00310 00312 virtual void ProcessFrame (); 00313 00315 virtual void PostProcessFrame (); 00316 00318 virtual void FinishFrame (); 00319 }; 00320 00323 #endif //__CS_CSBASEEVENTH_H__
Generated for Crystal Space by doxygen 1.4.6