kkeynative.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Ellis Whitehead <ellis@kde.org> 00003 00004 Win32 port: 00005 Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __KKEYNATIVE_H 00024 #define __KKEYNATIVE_H 00025 00026 #include <kshortcut.h> 00027 00028 #ifdef Q_WS_X11 00029 typedef union _XEvent XEvent; 00030 #endif 00031 00032 class KKeyNativePrivate; 00037 class KDECORE_EXPORT KKeyNative 00038 { 00039 public: 00046 KKeyNative(); 00047 00048 #ifdef Q_WS_X11 00049 00053 KKeyNative( const XEvent* xevent ); 00054 #endif 00055 00060 KKeyNative( const KKey& key ); 00061 00065 KKeyNative( const KKeyNative& ); 00066 00070 KKeyNative( uint code, uint mod, uint sym ); 00071 ~KKeyNative(); 00072 00077 void clear(); 00078 00079 #ifdef Q_WS_X11 00080 00086 bool init( const XEvent* xevent ); 00087 #endif 00088 00094 bool init( const KKey& key ); 00095 00101 bool init( const KKeyNative& key ); 00102 00108 KKeyNative& operator =( const KKeyNative& key ) 00109 { init( key ); return *this; } 00110 00117 int keyCodeQt() const; 00118 00123 KKey key() const; 00124 00130 operator KKey() const { return key(); } 00131 00136 uint code() const; 00137 00142 uint mod() const; 00143 00148 uint sym() const; 00149 00157 bool isNull() const; 00158 00170 int compare( const KKeyNative& key ) const; 00171 00176 bool operator == ( const KKeyNative& key ) const 00177 { return compare( key ) == 0; } 00178 00183 bool operator != ( const KKeyNative& key ) const 00184 { return compare( key ) != 0; } 00185 00190 bool operator < ( const KKeyNative& key ) const 00191 { return compare( key ) < 0; } 00192 00199 static KKeyNative& null(); 00200 00201 // General query functions. // 00206 static bool keyboardHasWinKey(); 00207 00208 #ifdef Q_WS_X11 00209 00214 static uint modX( KKey::ModFlag modFlag ); 00215 00221 static uint accelModMaskX(); 00222 00228 static uint modXNumLock(); 00229 00235 static uint modXLock(); 00236 00242 static uint modXScrollLock(); 00243 00250 static uint modXModeSwitch(); 00251 #endif 00252 00253 private: 00254 uint m_code, m_mod, m_sym; 00255 KKeyNativePrivate* d; 00256 }; 00257 00258 #endif // !__KKEYNATIVE_H