VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h@ 3806

Last change on this file since 3806 was 3806, checked in by vboxsync, 17 years ago

FE/Qt: Added VBoxAsyncEvent and VBoxGlobal::findWidget() helpers (see class docs for details).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 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-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 __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 #if !defined (VBOX_GUI_USE_REFRESH_TIMER)
64 #define VBOX_GUI_USE_REFRESH_TIMER
65 #endif
66#endif
67
68/////////////////////////////////////////////////////////////////////////////
69
70#if defined (VBOX_GUI_DEBUG)
71
72#include <VBox/types.h> // for uint64_t type
73
74#include <qthread.h>
75#include <qdatetime.h>
76
77/**
78 * A class to measure intervals using rdtsc instruction.
79 */
80class VMCPUTimer : public QThread // for crossplatform msleep()
81{
82public:
83 inline static uint64_t ticks() {
84 return ASMReadTSC();
85 }
86 inline static uint64_t msecs( uint64_t tcks ) {
87 return tcks / ticks_per_msec;
88 }
89 inline static uint64_t msecsSince( uint64_t tcks ) {
90 tcks = ticks() - tcks;
91 return tcks / ticks_per_msec;
92 }
93 inline static void calibrate( int ms )
94 {
95 QTime t;
96 uint64_t tcks = ticks();
97 t.start();
98 msleep( ms );
99 tcks = ticks() - tcks;
100 int msecs = t.elapsed();
101 ticks_per_msec = tcks / msecs;
102 }
103 inline static uint64_t ticksPerMsec() {
104 return ticks_per_msec;
105 }
106private:
107 static uint64_t ticks_per_msec;
108};
109
110#endif // VBOX_GUI_DEBUG
111
112/* A common namespace for all enums */
113struct VBoxDefs
114{
115 /** Disk image type. */
116 enum DiskType { InvalidType, HD = 0x01, CD = 0x02, FD = 0x04 };
117
118 /** VM display rendering mode. */
119 enum RenderMode
120 {
121 InvalidRenderMode, TimerMode, QImageMode, SDLMode, DDRAWMode
122 };
123
124 /** Additional Qt event types. */
125 enum
126 {
127 AsyncEventType = QEvent::User + 100,
128 ResizeEventType,
129 RepaintEventType,
130 SetRegionEventType,
131 MouseCapabilityEventType,
132 MousePointerChangeEventType,
133 MachineStateChangeEventType,
134 AdditionsStateChangeEventType,
135 MachineDataChangeEventType,
136 MachineRegisteredEventType,
137 SessionStateChangeEventType,
138 SnapshotEventType,
139 USBDeviceStateChangeEventType,
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 };
151
152 static const char* GUI_LastWindowPosition;
153 static const char* GUI_LastWindowPosition_Max;
154 static const char* GUI_Fullscreen;
155 static const char* GUI_Seamless;
156 static const char* GUI_AutoresizeGuest;
157 static const char* GUI_FirstRun;
158 static const char* GUI_SaveMountedAtRuntime;
159 static const char* GUI_LastCloseAction;
160 static const char* GUI_SuppressMessages;
161 static const char* GUI_PermanentSharedFoldersAtRuntime;
162};
163
164#endif // __VBoxDefs_h__
165
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