## 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 "csutil/scf.h"
    00024 #include "csutil/csunicode.h"
    00025 #include "csutil/strset.h"
    00026 #include "csutil/eventnames.h"
    00027
    00028 #include "iutil/evdefs.h"
    00029
    00030
    00038
    00039 #define CS_MAX_MOUSE_COUNT      4
    00040
    00041 #define CS_MAX_MOUSE_AXES       8
    00042
    00043 #define CS_MAX_MOUSE_BUTTONS    10
    00044
    00045 #define CS_MAX_JOYSTICK_COUNT   16
    00046
    00047 #define CS_MAX_JOYSTICK_BUTTONS 10
    00048
    00049 #define CS_MAX_JOYSTICK_AXES    8
    00050 /* Architecturally, AXES can go as high as 32 (limited by the uint32 change mask). */
    00051
    00052 struct iEventHandler;
    00053 struct iEvent;
    00054
    00059 struct iEventAttributeIterator : public virtual iBase
    00060 {
    00061   SCF_INTERFACE(iEventAttributeIterator, 3,0,0);
    00063   virtual bool HasNext() = 0;
    00065   virtual const char* Next() = 0;
    00067   virtual void Reset() = 0;
    00068 };
    00069
    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
    00127 struct csKeyEventData
    00128 {
    00130   csKeyEventType eventType;
    00132   utf32_char codeRaw;
    00134   utf32_char codeCooked;
    00136   csKeyModifiers modifiers;
    00138   bool autoRepeat;
    00140   csKeyCharType charType;
    00141 };
    00142
    00148 enum csMouseButton
    00149 {
    00151   csmbNone = -1,
    00153   csmbLeft = 0,
    00155   csmbRight = 1,
    00157   csmbMiddle = 2,
    00159   csmbWheelUp = 3,
    00161   csmbWheelDown = 4,
    00163   csmbExtra1 = 5,
    00165   csmbExtra2 = 6
    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 virtual iBase
    00301 {
    00302   SCF_INTERFACE(iEvent, 2,0,0);
    00304   csEventID Name;
    00306   virtual const csEventID GetName() = 0;
    00308   csTicks Time;
    00310   bool Broadcast;
    00311
    00313
    00316   virtual bool Add (const char *name, int8 v) = 0;
    00317   virtual bool Add (const char *name, uint8 v) = 0;
    00318   virtual bool Add (const char *name, int16 v) = 0;
    00319   virtual bool Add (const char *name, uint16 v) = 0;
    00320   virtual bool Add (const char *name, int32 v) = 0;
    00321   virtual bool Add (const char *name, uint32 v) = 0;
    00322   virtual bool Add (const char *name, int64 v) = 0;
    00323   virtual bool Add (const char *name, uint64 v) = 0;
    00324   virtual bool Add (const char *name, float v) = 0;
    00325   virtual bool Add (const char *name, double v) = 0;
    00326   virtual bool Add (const char *name, const char *v) = 0;
    00327   virtual bool Add (const char *name, const void *v, size_t size) = 0;
    00328   virtual bool Add (const char *name, bool v) = 0;
    00329   virtual bool Add (const char *name, iEvent* v) = 0;
    00330   virtual bool Add (const char *name, iBase* v) = 0;
    00332
    00334
    00337   virtual csEventError Retrieve (const char *name, int8 &v) const = 0;
    00338   virtual csEventError Retrieve (const char *name, uint8 &v) const = 0;
    00339   virtual csEventError Retrieve (const char *name, int16 &v) const = 0;
    00340   virtual csEventError Retrieve (const char *name, uint16 &v) const = 0;
    00341   virtual csEventError Retrieve (const char *name, int32 &v) const = 0;
    00342   virtual csEventError Retrieve (const char *name, uint32 &v) const = 0;
    00343   virtual csEventError Retrieve (const char *name, int64 &v) const = 0;
    00344   virtual csEventError Retrieve (const char *name, uint64 &v) const = 0;
    00345   virtual csEventError Retrieve (const char *name, float &v) const = 0;
    00346   virtual csEventError Retrieve (const char *name, double &v) const = 0;
    00347   virtual csEventError Retrieve (const char *name, const char *&v) const = 0;
    00348   virtual csEventError Retrieve (const char *name, const void *&v,
    00349     size_t& size) const = 0;
    00350   virtual csEventError Retrieve (const char *name, bool &v) const = 0;
    00351   virtual csEventError Retrieve (const char *name, csRef<iEvent> &v) const = 0;
    00352   virtual csEventError Retrieve (const char *name, csRef<iBase> &v) const = 0;
    00354
    00356   virtual bool AttributeExists (const char* name) = 0;
    00358   virtual csEventAttributeType GetAttributeType (const char* name) = 0;
    00359
    00361   virtual bool Remove (const char *name) = 0;
    00363   virtual bool RemoveAll() = 0;
    00364
    00366   virtual csRef<iEventAttributeIterator> GetAttributeIterator() = 0;
    00367 };
    00368
    00415 struct iEventPlug : public virtual iBase
    00416 {
    00417   SCF_INTERFACE(iEventPlug, 2,0,0);
    00426   virtual unsigned GetPotentiallyConflictingEvents () = 0;
    00427
    00436   virtual unsigned QueryEventPriority (unsigned iType) = 0;
    00437
    00445   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
    00446 };
    00447
    00462 struct iEventOutlet : public virtual iBase
    00463 {
    00464   SCF_INTERFACE(iEventOutlet, 2,0,0);
    00473   virtual csPtr<iEvent> CreateEvent () = 0;
    00474
    00486   virtual void Post (iEvent*) = 0;
    00487
    00501   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown) = 0;
    00502
    00510   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
    00511
    00520   virtual void Joystick(uint iNumber, int iButton, bool iDown,
    00521     const int32 *axes, uint numAxes) = 0;
    00522
    00532   virtual void Broadcast (csEventID iName, intptr_t iInfo = 0) = 0;
    00533
    00549   virtual void ImmediateBroadcast (csEventID iName, intptr_t iInfo) = 0;
    00550 };
    00551
    00552
    00560 struct iEventCord : public virtual iBase
    00561 {
    00562   SCF_INTERFACE(iEventCord, 2,0,0);
    00570   virtual int Insert (iEventHandler*, int priority) = 0;
    00571
    00575   virtual void Remove (iEventHandler*) = 0;
    00576
    00581   virtual bool GetPass () const = 0;
    00582
    00587   virtual void SetPass (bool) = 0;
    00588
    00590   virtual csEventID GetName() const = 0;
    00591 };
    00592
    00595 #endif // __CS_IUTIL_EVENT_H__