CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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 program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program 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
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     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/scf.h"
00025 
00033 enum {
00034   CS_CRYSTAL_PROTOCOL = 0x43533030L, // 'CS00'
00035   CS_MUSCLE_PROTOCOL = 0x504d3030L, // 'PM00'
00036   CS_XML_PROTOCOL = 0x584d4d30L // 'XML0'
00037 };
00038 
00039 struct iEventHandler;
00040 
00041 struct iNetworkConnection;
00042 struct iNetworkPacket;
00043 
00044 struct iNetworkSocket2;
00045 struct iNetworkPacket2;
00046 
00047 SCF_VERSION (iEvent, 0, 1, 1);
00048 
00049 // Event data structs. Defined outside of iEvent to allow SWIG to
00050 // handle the nested structs and union. Does not break any code.
00051 
00053 struct csEventKeyData
00054 {
00056   int Code;
00058   int Char;
00060   int Modifiers;
00061 };
00062 
00064 struct csEventMouseData
00065 {
00067   int x;
00069   int y;
00074   int Button;
00076   int Modifiers;
00077 };
00078 
00080 struct csEventJoystickData
00081 {
00083   int number;
00085   int x;
00087   int y;
00089   int Button;
00091   int Modifiers;
00092 };
00093 
00095 struct csEventCommandData
00096 {
00098   uint Code;
00100   void *Info;
00101 };
00102 
00104 struct csEventNetworkData
00105 {
00106   union
00107   {
00109     iNetworkConnection *From;
00111     iNetworkSocket2 *From2;
00112   };
00113   union
00114   {
00116     iNetworkPacket *Data;
00118     iNetworkPacket2 *Data2;
00119   };
00120 };
00121 
00137 struct iEvent : public iBase
00138 {
00140   uint8 Type;                   
00142   uint8 Category;               
00144   uint8 SubCategory;            
00146   uint8 Flags;                  
00148   csTicks Time;                 
00149   union
00150   {
00152     csEventKeyData Key;
00154     csEventMouseData Mouse;
00156     csEventJoystickData Joystick;
00158     csEventCommandData Command;
00160     csEventNetworkData Network;
00161   };
00162 
00163   virtual bool Add(const char *name, int8 v) = 0;
00164   virtual bool Add(const char *name, uint8 v) = 0;
00165   virtual bool Add(const char *name, int16 v) = 0;
00166   virtual bool Add(const char *name, uint16 v) = 0;
00167   virtual bool Add(const char *name, int32 v, bool force_boolean = false) = 0;
00168   virtual bool Add(const char *name, uint32 v) = 0;
00169   virtual bool Add(const char *name, int64 v) = 0;
00170   virtual bool Add(const char *name, uint64 v) = 0;
00171   virtual bool Add(const char *name, float v) = 0;
00172   virtual bool Add(const char *name, double v) = 0;
00173   virtual bool Add(const char *name, char *v) = 0;
00174   virtual bool Add(const char *name, void *v, uint32 size) = 0;
00175 #ifndef CS_USE_FAKE_BOOL_TYPE
00176   virtual bool Add(const char *name, bool v, bool force_boolean = true) = 0;
00177 #endif
00178   virtual bool Add(const char *name, iEvent *v) = 0;
00179 
00180   virtual bool Find(const char *name, int8 &v, int index = 0) = 0;
00181   virtual bool Find(const char *name, uint8 &v, int index = 0) = 0;
00182   virtual bool Find(const char *name, int16 &v, int index = 0) = 0;
00183   virtual bool Find(const char *name, uint16 &v, int index = 0) = 0;
00184   virtual bool Find(const char *name, int32 &v, int index = 0) = 0;
00185   virtual bool Find(const char *name, uint32 &v, int index = 0) = 0;
00186   virtual bool Find(const char *name, int64 &v, int index = 0) = 0;
00187   virtual bool Find(const char *name, uint64 &v, int index = 0) = 0;
00188   virtual bool Find(const char *name, float &v, int index = 0) = 0;
00189   virtual bool Find(const char *name, double &v, int index = 0) = 0;
00190   virtual bool Find(const char *name, char **v, int index = 0) = 0;
00191   virtual bool Find(const char *name, void **v, uint32 &size, int index = 0) = 0;
00192 #ifndef CS_USE_FAKE_BOOL_TYPE
00193   virtual bool Find(const char *name, bool &v, int index = 0) = 0;
00194 #endif
00195   virtual bool Find(const char *name, iEvent **v, int index = 0) = 0;
00196 
00197   virtual bool Remove(const char *name, int index = -1) = 0;
00198   virtual bool RemoveAll() = 0;
00199   
00200   virtual bool Print(int level = 0) = 0;
00201 
00202   // Note: The user is responsible for allocating and deallocating this memory
00203   virtual uint32 FlattenSize(int format = CS_CRYSTAL_PROTOCOL) = 0;
00204   virtual bool Flatten(char *buffer, int format = CS_CRYSTAL_PROTOCOL) = 0;
00205   virtual bool Unflatten(const char *buffer, uint32 length) = 0;
00206 };
00207 
00245 SCF_VERSION (iEventPlug, 0, 0, 1);
00246 
00255 struct iEventPlug : public iBase
00256 {
00265   virtual unsigned GetPotentiallyConflictingEvents () = 0;
00266 
00275   virtual unsigned QueryEventPriority (unsigned iType) = 0;
00276 
00284   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
00285 };
00286 
00287 SCF_VERSION (iEventOutlet, 0, 1, 0);
00288 
00303 struct iEventOutlet : public iBase
00304 {
00313   virtual csPtr<iEvent> CreateEvent () = 0;
00314 
00321   virtual void Post (iEvent*) = 0;
00322 
00340   virtual void Key (int iKey, int iChar, bool iDown) = 0;
00341 
00349   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
00350 
00358   virtual void Joystick(int iNumber, int iButton, bool iDown, int x,int y) = 0;
00359 
00369   virtual void Broadcast (int iCode, void *iInfo = 0) = 0;
00370 
00386   virtual void ImmediateBroadcast (int iCode, void *iInfo) = 0;
00387 };
00388 
00389 SCF_VERSION (iEventCord, 0, 0, 3);
00390 
00398 struct iEventCord : public iBase
00399 {
00407   virtual int Insert (iEventHandler*, int priority) = 0;
00408 
00412   virtual void Remove (iEventHandler*) = 0;
00413 
00418   virtual bool GetPass () const = 0;
00419 
00424   virtual void SetPass (bool) = 0;
00425 
00427   virtual int GetCategory() const = 0;
00428   // Get the subcategory of this cord.
00429   virtual int GetSubcategory() const = 0;
00430 };
00431 
00435 #endif // __CS_IUTIL_EVENT_H__

Generated for Crystal Space by doxygen 1.2.14