iutil/event.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

iutil/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 "cssysdef.h"
    00024
    00025 #include "csutil/scf_interface.h"
    00026 #include "csutil/csunicode.h"
    00027 #include "csutil/ref.h"
    00028 #include "iutil/eventnames.h"
    00029 #include "iutil/evdefs.h"
    00030
    00031
    00039
    00040 #define CS_MAX_MOUSE_COUNT      4
    00041
    00042 #define CS_MAX_MOUSE_AXES       8
    00043
    00044 #define CS_MAX_MOUSE_BUTTONS    10
    00045
    00046 #define CS_MAX_JOYSTICK_COUNT   16
    00047
    00048 #define CS_MAX_JOYSTICK_BUTTONS 32
    00049
    00050 #define CS_MAX_JOYSTICK_AXES    8
    00051 /* Architecturally, AXES can go as high as 32 (limited by the uint32 change mask). */
    00052
    00053 struct iEventHandler;
    00054 struct iEvent;
    00055
    00060 struct iEventAttributeIterator : public virtual iBase
    00061 {
    00062   SCF_INTERFACE(iEventAttributeIterator, 3,0,0);
    00064   virtual bool HasNext() = 0;
    00066   virtual const char* Next() = 0;
    00068   virtual void Reset() = 0;
    00069 };
    00070
    00071
    00072 // Event data structs. Defined outside of iEvent to allow SWIG to
    00073 // handle the nested structs and union. Does not break any code.
    00074
    00128 struct csKeyEventData
    00129 {
    00131   csKeyEventType eventType;
    00133   utf32_char codeRaw;
    00135   utf32_char codeCooked;
    00137   csKeyModifiers modifiers;
    00139   bool autoRepeat;
    00141   csKeyCharType charType;
    00142 };
    00143
    00144
    00152 struct csMouseEventData
    00153 {
    00155   int x;
    00157   int y;
    00159   int32 axes[CS_MAX_MOUSE_AXES];
    00161   uint numAxes;
    00166   uint Button;
    00168   uint32 Modifiers;
    00169 };
    00170
    00178 struct csJoystickEventData
    00179 {
    00181   uint number;
    00183   int32 axes[CS_MAX_JOYSTICK_AXES];
    00185   uint numAxes;
    00187   uint32 axesChanged;
    00189   uint Button;
    00191   uint32 Modifiers;
    00192 };
    00193
    00201 struct csCommandEventData
    00202 {
    00204   uint Code;
    00206   intptr_t Info;
    00207 };
    00208
    00212 enum csEventError
    00213 {
    00215   csEventErrNone,
    00220   csEventErrLossy,
    00222   csEventErrNotFound,
    00224
    00228   csEventErrMismatchInt,
    00229   csEventErrMismatchUInt,
    00230   csEventErrMismatchFloat,
    00231   csEventErrMismatchBuffer,
    00232   csEventErrMismatchEvent,
    00233   csEventErrMismatchIBase,
    00235
    00238   csEventErrUhOhUnknown
    00239 };
    00240
    00242 enum csEventAttributeType
    00243 {
    00247   csEventAttrUnknown,
    00249   csEventAttrInt,
    00251   csEventAttrUInt,
    00253   csEventAttrFloat,
    00255   csEventAttrDatabuffer,
    00257   csEventAttrEvent,
    00259   csEventAttriBase,
    00261   csEventAttrRawPtr
    00262 };
    00263
    00279 struct iEvent : public virtual iBase
    00280 {
    00281   SCF_INTERFACE(iEvent, 2,1,0);
    00283   csEventID Name;
    00285   virtual const csEventID GetName() = 0;
    00287   csTicks Time;
    00289   bool Broadcast;
    00290
    00292
    00295   virtual bool Add (const char *name, int8 v) = 0;
    00296   virtual bool Add (const char *name, uint8 v) = 0;
    00297   virtual bool Add (const char *name, int16 v) = 0;
    00298   virtual bool Add (const char *name, uint16 v) = 0;
    00299   virtual bool Add (const char *name, int32 v) = 0;
    00300   virtual bool Add (const char *name, uint32 v) = 0;
    00301   virtual bool Add (const char *name, int64 v) = 0;
    00302   virtual bool Add (const char *name, uint64 v) = 0;
    00303   virtual bool Add (const char *name, float v) = 0;
    00304   virtual bool Add (const char *name, double v) = 0;
    00305   virtual bool Add (const char *name, const char *v) = 0;
    00306   virtual bool Add (const char *name, const void *v, size_t size) = 0;
    00307   virtual bool Add (const char *name, bool v) = 0;
    00308   virtual bool Add (const char *name, iEvent* v) = 0;
    00309   virtual bool Add (const char *name, iBase* v) = 0;
    00310   virtual bool Add (const char *name, void* v) = 0;
    00312
    00314
    00317   virtual csEventError Retrieve (const char *name, int8 &v) const = 0;
    00318   virtual csEventError Retrieve (const char *name, uint8 &v) const = 0;
    00319   virtual csEventError Retrieve (const char *name, int16 &v) const = 0;
    00320   virtual csEventError Retrieve (const char *name, uint16 &v) const = 0;
    00321   virtual csEventError Retrieve (const char *name, int32 &v) const = 0;
    00322   virtual csEventError Retrieve (const char *name, uint32 &v) const = 0;
    00323   virtual csEventError Retrieve (const char *name, int64 &v) const = 0;
    00324   virtual csEventError Retrieve (const char *name, uint64 &v) const = 0;
    00325   virtual csEventError Retrieve (const char *name, float &v) const = 0;
    00326   virtual csEventError Retrieve (const char *name, double &v) const = 0;
    00327   virtual csEventError Retrieve (const char *name, const char *&v) const = 0;
    00328   virtual csEventError Retrieve (const char *name, const void *&v,
    00329     size_t& size) const = 0;
    00330   virtual csEventError Retrieve (const char *name, bool &v) const = 0;
    00331   virtual csEventError Retrieve (const char *name, csRef<iEvent> &v) const = 0;
    00332   virtual csEventError Retrieve (const char *name, csRef<iBase> &v) const = 0;
    00333   virtual csEventError Retrieve (const char *name, void* &v) const = 0;
    00335
    00337   virtual bool AttributeExists (const char* name) = 0;
    00339   virtual csEventAttributeType GetAttributeType (const char* name) = 0;
    00340
    00342   virtual bool Remove (const char *name) = 0;
    00344   virtual bool RemoveAll() = 0;
    00345
    00347   virtual csRef<iEventAttributeIterator> GetAttributeIterator() = 0;
    00348 };
    00349
    00396 struct iEventPlug : public virtual iBase
    00397 {
    00398   SCF_INTERFACE(iEventPlug, 2,0,0);
    00407   virtual unsigned GetPotentiallyConflictingEvents () = 0;
    00408
    00417   virtual unsigned QueryEventPriority (unsigned iType) = 0;
    00418
    00426   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
    00427 };
    00428
    00443 struct iEventOutlet : public virtual iBase
    00444 {
    00445   SCF_INTERFACE(iEventOutlet, 2,0,0);
    00454   virtual csPtr<iEvent> CreateEvent () = 0;
    00455
    00467   virtual void Post (iEvent*) = 0;
    00468
    00482   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown,
    00483       bool autorep = false) = 0;
    00484
    00492   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
    00493
    00502   virtual void Joystick(uint iNumber, int iButton, bool iDown,
    00503     const int32 *axes, uint numAxes) = 0;
    00504
    00514   virtual void Broadcast (csEventID iName, intptr_t iInfo = 0) = 0;
    00515
    00531   virtual void ImmediateBroadcast (csEventID iName, intptr_t iInfo) = 0;
    00532 };
    00533
    00534
    00542 struct iEventCord : public virtual iBase
    00543 {
    00544   SCF_INTERFACE(iEventCord, 2,0,0);
    00552   virtual int Insert (iEventHandler*, int priority) = 0;
    00553
    00557   virtual void Remove (iEventHandler*) = 0;
    00558
    00563   virtual bool GetPass () const = 0;
    00564
    00569   virtual void SetPass (bool) = 0;
    00570
    00572   virtual csEventID GetName() const = 0;
    00573 };
    00574
    00577 #endif // __CS_IUTIL_EVENT_H__