CrystalSpace

Public API Reference

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

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 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/ref.h"
00025 #include "csutil/scf.h"
00026 #include "csutil/csunicode.h"
00027 
00035 enum {
00036   CS_CRYSTAL_PROTOCOL = 0x43533030L, // 'CS00'
00037   CS_MUSCLE_PROTOCOL = 0x504d3030L, // 'PM00'
00038   CS_XML_PROTOCOL = 0x584d4d30L // 'XML0'
00039 };
00040 
00041 struct iEventHandler;
00042 struct iEvent;
00043 
00044 struct iNetworkConnection;
00045 struct iNetworkPacket;
00046 
00047 struct iNetworkSocket2;
00048 struct iNetworkPacket2;
00049 
00050 SCF_VERSION (iEvent, 0, 1, 1);
00051 
00052 // Event data structs. Defined outside of iEvent to allow SWIG to
00053 // handle the nested structs and union. Does not break any code.
00054 
00110 struct csKeyEventData
00111 {
00113   csKeyEventType eventType;
00115   utf32_char codeRaw;
00117   utf32_char codeCooked;
00119   csKeyModifiers modifiers;
00121   bool autoRepeat;
00123   csKeyCharType charType;
00124 };
00125 
00127 struct csEventMouseData
00128 {
00130   int x;
00132   int y;
00137   int Button;
00139   int Modifiers;
00140 };
00141 
00143 struct csEventJoystickData
00144 {
00146   int number;
00148   int x;
00150   int y;
00152   int Button;
00154   int Modifiers;
00155 };
00156 
00158 struct csEventCommandData
00159 {
00161   uint Code;
00163   void *Info;
00164 };
00165 
00167 struct csEventNetworkData
00168 {
00169   union
00170   {
00172     iNetworkConnection *From;
00174     iNetworkSocket2 *From2;
00175   };
00176   union
00177   {
00179     iNetworkPacket *Data;
00181     iNetworkPacket2 *Data2;
00182   };
00183 };
00184 
00200 struct iEvent : public iBase
00201 {
00203   uint8 Type;                   
00205   uint8 Category;               
00207   uint8 SubCategory;            
00209   uint8 Flags;                  
00211   csTicks Time;                 
00212   union
00213   {
00215     csEventMouseData Mouse;
00217     csEventJoystickData Joystick;
00219     csEventCommandData Command;
00221     csEventNetworkData Network;
00222   };
00223 
00224   virtual bool Add(const char *name, int8 v) = 0;
00225   virtual bool Add(const char *name, uint8 v) = 0;
00226   virtual bool Add(const char *name, int16 v) = 0;
00227   virtual bool Add(const char *name, uint16 v) = 0;
00228   virtual bool Add(const char *name, int32 v, bool force_boolean = false) = 0;
00229   virtual bool Add(const char *name, uint32 v) = 0;
00230   virtual bool Add(const char *name, int64 v) = 0;
00231   virtual bool Add(const char *name, uint64 v) = 0;
00232   virtual bool Add(const char *name, float v) = 0;
00233   virtual bool Add(const char *name, double v) = 0;
00234   virtual bool Add(const char *name, const char *v) = 0;
00235   virtual bool Add(const char *name, const void *v, uint32 size) = 0;
00236 #ifndef CS_USE_FAKE_BOOL_TYPE
00237   virtual bool Add(const char *name, bool v, bool force_boolean = true) = 0;
00238 #endif
00239   virtual bool Add(const char *name, iEvent *v) = 0;
00240 
00241   virtual bool Find(const char *name, int8 &v, int index = 0) const = 0;
00242   virtual bool Find(const char *name, uint8 &v, int index = 0) const = 0;
00243   virtual bool Find(const char *name, int16 &v, int index = 0) const = 0;
00244   virtual bool Find(const char *name, uint16 &v, int index = 0) const = 0;
00245   virtual bool Find(const char *name, int32 &v, int index = 0) const = 0;
00246   virtual bool Find(const char *name, uint32 &v, int index = 0) const = 0;
00247   virtual bool Find(const char *name, int64 &v, int index = 0) const = 0;
00248   virtual bool Find(const char *name, uint64 &v, int index = 0) const = 0;
00249   virtual bool Find(const char *name, float &v, int index = 0) const = 0;
00250   virtual bool Find(const char *name, double &v, int index = 0) const = 0;
00251   virtual bool Find(const char *name, const char *&v, int index = 0) const = 0;
00252   virtual bool Find(const char *name, const void *&v, uint32 &size, 
00253     int index = 0) const = 0;
00254 #ifndef CS_USE_FAKE_BOOL_TYPE
00255   virtual bool Find(const char *name, bool &v, int index = 0) const = 0;
00256 #endif
00257   virtual bool Find(const char *name, csRef<iEvent> &v,
00258     int index = 0) const = 0;
00259 
00260   virtual bool Remove(const char *name, int index = -1) = 0;
00261   virtual bool RemoveAll() = 0;
00262   
00263   virtual bool Print(int level = 0) = 0;
00264 
00265   // Note: The user is responsible for allocating and deallocating this memory
00266   virtual uint32 FlattenSize(int format = CS_CRYSTAL_PROTOCOL) = 0;
00267   virtual bool Flatten(char *buffer, int format = CS_CRYSTAL_PROTOCOL) = 0;
00268   virtual bool Unflatten(const char *buffer, uint32 length) = 0;
00269 };
00270 
00308 SCF_VERSION (iEventPlug, 0, 0, 1);
00309 
00318 struct iEventPlug : public iBase
00319 {
00328   virtual unsigned GetPotentiallyConflictingEvents () = 0;
00329 
00338   virtual unsigned QueryEventPriority (unsigned iType) = 0;
00339 
00347   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
00348 };
00349 
00350 SCF_VERSION (iEventOutlet, 0, 1, 0);
00351 
00366 struct iEventOutlet : public iBase
00367 {
00376   virtual csPtr<iEvent> CreateEvent () = 0;
00377 
00384   virtual void Post (iEvent*) = 0;
00385 
00403   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown) = 0;
00404 
00412   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
00413 
00421   virtual void Joystick(int iNumber, int iButton, bool iDown, int x,int y) = 0;
00422 
00432   virtual void Broadcast (int iCode, void *iInfo = 0) = 0;
00433 
00449   virtual void ImmediateBroadcast (int iCode, void *iInfo) = 0;
00450 };
00451 
00452 SCF_VERSION (iEventCord, 0, 0, 3);
00453 
00461 struct iEventCord : public iBase
00462 {
00470   virtual int Insert (iEventHandler*, int priority) = 0;
00471 
00475   virtual void Remove (iEventHandler*) = 0;
00476 
00481   virtual bool GetPass () const = 0;
00482 
00487   virtual void SetPass (bool) = 0;
00488 
00490   virtual int GetCategory() const = 0;
00491   // Get the subcategory of this cord.
00492   virtual int GetSubcategory() const = 0;
00493 };
00494 
00497 #endif // __CS_IUTIL_EVENT_H__

Generated for Crystal Space by doxygen 1.2.18