VirtualBox

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

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

InnoTek -> innotek: all the headers and comments.

  • 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 * 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/** @todo remove this hack when somebody get around fixing the conflicting typedef/enum OSType. */
42# define OSType VBoxOSType
43#endif
44
45class VBoxConsoleWnd;
46class MousePointerChangeEvent;
47class VBoxFrameBuffer;
48
49class QPainter;
50class QLabel;
51class QMenuData;
52
53class VBoxConsoleView : public QScrollView
54{
55 Q_OBJECT
56
57public:
58
59 enum {
60 MouseCaptured = 0x01,
61 MouseAbsolute = 0x02,
62 MouseAbsoluteDisabled = 0x04,
63 MouseNeedsHostCursor = 0x08,
64 KeyboardCaptured = 0x01,
65 HostKeyPressed = 0x02,
66 };
67
68 VBoxConsoleView (VBoxConsoleWnd *mainWnd,
69 const CConsole &console,
70 VBoxDefs::RenderMode rm,
71 QWidget *parent = 0, const char *name = 0, WFlags f = 0);
72 ~VBoxConsoleView();
73
74 QSize sizeHint() const;
75
76 void attach();
77 void detach();
78 void refresh() { doRefresh(); }
79 void normalizeGeometry (bool adjustPosition = false);
80
81 CConsole &console() { return cconsole; }
82
83 bool pause (bool on);
84
85 void setMouseIntegrationEnabled (bool enabled);
86
87 bool isMouseAbsolute() const { return mouse_absolute; }
88
89 void setAutoresizeGuest (bool on);
90
91 void onFullscreenChange (bool on);
92
93 void onViewOpened();
94
95 void fixModifierState (LONG *codes, uint *count);
96
97signals:
98
99 void keyboardStateChanged (int state);
100 void mouseStateChanged (int state);
101 void machineStateChanged (CEnums::MachineState state);
102 void additionsStateChanged (const QString &, bool);
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 ignore_mainwnd_resize : 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#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 *fb;
249 CConsoleCallback callback;
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