1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * InnoTek Qt extensions: QIHotKeyEdit class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __QIHotKeyEdit_h__
|
---|
24 | #define __QIHotKeyEdit_h__
|
---|
25 |
|
---|
26 | #include <qlabel.h>
|
---|
27 | #ifdef Q_WS_MAC
|
---|
28 | #include <Carbon/Carbon.h>
|
---|
29 | #endif
|
---|
30 |
|
---|
31 |
|
---|
32 | class QIHotKeyEdit : public QLabel
|
---|
33 | {
|
---|
34 | Q_OBJECT
|
---|
35 |
|
---|
36 | public:
|
---|
37 |
|
---|
38 | QIHotKeyEdit( QWidget * parent, const char * name = 0 );
|
---|
39 | virtual ~QIHotKeyEdit();
|
---|
40 |
|
---|
41 | void setKey( int keyval );
|
---|
42 | int key() const { return keyval; }
|
---|
43 |
|
---|
44 | QString symbolicName() const { return symbname; }
|
---|
45 |
|
---|
46 | QSize sizeHint() const;
|
---|
47 | QSize minimumSizeHint() const;
|
---|
48 |
|
---|
49 | static QString keyName (int key);
|
---|
50 | static bool isValidKey (int k);
|
---|
51 |
|
---|
52 | public slots:
|
---|
53 |
|
---|
54 | void clear();
|
---|
55 |
|
---|
56 | protected:
|
---|
57 |
|
---|
58 | #if defined(Q_WS_WIN32)
|
---|
59 | bool winEvent( MSG *msg );
|
---|
60 | #elif defined(Q_WS_X11)
|
---|
61 | bool x11Event( XEvent *event );
|
---|
62 | #elif defined(Q_WS_MAC)
|
---|
63 | static pascal OSStatus darwinEventHandlerProc( EventHandlerCallRef inHandlerCallRef,
|
---|
64 | EventRef inEvent, void *inUserData );
|
---|
65 | bool darwinKeyboardEvent( EventRef inEvent );
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | void focusInEvent( QFocusEvent * );
|
---|
69 | void focusOutEvent( QFocusEvent * );
|
---|
70 |
|
---|
71 | void drawContents( QPainter * p );
|
---|
72 |
|
---|
73 | private:
|
---|
74 |
|
---|
75 | void updateText();
|
---|
76 |
|
---|
77 | int keyval;
|
---|
78 | QString symbname;
|
---|
79 |
|
---|
80 | QColorGroup true_acg;
|
---|
81 |
|
---|
82 | #if defined(Q_WS_MAC)
|
---|
83 | /** Event handler reference. NULL if the handler isn't installed. */
|
---|
84 | EventHandlerRef m_darwinEventHandlerRef;
|
---|
85 | /** The current modifier key mask. Used to figure out which modifier
|
---|
86 | * key was pressed when we get a kEventRawKeyModifiersChanged event. */
|
---|
87 | UInt32 m_darwinKeyModifiers;
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | static const char *NoneSymbName;
|
---|
91 | };
|
---|
92 |
|
---|
93 | #endif // __QIHotKeyEdit_h__
|
---|