GG
|
00001 // -*- C++ -*- 00002 /* GG is a GUI for SDL and OpenGL. 00003 Copyright (C) 2003-2008 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@gmail.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 00074 class GG_API WndEvent 00075 { 00076 public: 00079 enum EventType { 00080 LButtonDown, 00081 LDrag, 00082 LButtonUp, 00083 LClick, 00084 LDoubleClick, 00085 MButtonDown, 00086 MDrag, 00087 MButtonUp, 00088 MClick, 00089 MDoubleClick, 00090 RButtonDown, 00091 RDrag, 00092 RButtonUp, 00093 RClick, 00094 RDoubleClick, 00095 MouseEnter, 00096 MouseHere, 00097 MouseLeave, 00098 MouseWheel, 00099 DragDropEnter, 00100 DragDropHere, 00101 DragDropLeave, 00102 KeyPress, 00103 KeyRelease, 00104 GainingFocus, 00105 LosingFocus, 00106 TimerFiring 00107 }; 00108 00112 WndEvent(EventType type, const Pt& pt, Flags<ModKey> mod_keys); 00113 00117 WndEvent(EventType type, const Pt& pt, const Pt& move, Flags<ModKey> mod_keys); 00118 00122 WndEvent(EventType type, const Pt& pt, int move, Flags<ModKey> mod_keys); 00123 00127 WndEvent(EventType type, const Pt& pt, const std::map<Wnd*, Pt>& drag_drop_wnds, Flags<ModKey> mod_keys); 00128 00131 WndEvent(EventType type, Key key, boost::uint32_t code_point, Flags<ModKey> mod_keys); 00132 00135 WndEvent(EventType type, unsigned int ticks, Timer* timer); 00136 00139 explicit WndEvent(EventType type); 00140 00141 EventType Type() const; 00142 const Pt& Point() const; 00143 Key GetKey() const; 00144 boost::uint32_t KeyCodePoint() const; 00145 Flags<ModKey> ModKeys() const; 00146 const Pt& DragMove() const; 00147 int WheelMove() const; 00148 const std::map<Wnd*, Pt>& DragDropWnds() const; 00149 unsigned int Ticks() const; 00150 Timer* GetTimer() const; 00151 00152 private: 00153 EventType m_type; 00154 Pt m_point; 00155 Key m_key; 00156 boost::uint32_t m_key_code_point; 00157 Flags<ModKey> m_mod_keys; 00158 Pt m_drag_move; 00159 int m_wheel_move; 00160 std::map<Wnd*, Pt> m_drag_drop_wnds; 00161 unsigned int m_ticks; 00162 Timer* m_timer; 00163 }; 00164 00165 } // namespace GG 00166 00167 #endif