VirtualBox

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

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

FE/Qt4: Quartz2D should be available for 64bit & Cocoa also. See what the 64bit build machine thinks about that.

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