kkeynative.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Ellis Whitehead <ellis@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef __KKEYNATIVE_H 00021 #define __KKEYNATIVE_H 00022 00023 #include <kshortcut.h> 00024 00025 typedef union _XEvent XEvent; 00026 00027 class KKeyNativePrivate; 00032 class KKeyNative 00033 { 00034 public: 00041 KKeyNative(); 00042 00047 KKeyNative( const XEvent* xevent ); 00048 00053 KKeyNative( const KKey& key ); 00054 00058 KKeyNative( const KKeyNative& ); 00059 00063 KKeyNative( uint code, uint mod, uint sym ); 00064 ~KKeyNative(); 00065 00070 void clear(); 00071 00078 bool init( const XEvent* xevent ); 00079 00085 bool init( const KKey& key ); 00086 00092 bool init( const KKeyNative& key ); 00093 00099 KKeyNative& operator =( const KKeyNative& key ) 00100 { init( key ); return *this; } 00101 00108 int keyCodeQt() const; 00109 00114 KKey key() const; 00115 00121 operator KKey() const { return key(); } 00122 00127 uint code() const; 00128 00133 uint mod() const; 00134 00139 uint sym() const; 00140 00148 bool isNull() const; 00149 00161 int compare( const KKeyNative& key ) const; 00162 00167 bool operator == ( const KKeyNative& key ) const 00168 { return compare( key ) == 0; } 00169 00174 bool operator != ( const KKeyNative& key ) const 00175 { return compare( key ) != 0; } 00176 00181 bool operator < ( const KKeyNative& key ) const 00182 { return compare( key ) < 0; } 00183 00190 static KKeyNative& null(); 00191 00192 // General query functions. // 00197 static bool keyboardHasWinKey(); 00198 00204 static uint modX( KKey::ModFlag modFlag ); 00205 00211 static uint accelModMaskX(); 00212 00213 private: 00214 uint m_code, m_mod, m_sym; 00215 KKeyNativePrivate* d; 00216 }; 00217 00218 #endif // !__KKEYNATIVE_H