VirtualBox

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

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

FE/Qt: Refined indicator tooltips in the console window (+ more useful info for the shared folders indicator).

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