VirtualBox

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

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

FE/Qt4-OSX: Quartz2D backend back to life for Cocoa.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 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.215389.xyz. 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# include <iprt/cdefs.h> /* for __BEGIN_DECLS/__END_DECLS & stuff */
42# include <qglobal.h> /* for QT_MAC_USE_COCOA */
43
44# include <ApplicationServices/ApplicationServices.h>
45class QWidget;
46class QToolBar;
47class QPixmap;
48class QRect;
49
50# ifdef QT_MAC_USE_COCOA
51/* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
52typedef void *NativeWindowRef;
53typedef void *NativeViewRef;
54# else /* QT_MAC_USE_COCOA */
55# include <Carbon/Carbon.h>
56typedef WindowRef NativeWindowRef;
57typedef HIViewRef NativeViewRef;
58# endif /* QT_MAC_USE_COCOA */
59#endif /* __OBJC__ */
60
61__BEGIN_DECLS
62
63/********************************************************************************
64 *
65 * Window/View management (OS System native)
66 *
67 ********************************************************************************/
68NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView);
69NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow);
70
71/********************************************************************************
72 *
73 * Simple setter methods (OS System native)
74 *
75 ********************************************************************************/
76void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled);
77void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled);
78void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow);
79void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled);
80void darwinSetMouseCoalescingEnabled (bool aEnabled);
81
82/********************************************************************************
83 *
84 * Simple helper methods (OS System native)
85 *
86 ********************************************************************************/
87void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height);
88void darwinWindowInvalidateShapeImpl (NativeWindowRef aWindow);
89void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow);
90
91
92__END_DECLS
93
94#ifndef __OBJC__
95/********************************************************************************
96 *
97 * Window/View management (Qt Wrapper)
98 *
99 ********************************************************************************/
100
101/**
102 * Returns a reference to the native View of the QWidget.
103 *
104 * @returns either HIViewRef or NSView* of the QWidget.
105 * @param aWidget Pointer to the QWidget
106 */
107NativeViewRef darwinToNativeView (QWidget *aWidget);
108
109/**
110 * Returns a reference to the native Window of the QWidget.
111 *
112 * @returns either WindowRef or NSWindow* of the QWidget.
113 * @param aWidget Pointer to the QWidget
114 */
115NativeWindowRef darwinToNativeWindow (QWidget *aWidget);
116
117/* This is necessary because of the C calling convention. Its a simple wrapper
118 for darwinToNativeWindowImpl to allow operator overloading which isn't
119 allowed in C. */
120/**
121 * Returns a reference to the native Window of the View..
122 *
123 * @returns either WindowRef or NSWindow* of the View.
124 * @param aWidget Pointer to the native View
125 */
126NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
127
128/**
129 * Returns a reference to the native View of the Window.
130 *
131 * @returns either HIViewRef or NSView* of the Window.
132 * @param aWidget Pointer to the native Window
133 */
134NativeViewRef darwinToNativeView (NativeWindowRef aWindow);
135
136/********************************************************************************
137 *
138 * Simple setter methods (Qt Wrapper)
139 *
140 ********************************************************************************/
141void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
142void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);
143void darwinSetHidesAllTitleButtons (QWidget *aWidget);
144void darwinSetShowsWindowTransparent (QWidget *aWidget, bool aEnabled);
145void darwinDisableIconsInMenus (void);
146
147/********************************************************************************
148 *
149 * Simple helper methods (Qt Wrapper)
150 *
151 ********************************************************************************/
152void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
153void darwinWindowInvalidateShape (QWidget *aWidget);
154void darwinWindowInvalidateShadow (QWidget *aWidget);
155QString darwinSystemLanguage (void);
156QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
157
158
159
160/********************************************************************************
161 *
162 * Old carbon stuff. Have to be converted soon!
163 *
164 ********************************************************************************/
165
166#include <QWidget>
167class QImage;
168
169/* Converting stuff */
170CGImageRef darwinToCGImageRef (const QImage *aImage);
171CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
172CGImageRef darwinToCGImageRef (const char *aSource);
173
174/**
175 * Returns a reference to the CGContext of the QWidget.
176 *
177 * @returns CGContextRef of the QWidget.
178 * @param aWidget Pointer to the QWidget
179 */
180DECLINLINE(CGContextRef) darwinToCGContextRef (QWidget *aWidget)
181{
182 return static_cast<CGContext *> (aWidget->macCGHandle());
183}
184
185DECLINLINE(CGRect) darwinToCGRect (const QRect& aRect) { return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height()); }
186DECLINLINE(CGRect) darwinFlipCGRect (CGRect aRect, int aTargetHeight) { aRect.origin.y = aTargetHeight - aRect.origin.y - aRect.size.height; return aRect; }
187
188# ifndef QT_MAC_USE_COCOA
189
190/* Asserts if a != noErr and prints the error code */
191# define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
192
193
194/**
195 * Converts a QRect to a HIRect.
196 *
197 * @returns HIRect for the converted QRect.
198 * @param aRect the QRect to convert
199 */
200DECLINLINE(HIRect) darwinToHIRect (const QRect &aRect)
201{
202 return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height());
203}
204
205/* Experimental region handler for the seamless mode */
206OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
207
208/* Handler for the OpenGL overlay window stuff & the possible messages. */
209enum
210{
211 /* Event classes */
212 kEventClassVBox = 'vbox',
213 /* Event kinds */
214 kEventVBoxShowWindow = 'swin',
215 kEventVBoxMoveWindow = 'mwin',
216 kEventVBoxResizeWindow = 'rwin',
217 kEventVBoxUpdateDock = 'udck'
218};
219OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
220
221bool darwinIsMenuOpen (void);
222
223# endif /* !QT_MAC_USE_COCOA */
224
225# ifdef DEBUG
226void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
227# endif
228
229#endif /* !__OBJC__ */
230
231#endif /* __VBoxUtils_darwin_h */
232
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette