CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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_MUSCLE_PROTOCOL = 1347235888L, // 'PM00'
00035   CS_CRYSTAL_PROTOCOL = 1129525296L, // 'CS00'
00036   CS_XML_PROTOCOL = 1481460784L // 'XML0'
00037 };
00038 
00039 struct iEventHandler;
00040 
00041 struct iNetworkSocket2;
00042 struct iNetworkPacket;
00043 
00044 SCF_VERSION (iEvent, 0, 0, 2);
00045 
00046 // Event data structs. Defined outside of iEvent to allow SWIG to
00047 // handle the nested structs and union. Does not break any code.
00048 
00050 struct csEventKeyData
00051 {
00053   int Code;
00055   int Char;
00057   int Modifiers;
00058 };
00059 
00061 struct csEventMouseData
00062 {
00064   int x;
00066   int y;
00071   int Button;
00073   int Modifiers;
00074 };
00075 
00077 struct csEventJoystickData
00078 {
00080   int number;
00082   int x;
00084   int y;
00086   int Button;
00088   int Modifiers;
00089 };
00090 
00092 struct csEventCommandData
00093 {
00095   uint Code;
00097   void *Info;
00098 };
00099 
00101 struct csEventNetworkData
00102 {
00104   iNetworkSocket2 *From;
00106   iNetworkPacket *Data;
00107 };
00108 
00124 struct iEvent : public iBase
00125 {
00127   uint8 Type;                   
00129   uint8 Category;               
00131   uint8 SubCategory;            
00133   uint8 Flags;                  
00135   csTicks Time;                 
00136   union
00137   {
00139     csEventKeyData Key;
00141     csEventMouseData Mouse;
00143     csEventJoystickData Joystick;
00145     csEventCommandData Command;
00147     csEventNetworkData Network;
00148   };
00149   virtual bool Add(const char *name, int8 v) = 0;
00150   virtual bool Add(const char *name, uint8 v) = 0;
00151   virtual bool Add(const char *name, int16 v) = 0;
00152   virtual bool Add(const char *name, uint16 v) = 0;
00153   virtual bool Add(const char *name, int32 v, bool force_boolean = false) = 0;
00154   virtual bool Add(const char *name, uint32 v) = 0;
00155   virtual bool Add(const char *name, int64 v) = 0;
00156   virtual bool Add(const char *name, uint64 v) = 0;
00157   virtual bool Add(const char *name, float v) = 0;
00158   virtual bool Add(const char *name, double v) = 0;
00159   virtual bool Add(const char *name, char *v) = 0;
00160   virtual bool Add(const char *name, void *v, uint32 size) = 0;
00161 #ifndef CS_USE_FAKE_BOOL_TYPE
00162   virtual bool Add(const char *name, bool v, bool force_boolean = true) = 0;
00163 #endif
00164   virtual bool Add(const char *name, iEvent *v) = 0;
00165 
00166   virtual bool Find(const char *name, int8 &v, int index = 0) = 0;
00167   virtual bool Find(const char *name, uint8 &v, int index = 0) = 0;
00168   virtual bool Find(const char *name, int16 &v, int index = 0) = 0;
00169   virtual bool Find(const char *name, uint16 &v, int index = 0) = 0;
00170   virtual bool Find(const char *name, int32 &v, int index = 0) = 0;
00171   virtual bool Find(const char *name, uint32 &v, int index = 0) = 0;
00172   virtual bool Find(const char *name, int64 &v, int index = 0) = 0;
00173   virtual bool Find(const char *name, uint64 &v, int index = 0) = 0;
00174   virtual bool Find(const char *name, float &v, int index = 0) = 0;
00175   virtual bool Find(const char *name, double &v, int index = 0) = 0;
00176   virtual bool Find(const char *name, char **v, int index = 0) = 0;
00177   virtual bool Find(const char *name, void **v, uint32 &size, int index = 0) = 0;
00178 #ifndef CS_USE_FAKE_BOOL_TYPE
00179   virtual bool Find(const char *name, bool &v, int index = 0) = 0;
00180 #endif
00181   virtual bool Find(const char *name, iEvent **v, int index = 0) = 0;
00182 
00183   virtual bool Remove(const char *name, int index = -1) = 0;
00184   virtual bool RemoveAll() = 0;
00185   
00186   virtual bool Print(int level = 0) = 0;
00187 
00188   // Note: The user is responsible for allocating and deallocating this memory
00189   virtual uint32 FlattenSize(int format = CS_CRYSTAL_PROTOCOL) = 0;
00190   virtual bool Flatten(char *buffer, int format = CS_CRYSTAL_PROTOCOL) = 0;
00191   virtual bool Unflatten(const char *buffer, uint32 length) = 0;
00192 };
00193 
00231 SCF_VERSION (iEventPlug, 0, 0, 1);
00232 
00241 struct iEventPlug : public iBase
00242 {
00251   virtual unsigned GetPotentiallyConflictingEvents () = 0;
00252 
00261   virtual unsigned QueryEventPriority (unsigned iType) = 0;
00262 
00270   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
00271 };
00272 
00273 SCF_VERSION (iEventOutlet, 0, 1, 0);
00274 
00289 struct iEventOutlet : public iBase
00290 {
00299   virtual csPtr<iEvent> CreateEvent () = 0;
00300 
00307   virtual void Post (iEvent*) = 0;
00308 
00326   virtual void Key (int iKey, int iChar, bool iDown) = 0;
00327 
00335   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
00336 
00344   virtual void Joystick(int iNumber, int iButton, bool iDown, int x,int y) = 0;
00345 
00355   virtual void Broadcast (int iCode, void *iInfo = NULL) = 0;
00356 
00372   virtual void ImmediateBroadcast (int iCode, void *iInfo) = 0;
00373 };
00374 
00375 SCF_VERSION (iEventCord, 0, 0, 3);
00376 
00384 struct iEventCord : public iBase
00385 {
00393   virtual int Insert (iEventHandler*, int priority) = 0;
00394 
00398   virtual void Remove (iEventHandler*) = 0;
00399 
00404   virtual bool GetPass () const = 0;
00405 
00410   virtual void SetPass (bool) = 0;
00411 
00413   virtual int GetCategory() const = 0;
00414   // Get the subcategory of this cord.
00415   virtual int GetSubcategory() const = 0;
00416 };
00417 
00421 #endif // __CS_IUTIL_EVENT_H__

Generated for Crystal Space by doxygen 1.2.14