VirtualBox

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

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 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 "VMGlobalSettings.h"
30
31#include <qdatetime.h>
32#include <qscrollview.h>
33#include <qpixmap.h>
34#include <qimage.h>
35
36#include <qkeysequence.h>
37
38class VBoxConsoleWnd;
39class MousePointerChangeEvent;
40class VBoxFrameBuffer;
41
42class QPainter;
43class QLabel;
44class QMenuData;
45
46class VBoxConsoleView : public QScrollView
47{
48 Q_OBJECT
49
50public:
51
52 enum {
53 MouseCaptured = 0x01,
54 MouseAbsolute = 0x02,
55 MouseAbsoluteDisabled = 0x04,
56 MouseNeedsHostCursor = 0x08,
57 KeyboardCaptured = 0x01,
58 HostKeyPressed = 0x02,
59 };
60
61 VBoxConsoleView (VBoxConsoleWnd *mainWnd,
62 const CConsole &console,
63 VBoxDefs::RenderMode rm,
64 QWidget *parent = 0, const char *name = 0, WFlags f = 0);
65 ~VBoxConsoleView();
66
67 QSize sizeHint() const;
68
69 void attach();
70 void detach();
71 void refresh() { doRefresh(); }
72 void normalizeGeometry (bool adjustPosition = false);
73
74 CConsole &console() { return cconsole; }
75
76 bool pause (bool on);
77
78 void setMouseIntegrationEnabled (bool enabled);
79
80 bool isMouseAbsolute() const { return mouse_absolute; }
81
82 void setAutoresizeGuest (bool on);
83
84 void onFullscreenChange (bool on);
85
86signals:
87
88 void keyboardStateChanged (int state);
89 void mouseStateChanged (int state);
90 void machineStateChanged (CEnums::MachineState state);
91
92protected:
93
94 // events
95 bool event( QEvent *e );
96 bool eventFilter( QObject *watched, QEvent *e );
97
98#if defined(Q_WS_WIN32)
99 bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
100 bool winEvent (MSG *msg);
101#elif defined(Q_WS_X11)
102 bool x11Event( XEvent *event );
103#endif
104
105private:
106
107 // flags for keyEvent()
108 enum {
109 KeyExtended = 0x01,
110 KeyPressed = 0x02,
111 KeyPause = 0x04,
112 KeyPrint = 0x08,
113 };
114
115 void focusEvent (bool focus);
116 bool keyEvent (int key, uint8_t scan, int flags);
117 bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
118 ButtonState aButton,
119 ButtonState aState, ButtonState aStateAfter,
120 int aWheelDelta, Orientation aWheelDir);
121
122 void emitKeyboardStateChanged() {
123 emit keyboardStateChanged (
124 (kbd_captured ? KeyboardCaptured : 0) |
125 (hostkey_pressed ? HostKeyPressed : 0));
126 }
127 void emitMouseStateChanged() {
128 emit mouseStateChanged ((mouse_captured ? MouseCaptured : 0) |
129 (mouse_absolute ? MouseAbsolute : 0) |
130 (!mouse_integration ? MouseAbsoluteDisabled : 0));
131 }
132
133 // IConsoleCallback event handlers
134 void onStateChange (CEnums::MachineState state);
135
136 void doRefresh();
137
138 void viewportPaintEvent( QPaintEvent * );
139#ifdef VBOX_GUI_USE_REFRESH_TIMER
140 void timerEvent( QTimerEvent * );
141#endif
142
143 void captureKbd (bool capture, bool emit_signal = true);
144 void captureMouse (bool capture, bool emit_signal = true);
145
146 bool processHotKey (const QKeySequence &key, QMenuData *data);
147
148 void releaseAllKeysPressed (bool release_hostkey = true);
149 void saveKeyStates();
150 void sendChangedKeyStates();
151 void updateMouseClipping();
152
153 void setPointerShape (MousePointerChangeEvent *me);
154
155 bool isPaused() { return last_state == CEnums::Paused; }
156 bool isRunning() { return last_state == CEnums::Running; }
157
158 static void dimImage (QImage &img);
159
160private slots:
161
162 void doResizeHint();
163 void normalizeGeo() { normalizeGeometry(); }
164
165private:
166
167 VBoxConsoleWnd *mainwnd;
168
169 CConsole cconsole;
170
171 const VMGlobalSettings &gs;
172
173 CEnums::MachineState last_state;
174
175 bool attached : 1;
176 bool kbd_captured : 1;
177 bool mouse_captured : 1;
178 bool mouse_absolute : 1;
179 bool mouse_integration : 1;
180 QPoint last_pos;
181 QPoint captured_pos;
182
183 enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
184 uint8_t keys_pressed[128];
185 uint8_t keys_pressed_copy[128];
186
187 bool hostkey_pressed : 1;
188 bool hostkey_alone : 1;
189 /** kbd_captured value during the the last host key press or release */
190 bool hostkey_in_capture : 1;
191
192 bool ignore_mainwnd_resize : 1;
193 bool autoresize_guest : 1;
194
195 QTimer *resize_hint_timer;
196
197 VBoxDefs::RenderMode mode;
198
199#if defined (VBOX_GUI_USE_REFRESH_TIMER)
200 QPixmap pm;
201 int tid; /**< Timer id */
202#endif
203
204 VBoxFrameBuffer *fb;
205 CConsoleCallback callback;
206
207 friend class VBoxConsoleCallback;
208
209#if defined (Q_WS_WIN32)
210 static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
211 WPARAM wParam, LPARAM lParam);
212#endif
213
214 QPixmap mPausedShot;
215};
216
217#endif // __VBoxConsoleView_h__
218
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