GG: WndEvent.h Source File

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

WndEvent.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3 Copyright (C) 2003-2008 T. Zachary Laine
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 2.1
8 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA
19
20 If you do not wish to comply with the terms of the LGPL please
21 contact the author as other terms are available for a fee.
22
23 Zach Laine
24 whatwasthataddress@gmail.com */
25
29 #ifndef _GG_WndEvent_h_
30 #define _GG_WndEvent_h_
31
32 #include <GG/Base.h>
33 #include <GG/Exception.h>
34 #include <GG/Flags.h>
35
36 #include <map>
37
38
39 namespace GG {
40
41 class Timer;
42 class Wnd;
43
44 // Adpated from SDLKey enum in SDL_keysym.h of the SDL library.
45 GG_FLAG_TYPE(ModKey);
46 extern GG_API const ModKey MOD_KEY_NONE;
47 extern GG_API const ModKey MOD_KEY_LSHIFT;
48 extern GG_API const ModKey MOD_KEY_RSHIFT;
49 extern GG_API const ModKey MOD_KEY_LCTRL;
50 extern GG_API const ModKey MOD_KEY_RCTRL;
51 extern GG_API const ModKey MOD_KEY_LALT;
52 extern GG_API const ModKey MOD_KEY_RALT;
53 extern GG_API const ModKey MOD_KEY_LMETA;
54 extern GG_API const ModKey MOD_KEY_RMETA;
55 extern GG_API const ModKey MOD_KEY_NUM;
56 extern GG_API const ModKey MOD_KEY_CAPS;
57 extern GG_API const ModKey MOD_KEY_MODE;
58 extern GG_API const Flags<ModKey> MOD_KEY_CTRL;
59 extern GG_API const Flags<ModKey> MOD_KEY_SHIFT;
60 extern GG_API const Flags<ModKey> MOD_KEY_ALT;
61 extern GG_API const Flags<ModKey> MOD_KEY_META;
62
74 class GG_API WndEvent
75 {
76 public:
79 enum EventType {
80 LButtonDown,
81 LDrag,
82 LButtonUp,
83 LClick,
84 LDoubleClick,
85 MButtonDown,
86 MDrag,
87 MButtonUp,
88 MClick,
89 MDoubleClick,
90 RButtonDown,
91 RDrag,
92 RButtonUp,
93 RClick,
94 RDoubleClick,
95 MouseEnter,
96 MouseHere,
97 MouseLeave,
98 MouseWheel,
99 DragDropEnter,
100 DragDropHere,
101 DragDropLeave,
102 KeyPress,
103 KeyRelease,
104 GainingFocus,
105 LosingFocus,
106 TimerFiring
107 };
108
112 WndEvent(EventType type, const Pt& pt, Flags<ModKey> mod_keys);
113
117 WndEvent(EventType type, const Pt& pt, const Pt& move, Flags<ModKey> mod_keys);
118
122 WndEvent(EventType type, const Pt& pt, int move, Flags<ModKey> mod_keys);
123
127 WndEvent(EventType type, const Pt& pt, const std::map<Wnd*, Pt>& drag_drop_wnds, Flags<ModKey> mod_keys);
128
131 WndEvent(EventType type, Key key, boost::uint32_t code_point, Flags<ModKey> mod_keys);
132
135 WndEvent(EventType type, unsigned int ticks, Timer* timer);
136
139 explicit WndEvent(EventType type);
140
141 EventType Type() const;
142 const Pt& Point() const;
143 Key GetKey() const;
144 boost::uint32_t KeyCodePoint() const;
145 Flags<ModKey> ModKeys() const;
146 const Pt& DragMove() const;
147 int WheelMove() const;
148 const std::map<Wnd*, Pt>& DragDropWnds() const;
149 unsigned int Ticks() const;
150 Timer* GetTimer() const;
151
152 private:
153 EventType m_type;
154 Pt m_point;
155 Key m_key;
156 boost::uint32_t m_key_code_point;
157 Flags<ModKey> m_mod_keys;
158 Pt m_drag_move;
159 int m_wheel_move;
160 std::map<Wnd*, Pt> m_drag_drop_wnds;
161 unsigned int m_ticks;
162 Timer* m_timer;
163 };
164
165 } // namespace GG
166
167 #endif