source: trunk/src/gui/kernel/qkeymapper_p.h@ 561

Last change on this file since 561 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 7.1 KB
RevLine 
[2]1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
[561]24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
[2]27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
[561]36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
[2]38** $QT_END_LICENSE$
39**
40****************************************************************************/
41#ifndef QKEYMAPPER_P_H
42#define QKEYMAPPER_P_H
43
44//
45// W A R N I N G
46// -------------
47//
48// This file is not part of the Qt API. It exists purely as an
49// implementation detail. This header file may change from version to
50// version without notice, or even be removed.
51//
52// We mean it.
53//
54
55#include <qobject.h>
56#include <private/qobject_p.h>
57#include <qkeysequence.h>
58#include <qlist.h>
59#include <qlocale.h>
60#include <qevent.h>
[561]61#include <qhash.h>
[2]62
63#if defined (Q_WS_MAC64)
64# include <private/qt_mac_p.h>
65#endif
66
67QT_BEGIN_NAMESPACE
68
69class QKeyMapperPrivate;
70class QKeyMapper : public QObject
71{
72 Q_OBJECT
73public:
74 explicit QKeyMapper();
75 ~QKeyMapper();
76
77 static QKeyMapper *instance();
78 static void changeKeyboard();
79 static bool sendKeyEvent(QWidget *widget, bool grab,
80 QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
81 const QString &text, bool autorepeat, int count,
82 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
83 bool *unusedExceptForCocoa = 0);
84 static QList<int> possibleKeys(QKeyEvent *e);
85
86private:
87 friend QKeyMapperPrivate *qt_keymapper_private();
88 Q_DECLARE_PRIVATE(QKeyMapper)
89 Q_DISABLE_COPY(QKeyMapper)
90};
91
92
93
94#if defined(Q_OS_WIN)
95enum WindowsNativeModifiers {
96 ShiftLeft = 0x00000001,
97 ControlLeft = 0x00000002,
98 AltLeft = 0x00000004,
99 MetaLeft = 0x00000008,
100 ShiftRight = 0x00000010,
101 ControlRight = 0x00000020,
102 AltRight = 0x00000040,
103 MetaRight = 0x00000080,
104 CapsLock = 0x00000100,
105 NumLock = 0x00000200,
106 ScrollLock = 0x00000400,
107 ExtendedKey = 0x01000000,
108
109 // Convenience mappings
110 ShiftAny = 0x00000011,
111 ControlAny = 0x00000022,
112 AltAny = 0x00000044,
113 MetaAny = 0x00000088,
114 LockAny = 0x00000700
115};
116# if !defined(tagMSG)
117 typedef struct tagMSG MSG;
118# endif
119#elif defined(Q_WS_MAC)
120QT_BEGIN_INCLUDE_NAMESPACE
121# include <private/qt_mac_p.h>
122QT_END_INCLUDE_NAMESPACE
123#elif defined(Q_WS_X11)
124
125QT_BEGIN_INCLUDE_NAMESPACE
126typedef ulong XID;
127typedef XID KeySym;
128QT_END_INCLUDE_NAMESPACE
129
130struct QXCoreDesc {
131 int min_keycode;
132 int max_keycode;
133 int keysyms_per_keycode;
134 KeySym *keysyms;
135 uchar mode_switch;
136 uchar num_lock;
137 KeySym lock_meaning;
138};
139
140#endif
141
142struct KeyboardLayoutItem;
143typedef struct __TISInputSource * TISInputSourceRef;
144class QKeyEvent;
145class QKeyMapperPrivate : public QObjectPrivate
146{
147 Q_DECLARE_PUBLIC(QKeyMapper)
148public:
149 QKeyMapperPrivate();
150 ~QKeyMapperPrivate();
151
152 void clearMappings();
153 QList<int> possibleKeys(QKeyEvent *e);
154
155 QLocale keyboardInputLocale;
156 Qt::LayoutDirection keyboardInputDirection;
157
158#if defined(Q_OS_WIN)
159 void clearRecordedKeys();
160 void updateKeyMap(const MSG &msg);
161 bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
162 void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
163 bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
[561]164 void deleteLayouts();
[2]165
166 KeyboardLayoutItem *keyLayout[256];
167
[136]168#elif defined(Q_WS_PM)
169
[434]170 void updateKeyMap(const QMSG &qmsg);
[136]171 bool translateKeyEvent(QWidget *receiver, const QMSG &qmsg, bool grab);
172
173 int extraKeyState;
[434]174 KeyboardLayoutItem *keyLayout[256];
175 enum { KeyLayoutSize = sizeof(keyLayout) / sizeof(keyLayout[0]) };
[136]176
[2]177#elif defined(Q_WS_X11)
178
179 QList<int> possibleKeysXKB(QKeyEvent *event);
180 QList<int> possibleKeysCore(QKeyEvent *event);
181
182 bool translateKeyEventInternal(QWidget *keywidget,
183 const XEvent *,
184 KeySym &keysym,
185 int& count,
186 QString& text,
187 Qt::KeyboardModifiers& modifiers,
188 int &code,
189 QEvent::Type &type,
190 bool statefulTranslation = true);
191 bool translateKeyEvent(QWidget *keywidget,
192 const XEvent *,
193 bool grab);
194
195 bool useXKB;
196 QXCoreDesc coreDesc;
197
198#elif defined(Q_WS_MAC)
199 bool updateKeyboard();
200 void updateKeyMap(EventHandlerCallRef, EventRef, void *);
201 bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
[561]202 void deleteLayouts();
[2]203
204 enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
205 union {
206 const UCKeyboardLayout *unicode;
207 void *other;
208 } keyboard_layout_format;
209#ifdef Q_WS_MAC64
210 QCFType<TISInputSourceRef> currentInputSource;
211#else
212 KeyboardLayoutRef currentKeyboardLayout;
213#endif
214 KeyboardLayoutKind keyboard_kind;
215 UInt32 keyboard_dead;
216 KeyboardLayoutItem *keyLayout[256];
217#elif defined(Q_WS_QWS)
[561]218#elif defined(Q_OS_SYMBIAN)
219private:
220 QHash<TUint, int> s60ToQtKeyMap;
221 void fillKeyMap();
222public:
223 QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
224 int mapS60KeyToQt(TUint s60key);
[2]225#endif
226};
227
228QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
229
230QT_END_NAMESPACE
231
232#endif // QKEYMAPPER_P_H
Note: See TracBrowser for help on using the repository browser.