VirtualBox

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

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

FE/Qt-OSX: Make the handling of Darwin tasks more generic for Carbon & Cocoa. Disable settings window animation on Cocoa.

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