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 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 "iutil/evdefs.h"
00024 #include "csutil/ref.h"
00025 #include "csutil/scf.h"
00026 #include "csutil/csunicode.h"
00027 
00035 enum
00036 {
00037   CS_CRYSTAL_PROTOCOL = 0x43533030L, // 'CS00'
00038   CS_MUSCLE_PROTOCOL = 0x504d3030L, // 'PM00'
00039   CS_XML_PROTOCOL = 0x584d4d30L // 'XML0'
00040 };
00041 
00042 struct iEventHandler;
00043 struct iEvent;
00044 
00045 SCF_VERSION (iEvent, 0, 1, 1);
00046 
00047 // Event data structs. Defined outside of iEvent to allow SWIG to
00048 // handle the nested structs and union. Does not break any code.
00049 
00105 struct csKeyEventData
00106 {
00108   csKeyEventType eventType;
00110   utf32_char codeRaw;
00112   utf32_char codeCooked;
00114   csKeyModifiers modifiers;
00116   bool autoRepeat;
00118   csKeyCharType charType;
00119 };
00120 
00122 struct csEventMouseData
00123 {
00125   int x;
00127   int y;
00132   int Button;
00134   int Modifiers;
00135 };
00136 
00138 struct csEventJoystickData
00139 {
00141   int number;
00143   int x;
00145   int y;
00147   int Button;
00149   int Modifiers;
00150 };
00151 
00153 struct csEventCommandData
00154 {
00156   uint Code;
00158   void *Info;
00159 };
00160 
00176 struct iEvent : public iBase
00177 {
00179   uint8 Type;                   
00181   uint8 Category;               
00183   uint8 SubCategory;            
00185   uint8 Flags;                  
00187   csTicks Time;                 
00188   union
00189   {
00191     csEventMouseData Mouse;
00193     csEventJoystickData Joystick;
00195     csEventCommandData Command;
00196   };
00197 
00198   virtual bool Add(const char *name, int8 v) = 0;
00199   virtual bool Add(const char *name, uint8 v) = 0;
00200   virtual bool Add(const char *name, int16 v) = 0;
00201   virtual bool Add(const char *name, uint16 v) = 0;
00202   virtual bool Add(const char *name, int32 v, bool force_boolean = false) = 0;
00203   virtual bool Add(const char *name, uint32 v) = 0;
00204   virtual bool Add(const char *name, int64 v) = 0;
00205   virtual bool Add(const char *name, uint64 v) = 0;
00206   virtual bool Add(const char *name, float v) = 0;
00207   virtual bool Add(const char *name, double v) = 0;
00208   virtual bool Add(const char *name, const char *v) = 0;
00209   virtual bool Add(const char *name, const void *v, uint32 size) = 0;
00210 #ifndef CS_USE_FAKE_BOOL_TYPE
00211   virtual bool Add(const char *name, bool v, bool force_boolean = true) = 0;
00212 #endif
00213   virtual bool Add(const char *name, iEvent *v) = 0;
00214 
00215   virtual bool Find(const char *name, int8 &v, int index = 0) const = 0;
00216   virtual bool Find(const char *name, uint8 &v, int index = 0) const = 0;
00217   virtual bool Find(const char *name, int16 &v, int index = 0) const = 0;
00218   virtual bool Find(const char *name, uint16 &v, int index = 0) const = 0;
00219   virtual bool Find(const char *name, int32 &v, int index = 0) const = 0;
00220   virtual bool Find(const char *name, uint32 &v, int index = 0) const = 0;
00221   virtual bool Find(const char *name, int64 &v, int index = 0) const = 0;
00222   virtual bool Find(const char *name, uint64 &v, int index = 0) const = 0;
00223   virtual bool Find(const char *name, float &v, int index = 0) const = 0;
00224   virtual bool Find(const char *name, double &v, int index = 0) const = 0;
00225   virtual bool Find(const char *name, const char *&v, int index = 0) const = 0;
00226   virtual bool Find(const char *name, const void *&v, uint32 &size, 
00227     int index = 0) const = 0;
00228 #ifndef CS_USE_FAKE_BOOL_TYPE
00229   virtual bool Find(const char *name, bool &v, int index = 0) const = 0;
00230 #endif
00231   virtual bool Find(const char *name, csRef<iEvent> &v,
00232     int index = 0) const = 0;
00233 
00234   virtual bool Remove(const char *name, int index = -1) = 0;
00235   virtual bool RemoveAll() = 0;
00236   
00237   virtual bool Print(int level = 0) = 0;
00238 
00239   // Note: The user is responsible for allocating and deallocating this memory
00240   virtual uint32 FlattenSize(int format = CS_CRYSTAL_PROTOCOL) = 0;
00241   virtual bool Flatten(char *buffer, int format = CS_CRYSTAL_PROTOCOL) = 0;
00242   virtual bool Unflatten(const char *buffer, uint32 length) = 0;
00243 };
00244 
00282 SCF_VERSION (iEventPlug, 0, 0, 1);
00283 
00292 struct iEventPlug : public iBase
00293 {
00302   virtual unsigned GetPotentiallyConflictingEvents () = 0;
00303 
00312   virtual unsigned QueryEventPriority (unsigned iType) = 0;
00313 
00321   virtual void EnableEvents (unsigned /*iType*/, bool /*iEnable*/) {}
00322 };
00323 
00324 SCF_VERSION (iEventOutlet, 0, 1, 0);
00325 
00340 struct iEventOutlet : public iBase
00341 {
00350   virtual csPtr<iEvent> CreateEvent () = 0;
00351 
00358   virtual void Post (iEvent*) = 0;
00359 
00377   virtual void Key (utf32_char codeRaw, utf32_char codeCooked, bool iDown) = 0;
00378 
00386   virtual void Mouse (int iButton, bool iDown, int x, int y) = 0;
00387 
00395   virtual void Joystick(int iNumber, int iButton, bool iDown, int x,int y) = 0;
00396 
00406   virtual void Broadcast (int iCode, void *iInfo = 0) = 0;
00407 
00423   virtual void ImmediateBroadcast (int iCode, void *iInfo) = 0;
00424 };
00425 
00426 SCF_VERSION (iEventCord, 0, 0, 3);
00427 
00435 struct iEventCord : public iBase
00436 {
00444   virtual int Insert (iEventHandler*, int priority) = 0;
00445 
00449   virtual void Remove (iEventHandler*) = 0;
00450 
00455   virtual bool GetPass () const = 0;
00456 
00461   virtual void SetPass (bool) = 0;
00462 
00464   virtual int GetCategory() const = 0;
00465   // Get the subcategory of this cord.
00466   virtual int GetSubcategory() const = 0;
00467 };
00468 
00471 #endif // __CS_IUTIL_EVENT_H__

Generated for Crystal Space by doxygen 1.2.18