VirtualBox

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

Last change on this file since 4225 was 4202, checked in by vboxsync, 18 years ago

Network & USB ToolTip classes were removed from ConsoleWnd.
Call-back notifications are used for tool-tip updates reason now.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 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 void mediaChanged (VBoxDefs::DiskType aType);
100 void networkStateChange();
101 void usbStateChange();
102 void sharedFoldersChanged();
103
104protected:
105
106 // events
107 bool event( QEvent *e );
108 bool eventFilter( QObject *watched, QEvent *e );
109
110#if defined(Q_WS_WIN32)
111 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
112 bool winEvent (MSG *msg);
113#elif defined(Q_WS_X11)
114 bool x11Event (XEvent *event );
115#elif defined(Q_WS_MAC)
116 bool darwinKeyboardEvent (EventRef inEvent);
117 void darwinGrabKeyboardEvents (bool fGrab);
118#endif
119
120private:
121
122 // flags for keyEvent()
123 enum {
124 KeyExtended = 0x01,
125 KeyPressed = 0x02,
126 KeyPause = 0x04,
127 KeyPrint = 0x08,
128 };
129
130 void focusEvent (bool focus);
131 bool keyEvent (int key, uint8_t scan, int flags, wchar_t *aUniKey = NULL);
132 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
133 ButtonState aButton,
134 ButtonState aState, ButtonState aStateAfter,
135 int aWheelDelta, Orientation aWheelDir);
136
137 void emitKeyboardStateChanged() {
138 emit keyboardStateChanged (
139 (kbd_captured ? KeyboardCaptured : 0) |
140 (hostkey_pressed ? HostKeyPressed : 0));
141 }
142 void emitMouseStateChanged() {
143 emit mouseStateChanged ((mouse_captured ? MouseCaptured : 0) |
144 (mouse_absolute ? MouseAbsolute : 0) |
145 (!mouse_integration ? MouseAbsoluteDisabled : 0));
146 }
147
148 // IConsoleCallback event handlers
149 void onStateChange (CEnums::MachineState state);
150
151 void doRefresh();
152
153 void viewportPaintEvent( QPaintEvent * );
154#ifdef VBOX_GUI_USE_REFRESH_TIMER
155 void timerEvent( QTimerEvent * );
156#endif
157
158 void captureKbd (bool capture, bool emit_signal = true);
159 void captureMouse (bool capture, bool emit_signal = true);
160
161 bool processHotKey (const QKeySequence &key, QMenuData *data);
162 void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
163
164 void releaseAllKeysPressed (bool release_hostkey = true);
165 void saveKeyStates();
166 void sendChangedKeyStates();
167 void updateMouseClipping();
168
169 void setPointerShape (MousePointerChangeEvent *me);
170
171 bool isPaused() { return last_state == CEnums::Paused; }
172 bool isRunning() { return last_state == CEnums::Running; }
173
174 static void dimImage (QImage &img);
175
176private slots:
177
178 void exitFullScreen();
179
180 void doResizeHint();
181 void normalizeGeo() { normalizeGeometry (true); }
182
183private:
184
185 void maybeRestrictMinimumSize();
186
187 VBoxConsoleWnd *mainwnd;
188
189 CConsole cconsole;
190
191 const VBoxGlobalSettings &gs;
192
193 CEnums::MachineState last_state;
194
195 bool attached : 1;
196 bool kbd_captured : 1;
197 bool mouse_captured : 1;
198 bool mouse_absolute : 1;
199 bool mouse_integration : 1;
200 QPoint last_pos;
201 QPoint captured_pos;
202
203 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
204 uint8_t keys_pressed[128];
205 uint8_t keys_pressed_copy[128];
206
207 bool hostkey_pressed : 1;
208 bool hostkey_alone : 1;
209 /** kbd_captured value during the the last host key press or release */
210 bool hostkey_in_capture : 1;
211
212 bool mIgnoreMainwndResize : 1;
213 bool mAutoresizeGuest : 1;
214
215 bool mIsAdditionsActive : 1;
216
217 bool mfNumLock : 1;
218 bool mfScrollLock : 1;
219 bool mfCapsLock : 1;
220 long muNumLockAdaptionCnt;
221 long muCapsLockAdaptionCnt;
222
223 QTimer *resize_hint_timer;
224
225 VBoxDefs::RenderMode mode;
226
227 QRegion mLastVisibleRegion;
228
229#if defined(Q_WS_WIN)
230 HCURSOR mAlphaCursor;
231#endif
232
233#if defined(Q_WS_MAC)
234# ifndef VBOX_WITH_HACKED_QT
235 /** Event handler reference. NULL if the handler isn't installed. */
236 EventHandlerRef m_darwinEventHandlerRef;
237# endif
238 /** The current modifier key mask. Used to figure out which modifier
239 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
240 UInt32 m_darwinKeyModifiers;
241 /** The darwin cursor handle (see DarwinCursor.h/.cpp). */
242 DARWINCURSOR m_darwinCursor;
243#endif
244
245#if defined (VBOX_GUI_USE_REFRESH_TIMER)
246 QPixmap pm;
247 int tid; /**< Timer id */
248#endif
249
250 VBoxFrameBuffer *mFrameBuf;
251 CConsoleCallback mCallback;
252
253 friend class VBoxConsoleCallback;
254
255#if defined (Q_WS_WIN32)
256 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
257 WPARAM wParam, LPARAM lParam);
258#elif defined (Q_WS_MAC)
259# ifndef VBOX_WITH_HACKED_QT
260 static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
261 EventRef inEvent, void *inUserData);
262# else /* VBOX_WITH_HACKED_QT */
263 static bool macEventFilter (EventRef inEvent, void *inUserData);
264# endif /* VBOX_WITH_HACKED_QT */
265#endif
266
267 QPixmap mPausedShot;
268};
269
270#endif // __VBoxConsoleView_h__
271
Note: See TracBrowser for help on using the repository browser.

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