VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h@ 2524

Last change on this file since 2524 was 2354, checked in by vboxsync, 18 years ago

FE/Qt: Renamed class VMGlobalSettings to VBoxGlobalSettings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxConsoleView 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 __VBoxConsoleView_h__
24#define __VBoxConsoleView_h__
25
26#include "COMDefs.h"
27
28#include "VBoxDefs.h"
29#include "VBoxGlobalSettings.h"
30
31#include <qdatetime.h>
32#include <qscrollview.h>
33#include <qpixmap.h>
34#include <qimage.h>
35
36#include <qkeysequence.h>
37
38#if defined (Q_WS_MAC)
39# include <Carbon/Carbon.h>
40# include "DarwinCursor.h"
41#endif
42
43class VBoxConsoleWnd;
44class MousePointerChangeEvent;
45class VBoxFrameBuffer;
46
47class QPainter;
48class QLabel;
49class QMenuData;
50
51class VBoxConsoleView : public QScrollView
52{
53 Q_OBJECT
54
55public:
56
57 enum {
58 MouseCaptured = 0x01,
59 MouseAbsolute = 0x02,
60 MouseAbsoluteDisabled = 0x04,
61 MouseNeedsHostCursor = 0x08,
62 KeyboardCaptured = 0x01,
63 HostKeyPressed = 0x02,
64 };
65
66 VBoxConsoleView (VBoxConsoleWnd *mainWnd,
67 const CConsole &console,
68 VBoxDefs::RenderMode rm,
69 QWidget *parent = 0, const char *name = 0, WFlags f = 0);
70 ~VBoxConsoleView();
71
72 QSize sizeHint() const;
73
74 void attach();
75 void detach();
76 void refresh() { doRefresh(); }
77 void normalizeGeometry (bool adjustPosition = false);
78
79 CConsole &console() { return cconsole; }
80
81 bool pause (bool on);
82
83 void setMouseIntegrationEnabled (bool enabled);
84
85 bool isMouseAbsolute() const { return mouse_absolute; }
86
87 void setAutoresizeGuest (bool on);
88
89 void onFullscreenChange (bool on);
90
91 void fixModifierState (LONG *codes, uint *count);
92
93signals:
94
95 void keyboardStateChanged (int state);
96 void mouseStateChanged (int state);
97 void machineStateChanged (CEnums::MachineState state);
98
99protected:
100
101 // events
102 bool event( QEvent *e );
103 bool eventFilter( QObject *watched, QEvent *e );
104
105#if defined(Q_WS_WIN32)
106 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
107 bool winEvent (MSG *msg);
108#elif defined(Q_WS_X11)
109 bool x11Event (XEvent *event );
110#elif defined(Q_WS_MAC)
111 bool darwinKeyboardEvent (EventRef inEvent);
112 void darwinGrabKeyboardEvents (bool fGrab);
113#endif
114
115private:
116
117 // flags for keyEvent()
118 enum {
119 KeyExtended = 0x01,
120 KeyPressed = 0x02,
121 KeyPause = 0x04,
122 KeyPrint = 0x08,
123 };
124
125 void focusEvent (bool focus);
126 bool keyEvent (int key, uint8_t scan, int flags, wchar_t *aUniKey = NULL);
127 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
128 ButtonState aButton,
129 ButtonState aState, ButtonState aStateAfter,
130 int aWheelDelta, Orientation aWheelDir);
131
132 void emitKeyboardStateChanged() {
133 emit keyboardStateChanged (
134 (kbd_captured ? KeyboardCaptured : 0) |
135 (hostkey_pressed ? HostKeyPressed : 0));
136 }
137 void emitMouseStateChanged() {
138 emit mouseStateChanged ((mouse_captured ? MouseCaptured : 0) |
139 (mouse_absolute ? MouseAbsolute : 0) |
140 (!mouse_integration ? MouseAbsoluteDisabled : 0));
141 }
142
143 // IConsoleCallback event handlers
144 void onStateChange (CEnums::MachineState state);
145
146 void doRefresh();
147
148 void viewportPaintEvent( QPaintEvent * );
149#ifdef VBOX_GUI_USE_REFRESH_TIMER
150 void timerEvent( QTimerEvent * );
151#endif
152
153 void captureKbd (bool capture, bool emit_signal = true);
154 void captureMouse (bool capture, bool emit_signal = true);
155
156 bool processHotKey (const QKeySequence &key, QMenuData *data);
157 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
158
159 void releaseAllKeysPressed (bool release_hostkey = true);
160 void saveKeyStates();
161 void sendChangedKeyStates();
162 void updateMouseClipping();
163
164 void setPointerShape (MousePointerChangeEvent *me);
165
166 bool isPaused() { return last_state == CEnums::Paused; }
167 bool isRunning() { return last_state == CEnums::Running; }
168
169 static void dimImage (QImage &img);
170
171private slots:
172
173 void doResizeHint();
174 void normalizeGeo() { normalizeGeometry(); }
175
176private:
177
178 VBoxConsoleWnd *mainwnd;
179
180 CConsole cconsole;
181
182 const VBoxGlobalSettings &gs;
183
184 CEnums::MachineState last_state;
185
186 bool attached : 1;
187 bool kbd_captured : 1;
188 bool mouse_captured : 1;
189 bool mouse_absolute : 1;
190 bool mouse_integration : 1;
191 QPoint last_pos;
192 QPoint captured_pos;
193
194 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
195 uint8_t keys_pressed[128];
196 uint8_t keys_pressed_copy[128];
197
198 bool hostkey_pressed : 1;
199 bool hostkey_alone : 1;
200 /** kbd_captured value during the the last host key press or release */
201 bool hostkey_in_capture : 1;
202
203 bool ignore_mainwnd_resize : 1;
204 bool autoresize_guest : 1;
205
206 bool mfNumLock : 1;
207 bool mfScrollLock : 1;
208 bool mfCapsLock : 1;
209 long muNumLockAdaptionCnt;
210 long muCapsLockAdaptionCnt;
211
212 QTimer *resize_hint_timer;
213
214 VBoxDefs::RenderMode mode;
215
216#if defined(Q_WS_WIN)
217 HCURSOR mAlphaCursor;
218#endif
219
220#if defined(Q_WS_MAC)
221# ifndef VBOX_WITH_HACKED_QT
222 /** Event handler reference. NULL if the handler isn't installed. */
223 EventHandlerRef m_darwinEventHandlerRef;
224# endif
225 /** The current modifier key mask. Used to figure out which modifier
226 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
227 UInt32 m_darwinKeyModifiers;
228 /** The darwin cursor handle (see DarwinCursor.h/.cpp). */
229 DARWINCURSOR m_darwinCursor;
230#endif
231
232#if defined (VBOX_GUI_USE_REFRESH_TIMER)
233 QPixmap pm;
234 int tid; /**< Timer id */
235#endif
236
237 VBoxFrameBuffer *fb;
238 CConsoleCallback callback;
239
240 friend class VBoxConsoleCallback;
241
242#if defined (Q_WS_WIN32)
243 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
244 WPARAM wParam, LPARAM lParam);
245#elif defined (Q_WS_MAC)
246# ifndef VBOX_WITH_HACKED_QT
247 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
248 EventRef inEvent, void *inUserData);
249# else /* VBOX_WITH_HACKED_QT */
250 static bool macEventFilter (EventRef inEvent, void *inUserData);
251# endif /* VBOX_WITH_HACKED_QT */
252#endif
253
254 QPixmap mPausedShot;
255};
256
257#endif // __VBoxConsoleView_h__
258
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette