FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
inputevent.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library 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 GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, 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 "event.h"
37 
38 namespace FIFE {
39 
42  class InputEvent: public Event {
43  public:
47  Event(),
48  m_consumedByWidgets(false),
49  m_isShiftPressed(false),
50  m_isControlPressed(false),
51  m_isAltPressed(false),
52  m_isMetaPressed(false) {}
53 
57 
60  virtual bool isAltPressed() const { return m_isAltPressed; }
61 
64  virtual void setAltPressed(bool pressed) { m_isAltPressed = pressed; }
65 
68  virtual bool isControlPressed() const { return m_isControlPressed; }
69 
72  virtual void setControlPressed(bool pressed) { m_isControlPressed = pressed; }
73 
76  virtual bool isMetaPressed() const { return m_isMetaPressed; }
77 
80  virtual void setMetaPressed(bool pressed) { m_isMetaPressed = pressed; }
81 
84  virtual bool isShiftPressed() const { return m_isShiftPressed; }
85 
88  virtual void setShiftPressed(bool pressed) { m_isShiftPressed = pressed; }
89 
92  virtual void consumedByWidgets() { m_consumedByWidgets = true; }
93 
96  virtual bool isConsumedByWidgets() const { return m_consumedByWidgets; }
97 
100  virtual void consume() { Event::consume(); }
101 
104  virtual bool isConsumed() const { return Event::isConsumed(); }
105 
108  virtual IEventSource* getSource() const { return Event::getSource(); }
109 
112  virtual void setSource(IEventSource* source) { Event::setSource(source); }
113 
116  virtual int32_t getTimeStamp() const { return Event::getTimeStamp(); }
117 
120  virtual void setTimeStamp(int32_t timestamp ) { Event::setTimeStamp(timestamp); }
121 
124  virtual const std::string& getName() const {
125  const static std::string eventName("InputEvent");
126  return eventName;
127  }
128 
131  virtual std::string getDebugString() const { return Event::getDebugString(); }
132 
135  virtual std::string getAttrStr() const {
136  std::stringstream ss;
137  ss << Event::getAttrStr() << std::endl;
138  ss << "shift = " << m_isShiftPressed << ", ";
139  ss << "ctrl = " << m_isControlPressed << ", ";
140  ss << "alt = " << m_isAltPressed << ", ";
141  ss << "meta = " << m_isMetaPressed;
142  return ss.str();
143  }
144 
145 
146  private:
152  };
153 } //FIFE
154 
155 #endif
virtual bool isConsumedByWidgets() const
Checks whether event is consumed by widget library.
Definition: inputevent.h:96
bool m_isControlPressed
Definition: inputevent.h:149
virtual void setControlPressed(bool pressed)
Sets control to pressed.
Definition: inputevent.h:72
virtual int32_t getTimeStamp() const
Gets the timestamp of the event.
Definition: event.h:81
Base class for input events (like mouse and keyboard)
Definition: inputevent.h:42
virtual void setShiftPressed(bool pressed)
Sets shift to pressed.
Definition: inputevent.h:88
virtual bool isShiftPressed() const
Checks whether shift is pressed.
Definition: inputevent.h:84
virtual void setTimeStamp(int32_t timestamp)
Sets the timestamp of the event.
Definition: inputevent.h:120
virtual bool isConsumed() const
Checks whether event is consumed.
Definition: inputevent.h:104
virtual void setAltPressed(bool pressed)
Sets alt to pressed.
Definition: inputevent.h:64
virtual IEventSource * getSource() const
Gets the source of the event.
Definition: event.h:73
virtual void setSource(IEventSource *source)
Sets the source of the event.
Definition: event.h:77
virtual std::string getAttrStr() const
Gets attribute string of the event.
Definition: inputevent.h:135
virtual void consumedByWidgets()
Marks events as consumed by widget library.
Definition: inputevent.h:92
bool m_consumedByWidgets
Definition: inputevent.h:147
Base class for all events.
Definition: event.h:49
~InputEvent()
Destructor.
Definition: inputevent.h:56
virtual const std::string & getName() const
Gets the name of the event.
Definition: inputevent.h:124
virtual std::string getAttrStr() const
Gets attribute string of the event.
Definition: event.h:96
virtual bool isAltPressed() const
Checks whether alt is pressed.
Definition: inputevent.h:60
virtual std::string getDebugString() const
Gets the debugstring of the event.
Definition: inputevent.h:131
virtual int32_t getTimeStamp() const
Gets the timestamp of the event.
Definition: inputevent.h:116
virtual bool isConsumed() const
Checks if the event is consumed.
Definition: event.h:69
virtual bool isControlPressed() const
Checks whether control is pressed.
Definition: inputevent.h:68
virtual std::string getDebugString() const
Gets the debugstring of the event.
Definition: event.h:106
virtual void setTimeStamp(int32_t timestamp)
Sets the timestamp of the event.
Definition: event.h:85
virtual void setSource(IEventSource *source)
Sets the source of the event.
Definition: inputevent.h:112
virtual bool isMetaPressed() const
Checks whether meta is pressed.
Definition: inputevent.h:76
InputEvent()
Constructor.
Definition: inputevent.h:46
virtual void consume()
Marks events as consumed.
Definition: inputevent.h:100
Representation of event source (a thing sending events)
Definition: ieventsource.h:42
virtual void setMetaPressed(bool pressed)
Sets meta to pressed.
Definition: inputevent.h:80
virtual void consume()
Marks the event as consumed.
Definition: event.h:64
virtual IEventSource * getSource() const
Gets the source of the event.
Definition: inputevent.h:108