Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
event.h
Go to the documentation of this file.00001 /* 00002 Event system related interfaces 00003 Written by Andrew Zabolotny <bit@eltech.ru> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_IUTIL_EVENT_H__ 00021 #define __CS_IUTIL_EVENT_H__ 00022 00023 #include "iutil/evdefs.h" 00024 #include "csutil/ref.h" 00025 #include "csutil/scf.h" 00026 #include "csutil/csunicode.h" 00027 00035 struct iEventHandler; 00036 struct iEvent; 00037 00038 SCF_VERSION (iEventAttributeIterator, 0, 0, 1); 00039 00044 struct iEventAttributeIterator : public iBase 00045 { 00047 virtual bool HasNext() = 0; 00049 virtual const char* Next() = 0; 00051 virtual void Reset() = 0; 00052 }; 00053 00054 SCF_VERSION (iEvent, 0, 2, 0); 00055 00056 // Event data structs. Defined outside of iEvent to allow SWIG to 00057 // handle the nested structs and union. Does not break any code. 00058 00114 struct csKeyEventData 00115 { 00117 csKeyEventType eventType; 00119 utf32_char codeRaw; 00121 utf32_char codeCooked; 00123 csKeyModifiers modifiers; 00125 bool autoRepeat; 00127 csKeyCharType charType; 00128 }; 00129 00135 enum csMouseButton 00136 { 00138 csmbLeft = 1, 00140 csmbRight = 2, 00142 csmbMiddle = 3, 00144 csmbWheelUp = 4, 00146 csmbWheelDown = 5, 00148 csmbExtra1 = 6, 00150 csmbExtra2 = 7 00151 }; 00152 00154 struct csEventMouseData 00155 { 00157 int x; 00159 int y; 00164 int Button; 00166 int Modifiers; 00167 }; 00168 00170 struct csEventJoystickData 00171 { 00173 int number; 00175 int x; 00177 int y; 00179 int Button; 00181 int Modifiers; 00182 }; 00183 00185 struct csEventCommandData 00186 { 00188 uint Code; 00190 void *Info; 00191 }; 00192 00196 enum csEventError 00197 { 00199 csEventErrNone, 00204 csEventErrLossy, 00206 csEventErrNotFound, 00208 00212 csEventErrMismatchInt, 00213 csEventErrMismatchUInt, 00214 csEventErrMismatchFloat, 00215 csEventErrMismatchBuffer, 00216 csEventErrMismatchEvent, 00217 csEventErrMismatchIBase, 00219 00222 csEventErrUhOhUnknown 00223 }; 00224 00226 enum csEventAttributeType 00227 { 00231 csEventAttrUnknown, 00233 csEventAttrInt, 00235 csEventAttrUInt, 00237 csEventAttrFloat, 00239 csEventAttrDatabuffer, 00241 csEventAttrEvent, 00243 csEventAttriBase 00244 }; 00245 00261 struct iEvent : public iBase 00262 { 00266 uint8 Type; 00268 uint8 Category; 00270 uint8 SubCategory; 00272 uint8 Flags; 00274 csTicks Time; 00275 union 00276 { 00278 csEventMouseData Mouse; 00280 csEventJoystickData Joystick; 00282 csEventCommandData Command; 00283 }; 00284 00286 00289 virtual bool Add (const char *name, int8 v) = 0; 00290 virtual bool Add (const char *name, uint8 v) = 0; 00291 virtual bool Add (const char *name, int16 v) = 0; 00292 virtual bool Add (const char *name, uint16 v) = 0; 00293 virtual bool Add (const char *name, int32 v) = 0; 00294 virtual bool Add (const char *name, uint32 v) = 0; 00295 virtual bool Add (const char *name, int64 v) = 0; 00296 virtual bool Add (const char *name, uint64 v) = 0; 00297 virtual bool Add (const char *name, float v) = 0; 00298 virtual bool Add (const char *name, double v) = 0; 00299 virtual bool Add (const char *name, const char *v) = 0; 00300 virtual bool Add (const char *name, const void *v, size_t size) = 0; 00301 virtual bool Add (const char *name, bool v) = 0; 00302 virtual bool Add (const char *name, iEvent* v) = 0; 00303 virtual bool Add (const char *name, iBase* v) = 0; 00305 00307 00310 virtual csEventError Retrieve (const char *name, int8 &v) const = 0; 00311 virtual csEventError Retrieve (const char *name, uint8 &v) const = 0; 00312 virtual csEventError Retrieve (const char *name, int16 &v) const = 0; 00313 virtual csEventError Retrieve (const char *name, uint16 &v) const = 0; 00314 virtual csEventError Retrieve (const char *name, int32 &v) const = 0; 00315 virtual csEventError Retrieve (const char *name, uint32 &v) const = 0; 00316 virtual csEventError Retrieve (const char *name, int64 &v) const = 0; 00317 virtual csEventError Retrieve (const char *name, uint64 &v) const = 0; 00318 virtual csEventError Retrieve (const char *name, float &v) const = 0; 00319 virtual csEventError Retrieve (const char *name, double &v) const = 0; 00320 virtual csEventError Retrieve (const char *name, const char *&v) const = 0; 00321 virtual csEventError Retrieve (const char *name, const void *&v, 00322 size_t& size) const = 0; 00323 virtual csEventError Retrieve (const char *name, bool &v) const = 0; 00324 virtual csEventError Retrieve (const char *name, csRef<iEvent> &v) const = 0; 00325 virtual csEventError Retrieve (const char *name, csRef<iBase> &v) const = 0; 00327 00329 virtual bool AttributeExists (const char* name) = 0; 00331 virtual csEventAttributeType GetAttributeType (const char* name) = 0; 00332 00334 virtual bool Remove (const char *name) = 0; 00336 virtual bool RemoveAll() = 0; 00337 00339 virtual csRef<iEventAttributeIterator> GetAttributeIterator() = 0; 00340 }; 00341 00379 SCF_VERSION (iEventPlug, 0, 0, 1); 00380 00389 struct iEventPlug : public iBase 00390 { 00399 virtual unsigned GetPotentiallyConflictingEvents () = 0; 00400 00409 virtual unsigned QueryEventPriority (unsigned iType) = 0; 00410 00418 virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {} 00419 }; 00420 00421 SCF_VERSION (iEventOutlet, 0, 1, 0); 00422 00437 struct iEventOutlet : public iBase 00438 { 00447 virtual csPtr<iEvent> CreateEvent () = 0; 00448 00460 virtual void Post (iEvent*) = 0; 00461 00475 virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown) = 0; 00476 00484 virtual void Mouse (int iButton, bool iDown, int x, int y) = 0; 00485 00493 virtual void Joystick(int iNumber, int iButton, bool iDown, int x,int y) = 0; 00494 00504 virtual void Broadcast (int iCode, void *iInfo = 0) = 0; 00505 00521 virtual void ImmediateBroadcast (int iCode, void *iInfo) = 0; 00522 }; 00523 00524 SCF_VERSION (iEventCord, 0, 0, 3); 00525 00533 struct iEventCord : public iBase 00534 { 00542 virtual int Insert (iEventHandler*, int priority) = 0; 00543 00547 virtual void Remove (iEventHandler*) = 0; 00548 00553 virtual bool GetPass () const = 0; 00554 00559 virtual void SetPass (bool) = 0; 00560 00562 virtual int GetCategory() const = 0; 00563 // Get the subcategory of this cord. 00564 virtual int GetSubcategory() const = 0; 00565 }; 00566 00569 #endif // __CS_IUTIL_EVENT_H__
Generated for Crystal Space by doxygen 1.3.9.1