VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h@ 20554

Last change on this file since 20554 was 20391, checked in by vboxsync, 16 years ago

darwin build fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * Declarations of utility classes and functions for handling Darwin specific
5 * tasks
6 */
7
8/*
9 * Copyright (C) 2009 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef __VBoxUtils_darwin_h
25#define __VBoxUtils_darwin_h
26
27/*
28 * Here is some really magic in. The "OS System native" methods are implemented
29 * in the current OS specific way. This means either Carbon
30 * (VBoxUtils-darwin-carbon.cpp) or Cocoa (VBoxUtils-darwin-cocoa.m). The Qt
31 * wrapper methods handle the conversion from Q* data types to the native one
32 * (VBoxUtils-darwin.cpp).
33 */
34
35#ifdef __OBJC__
36#import <AppKit/NSWindow.h>
37
38typedef NSWindow *NativeWindowRef;
39typedef NSView *NativeViewRef;
40#else
41
42# include <qglobal.h> /* for QT_MAC_USE_COCOA */
43# include <QRect>
44
45# include <ApplicationServices/ApplicationServices.h>
46
47class QWidget;
48class QToolBar;
49class QPixmap;
50class QImage;
51
52# ifdef QT_MAC_USE_COCOA
53/* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
54typedef void *NativeWindowRef;
55typedef void *NativeViewRef;
56# else /* QT_MAC_USE_COCOA */
57# include <Carbon/Carbon.h>
58typedef WindowRef NativeWindowRef;
59typedef HIViewRef NativeViewRef;
60# endif /* QT_MAC_USE_COCOA */
61#endif /* __OBJC__ */
62
63#include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */
64
65RT_C_DECLS_BEGIN
66
67/********************************************************************************
68 *
69 * Window/View management (OS System native)
70 *
71 ********************************************************************************/
72NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView);
73NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow);
74
75/********************************************************************************
76 *
77 * Simple setter methods (OS System native)
78 *
79 ********************************************************************************/
80void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled);
81void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled);
82void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow);
83void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled);
84void darwinSetMouseCoalescingEnabled (bool aEnabled);
85
86/********************************************************************************
87 *
88 * Simple helper methods (OS System native)
89 *
90 ********************************************************************************/
91void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height);
92void darwinWindowInvalidateShapeImpl (NativeWindowRef aWindow);
93void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow);
94
95RT_C_DECLS_END
96
97#ifndef __OBJC__
98/********************************************************************************
99 *
100 * Window/View management (Qt Wrapper)
101 *
102 ********************************************************************************/
103
104/**
105 * Returns a reference to the native View of the QWidget.
106 *
107 * @returns either HIViewRef or NSView* of the QWidget.
108 * @param aWidget Pointer to the QWidget
109 */
110NativeViewRef darwinToNativeView (QWidget *aWidget);
111
112/**
113 * Returns a reference to the native Window of the QWidget.
114 *
115 * @returns either WindowRef or NSWindow* of the QWidget.
116 * @param aWidget Pointer to the QWidget
117 */
118NativeWindowRef darwinToNativeWindow (QWidget *aWidget);
119
120/* This is necessary because of the C calling convention. Its a simple wrapper
121 for darwinToNativeWindowImpl to allow operator overloading which isn't
122 allowed in C. */
123/**
124 * Returns a reference to the native Window of the View..
125 *
126 * @returns either WindowRef or NSWindow* of the View.
127 * @param aWidget Pointer to the native View
128 */
129NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
130
131/**
132 * Returns a reference to the native View of the Window.
133 *
134 * @returns either HIViewRef or NSView* of the Window.
135 * @param aWidget Pointer to the native Window
136 */
137NativeViewRef darwinToNativeView (NativeWindowRef aWindow);
138
139/********************************************************************************
140 *
141 * Simple setter methods (Qt Wrapper)
142 *
143 ********************************************************************************/
144void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
145void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);
146void darwinSetHidesAllTitleButtons (QWidget *aWidget);
147void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled);
148void darwinDisableIconsInMenus (void);
149
150/********************************************************************************
151 *
152 * Simple helper methods (Qt Wrapper)
153 *
154 ********************************************************************************/
155void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
156void darwinWindowInvalidateShape (QWidget *aWidget);
157void darwinWindowInvalidateShadow (QWidget *aWidget);
158QString darwinSystemLanguage (void);
159QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
160
161
162/********************************************************************************
163 *
164 * Graphics stuff (Qt Wrapper)
165 *
166 ********************************************************************************/
167/**
168 * Returns a reference to the CGContext of the QWidget.
169 *
170 * @returns CGContextRef of the QWidget.
171 * @param aWidget Pointer to the QWidget
172 */
173CGContextRef darwinToCGContextRef (QWidget *aWidget);
174
175CGImageRef darwinToCGImageRef (const QImage *aImage);
176CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
177CGImageRef darwinToCGImageRef (const char *aSource);
178
179DECLINLINE(CGRect) darwinToCGRect (const QRect& aRect) { return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height()); }
180DECLINLINE(CGRect) darwinFlipCGRect (CGRect aRect, int aTargetHeight) { aRect.origin.y = aTargetHeight - aRect.origin.y - aRect.size.height; return aRect; }
181DECLINLINE(CGRect) darwinFlipCGRect (CGRect aRect, const CGRect &aTarget) { return darwinFlipCGRect (aRect, aTarget.size.height); }
182DECLINLINE(CGRect) darwinCenterRectTo (CGRect aRect, const CGRect& aToRect)
183{
184 aRect.origin.x = aToRect.origin.x + (aToRect.size.width - aRect.size.width) / 2.0;
185 aRect.origin.y = aToRect.origin.y + (aToRect.size.height - aRect.size.height) / 2.0;
186 return aRect;
187}
188
189
190
191
192
193/********************************************************************************
194 *
195 * Old carbon stuff. Have to be converted soon!
196 *
197 ********************************************************************************/
198
199#include <QWidget>
200
201# ifndef QT_MAC_USE_COCOA
202
203/* Asserts if a != noErr and prints the error code */
204# define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
205
206
207/**
208 * Converts a QRect to a HIRect.
209 *
210 * @returns HIRect for the converted QRect.
211 * @param aRect the QRect to convert
212 */
213DECLINLINE(HIRect) darwinToHIRect (const QRect &aRect)
214{
215 return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height());
216}
217
218/* Experimental region handler for the seamless mode */
219OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
220
221/* Handler for the OpenGL overlay window stuff & the possible messages. */
222enum
223{
224 /* Event classes */
225 kEventClassVBox = 'vbox',
226 /* Event kinds */
227 kEventVBoxShowWindow = 'swin',
228 kEventVBoxHideWindow = 'hwin',
229 kEventVBoxMoveWindow = 'mwin',
230 kEventVBoxResizeWindow = 'rwin',
231 kEventVBoxDisposeWindow = 'dwin',
232 kEventVBoxUpdateDock = 'udck',
233 kEventVBoxUpdateContext = 'uctx',
234 kEventVBoxBoundsChanged = 'bchg'
235};
236
237void PostBoundsChanged (const QRect& rect);
238OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
239
240bool darwinIsMenuOpen (void);
241
242# endif /* !QT_MAC_USE_COCOA */
243
244# ifdef DEBUG
245void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
246# endif
247
248#endif /* !__OBJC__ */
249
250#endif /* __VBoxUtils_darwin_h */
251
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