1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VirtualBox Qt extensions: QIHotKeyEdit class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __QIHotKeyEdit_h__
|
---|
24 | #define __QIHotKeyEdit_h__
|
---|
25 |
|
---|
26 | #include <qlabel.h>
|
---|
27 | //Added by qt3to4:
|
---|
28 | #include <QPalette>
|
---|
29 | #include <QFocusEvent>
|
---|
30 | #if defined(Q_WS_X11)
|
---|
31 | #include <qmap.h>
|
---|
32 | #endif
|
---|
33 | #if defined(Q_WS_MAC)
|
---|
34 | #include <Carbon/Carbon.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #if defined(Q_WS_PM)
|
---|
38 | /* Extra virtual keys returned by QIHotKeyEdit::virtualKey() */
|
---|
39 | #define VK_LSHIFT VK_USERFIRST + 0
|
---|
40 | #define VK_LCTRL VK_USERFIRST + 1
|
---|
41 | #define VK_LWIN VK_USERFIRST + 2
|
---|
42 | #define VK_RWIN VK_USERFIRST + 3
|
---|
43 | #define VK_WINMENU VK_USERFIRST + 4
|
---|
44 | #define VK_FORWARD VK_USERFIRST + 5
|
---|
45 | #define VK_BACKWARD VK_USERFIRST + 6
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | class QIHotKeyEdit : public QLabel
|
---|
49 | {
|
---|
50 | Q_OBJECT
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | QIHotKeyEdit (QWidget *aParent, const char *aName = 0);
|
---|
55 | virtual ~QIHotKeyEdit();
|
---|
56 |
|
---|
57 | void setKey (int aKeyVal);
|
---|
58 | int key() const { return mKeyVal; }
|
---|
59 |
|
---|
60 | QString symbolicName() const { return mSymbName; }
|
---|
61 |
|
---|
62 | QSize sizeHint() const;
|
---|
63 | QSize minimumSizeHint() const;
|
---|
64 |
|
---|
65 | #if defined (Q_WS_PM)
|
---|
66 | static int virtualKey (QMSG *aMsg);
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #if defined (Q_WS_PM) || defined (Q_WS_X11)
|
---|
70 | static void retranslateUi();
|
---|
71 | #endif
|
---|
72 | static QString keyName (int aKeyVal);
|
---|
73 | static bool isValidKey (int aKeyVal);
|
---|
74 |
|
---|
75 | public slots:
|
---|
76 |
|
---|
77 | void clear();
|
---|
78 |
|
---|
79 | protected:
|
---|
80 |
|
---|
81 | #if defined (Q_WS_WIN32)
|
---|
82 | bool winEvent (MSG *msg);
|
---|
83 | #elif defined (Q_WS_PM)
|
---|
84 | bool pmEvent (QMSG *aMsg);
|
---|
85 | #elif defined (Q_WS_X11)
|
---|
86 | bool x11Event (XEvent *event);
|
---|
87 | #elif defined (Q_WS_MAC)
|
---|
88 | static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
|
---|
89 | EventRef inEvent, void *inUserData);
|
---|
90 | bool darwinKeyboardEvent (EventRef inEvent);
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | void focusInEvent (QFocusEvent *);
|
---|
94 | void focusOutEvent (QFocusEvent *);
|
---|
95 |
|
---|
96 | void drawContents (QPainter *p);
|
---|
97 |
|
---|
98 | private:
|
---|
99 |
|
---|
100 | void updateText();
|
---|
101 |
|
---|
102 | int mKeyVal;
|
---|
103 | QString mSymbName;
|
---|
104 |
|
---|
105 | QColorGroup mTrueACG;
|
---|
106 |
|
---|
107 | #if defined (Q_WS_PM)
|
---|
108 | static QMap <int, QString> sKeyNames;
|
---|
109 | #elif defined (Q_WS_X11)
|
---|
110 | static QMap <QString, QString> sKeyNames;
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #if defined (Q_WS_MAC)
|
---|
114 | /** Event handler reference. NULL if the handler isn't installed. */
|
---|
115 | EventHandlerRef mDarwinEventHandlerRef;
|
---|
116 | /** The current modifier key mask. Used to figure out which modifier
|
---|
117 | * key was pressed when we get a kEventRawKeyModifiersChanged event. */
|
---|
118 | UInt32 mDarwinKeyModifiers;
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | static const char *kNoneSymbName;
|
---|
122 | };
|
---|
123 |
|
---|
124 | #endif // __QIHotKeyEdit_h__
|
---|