WndEvent.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2003 T. Zachary Laine
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License
00007    as published by the Free Software Foundation; either version 2.1
00008    of the License, or (at your option) any later version.
00009    
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014     
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA
00019 
00020    If you do not wish to comply with the terms of the LGPL please
00021    contact the author as other terms are available for a fee.
00022     
00023    Zach Laine
00024    whatwasthataddress@hotmail.com */
00025 
00029 #ifndef _GG_WndEvent_h_
00030 #define _GG_WndEvent_h_
00031 
00032 #include <GG/Base.h>
00033 #include <GG/Exception.h>
00034 #include <GG/Flags.h>
00035 
00036 #include <map>
00037 
00038 
00039 namespace GG {
00040 
00041 class Timer;
00042 class Wnd;
00043 
00044 // Adpated from SDLKey enum in SDL_keysym.h of the SDL library.
00045 GG_FLAG_TYPE(ModKey);
00046 extern GG_API const ModKey MOD_KEY_NONE;         
00047 extern GG_API const ModKey MOD_KEY_LSHIFT;       
00048 extern GG_API const ModKey MOD_KEY_RSHIFT;       
00049 extern GG_API const ModKey MOD_KEY_LCTRL;        
00050 extern GG_API const ModKey MOD_KEY_RCTRL;        
00051 extern GG_API const ModKey MOD_KEY_LALT;         
00052 extern GG_API const ModKey MOD_KEY_RALT;         
00053 extern GG_API const ModKey MOD_KEY_LMETA;        
00054 extern GG_API const ModKey MOD_KEY_RMETA;        
00055 extern GG_API const ModKey MOD_KEY_NUM;          
00056 extern GG_API const ModKey MOD_KEY_CAPS;         
00057 extern GG_API const ModKey MOD_KEY_MODE;         
00058 extern GG_API const Flags<ModKey> MOD_KEY_CTRL;  
00059 extern GG_API const Flags<ModKey> MOD_KEY_SHIFT; 
00060 extern GG_API const Flags<ModKey> MOD_KEY_ALT;   
00061 extern GG_API const Flags<ModKey> MOD_KEY_META;  
00062 
00069 class GG_API WndEvent
00070 {
00071 public:
00073     enum EventType {
00074         LButtonDown,
00075         LDrag,
00076         LButtonUp,
00077         LClick,
00078         LDoubleClick,
00079         MButtonDown,
00080         MDrag,
00081         MButtonUp,
00082         MClick,
00083         MDoubleClick,
00084         RButtonDown,
00085         RDrag,
00086         RButtonUp,
00087         RClick,
00088         RDoubleClick,
00089         MouseEnter,
00090         MouseHere,
00091         MouseLeave,
00092         MouseWheel,
00093         DragDropEnter,
00094         DragDropHere,
00095         DragDropLeave,
00096         KeyPress,
00097         KeyRelease,
00098         GainingFocus,
00099         LosingFocus,
00100         TimerFiring
00101     };
00102 
00105     WndEvent(EventType type, const Pt& pt, Flags<ModKey> mod_keys);
00106 
00109     WndEvent(EventType type, const Pt& pt, const Pt& move, Flags<ModKey> mod_keys);
00110 
00113     WndEvent(EventType type, const Pt& pt, int move, Flags<ModKey> mod_keys);
00114 
00117     WndEvent(EventType type, const Pt& pt, const std::map<Wnd*, Pt>& drag_drop_wnds, Flags<ModKey> mod_keys);
00118 
00121     WndEvent(EventType type, Key key, Flags<ModKey> mod_keys);
00122 
00124     WndEvent(EventType type, int ticks, Timer* timer);
00125 
00127     explicit WndEvent(EventType type);
00128 
00129     EventType                 Type() const;         
00130     const Pt&                 Point() const;        
00131     Key                       GetKey() const;       
00132     Flags<ModKey>             ModKeys() const;      
00133     const Pt&                 DragMove() const;     
00134     int                       WheelMove() const;    
00135     const std::map<Wnd*, Pt>& DragDropWnds() const; 
00136     int                       Ticks() const;        
00137     Timer*                    GetTimer() const;     
00138 
00139 private:
00140     EventType          m_type;
00141     Pt                 m_point;
00142     Key                m_key;
00143     Flags<ModKey>      m_mod_keys;
00144     Pt                 m_drag_move;
00145     int                m_wheel_move;
00146     std::map<Wnd*, Pt> m_drag_drop_wnds;
00147     int                m_ticks;
00148     Timer*             m_timer;
00149 };
00150 
00151 } // namespace GG
00152 
00153 #endif

Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2