- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ukeystroke.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/ukeystroke.hpp 00008 begin : Mon Feb 11 2002 00009 $Id: ukeystroke.hpp,v 1.12 2005/05/21 15:17:23 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UKEYSTROKE_HPP 00029 #define UKEYSTROKE_HPP 00030 00031 #include "uobject.hpp" 00032 00033 #include "events/ukeysym.hpp" 00034 00035 namespace ufo { 00036 00037 class UKeyEvent; 00038 00045 class UFO_EXPORT UKeyStroke : public UObject { 00046 UFO_DECLARE_ABSTRACT_CLASS(UKeyStroke) 00047 public: 00048 UKeyStroke(); 00049 UKeyStroke(const char * key); 00050 UKeyStroke(const std::string & key); 00051 explicit UKeyStroke(wchar_t keyChar, bool onKeyRelease = false); 00052 explicit UKeyStroke(UKeyCode_t keyCode, UMod_t modifiers = UMod::NoModifier, 00053 bool onKeyRelease = false); 00054 explicit UKeyStroke(wchar_t keyChar, UKeyCode_t keyCode, 00055 UMod_t modifiers = UMod::NoModifier, bool onKeyRelease = false); 00056 UKeyStroke(UKeyEvent * e); 00057 00058 public: 00059 bool operator==(const UKeyStroke&) const; 00060 bool operator!= (const UKeyStroke&) const; 00062 bool operator<(const UKeyStroke&) const; 00063 00064 wchar_t getKeyChar() const { return m_keyChar; } 00065 UKeyCode_t getKeyCode() const { return m_keyCode; } 00066 UMod_t getModifiers() const { return m_modifiers; } 00067 bool onKeyRelease() const { return m_onKeyRelease; } 00068 00069 public: // Overrides UObject 00070 virtual std::string toString() const; 00071 00072 virtual unsigned int hashCode() const { 00073 unsigned int ret = m_keyCode << 16; 00074 ret |= m_keyChar; 00075 ret += m_modifiers << 16; 00076 ret += (m_onKeyRelease) ? 1 : 0; 00077 return ret; 00078 } 00079 00080 virtual bool equals(const UObject * objA) const; 00081 virtual bool equals(const UKeyStroke * strokeA) const; 00082 00083 private: // Private methods 00084 void initFromString(const char * key); 00085 00086 private: // Private attributes 00087 wchar_t m_keyChar; 00088 UKeyCode_t m_keyCode; 00089 UMod_t m_modifiers; 00090 bool m_onKeyRelease; 00091 }; 00092 00093 } // namespace ufo 00094 00095 #endif // UKEYSTROKE_HPP

The libUFO Project - written by Johannes Schmidt