VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h@ 10887

Last change on this file since 10887 was 10439, checked in by vboxsync, 16 years ago

Fe/Qt4: VirtualBox New Version Notifier dialog implemented.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * Header with common definitions and global functions
5 */
6
7/*
8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __VBoxDefs_h__
24#define __VBoxDefs_h__
25
26#include <qevent.h>
27
28#define LOG_GROUP LOG_GROUP_GUI
29#include <VBox/log.h>
30#include <iprt/assert.h>
31
32#include <iprt/alloc.h>
33#include <iprt/asm.h>
34
35#ifdef VBOX_GUI_DEBUG
36
37#define AssertWrapperOk(w) \
38 AssertMsg (w.isOk(), (#w " is not okay (RC=0x%08X)", w.lastRC()))
39#define AssertWrapperOkMsg(w, m) \
40 AssertMsg (w.isOk(), (#w ": " m " (RC=0x%08X)", w.lastRC()))
41
42#else // !VBOX_GUI_DEBUG
43
44#define AssertWrapperOk(w) do {} while (0)
45#define AssertWrapperOkMsg(w, m) do {} while (0)
46
47#endif // !VBOX_GUI_DEBUG
48
49#ifndef SIZEOF_ARRAY
50#define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(a[0]))
51#endif
52
53#if defined (VBOX_GUI_USE_QIMAGE) || \
54 defined (VBOX_GUI_USE_SDL) || \
55 defined (VBOX_GUI_USE_DDRAW)
56 #if !defined (VBOX_GUI_USE_EXT_FRAMEBUFFER)
57 #define VBOX_GUI_USE_EXT_FRAMEBUFFER
58 #endif
59#else
60 #if defined (VBOX_GUI_USE_EXT_FRAMEBUFFER)
61 #undef VBOX_GUI_USE_EXT_FRAMEBUFFER
62 #endif
63#endif
64
65/////////////////////////////////////////////////////////////////////////////
66
67#if defined (VBOX_GUI_DEBUG)
68
69#include <VBox/types.h> // for uint64_t type
70
71#include <qthread.h>
72#include <qdatetime.h>
73
74/**
75 * A class to measure intervals using rdtsc instruction.
76 */
77class VMCPUTimer : public QThread // for crossplatform msleep()
78{
79public:
80 inline static uint64_t ticks() {
81 return ASMReadTSC();
82 }
83 inline static uint64_t msecs( uint64_t tcks ) {
84 return tcks / ticks_per_msec;
85 }
86 inline static uint64_t msecsSince( uint64_t tcks ) {
87 tcks = ticks() - tcks;
88 return tcks / ticks_per_msec;
89 }
90 inline static void calibrate( int ms )
91 {
92 QTime t;
93 uint64_t tcks = ticks();
94 t.start();
95 msleep( ms );
96 tcks = ticks() - tcks;
97 int msecs = t.elapsed();
98 ticks_per_msec = tcks / msecs;
99 }
100 inline static uint64_t ticksPerMsec() {
101 return ticks_per_msec;
102 }
103private:
104 static uint64_t ticks_per_msec;
105};
106
107#endif // VBOX_GUI_DEBUG
108
109/* A common namespace for all enums */
110struct VBoxDefs
111{
112 /** Disk image type. */
113 enum DiskType { InvalidType, HD = 0x01, CD = 0x02, FD = 0x04 };
114
115 /** VM display rendering mode. */
116 enum RenderMode
117 {
118 InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode, Quartz2DMode
119 };
120
121 /** Additional Qt event types. */
122 enum
123 {
124 AsyncEventType = QEvent::User + 100,
125 ResizeEventType,
126 RepaintEventType,
127 SetRegionEventType,
128 MouseCapabilityEventType,
129 MousePointerChangeEventType,
130 MachineStateChangeEventType,
131 AdditionsStateChangeEventType,
132 MediaChangeEventType,
133 MachineDataChangeEventType,
134 MachineRegisteredEventType,
135 SessionStateChangeEventType,
136 SnapshotEventType,
137 CanShowRegDlgEventType,
138 CanShowUpdDlgEventType,
139 NetworkAdapterChangeEventType,
140 USBCtlStateChangeEventType,
141 USBDeviceStateChangeEventType,
142 SharedFolderChangeEventType,
143 RuntimeErrorEventType,
144 ModifierKeyChangeEventType,
145 EnumerateMediaEventType,
146#if defined (Q_WS_WIN)
147 ShellExecuteEventType,
148#endif
149 ActivateMenuEventType,
150#if defined (Q_WS_MAC)
151 ShowWindowEventType,
152#endif
153 ChangeGUILanguageEventType,
154 AddVDMUrlsEventType
155 };
156
157 static const char* GUI_LastWindowPosition;
158 static const char* GUI_LastWindowPosition_Max;
159 static const char* GUI_Fullscreen;
160 static const char* GUI_Seamless;
161 static const char* GUI_AutoresizeGuest;
162 static const char* GUI_FirstRun;
163 static const char* GUI_SaveMountedAtRuntime;
164 static const char* GUI_LastCloseAction;
165 static const char* GUI_SuppressMessages;
166 static const char* GUI_PermanentSharedFoldersAtRuntime;
167#ifdef Q_WS_X11
168 static const char* GUI_LicenseKey;
169#endif
170 static const char* GUI_RegistrationDlgWinID;
171 static const char* GUI_RegistrationData;
172 static const char* GUI_UpdateDlgWinID;
173 static const char* GUI_UpdateDate;
174 static const char* GUI_LastVMSelected;
175 static const char* GUI_InfoDlgState;
176};
177
178#define MAC_LEOPARD_STYLE defined(Q_WS_MAC) && (QT_VERSION >= 0x040300)
179
180#endif // __VBoxDefs_h__
181
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