00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_WIN_EVENT_EMITTER_H
00027 #define NL_WIN_EVENT_EMITTER_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/event_emitter.h"
00031 #include "nel/misc/events.h"
00032
00033
00034 #ifdef NL_OS_WINDOWS
00035
00036 namespace NLMISC {
00037
00042 class CWinEventEmitter : public IEventEmitter
00043 {
00044 public:
00045 CWinEventEmitter () : _MouseEventsEnabled(true), _KeyboardEventsEnabled(true)
00046 {
00047 _HWnd=NULL;
00048 resetButtonFlagState ();
00049 }
00050 void setHWnd (uint32 hWnd)
00051 {
00052 _HWnd=hWnd;
00053 resetButtonFlagState ();
00054 }
00055
00061 virtual void submitEvents(CEventServer & server, bool allWindows);
00062
00064 TMouseButton buildFlags() const;
00065
00066
00067 void resetButtonFlagState ();
00068
00069
00070 void enableMouseEvents(bool enabled = true) { _MouseEventsEnabled = enabled;}
00071
00072
00073 void enableKeyboardEvents(bool enabled = true) { _KeyboardEventsEnabled = enabled;}
00074
00075
00076 bool areMouseEventsEnabled() const { return _MouseEventsEnabled; }
00077
00078
00079 bool areKeyboardEventsEnabled() const { return _KeyboardEventsEnabled; }
00080 private:
00081
00082
00083
00084 class CWinEventServer : CEventServer
00085 {
00086 friend class CWinEventEmitter;
00087 public:
00088 void setServer (CEventServer *server)
00089 {
00090 _Server=server;
00091 }
00092 private:
00093 virtual bool pumpEvent(CEvent* event)
00094 {
00095 CEventServer::pumpEvent(event);
00096 _Server->postEvent (event);
00097 return false;
00098 }
00099 private:
00100 CEventServer *_Server;
00101 };
00102
00103 public:
00106 void processMessage (uint32 hWnd, uint32 msg, uint32 wParam, uint32 lParam, CEventServer *server=NULL);
00107 private:
00108 CWinEventServer _InternalServer;
00109 uint32 _HWnd;
00110 public:
00111
00112 bool _CtrlButton;
00113 bool _ShiftButton;
00114 bool _AltButton;
00115 bool _MouseButtons[3];
00116 bool _MouseEventsEnabled;
00117 bool _KeyboardEventsEnabled;
00118 private:
00119 NLMISC::TMouseButton getButtons() const;
00120 };
00121
00122 }
00123
00124 #endif // NL_OS_WINDOWS
00125
00126 #endif // NL_WIN_EVENT_EMITTER_H
00127
00128