FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
ec_inputevent.h
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 *
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 "ec_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  virtual void setAltPressed(bool pressed) { m_isaltpressed = pressed; }
62 
65  virtual bool isControlPressed() const { return m_iscontrolpressed; }
66  virtual void setControlPressed(bool pressed) { m_iscontrolpressed = pressed; }
67 
70  virtual bool isMetaPressed() const { return m_ismetapressed; }
71  virtual void setMetaPressed(bool pressed) { m_ismetapressed = pressed; }
72 
75  virtual bool isShiftPressed() const { return m_isshiftpressed; }
76  virtual void setShiftPressed(bool pressed) { m_isshiftpressed = pressed; }
77 
80  virtual void consumedByWidgets() { m_consumedbywidgets = true; }
81  virtual bool isConsumedByWidgets() const { return m_consumedbywidgets; }
82 
83  virtual void consume() { Event::consume(); }
84  virtual bool isConsumed() const { return Event::isConsumed(); }
85  virtual IEventSource* getSource() { return Event::getSource(); }
86  virtual void setSource(IEventSource* source) { Event::setSource(source); }
87  virtual int getTimeStamp() const { return Event::getTimeStamp(); }
88  virtual void setTimeStamp(int timestamp ) { Event::setTimeStamp(timestamp); }
89 
90  virtual const std::string& getName() const {
91  const static std::string eventName("InputEvent");
92  return eventName;
93  }
94  virtual std::string getDebugString() const { return Event::getDebugString(); }
95 
96  virtual std::string getAttrStr() const {
97  std::stringstream ss;
98  ss << Event::getAttrStr() << std::endl;
99  ss << "shift = " << m_isshiftpressed << ", ";
100  ss << "ctrl = " << m_iscontrolpressed << ", ";
101  ss << "alt = " << m_isaltpressed << ", ";
102  ss << "meta = " << m_ismetapressed;
103  return ss.str();
104  }
105 
106 
107  private:
108  bool m_consumedbywidgets;
109  bool m_isshiftpressed;
110  bool m_iscontrolpressed;
111  bool m_isaltpressed;
112  bool m_ismetapressed;
113  };
114 } //FIFE
115 
116 #endif