QIHotKeyEdit.h revision c3d6dbf046494d6b43f11aa35955aa713f17860c
65fea56f17cd614bc8908264df980a62e1931468vboxsync/** @file
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * VBox frontends: Qt GUI ("VirtualBox"):
65fea56f17cd614bc8908264df980a62e1931468vboxsync * VirtualBox Qt extensions: QIHotKeyEdit class declaration
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
65fea56f17cd614bc8908264df980a62e1931468vboxsync * available from http://www.virtualbox.org. This file is free software;
65fea56f17cd614bc8908264df980a62e1931468vboxsync * you can redistribute it and/or modify it under the terms of the GNU
65fea56f17cd614bc8908264df980a62e1931468vboxsync * General Public License (GPL) as published by the Free Software
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
65fea56f17cd614bc8908264df980a62e1931468vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
65fea56f17cd614bc8908264df980a62e1931468vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
65fea56f17cd614bc8908264df980a62e1931468vboxsync *
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
65fea56f17cd614bc8908264df980a62e1931468vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
65fea56f17cd614bc8908264df980a62e1931468vboxsync * additional information or have any questions.
65fea56f17cd614bc8908264df980a62e1931468vboxsync */
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef __QIHotKeyEdit_h__
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define __QIHotKeyEdit_h__
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <QLabel>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined (Q_WS_X11)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <QMap>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined (Q_WS_MAC)
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <Carbon/Carbon.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#if defined (Q_WS_PM)
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Extra virtual keys returned by QIHotKeyEdit::virtualKey() */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_LSHIFT VK_USERFIRST + 0
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_LCTRL VK_USERFIRST + 1
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_LWIN VK_USERFIRST + 2
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_RWIN VK_USERFIRST + 3
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_WINMENU VK_USERFIRST + 4
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_FORWARD VK_USERFIRST + 5
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define VK_BACKWARD VK_USERFIRST + 6
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncclass QIHotKeyEdit : public QLabel
65fea56f17cd614bc8908264df980a62e1931468vboxsync{
65fea56f17cd614bc8908264df980a62e1931468vboxsync Q_OBJECT
65fea56f17cd614bc8908264df980a62e1931468vboxsync
public:
QIHotKeyEdit (QWidget *aParent);
virtual ~QIHotKeyEdit();
void setKey (int aKeyVal);
int key() const { return mKeyVal; }
QString symbolicName() const { return mSymbName; }
QSize sizeHint() const;
QSize minimumSizeHint() const;
#if defined (Q_WS_PM)
static int virtualKey (QMSG *aMsg);
#endif
#if defined (Q_WS_PM) || defined (Q_WS_X11)
static void retranslateUi();
#endif
static QString keyName (int aKeyVal);
static bool isValidKey (int aKeyVal);
public slots:
void clear();
protected:
#if defined (Q_WS_WIN32)
bool winEvent (MSG *aMsg, long *aResult);
#elif defined (Q_WS_PM)
bool pmEvent (QMSG *aMsg);
#elif defined (Q_WS_X11)
bool x11Event (XEvent *event);
#elif defined (Q_WS_MAC)
static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
EventRef inEvent, void *inUserData);
bool darwinKeyboardEvent (EventRef inEvent);
#endif
void focusInEvent (QFocusEvent *);
void focusOutEvent (QFocusEvent *);
void paintEvent (QPaintEvent *);
private:
void updateText();
int mKeyVal;
QString mSymbName;
#if defined (Q_WS_PM)
static QMap <int, QString> sKeyNames;
#elif defined (Q_WS_X11)
static QMap <QString, QString> sKeyNames;
#endif
#if defined (Q_WS_MAC)
/** Event handler reference. NULL if the handler isn't installed. */
EventHandlerRef mDarwinEventHandlerRef;
/** The current modifier key mask. Used to figure out which modifier
* key was pressed when we get a kEventRawKeyModifiersChanged event. */
UInt32 mDarwinKeyModifiers;
#endif
static const char *kNoneSymbName;
};
#endif // __QIHotKeyEdit_h__