comparison ext/guichan-0.8.2/include/guichan/mouseevent.hpp @ 378:64738befdf3b

bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 11 Jan 2010 23:34:52 +0000
parents
children
comparison
equal deleted inserted replaced
377:fe6fb0e0ed23 378:64738befdf3b
1 /* _______ __ __ __ ______ __ __ _______ __ __
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8 *
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
10 *
11 *
12 * Per Larsson a.k.a finalman
13 * Olof Naessén a.k.a jansem/yakslem
14 *
15 * Visit: http://guichan.sourceforge.net
16 *
17 * License: (BSD)
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 * 3. Neither the name of Guichan nor the names of its contributors may
28 * be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 #ifndef GCN_MOUSEEVENT_HPP
45 #define GCN_MOUSEEVENT_HPP
46
47 #include "guichan/inputevent.hpp"
48 #include "guichan/platform.hpp"
49
50 namespace gcn
51 {
52 class Gui;
53 class Widget;
54
55 /**
56 * Represents a mouse event.
57 *
58 * @author Olof Naessén
59 * @since 0.6.0
60 */
61 class GCN_CORE_DECLSPEC MouseEvent: public InputEvent
62 {
63 public:
64
65 /**
66 * Constructor.
67 *
68 * @param source The source widget of the mouse event.
69 * @param isShiftPressed True if shift is pressed, false otherwise.
70 * @param isControlPressed True if control is pressed, false otherwise.
71 * @param isAltPressed True if alt is pressed, false otherwise.
72 * @param isMetaPressed True if meta is pressed, false otherwise.
73 * @param type The type of the mouse event.
74 * @param button The button of the mouse event.
75 * @param x The x coordinate of the event relative to the source widget.
76 * @param y The y coordinate of the event relative the source widget.
77 * @param clickCount The number of clicks generated with the same button.
78 * It's set to zero if another button is used.
79 */
80 MouseEvent(Widget* source,
81 bool isShiftPressed,
82 bool isControlPressed,
83 bool isAltPressed,
84 bool isMetaPressed,
85 unsigned int type,
86 unsigned int button,
87 int x,
88 int y,
89 int clickCount);
90
91 /**
92 * Gets the button of the mouse event.
93 *
94 * @return The button of the mouse event.
95 */
96 unsigned int getButton() const;
97
98 /**
99 * Gets the x coordinate of the mouse event.
100 * The coordinate relative to widget the mouse listener
101 * receiving the events have registered to.
102 *
103 * @return The x coordinate of the mouse event.
104 * @see Widget::addMouseListener, Widget::removeMouseListener
105 */
106 int getX() const;
107
108 /**
109 * Gets the y coordinate of the mouse event.
110 * The coordinate relative to widget the mouse listener
111 * receiving the events have registered to.
112 *
113 * @return The y coordinate of the mouse event.
114 * @see Widget::addMouseListener, Widget::removeMouseListener
115 */
116 int getY() const;
117
118 /**
119 * Gets the number of clicks generated with the same button.
120 * It's set to zero if another button is used.
121 *
122 * @return The number of clicks generated with the same button.
123 */
124 int getClickCount() const;
125
126 /**
127 * Gets the type of the event.
128 *
129 * @return The type of the event.
130 */
131 unsigned int getType() const;
132
133 /**
134 * Mouse event types.
135 */
136 enum
137 {
138 MOVED = 0,
139 PRESSED,
140 RELEASED,
141 WHEEL_MOVED_DOWN,
142 WHEEL_MOVED_UP,
143 CLICKED,
144 ENTERED,
145 EXITED,
146 DRAGGED
147
148 };
149
150 /**
151 * Mouse button types.
152 */
153 enum
154 {
155 EMPTY = 0,
156 LEFT,
157 RIGHT,
158 MIDDLE
159 };
160
161 protected:
162 /**
163 * Holds the type of the mouse event.
164 */
165 unsigned int mType;
166
167 /**
168 * Holds the button of the mouse event.
169 */
170 unsigned int mButton;
171
172 /**
173 * Holds the x-coordinate of the mouse event.
174 */
175 int mX;
176
177 /**
178 * Holds the y-coordinate of the mouse event.
179 */
180 int mY;
181
182 /**
183 * The number of clicks generated with the same button.
184 * It's set to zero if another button is used.
185 */
186 int mClickCount;
187
188 /**
189 * Gui is a friend of this class in order to be able to manipulate
190 * the protected member variables of this class and at the same time
191 * keep the MouseEvent class as const as possible. Gui needs to
192 * update the x och y coordinates for the coordinates to be relative
193 * to widget the mouse listener receiving the events have registered
194 * to.
195 */
196 friend class Gui;
197 };
198 }
199
200 #endif // GCN_MOUSEEVENT_HPP