CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csutil/binder.h

00001 /*
00002     Copyright (C) 2003 by Mathew Sutcliffe <oktal@gmx.co.uk>
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_UTIL_BINDER_H__
00020 #define __CS_UTIL_BINDER_H__
00021 
00022 #include "csextern.h"
00023 #include "iutil/binder.h"
00024 #include "iutil/eventh.h"
00025 #include "hashmap.h"
00026 
00031 csHashKey csHashComputeEvent (iEvent* const);
00032 
00037 class CS_CSUTIL_EXPORT csInputBinder : public iInputBinder
00038 {
00039 private:
00040   csHashMap Hash;
00041 
00042 protected:
00043   bool HandleEvent (iEvent&);
00044 
00045 public:
00046   SCF_DECLARE_IBASE;
00047 
00052   csInputBinder (iBase *parent = 0, int size = 127);
00053 
00057   virtual ~csInputBinder ();
00058 
00059   struct CS_CSUTIL_EXPORT eiEventHandler : public iEventHandler
00060   {
00061     SCF_DECLARE_EMBEDDED_IBASE (csInputBinder);
00062     bool HandleEvent (iEvent &ev) { return scfParent->HandleEvent (ev); }
00063   } scfiEventHandler;
00064   friend struct eiEventHandler;
00065 
00071   virtual iEventHandler* QueryHandler () { return &scfiEventHandler; }
00072 
00078   virtual void Bind (iEvent&, iInputBinderBoolean*, bool toggle = false);
00079 
00083   virtual void Bind (iEvent&, iInputBinderPosition*);
00084 
00088   virtual bool Unbind (iEvent&);
00089 
00093   virtual bool UnbindAll();
00094 };
00095 
00099 class CS_CSUTIL_EXPORT csInputBinderPosition : public iInputBinderPosition
00100 {
00101 private:
00103   int p;
00104 
00105 public:
00106   SCF_DECLARE_IBASE;
00107 
00109   csInputBinderPosition (int pp) : p (pp)
00110   { SCF_CONSTRUCT_IBASE (0); }
00112   csInputBinderPosition () : p (0)
00113   { SCF_CONSTRUCT_IBASE (0); }
00115   csInputBinderPosition (iInputBinderPosition *pp) : p (pp->Get ())
00116   { SCF_CONSTRUCT_IBASE (0); }
00118   virtual ~csInputBinderPosition ()
00119   { SCF_DESTRUCT_IBASE(); }
00120 
00122   virtual void Set (int pp) { p = pp; }
00124   virtual int Get () const { return p; }
00125 };
00126 
00131 class CS_CSUTIL_EXPORT csInputBinderBoolean : public iInputBinderBoolean
00132 {
00133 private:
00135   bool s;
00136 
00137 public:
00138   SCF_DECLARE_IBASE;
00139 
00141   csInputBinderBoolean (bool ss) : s (ss)
00142   { SCF_CONSTRUCT_IBASE (0); }
00144   csInputBinderBoolean () : s (0)
00145   { SCF_CONSTRUCT_IBASE (0); }
00147   csInputBinderBoolean (iInputBinderBoolean *ss) : s (ss->Get ())
00148   { SCF_CONSTRUCT_IBASE (0); }
00150   virtual ~csInputBinderBoolean ()
00151   { SCF_DESTRUCT_IBASE(); }
00152 
00154   virtual void Set (bool ss) { s = ss; }
00156   virtual bool Get () const { return s; }
00157 };
00158 
00159 #endif // __CS_UTIL_BINDER_H__

Generated for Crystal Space by doxygen 1.2.18