CrystalSpace

Public API Reference

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[]);
00194   void UnregisterQueue ();
00195 
00196 protected:
00217   virtual bool HandleEvent (iEvent &event);
00218 
00224   CS_CONST_METHOD virtual const char *GenericName() const 
00225   { return "application"; }
00226   
00227   CS_CONST_METHOD virtual csHandlerID GenericID (
00228     csRef<iEventHandlerRegistry>& reg) const 
00229   { 
00230     return reg->GetGenericID (GenericName ()); 
00231   }
00232 
00237   CS_CONST_METHOD virtual const csHandlerID *GenericPrec (
00238     csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
00239     csEventID) const 
00240   { return 0; }
00241 
00246   CS_CONST_METHOD virtual const csHandlerID *GenericSucc (
00247     csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
00248     csEventID) const 
00249   { return 0; }
00250 
00255   CS_CONST_METHOD virtual const csHandlerID *InstancePrec (
00256     csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
00257     csEventID) const 
00258   { return 0; }
00259 
00264   CS_CONST_METHOD virtual const csHandlerID *InstanceSucc (
00265     csRef<iEventHandlerRegistry>&, csRef<iEventNameRegistry>&, 
00266     csEventID) const 
00267   { return 0; }
00268 
00270   virtual bool OnJoystickMove (iEvent &event);
00271 
00276   virtual bool OnJoystickDown (iEvent &event);
00277 
00279   virtual bool OnJoystickUp (iEvent &event);
00280 
00282   virtual bool OnKeyboard (iEvent &event);
00283 
00285   virtual bool OnMouseMove (iEvent &event);
00286 
00288   virtual bool OnMouseDown (iEvent &event);
00289 
00291   virtual bool OnMouseUp (iEvent &event);
00292 
00294   virtual bool OnMouseClick (iEvent &event);
00295 
00300   virtual bool OnMouseDoubleClick (iEvent &event);
00301 
00308   virtual bool OnUnhandledEvent (iEvent &event);
00309 
00311   virtual void Frame ();
00312 
00314   virtual void PreProcessFrame ();
00315 
00317   virtual void ProcessFrame ();
00318 
00320   virtual void PostProcessFrame ();
00321 
00323   virtual void FinishFrame ();
00324 };
00325 
00328 #endif //__CS_CSBASEEVENTH_H__

Generated for Crystal Space by doxygen 1.4.7