## Public API Reference

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

- 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
    00042 #define CS_MAX_MOUSE_AXES       8
    00044 #define CS_MAX_MOUSE_BUTTONS    10
    00046 #define CS_MAX_JOYSTICK_COUNT   16
    00048 #define CS_MAX_JOYSTICK_BUTTONS 10
    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
    00260 };
    00261
    00277 struct iEvent : public virtual iBase
    00278 {
    00279   SCF_INTERFACE(iEvent, 2,0,0);
    00281   csEventID Name;
    00283   virtual const csEventID GetName() = 0;
    00285   csTicks Time;
    00287   bool Broadcast;
    00288
    00290
    00293   virtual bool Add (const char *name, int8 v) = 0;
    00294   virtual bool Add (const char *name, uint8 v) = 0;
    00295   virtual bool Add (const char *name, int16 v) = 0;
    00296   virtual bool Add (const char *name, uint16 v) = 0;
    00297   virtual bool Add (const char *name, int32 v) = 0;
    00298   virtual bool Add (const char *name, uint32 v) = 0;
    00299   virtual bool Add (const char *name, int64 v) = 0;
    00300   virtual bool Add (const char *name, uint64 v) = 0;
    00301   virtual bool Add (const char *name, float v) = 0;
    00302   virtual bool Add (const char *name, double v) = 0;
    00303   virtual bool Add (const char *name, const char *v) = 0;
    00304   virtual bool Add (const char *name, const void *v, size_t size) = 0;
    00305   virtual bool Add (const char *name, bool v) = 0;
    00306   virtual bool Add (const char *name, iEvent* v) = 0;
    00307   virtual bool Add (const char *name, iBase* v) = 0;
    00309
    00311
    00314   virtual csEventError Retrieve (const char *name, int8 &v) const = 0;
    00315   virtual csEventError Retrieve (const char *name, uint8 &v) const = 0;
    00316   virtual csEventError Retrieve (const char *name, int16 &v) const = 0;
    00317   virtual csEventError Retrieve (const char *name, uint16 &v) const = 0;
    00318   virtual csEventError Retrieve (const char *name, int32 &v) const = 0;
    00319   virtual csEventError Retrieve (const char *name, uint32 &v) const = 0;
    00320   virtual csEventError Retrieve (const char *name, int64 &v) const = 0;
    00321   virtual csEventError Retrieve (const char *name, uint64 &v) const = 0;
    00322   virtual csEventError Retrieve (const char *name, float &v) const = 0;
    00323   virtual csEventError Retrieve (const char *name, double &v) const = 0;
    00324   virtual csEventError Retrieve (const char *name, const char *&v) const = 0;
    00325   virtual csEventError Retrieve (const char *name, const void *&v,
    00326     size_t& size) const = 0;
    00327   virtual csEventError Retrieve (const char *name, bool &v) const = 0;
    00328   virtual csEventError Retrieve (const char *name, csRef<iEvent> &v) const = 0;
    00329   virtual csEventError Retrieve (const char *name, csRef<iBase> &v) const = 0;
    00331
    00333   virtual bool AttributeExists (const char* name) = 0;
    00335   virtual csEventAttributeType GetAttributeType (const char* name) = 0;
    00336
    00338   virtual bool Remove (const char *name) = 0;
    00340   virtual bool RemoveAll() = 0;
    00341
    00343   virtual csRef<iEventAttributeIterator> GetAttributeIterator() = 0;
    00344 };
    00345
    00392 struct iEventPlug : public virtual iBase
    00393 {
    00394   SCF_INTERFACE(iEventPlug, 2,0,0);
    00403   virtual unsigned GetPotentiallyConflictingEvents () = 0;
    00404
    00413   virtual unsigned QueryEventPriority (unsigned iType) = 0;
    00414
    00422   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
    00423 };
    00424
    00439 struct iEventOutlet : public virtual iBase
    00440 {
    00441   SCF_INTERFACE(iEventOutlet, 2,0,0);
    00450   virtual csPtr<iEvent> CreateEvent () = 0;
    00451
    00463   virtual void Post (iEvent*) = 0;
    00464
    00478   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown,
    00479       bool autorep = false) = 0;
    00480
    00488   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
    00489
    00498   virtual void Joystick(uint iNumber, int iButton, bool iDown,
    00499     const int32 *axes, uint numAxes) = 0;
    00500
    00510   virtual void Broadcast (csEventID iName, intptr_t iInfo = 0) = 0;
    00511
    00527   virtual void ImmediateBroadcast (csEventID iName, intptr_t iInfo) = 0;
    00528 };
    00529
    00530
    00538 struct iEventCord : public virtual iBase
    00539 {
    00540   SCF_INTERFACE(iEventCord, 2,0,0);
    00548   virtual int Insert (iEventHandler*, int priority) = 0;
    00549
    00553   virtual void Remove (iEventHandler*) = 0;
    00554
    00559   virtual bool GetPass () const = 0;
    00560
    00565   virtual void SetPass (bool) = 0;
    00566
    00568   virtual csEventID GetName() const = 0;
    00569 };
    00570
    00573 #endif // __CS_IUTIL_EVENT_H__