VirtualBox

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

Last change on this file since 4071 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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