VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h@ 31698

Last change on this file since 31698 was 31698, checked in by vboxsync, 14 years ago

Main, frontends: unsigned long long -> long long

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * UIMachineView class declaration
5 */
6
7/*
8 * Copyright (C) 2010 Oracle Corporation
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 (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___UIMachineView_h___
20#define ___UIMachineView_h___
21
22/* Global includes */
23#include <QAbstractScrollArea>
24#include <QEventLoop>
25
26/* Local includes */
27#include "COMDefs.h"
28#include "UIMachineDefs.h"
29
30#ifdef Q_WS_MAC
31# include <CoreFoundation/CFBase.h>
32#endif /* Q_WS_MAC */
33
34/* Local forwards */
35class UISession;
36class UIMachineLogic;
37class UIMachineWindow;
38class UIFrameBuffer;
39
40class UIMachineView : public QAbstractScrollArea
41{
42 Q_OBJECT;
43
44public:
45
46 /* Desktop geometry types: */
47 enum DesktopGeo { DesktopGeo_Invalid = 0, DesktopGeo_Fixed, DesktopGeo_Automatic, DesktopGeo_Any };
48
49 /* Factory function to create machine-view: */
50 static UIMachineView* create( UIMachineWindow *pMachineWindow
51 , ulong uScreenId
52 , UIVisualStateType visualStateType
53#ifdef VBOX_WITH_VIDEOHWACCEL
54 , bool bAccelerate2DVideo
55#endif /* VBOX_WITH_VIDEOHWACCEL */
56 );
57 /* Factory function to destroy required machine-view: */
58 static void destroy(UIMachineView *pMachineView);
59
60 /* Public setters: */
61 virtual void setGuestAutoresizeEnabled(bool /* fEnabled */) {}
62
63 /* Public members: */
64 virtual void normalizeGeometry(bool /* bAdjustPosition = false */) = 0;
65
66signals:
67
68 /* Utility signals: */
69 void resizeHintDone();
70
71protected slots:
72
73 /* Console callback handlers: */
74 virtual void sltMachineStateChanged();
75
76protected:
77
78 /* Machine-view constructor: */
79 UIMachineView( UIMachineWindow *pMachineWindow
80 , ulong uScreenId
81#ifdef VBOX_WITH_VIDEOHWACCEL
82 , bool bAccelerate2DVideo
83#endif /* VBOX_WITH_VIDEOHWACCEL */
84 );
85 /* Machine-view destructor: */
86 virtual ~UIMachineView();
87
88 /* Prepare routines: */
89 virtual void prepareViewport();
90 virtual void prepareFrameBuffer();
91 virtual void prepareCommon();
92 virtual void prepareFilters();
93 virtual void prepareConsoleConnections();
94 virtual void loadMachineViewSettings();
95
96 /* Cleanup routines: */
97 //virtual void saveMachineViewSettings() {}
98 //virtual void cleanupConsoleConnections() {}
99 //virtual void cleanupFilters() {}
100 //virtual void cleanupCommon() {}
101 virtual void cleanupFrameBuffer();
102 //virtual void cleanupViewport();
103
104 /* Protected getters: */
105 UIMachineWindow* machineWindowWrapper() const { return m_pMachineWindow; }
106 UIMachineLogic* machineLogic() const;
107 UISession* uisession() const;
108 CSession& session();
109 QSize sizeHint() const;
110 int contentsX() const;
111 int contentsY() const;
112 int contentsWidth() const;
113 int contentsHeight() const;
114 int visibleWidth() const;
115 int visibleHeight() const;
116 ulong screenId() const { return m_uScreenId; }
117 UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; }
118 bool isMachineWindowResizeIgnored() const { return m_bIsMachineWindowResizeIgnored; }
119 const QPixmap& pauseShot() const { return m_pauseShot; }
120 QSize storedConsoleSize() const { return m_storedConsoleSize; }
121 DesktopGeo desktopGeometryType() const { return m_desktopGeometryType; }
122 QSize desktopGeometry() const;
123 QSize guestSizeHint();
124
125 /* Protected setters: */
126 void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight);
127 void storeConsoleSize(int iWidth, int iHeight);
128 void setMachineWindowResizeIgnored(bool fIgnore = true) { m_bIsMachineWindowResizeIgnored = fIgnore; }
129 void storeGuestSizeHint(const QSize &sizeHint);
130
131 /* Protected helpers: */
132 virtual void takePauseShotLive();
133 virtual void takePauseShotSnapshot();
134 virtual void resetPauseShot() { m_pauseShot = QPixmap(); }
135 virtual QRect workingArea() = 0;
136 virtual void calculateDesktopGeometry() = 0;
137 virtual void maybeRestrictMinimumSize() = 0;
138 virtual void updateSliders();
139 QPoint viewportToContents(const QPoint &vp) const;
140 void scrollBy(int dx, int dy);
141 static void dimImage(QImage &img);
142#ifdef VBOX_WITH_VIDEOHWACCEL
143 void scrollContentsBy(int dx, int dy);
144#endif /* VBOX_WITH_VIDEOHWACCEL */
145#ifdef Q_WS_MAC
146 void updateDockIcon();
147 CGImageRef vmContentImage();
148 CGImageRef frameBuffertoCGImageRef(UIFrameBuffer *pFrameBuffer);
149#endif /* Q_WS_MAC */
150
151 /* Cross-platforms event processors: */
152 bool event(QEvent *pEvent);
153 bool eventFilter(QObject *pWatched, QEvent *pEvent);
154 void resizeEvent(QResizeEvent *pEvent);
155 void moveEvent(QMoveEvent *pEvent);
156 void paintEvent(QPaintEvent *pEvent);
157
158 /* Platform specific event processors: */
159#if defined(Q_WS_WIN)
160 bool winEvent(MSG *pMsg, long *puResult);
161#elif defined(Q_WS_X11)
162 bool x11Event(XEvent *event);
163#endif
164
165 /* Private members: */
166 UIMachineWindow *m_pMachineWindow;
167 ulong m_uScreenId;
168 UIFrameBuffer *m_pFrameBuffer;
169 KMachineState m_previousState;
170
171 DesktopGeo m_desktopGeometryType;
172 QSize m_desktopGeometry;
173 QSize m_storedConsoleSize;
174
175 bool m_bIsMachineWindowResizeIgnored : 1;
176#ifdef VBOX_WITH_VIDEOHWACCEL
177 bool m_fAccelerate2DVideo : 1;
178#endif /* VBOX_WITH_VIDEOHWACCEL */
179
180 QPixmap m_pauseShot;
181
182 /* Friend classes: */
183 friend class UIKeyboardHandler;
184 friend class UIMouseHandler;
185 friend class UIMachineLogic;
186 friend class UIFrameBuffer;
187 friend class UIFrameBufferQImage;
188 friend class UIFrameBufferQuartz2D;
189 friend class UIFrameBufferQGL;
190 template<class, class, class> friend class VBoxOverlayFrameBuffer;
191};
192
193/* This maintenance class is a part of future roll-back mechanism.
194 * It allows to block main GUI thread until specific event received.
195 * Later it will become more abstract but now its just used to help
196 * fullscreen & seamless modes to restore normal guest size hint. */
197class UIMachineViewBlocker : public QEventLoop
198{
199 Q_OBJECT;
200
201public:
202
203 UIMachineViewBlocker()
204 : QEventLoop(0)
205 , m_iTimerId(0)
206 {
207 /* Also start timer to unlock pool in case of
208 * required condition doesn't happens by some reason: */
209 m_iTimerId = startTimer(3000);
210 }
211
212 virtual ~UIMachineViewBlocker()
213 {
214 /* Kill the timer: */
215 killTimer(m_iTimerId);
216 }
217
218protected:
219
220 void timerEvent(QTimerEvent *pEvent)
221 {
222 /* If that timer event occurs => it seems
223 * guest resize event doesn't comes in time,
224 * shame on it, but we just unlocking 'this': */
225 QEventLoop::timerEvent(pEvent);
226 exit();
227 }
228
229 int m_iTimerId;
230};
231
232#endif // !___UIMachineView_h___
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use