VirtualBox

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

Last change on this file since 13374 was 12627, checked in by vboxsync, 16 years ago

FE/Qt: reduce the number of dependencies to iprt/asm.h

  • 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#include <iprt/alloc.h>
32
33#ifdef VBOX_GUI_DEBUG
34
35#define AssertWrapperOk(w) \
36 AssertMsg (w.isOk(), (#w " is not okay (RC=0x%08X)", w.lastRC()))
37#define AssertWrapperOkMsg(w, m) \
38 AssertMsg (w.isOk(), (#w ": " m " (RC=0x%08X)", w.lastRC()))
39
40#else // !VBOX_GUI_DEBUG
41
42#define AssertWrapperOk(w) do {} while (0)
43#define AssertWrapperOkMsg(w, m) do {} while (0)
44
45#endif // !VBOX_GUI_DEBUG
46
47#ifndef SIZEOF_ARRAY
48#define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(a[0]))
49#endif
50
51#if defined (VBOX_GUI_USE_QIMAGE) || \
52 defined (VBOX_GUI_USE_SDL) || \
53 defined (VBOX_GUI_USE_DDRAW)
54 #if !defined (VBOX_GUI_USE_EXT_FRAMEBUFFER)
55 #define VBOX_GUI_USE_EXT_FRAMEBUFFER
56 #endif
57#else
58 #if defined (VBOX_GUI_USE_EXT_FRAMEBUFFER)
59 #undef VBOX_GUI_USE_EXT_FRAMEBUFFER
60 #endif
61#endif
62
63/////////////////////////////////////////////////////////////////////////////
64
65#if defined (VBOX_GUI_DEBUG)
66
67#include <VBox/types.h> // for uint64_t type
68
69#include <qthread.h>
70#include <qdatetime.h>
71
72/**
73 * A class to measure intervals using rdtsc instruction.
74 */
75class VMCPUTimer : public QThread // for crossplatform msleep()
76{
77public:
78 /* don't inline this function to not depend on iprt/asm.h here */
79 static uint64_t ticks();
80 inline static uint64_t msecs( uint64_t tcks ) {
81 return tcks / ticks_per_msec;
82 }
83 inline static uint64_t msecsSince( uint64_t tcks ) {
84 tcks = ticks() - tcks;
85 return tcks / ticks_per_msec;
86 }
87 inline static void calibrate( int ms )
88 {
89 QTime t;
90 uint64_t tcks = ticks();
91 t.start();
92 msleep( ms );
93 tcks = ticks() - tcks;
94 int msecs = t.elapsed();
95 ticks_per_msec = tcks / msecs;
96 }
97 inline static uint64_t ticksPerMsec() {
98 return ticks_per_msec;
99 }
100private:
101 static uint64_t ticks_per_msec;
102};
103
104#endif // VBOX_GUI_DEBUG
105
106/* A common namespace for all enums */
107struct VBoxDefs
108{
109 /** Disk image type. */
110 enum DiskType { InvalidType, HD = 0x01, CD = 0x02, FD = 0x04 };
111
112 /** VM display rendering mode. */
113 enum RenderMode
114 {
115 InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode, Quartz2DMode
116 };
117
118 /** Additional Qt event types. */
119 enum
120 {
121 AsyncEventType = QEvent::User + 100,
122 ResizeEventType,
123 RepaintEventType,
124 SetRegionEventType,
125 MouseCapabilityEventType,
126 MousePointerChangeEventType,
127 MachineStateChangeEventType,
128 AdditionsStateChangeEventType,
129 MediaChangeEventType,
130 MachineDataChangeEventType,
131 MachineRegisteredEventType,
132 SessionStateChangeEventType,
133 SnapshotEventType,
134 CanShowRegDlgEventType,
135 CanShowUpdDlgEventType,
136 NetworkAdapterChangeEventType,
137 USBCtlStateChangeEventType,
138 USBDeviceStateChangeEventType,
139 SharedFolderChangeEventType,
140 RuntimeErrorEventType,
141 ModifierKeyChangeEventType,
142 EnumerateMediaEventType,
143#if defined (Q_WS_WIN)
144 ShellExecuteEventType,
145#endif
146 ActivateMenuEventType,
147#if defined (Q_WS_MAC)
148 ShowWindowEventType,
149#endif
150 ChangeGUILanguageEventType,
151 AddVDMUrlsEventType
152 };
153
154 static const char* GUI_LastWindowPosition;
155 static const char* GUI_LastWindowPosition_Max;
156 static const char* GUI_Fullscreen;
157 static const char* GUI_Seamless;
158 static const char* GUI_AutoresizeGuest;
159 static const char* GUI_FirstRun;
160 static const char* GUI_SaveMountedAtRuntime;
161 static const char* GUI_LastCloseAction;
162 static const char* GUI_SuppressMessages;
163 static const char* GUI_PermanentSharedFoldersAtRuntime;
164#ifdef Q_WS_X11
165 static const char* GUI_LicenseKey;
166#endif
167 static const char* GUI_RegistrationDlgWinID;
168 static const char* GUI_RegistrationData;
169 static const char* GUI_UpdateDlgWinID;
170 static const char* GUI_UpdateDate;
171 static const char* GUI_UpdateCheckCount;
172 static const char* GUI_LastVMSelected;
173 static const char* GUI_InfoDlgState;
174};
175
176#define MAC_LEOPARD_STYLE defined(Q_WS_MAC) && (QT_VERSION >= 0x040300)
177
178#endif // __VBoxDefs_h__
179
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