![]() |
Public API Reference |
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 "iutil/binder.h" 00023 #include "iutil/eventh.h" 00024 #include "csutil/hashmap.h" 00025 00030 csHashKey csHashComputeEvent (iEvent const&); 00031 00036 class csInputBinder : public iInputBinder 00037 { 00038 private: 00039 csHashMap Hash; 00040 00041 protected: 00042 bool HandleEvent (iEvent&); 00043 00044 public: 00045 SCF_DECLARE_IBASE; 00046 00051 csInputBinder (iBase *parent = 0, int size = 127); 00052 00056 virtual ~csInputBinder (); 00057 00058 struct eiEventHandler : public iEventHandler 00059 { 00060 SCF_DECLARE_EMBEDDED_IBASE (csInputBinder); 00061 bool HandleEvent (iEvent &ev) { return scfParent->HandleEvent (ev); } 00062 } scfiEventHandler; 00063 friend struct eiEventHandler; 00064 00070 virtual iEventHandler* QueryHandler () { return &scfiEventHandler; } 00071 00077 virtual void Bind (iEvent&, iInputBinderBoolean*, bool toggle = false); 00078 00082 virtual void Bind (iEvent&, iInputBinderPosition*); 00083 00087 virtual bool Unbind (iEvent&); 00088 00092 virtual bool UnbindAll(); 00093 }; 00094 00098 class csInputBinderPosition : public iInputBinderPosition 00099 { 00100 private: 00102 int p; 00103 00104 public: 00105 SCF_DECLARE_IBASE; 00106 00108 csInputBinderPosition (int pp) : p (pp) 00109 { SCF_CONSTRUCT_IBASE (0); } 00111 csInputBinderPosition () : p (0) 00112 { SCF_CONSTRUCT_IBASE (0); } 00114 csInputBinderPosition (iInputBinderPosition *pp) : p (pp->Get ()) 00115 { SCF_CONSTRUCT_IBASE (0); } 00117 virtual ~csInputBinderPosition () {} 00118 00120 virtual void Set (int pp) { p = pp; } 00122 virtual int Get () const { return p; } 00123 }; 00124 00129 class csInputBinderBoolean : public iInputBinderBoolean 00130 { 00131 private: 00133 bool s; 00134 00135 public: 00136 SCF_DECLARE_IBASE; 00137 00139 csInputBinderBoolean (bool ss) : s (ss) 00140 { SCF_CONSTRUCT_IBASE (0); } 00142 csInputBinderBoolean () : s (0) 00143 { SCF_CONSTRUCT_IBASE (0); } 00145 csInputBinderBoolean (iInputBinderBoolean *ss) : s (ss->Get ()) 00146 { SCF_CONSTRUCT_IBASE (0); } 00148 virtual ~csInputBinderBoolean () {} 00149 00151 virtual void Set (bool ss) { s = ss; } 00153 virtual bool Get () const { return s; } 00154 }; 00155 00156 #endif // __CS_UTIL_BINDER_H__