events.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_EVENTS_H
00025 #define NL_EVENTS_H
00026 
00027 #include "types_nl.h"
00028 #include "class_id.h"
00029 #include <map>
00030 #include <list>
00031 
00032 namespace NLMISC {
00033 
00034 /*===================================================================*/
00035 
00036 class IEventEmitter;
00037 
00042 class CEvent : public CClassId
00043 {
00044 public:
00046     IEventEmitter* Emitter;
00047 
00048     // duplicate the object
00049     virtual CEvent      *clone() const =0;
00050 
00051     virtual ~CEvent() {}
00052 
00053 protected:
00058     CEvent (IEventEmitter* emitter, const CClassId& classId) : CClassId (classId)
00059     {
00060         Emitter=emitter;
00061     }
00062 };
00063 
00064 // Key events
00065 const CClassId EventKeyDownId (0x3c2643da, 0x43f802a1);
00066 const CClassId EventKeyUpId (0x1e62e85, 0x68a35d46);
00067 const CClassId EventCharId (0x552255fe, 0x75a2373f);
00068 
00069 // Window events
00070 const CClassId EventActivateId (0x7da66b0a, 0x1ef74519);
00071 const CClassId EventSetFocusId (0x17650fac, 0x19f85dde);
00072 const CClassId EventDestroyWindowId (0x69be73fe, 0x4b07603b);
00073 
00074 // Mouse events
00075 const CClassId EventMouseMoveId (0x3dd12fdb, 0x472f548b);
00076 const CClassId EventMouseDownId (0x35b7878, 0x5d4a0f86);
00077 const CClassId EventMouseUpId (0xcce1f7e, 0x7ed344d7);
00078 const CClassId EventMouseDblClkId (0x55a94cb3, 0x3e641517);
00079 const CClassId EventMouseWheelId (0x73ac4321, 0x4c273150);
00080 
00081 // Misc events
00082 const CClassId EventDisplayChangeId(0x1751559, 0x25b52b3c);
00083 
00084 // Input Mehod Editor (IME) events
00085 const CClassId EventIME (0x261f1ede, 0x1b0a6c3a);
00086 
00087 
00088 enum TKey
00089 {
00090     Key0                ='0',
00091     Key1                ='1',
00092     Key2                ='2',
00093     Key3                ='3',
00094     Key4                ='4',
00095     Key5                ='5',
00096     Key6                ='6',
00097     Key7                ='7',
00098     Key8                ='8',
00099     Key9                ='9',
00100     KeyA                ='A',
00101     KeyB                ='B',
00102     KeyC                ='C',
00103     KeyD                ='D',
00104     KeyE                ='E',
00105     KeyF                ='F',
00106     KeyG                ='G',
00107     KeyH                ='H',
00108     KeyI                ='I',
00109     KeyJ                ='J',
00110     KeyK                ='K',
00111     KeyL                ='L',
00112     KeyM                ='M',
00113     KeyN                ='N',
00114     KeyO                ='O',
00115     KeyP                ='P',
00116     KeyQ                ='Q',
00117     KeyR                ='R',
00118     KeyS                ='S',
00119     KeyT                ='T',
00120     KeyU                ='U',
00121     KeyV                ='V',
00122     KeyW                ='W',
00123     KeyX                ='X',
00124     KeyY                ='Y',
00125     KeyZ                ='Z',
00126     KeyLBUTTON        =0x01,
00127     KeyRBUTTON        =0x02,
00128     KeyCANCEL         =0x03,
00129     KeyMBUTTON        =0x04,
00130     KeyBACK           =0x08,
00131     KeyTAB            =0x09,
00132     KeyCLEAR          =0x0C,
00133     KeyRETURN         =0x0D,
00134     KeySHIFT          =0x10,
00135     KeyCONTROL        =0x11,
00136     KeyMENU           =0x12,
00137     KeyPAUSE          =0x13,
00138     KeyCAPITAL        =0x14,
00139     KeyKANA           =0x15,
00140     KeyHANGEUL        =0x15,
00141     KeyHANGUL         =0x15,
00142     KeyJUNJA          =0x17,
00143     KeyFINAL          =0x18,
00144     KeyHANJA          =0x19,
00145     KeyKANJI          =0x19,
00146     KeyESCAPE         =0x1B,
00147     KeyCONVERT        =0x1C,
00148     KeyNONCONVERT     =0x1D,
00149     KeyACCEPT         =0x1E,
00150     KeyMODECHANGE     =0x1F,
00151     KeySPACE          =0x20,
00152     KeyPRIOR          =0x21,
00153     KeyNEXT           =0x22,
00154     KeyEND            =0x23,
00155     KeyHOME           =0x24,
00156     KeyLEFT           =0x25,
00157     KeyUP             =0x26,
00158     KeyRIGHT          =0x27,
00159     KeyDOWN           =0x28,
00160     KeySELECT         =0x29,
00161     KeyPRINT          =0x2A,
00162     KeyEXECUTE        =0x2B,
00163     KeySNAPSHOT       =0x2C,
00164     KeyINSERT         =0x2D,
00165     KeyDELETE         =0x2E,
00166     KeyHELP           =0x2F,
00167     KeyLWIN           =0x5B,
00168     KeyRWIN           =0x5C,
00169     KeyAPPS           =0x5D,
00170     KeyNUMPAD0        =0x60,
00171     KeyNUMPAD1        =0x61,
00172     KeyNUMPAD2        =0x62,
00173     KeyNUMPAD3        =0x63,
00174     KeyNUMPAD4        =0x64,
00175     KeyNUMPAD5        =0x65,
00176     KeyNUMPAD6        =0x66,
00177     KeyNUMPAD7        =0x67,
00178     KeyNUMPAD8        =0x68,
00179     KeyNUMPAD9        =0x69,
00180     KeyMULTIPLY       =0x6A,
00181     KeyADD            =0x6B,
00182     KeySEPARATOR      =0x6C,
00183     KeySUBTRACT       =0x6D,
00184     KeyDECIMAL        =0x6E,
00185     KeyDIVIDE         =0x6F,
00186     KeyF1             =0x70,
00187     KeyF2             =0x71,
00188     KeyF3             =0x72,
00189     KeyF4             =0x73,
00190     KeyF5             =0x74,
00191     KeyF6             =0x75,
00192     KeyF7             =0x76,
00193     KeyF8             =0x77,
00194     KeyF9             =0x78,
00195     KeyF10            =0x79,
00196     KeyF11            =0x7A,
00197     KeyF12            =0x7B,
00198     KeyF13            =0x7C,
00199     KeyF14            =0x7D,
00200     KeyF15            =0x7E,
00201     KeyF16            =0x7F,
00202     KeyF17            =0x80,
00203     KeyF18            =0x81,
00204     KeyF19            =0x82,
00205     KeyF20            =0x83,
00206     KeyF21            =0x84,
00207     KeyF22            =0x85,
00208     KeyF23            =0x86,
00209     KeyF24            =0x87,
00210     KeyNUMLOCK        =0x90,
00211     KeySCROLL         =0x91,
00212     KeyLSHIFT         =0xA0,
00213     KeyRSHIFT         =0xA1,
00214     KeyLCONTROL       =0xA2,
00215     KeyRCONTROL       =0xA3,
00216     KeyLMENU          =0xA4,
00217     KeyRMENU          =0xA5,
00218     KeySEMICOLON      =0xBA,
00219     KeyEQUALS     =0xBB,
00220     KeyCOMMA      =0xBC,
00221     KeyDASH       =0xBD,
00222     KeyPERIOD     =0xBE,
00223     KeySLASH      =0xBF,
00224     KeyTILDE      =0xC0,
00225     KeyLBRACKET   =0xDB,
00226     KeyBACKSLASH      =0xDC,
00227     KeyRBRACKET   =0xDD,
00228     KeyAPOSTROPHE     =0xDE,
00229     KeyPARAGRAPH    =0xDF,
00230     KeyOEM_102      =0xE2,
00231     KeyPROCESSKEY     =0xE5,
00232     KeyATTN           =0xF6,
00233     KeyCRSEL          =0xF7,
00234     KeyEXSEL          =0xF8,
00235     KeyEREOF          =0xF9,
00236     KeyPLAY           =0xFA,
00237     KeyZOOM           =0xFB,
00238     KeyNONAME         =0xFC,
00239     KeyPA1            =0xFD,
00240     KeyOEM_CLEAR      =0xFE,
00241     KeyCount          =0xFF
00242 };
00243 
00244 enum TMouseButton
00245 {
00246     noButton        =0x0,
00247     leftButton      =0x1,
00248     middleButton    =0x2,
00249     rightButton     =0x4,
00250     ctrlButton      =0x8,
00251     shiftButton     =0x10,
00252     altButton       =0x20
00253 };
00254 
00255 enum TKeyButton
00256 {
00257     noKeyButton         =0x0,
00258     ctrlKeyButton       =0x8,
00259     shiftKeyButton      =0x10,
00260     altKeyButton        =0x20
00261 };
00262 
00266 class CEventKey : public CEvent
00267 {
00268 public:
00269     CEventKey (TKeyButton button, IEventEmitter* emitter, const CClassId& classId) : CEvent (emitter, classId)
00270     {
00271         Button=button;
00272     }
00273     TKeyButton Button;
00274 
00275 public:
00276     // return a TKey for its associated String (eg KeyA for "KeyA")
00277     static  TKey                getKeyFromString(const std::string &str);
00278     // return the string equivalent to the TKey (eg "KeyA" for KeyA)
00279     static  const std::string   &getStringFromKey(TKey k);
00280 };
00281 
00286 class CEventKeyDown : public CEventKey
00287 {
00288 public:
00289     CEventKeyDown (TKey key, TKeyButton button, bool bFirstTime, IEventEmitter* emitter) : CEventKey (button, emitter, EventKeyDownId)
00290     {
00291         Key=key;
00292         FirstTime=bFirstTime;
00293     }
00294     TKey Key;
00295     bool FirstTime;
00296 
00297     virtual CEvent          *clone() const {return new CEventKeyDown(*this);}
00298 };
00299 
00303 class CEventKeyUp : public CEventKey
00304 {
00305 public:
00306     CEventKeyUp (TKey key, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventKeyUpId)
00307     {
00308         Key=key;
00309     }
00310     TKey Key;
00311 
00312     virtual CEvent          *clone() const {return new CEventKeyUp(*this);}
00313 };
00314 
00318 class CEventChar : public CEventKey
00319 {
00320 public:
00321     CEventChar (ucchar c, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventCharId), _Raw(true)
00322     {
00323         Char=c;
00324     }
00325     ucchar Char;
00326 
00327     virtual CEvent          *clone() const {return new CEventChar(*this);}
00328     void                    setRaw( bool raw ) { _Raw = raw; }
00329     bool                    isRaw() const { return _Raw; }
00330 
00331 private:
00332     bool    _Raw; // true if raw, false if composed by an IME
00333 
00334 };
00335 
00336 
00341 class CEventMouse : public CEvent
00342 {
00343 public:
00344     float X,Y;
00345     TMouseButton Button;
00346 
00347     CEventMouse (float x, float y, TMouseButton button, IEventEmitter* emitter, const CClassId& classId) : CEvent (emitter, classId)
00348     {
00349         X = x;
00350         Y = y;
00351         Button = button;
00352     }
00353 };
00354 
00355 
00361 class CEventMouseDown : public CEventMouse
00362 {
00363 public:
00364     CEventMouseDown (float x, float y, TMouseButton button, IEventEmitter* emitter) : CEventMouse (x, y, button, emitter, EventMouseDownId)
00365     {}
00366 
00367     virtual CEvent          *clone() const {return new CEventMouseDown(*this);}
00368 };
00369 
00370 
00376 class CEventMouseUp : public CEventMouse
00377 {
00378 public:
00379     CEventMouseUp (float x, float y, TMouseButton button, IEventEmitter* emitter) : CEventMouse (x, y, button, emitter, EventMouseUpId)
00380     {}
00381 
00382     virtual CEvent          *clone() const {return new CEventMouseUp(*this);}
00383 };
00384 
00385 
00391 class CEventMouseMove : public CEventMouse
00392 {
00393 public:
00394     CEventMouseMove (float x, float y, TMouseButton button, IEventEmitter* emitter) : CEventMouse (x, y, button, emitter, EventMouseMoveId)
00395     {}
00396 
00397     virtual CEvent          *clone() const {return new CEventMouseMove(*this);}
00398 };
00399 
00400 
00406 class CEventMouseDblClk : public CEventMouse
00407 {
00408 public:
00409     CEventMouseDblClk (float x, float y, TMouseButton button, IEventEmitter* emitter) : CEventMouse (x, y, button, emitter, EventMouseDblClkId)
00410     {}
00411 
00412     virtual CEvent          *clone() const {return new CEventMouseDblClk(*this);}
00413 };
00414 
00415 
00423 class CEventMouseWheel : public CEventMouse
00424 {
00425 public:
00426     bool    Direction;
00427     CEventMouseWheel (float x, float y, TMouseButton button, bool direction, IEventEmitter* emitter) : CEventMouse (x, y, button, emitter, EventMouseWheelId)
00428     {
00429         Direction=direction;
00430     }
00431 
00432     virtual CEvent          *clone() const {return new CEventMouseWheel(*this);}
00433 };
00434 
00435 
00439 class CEventActivate : public CEvent
00440 {
00441 public:
00445     bool Activate;
00446 
00451     CEventActivate (bool activate, IEventEmitter* emitter) : CEvent (emitter, EventActivateId)
00452     {
00453         Activate = activate;
00454     }
00455 
00456     virtual CEvent          *clone() const {return new CEventActivate(*this);}
00457 };
00458 
00459 
00463 class CEventSetFocus : public CEvent
00464 {
00465 public:
00469     bool Get;
00470 
00475     CEventSetFocus (bool get, IEventEmitter* emitter) : CEvent (emitter, EventSetFocusId)
00476     {
00477         Get = get;
00478     }
00479 
00480     virtual CEvent          *clone() const {return new CEventSetFocus(*this);}
00481 };
00482 
00483 
00487 class CEventDestroyWindow : public CEvent
00488 {
00489 public:
00490     CEventDestroyWindow (IEventEmitter* emitter) : CEvent (emitter, EventDestroyWindowId)
00491     {
00492     }
00493 
00494     virtual CEvent          *clone() const {return new CEventDestroyWindow(*this);}
00495 };
00496 
00500 class CEventIME : public CEvent
00501 {
00502 public:
00503     CEventIME (uint32 msg, uint32 wParam, uint32 lParam, IEventEmitter* emitter) : CEvent (emitter, EventIME), EventMessage(msg), WParam(wParam), LParam(lParam)
00504     {}
00505 
00506     uint32  EventMessage;
00507     uint32  WParam, LParam;
00508 
00509     virtual CEvent          *clone() const {return new CEventIME(*this);}
00510 };
00511 
00515 class CEventDisplayChange : public CEvent
00516 {
00517 public:
00518     uint Width;
00519     uint Height;
00520     uint BitDepth;
00521 
00526     CEventDisplayChange(uint width, uint height, uint bitDepth, IEventEmitter* emitter) : CEvent (emitter, EventDisplayChangeId)
00527     {
00528         Width    = width;
00529         Height   = height;
00530         BitDepth = bitDepth;
00531     }
00532 
00533     virtual CEvent          *clone() const {return new CEventDisplayChange(*this);}
00534 };
00535 
00536 
00537 } // NLMISC
00538 
00539 
00540 #endif // NL_EVENTS_H
00541 
00542 /* End of events.h */

Generated on Thu Jan 7 08:26:22 2010 for NeL by  doxygen 1.6.1