00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_KrEventManager_INCLUDED
00033 #define KYRA_KrEventManager_INCLUDED
00034
00035 #ifdef _MSC_VER
00036 #pragma warning( disable : 4530 )
00037 #pragma warning( disable : 4786 )
00038 #endif
00039
00040 #include "SDL.h"
00041 #include <list>
00042
00043 class KrEngine;
00044 class KrWidget;
00045
00052 class KrEventManager
00053 {
00054 public:
00055 ~KrEventManager();
00056 static KrEventManager* Instance() { if ( !instance ) instance = new KrEventManager();
00057 return instance;
00058 }
00059
00061 bool HandleEvent( const SDL_Event& event, KrEngine* engine );
00062
00064 void SetAccelerator( int keymod, int keysym, KrWidget* );
00065
00066 void AddListener( KrWidget* widget );
00067 void RemoveListener( KrWidget* widget );
00068
00069 void GrabKeyFocus( KrWidget* w );
00070 void SelectMe( KrWidget* w );
00071
00072 private:
00073 enum eFOCUS
00074 {
00075 FOCUS_KEY_INVALID = -1
00076 };
00077 struct Accel
00078 {
00079 int keymod;
00080 int keysym;
00081 KrWidget* target;
00082
00083 bool operator==( const Accel& rhs ) { return rhs.target == target; }
00084 };
00085
00086 KrEventManager();
00087 static KrEventManager* instance;
00088
00089 void ChangeKeyFocus( KrWidget* newFocus );
00090
00091 bool HandleEventKeyDown( const SDL_Event& event, KrEngine* engine );
00092 bool HandleEventKeyUp( const SDL_Event& event, KrEngine* engine );
00093 bool HandleEventMouseMotion( const SDL_Event& event, KrEngine* engine );
00094 bool HandleEventMouseButton( const SDL_Event& event, KrEngine* engine );
00095
00096
00097
00098 KrWidget* keyFocus;
00099 KrWidget* mouseFocus;
00100 bool mouseDown;
00101
00102 std::list< KrWidget* > keyListeners;
00103 std::list< KrWidget* > mouseListeners;
00104
00105 std::list< Accel > accelListeners;
00106 };
00107
00108 #endif
00109