comparison ext/guichan-0.8.2/include/guichan/inputevent.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_INPUTEVENT_HPP
45 #define GCN_INPUTEVENT_HPP
46
47 #include "guichan/event.hpp"
48 #include "guichan/platform.hpp"
49
50 namespace gcn
51 {
52 /**
53 * Base class for all events concerning input.
54 *
55 * @author Olof Naessén
56 * @since 0.6.0
57 */
58 class GCN_CORE_DECLSPEC InputEvent: public Event
59 {
60 public:
61
62 /**
63 * Constructor.
64 *
65 * @param source The source widget of the event.
66 * @param isShiftPressed True if shift is pressed, false otherwise.
67 * @param isControlPressed True if control is pressed, false otherwise.
68 * @param isAltPressed True if alt is pressed, false otherwise.
69 * @param isMetaPressed True if meta is pressed, false otherwise.
70 */
71 InputEvent(Widget* source,
72 bool isShiftPressed,
73 bool isControlPressed,
74 bool isAltPressed,
75 bool isMetaPressed);
76
77 /**
78 * Checks if shift is pressed.
79 *
80 * @return True if shift was pressed at the same time as the key,
81 * false otherwise.
82 */
83 bool isShiftPressed() const;
84
85 /**
86 * Checks if control is pressed.
87 *
88 * @return True if control was pressed at the same time as the key,
89 * false otherwise.
90 */
91 bool isControlPressed() const;
92
93 /**
94 * Checks if alt is pressed.
95 *
96 * @return True if alt was pressed at the same time as the key,
97 * false otherwise.
98 */
99 bool isAltPressed() const;
100
101 /**
102 * Checks whether meta is pressed.
103 *
104 * @return True if meta was pressed at the same time as the key,
105 * false otherwise.
106 */
107 bool isMetaPressed() const;
108
109 /**
110 * Marks the event as consumed. Input event listeners may discard
111 * consumed input or act on consumed input. An example of a widget
112 * that discards consumed input is the ScrollArea widget that
113 * discards consumed mouse wheel events so the ScrollArea will not
114 * scroll if for instance a Slider's value inside the ScrollArea was
115 * changed with the mouse wheel.
116 *
117 * @see isConsumed
118 */
119 void consume();
120
121 /**
122 * Checks if the input event is consumed.
123 *
124 * @return True if the input event is consumed,
125 * false otherwise.
126 * @see consume
127 */
128 bool isConsumed() const;
129
130 protected:
131 /**
132 * True if shift is pressed, false otherwise.
133 */
134 bool mShiftPressed;
135
136 /**
137 * True if control is pressed, false otherwise.
138 */
139 bool mControlPressed;
140
141 /**
142 * True if alt is pressed, false otherwise.
143 */
144 bool mAltPressed;
145
146 /**
147 * True if meta is pressed, false otherwise.
148 */
149 bool mMetaPressed;
150
151 /**
152 * True if the input event is consumed,
153 * false otherwise.
154 */
155 bool mIsConsumed;
156 };
157 }
158
159 #endif // end GCN_INPUTEVENT_HPP