FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_EVENTCHANNEL_KEYEVENT_H 00023 #define FIFE_EVENTCHANNEL_KEYEVENT_H 00024 00025 // Standard C++ library includes 00026 // 00027 00028 // 3rd party library includes 00029 // 00030 00031 // FIFE includes 00032 // These includes are split up in two parts, separated by one empty line 00033 // First block: files included from the FIFE root src directory 00034 // Second block: files included from the same folder 00035 // 00036 #include "eventchannel/base/ec_inputevent.h" 00037 #include "eventchannel/source/ec_ieventsource.h" 00038 00039 #include "ec_key.h" 00040 00041 namespace FIFE { 00042 00045 class KeyEvent: public InputEvent { 00046 public: 00047 enum KeyEventType { 00048 UNKNOWN = -1, 00049 PRESSED = 0, 00050 RELEASED 00051 }; 00052 00055 KeyEvent(): 00056 InputEvent(), 00057 m_eventtype(UNKNOWN), 00058 m_isnumericpad(false), 00059 m_key(Key()) {} 00060 00063 virtual ~KeyEvent() {} 00064 00065 KeyEventType getType() const { return m_eventtype; } 00066 void setType(KeyEventType type) { m_eventtype = type; } 00067 00068 bool isNumericPad() const { return m_isnumericpad; } 00069 void setNumericPad(bool ispad) { m_isnumericpad = ispad; } 00070 00071 const Key& getKey() const { return m_key; } 00072 void setKey(const Key& key) { m_key = key; } 00073 00074 virtual bool isAltPressed() const { return InputEvent::isAltPressed(); } 00075 virtual void setAltPressed(bool pressed) { InputEvent::setAltPressed(pressed); } 00076 virtual bool isControlPressed() const { return InputEvent::isControlPressed(); } 00077 virtual void setControlPressed(bool pressed) { InputEvent::setControlPressed(pressed); } 00078 virtual bool isMetaPressed() const { return InputEvent::isMetaPressed(); } 00079 virtual void setMetaPressed(bool pressed) { InputEvent::setMetaPressed(pressed); } 00080 virtual bool isShiftPressed() const { return InputEvent::isShiftPressed(); } 00081 virtual void setShiftPressed(bool pressed) { InputEvent::setShiftPressed(pressed); } 00082 00083 virtual void consume() { InputEvent::consume(); } 00084 virtual bool isConsumed() const { return InputEvent::isConsumed(); } 00085 virtual void consumedByWidgets() { InputEvent::consumedByWidgets(); } 00086 virtual bool isConsumedByWidgets() const { return InputEvent::isConsumedByWidgets(); } 00087 virtual IEventSource* getSource() { return InputEvent::getSource(); } 00088 virtual void setSource(IEventSource* source) { InputEvent::setSource(source); } 00089 virtual int getTimeStamp() const { return InputEvent::getTimeStamp(); } 00090 virtual void setTimeStamp(int timestamp ) { InputEvent::setTimeStamp(timestamp); } 00091 00092 virtual const std::string& getName() const { 00093 const static std::string eventName("KeyEvent"); 00094 return eventName; 00095 } 00096 virtual std::string getDebugString() const { return InputEvent::getDebugString(); } 00097 00098 private: 00099 KeyEventType m_eventtype; 00100 bool m_isnumericpad; 00101 Key m_key; 00102 }; 00103 00104 } //FIFE 00105 00106 #endif