comparison engine/core/eventchannel/base/ec_inputevent.h @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children e84dccee1bb7
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_EVENTCHANNEL_INPUTEVENT_H
23 #define FIFE_EVENTCHANNEL_INPUTEVENT_H
24
25 // Standard C++ library includes
26 //
27
28 // 3rd party library includes
29 //
30
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 //
36 #include "ec_event.h"
37
38 namespace FIFE {
39
40 /** Base class for input events (like mouse and keyboard)
41 */
42 class InputEvent: public Event {
43 public:
44 /** Constructor.
45 */
46 InputEvent():
47 Event(),
48 m_isshiftpressed(false),
49 m_iscontrolpressed(false),
50 m_isaltpressed(false),
51 m_ismetapressed(false) {};
52
53 /** Destructor.
54 */
55 ~InputEvent() {}
56
57 /** Checks whether alt is pressed.
58 */
59 virtual bool isAltPressed() const { return m_isaltpressed; }
60 virtual void setAltPressed(bool pressed) { m_isaltpressed = pressed; }
61
62 /** Checks whether control is pressed.
63 */
64 virtual bool isControlPressed() const { return m_iscontrolpressed; }
65 virtual void setControlPressed(bool pressed) { m_iscontrolpressed = pressed; }
66
67 /** Checks whether meta is pressed.
68 */
69 virtual bool isMetaPressed() const { return m_ismetapressed; }
70 virtual void setMetaPressed(bool pressed) { m_ismetapressed = pressed; }
71
72 /** Checks whether shift is pressed.
73 */
74 virtual bool isShiftPressed() const { return m_isshiftpressed; }
75 virtual void setShiftPressed(bool pressed) { m_isshiftpressed = pressed; }
76
77 virtual void consume() { Event::consume(); }
78 virtual bool isConsumed() const { return Event::isConsumed(); }
79 virtual IEventSource* getSource() { return Event::getSource(); }
80 virtual void setSource(IEventSource* source) { Event::setSource(source); }
81 virtual gcn::Widget* getSourceWidget() { return Event::getSourceWidget(); }
82 virtual void setSourceWidget(gcn::Widget* widget) { Event::setSourceWidget(widget); }
83 virtual int getTimeStamp() const { return Event::getTimeStamp(); }
84 virtual void setTimeStamp(int timestamp ) { Event::setTimeStamp(timestamp); }
85
86 virtual const std::string& getName() const {
87 const static std::string eventName("InputEvent");
88 return eventName;
89 }
90 virtual std::string getDebugString() const { return Event::getDebugString(); }
91
92 virtual std::string getAttrStr() const {
93 std::stringstream ss;
94 ss << Event::getAttrStr() << std::endl;
95 ss << "shift = " << m_isshiftpressed << ", ";
96 ss << "ctrl = " << m_iscontrolpressed << ", ";
97 ss << "alt = " << m_isaltpressed << ", ";
98 ss << "meta = " << m_ismetapressed;
99 return ss.str();
100 }
101
102
103 private:
104 bool m_isshiftpressed;
105 bool m_iscontrolpressed;
106 bool m_isaltpressed;
107 bool m_ismetapressed;
108 };
109 } //FIFE
110
111 #endif