win_event_emitter.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
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         // Reset button flag state
00067         void resetButtonFlagState ();
00068         
00069         // enable / disable mouse events to be processed. The default is enabled.
00070         void enableMouseEvents(bool enabled = true) { _MouseEventsEnabled = enabled;}
00071         
00072         // enable / disable keyboard events to be processed. The default is enabled.
00073         void enableKeyboardEvents(bool enabled = true) { _KeyboardEventsEnabled = enabled;}
00074         
00075         // Test wether mouse events are enabled.
00076         bool areMouseEventsEnabled() const { return _MouseEventsEnabled; }
00077 
00078         // Test wether keyboard events are enabled.
00079         bool areKeyboardEventsEnabled() const { return _KeyboardEventsEnabled; }
00080 private:
00081         
00082 
00083         // Private internal server message
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         // private: may need to be in sync with direct input flags however...
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 } // NLMISC
00123 
00124 #endif // NL_OS_WINDOWS
00125 
00126 #endif // NL_WIN_EVENT_EMITTER_H
00127 
00128 /* End of win_event_emitter.h */

Generated on Tue Mar 16 06:41:41 2004 for NeL by doxygen 1.3.6