CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | 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 "csutil/scf.h"
00024 #include "csutil/csunicode.h"
00025 
00026 #include "iutil/evdefs.h"
00027 
00028 
00036 
00037 #define CS_MAX_MOUSE_COUNT      4
00038 
00039 #define CS_MAX_MOUSE_AXES       8
00040 
00041 #define CS_MAX_MOUSE_BUTTONS    10
00042 
00043 #define CS_MAX_JOYSTICK_COUNT   16
00044 
00045 #define CS_MAX_JOYSTICK_BUTTONS 10
00046 
00047 #define CS_MAX_JOYSTICK_AXES    8
00048 /* Architecturally, AXES can go as high as 32 (limited by the uint32 change mask). */
00049 
00050 struct iEventHandler;
00051 struct iEvent;
00052 
00053 SCF_VERSION (iEventAttributeIterator, 0, 0, 1);
00054 
00059 struct iEventAttributeIterator : public iBase
00060 {
00062   virtual bool HasNext() = 0;
00064   virtual const char* Next() = 0;
00066   virtual void Reset() = 0;
00067 };
00068 
00069 SCF_VERSION (iEvent, 0, 2, 0);
00070 
00071 // Event data structs. Defined outside of iEvent to allow SWIG to
00072 // handle the nested structs and union. Does not break any code.
00073 
00129 struct csKeyEventData
00130 {
00132   csKeyEventType eventType;
00134   utf32_char codeRaw;
00136   utf32_char codeCooked;
00138   csKeyModifiers modifiers;
00140   bool autoRepeat;
00142   csKeyCharType charType;
00143 };
00144 
00150 enum csMouseButton
00151 {
00153   csmbLeft = 1,
00155   csmbRight = 2,
00157   csmbMiddle = 3,
00159   csmbWheelUp = 4,
00161   csmbWheelDown = 5,
00163   csmbExtra1 = 6,
00165   csmbExtra2 = 7
00166 };
00167 
00175 struct csMouseEventData
00176 {
00178   int x;
00180   int y;
00182   int32 axes[CS_MAX_MOUSE_AXES];
00184   uint numAxes;
00189   uint Button;
00191   uint32 Modifiers;
00192 };
00193 
00201 struct csJoystickEventData
00202 {
00204   uint number;
00206   int32 axes[CS_MAX_JOYSTICK_AXES];
00208   uint numAxes;
00210   uint32 axesChanged;
00212   uint Button;
00214   uint32 Modifiers;
00215 };
00216 
00224 struct csCommandEventData
00225 {
00227   uint Code;
00229   intptr_t Info;
00230 };
00231 
00235 enum csEventError
00236 {
00238   csEventErrNone,
00243   csEventErrLossy,
00245   csEventErrNotFound,
00247 
00251   csEventErrMismatchInt,
00252   csEventErrMismatchUInt,
00253   csEventErrMismatchFloat,
00254   csEventErrMismatchBuffer,
00255   csEventErrMismatchEvent,
00256   csEventErrMismatchIBase,
00258 
00261   csEventErrUhOhUnknown
00262 };
00263 
00265 enum csEventAttributeType
00266 {
00270   csEventAttrUnknown,
00272   csEventAttrInt,
00274   csEventAttrUInt,
00276   csEventAttrFloat,
00278   csEventAttrDatabuffer,
00280   csEventAttrEvent,
00282   csEventAttriBase
00283 };
00284 
00300 struct iEvent : public iBase
00301 {
00305   uint8 Type;                   
00307   uint8 Category;               
00309   uint8 SubCategory;            
00311   uint8 Flags;                  
00313   csTicks Time;                 
00314 
00316 
00319   virtual bool Add (const char *name, int8 v) = 0;
00320   virtual bool Add (const char *name, uint8 v) = 0;
00321   virtual bool Add (const char *name, int16 v) = 0;
00322   virtual bool Add (const char *name, uint16 v) = 0;
00323   virtual bool Add (const char *name, int32 v) = 0;
00324   virtual bool Add (const char *name, uint32 v) = 0;
00325   virtual bool Add (const char *name, int64 v) = 0;
00326   virtual bool Add (const char *name, uint64 v) = 0;
00327   virtual bool Add (const char *name, float v) = 0;
00328   virtual bool Add (const char *name, double v) = 0;
00329   virtual bool Add (const char *name, const char *v) = 0;
00330   virtual bool Add (const char *name, const void *v, size_t size) = 0;
00331   virtual bool Add (const char *name, bool v) = 0;
00332   virtual bool Add (const char *name, iEvent* v) = 0;
00333   virtual bool Add (const char *name, iBase* v) = 0;
00335 
00337 
00340   virtual csEventError Retrieve (const char *name, int8 &v) const = 0;
00341   virtual csEventError Retrieve (const char *name, uint8 &v) const = 0;
00342   virtual csEventError Retrieve (const char *name, int16 &v) const = 0;
00343   virtual csEventError Retrieve (const char *name, uint16 &v) const = 0;
00344   virtual csEventError Retrieve (const char *name, int32 &v) const = 0;
00345   virtual csEventError Retrieve (const char *name, uint32 &v) const = 0;
00346   virtual csEventError Retrieve (const char *name, int64 &v) const = 0;
00347   virtual csEventError Retrieve (const char *name, uint64 &v) const = 0;
00348   virtual csEventError Retrieve (const char *name, float &v) const = 0;
00349   virtual csEventError Retrieve (const char *name, double &v) const = 0;
00350   virtual csEventError Retrieve (const char *name, const char *&v) const = 0;
00351   virtual csEventError Retrieve (const char *name, const void *&v, 
00352     size_t& size) const = 0;
00353   virtual csEventError Retrieve (const char *name, bool &v) const = 0;
00354   virtual csEventError Retrieve (const char *name, csRef<iEvent> &v) const = 0;
00355   virtual csEventError Retrieve (const char *name, csRef<iBase> &v) const = 0;
00357 
00359   virtual bool AttributeExists (const char* name) = 0;
00361   virtual csEventAttributeType GetAttributeType (const char* name) = 0;
00362 
00364   virtual bool Remove (const char *name) = 0;
00366   virtual bool RemoveAll() = 0;
00367 
00369   virtual csRef<iEventAttributeIterator> GetAttributeIterator() = 0;
00370 };
00371 
00409 SCF_VERSION (iEventPlug, 0, 0, 1);
00410 
00419 struct iEventPlug : public virtual iBase
00420 {
00429   virtual unsigned GetPotentiallyConflictingEvents () = 0;
00430 
00439   virtual unsigned QueryEventPriority (unsigned iType) = 0;
00440 
00448   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
00449 };
00450 
00451 SCF_VERSION (iEventOutlet, 0, 1, 0);
00452 
00467 struct iEventOutlet : public iBase
00468 {
00477   virtual csPtr<iEvent> CreateEvent () = 0;
00478 
00490   virtual void Post (iEvent*) = 0;
00491 
00505   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown) = 0;
00506 
00514   virtual void Mouse (uint iButton, bool iDown, int x, int y) = 0;
00515 
00524   virtual void Joystick(uint iNumber, uint iButton, bool iDown, 
00525     const int32 *axes, uint numAxes) = 0;
00526 
00536   virtual void Broadcast (uint iCode, intptr_t iInfo = 0) = 0;
00537 
00553   virtual void ImmediateBroadcast (uint iCode, intptr_t iInfo) = 0;
00554 };
00555 
00556 SCF_VERSION (iEventCord, 0, 0, 3);
00557 
00565 struct iEventCord : public iBase
00566 {
00574   virtual int Insert (iEventHandler*, int priority) = 0;
00575 
00579   virtual void Remove (iEventHandler*) = 0;
00580 
00585   virtual bool GetPass () const = 0;
00586 
00591   virtual void SetPass (bool) = 0;
00592 
00594   virtual int GetCategory() const = 0;
00595   // Get the subcategory of this cord.
00596   virtual int GetSubcategory() const = 0;
00597 };
00598 
00601 #endif // __CS_IUTIL_EVENT_H__

Generated for Crystal Space by doxygen 1.4.4