eventmanager.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2005
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under the LGPL. 
00008         
00009         I kindly request you display a splash screen (provided in the HTML documentation)
00010         to promote Kyra and acknowledge the software and everyone who has contributed to it, 
00011         but it is not required by the license.
00012 
00013 --- LGPL License --
00014 
00015     This library is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU Lesser General Public
00017     License as published by the Free Software Foundation; either
00018     version 2.1 of the License, or (at your option) any later version.
00019 
00020     This library is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023     Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public
00026     License along with this library; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029         The full text of the license can be found in lgpl.txt
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         //int keyFocus;
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 

Generated on Thu Jul 20 20:45:31 2006 for Kyra by  doxygen 1.4.7