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 |
|
---|
38 | typedef NSWindow *NativeWindowRef;
|
---|
39 | typedef 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 | class QWidget;
|
---|
44 | class QToolBar;
|
---|
45 | class QPixmap;
|
---|
46 | class QRect;
|
---|
47 |
|
---|
48 | # ifdef QT_MAC_USE_COCOA
|
---|
49 | /* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
|
---|
50 | typedef void *NativeWindowRef;
|
---|
51 | typedef void *NativeViewRef;
|
---|
52 | # else /* QT_MAC_USE_COCOA */
|
---|
53 | # include <Carbon/Carbon.h>
|
---|
54 | typedef WindowRef NativeWindowRef;
|
---|
55 | typedef 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 | ********************************************************************************/
|
---|
66 | NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView);
|
---|
67 |
|
---|
68 | /********************************************************************************
|
---|
69 | *
|
---|
70 | * Simple setter methods (OS System native)
|
---|
71 | *
|
---|
72 | ********************************************************************************/
|
---|
73 | void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled);
|
---|
74 | void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled);
|
---|
75 | void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow);
|
---|
76 | void darwinSetMouseCoalescingEnabled (bool aEnabled);
|
---|
77 |
|
---|
78 | /********************************************************************************
|
---|
79 | *
|
---|
80 | * Simple helper methods (OS System native)
|
---|
81 | *
|
---|
82 | ********************************************************************************/
|
---|
83 | void 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 | */
|
---|
100 | NativeViewRef 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 | */
|
---|
108 | NativeWindowRef 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 | */
|
---|
119 | NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
|
---|
120 |
|
---|
121 | /********************************************************************************
|
---|
122 | *
|
---|
123 | * Simple setter methods (Qt Wrapper)
|
---|
124 | *
|
---|
125 | ********************************************************************************/
|
---|
126 | void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
|
---|
127 | void darwinSetShowsResizeIndicator (QWidget *aWidget, bool aEnabled);
|
---|
128 | void darwinSetHidesAllTitleButtons (QWidget *aWidget);
|
---|
129 | void darwinDisableIconsInMenus (void);
|
---|
130 |
|
---|
131 | /********************************************************************************
|
---|
132 | *
|
---|
133 | * Simple helper methods (Qt Wrapper)
|
---|
134 | *
|
---|
135 | ********************************************************************************/
|
---|
136 | void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
|
---|
137 | QString darwinSystemLanguage (void);
|
---|
138 | QPixmap 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>
|
---|
151 | class QImage;
|
---|
152 |
|
---|
153 | /* Converting stuff */
|
---|
154 | CGImageRef darwinToCGImageRef (const QImage *aImage);
|
---|
155 | CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
|
---|
156 | CGImageRef 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 | */
|
---|
164 | DECLINLINE(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 | */
|
---|
181 | DECLINLINE(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 */
|
---|
187 | OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
|
---|
188 |
|
---|
189 | /* Handler for the OpenGL overlay window stuff & the possible messages. */
|
---|
190 | enum
|
---|
191 | {
|
---|
192 | /* Event classes */
|
---|
193 | kEventClassVBox = 'vbox',
|
---|
194 | /* Event kinds */
|
---|
195 | kEventVBoxShowWindow = 'swin',
|
---|
196 | kEventVBoxMoveWindow = 'mwin',
|
---|
197 | kEventVBoxResizeWindow = 'rwin',
|
---|
198 | kEventVBoxUpdateDock = 'udck'
|
---|
199 | };
|
---|
200 | OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
|
---|
201 |
|
---|
202 | bool darwinIsMenuOpen (void);
|
---|
203 |
|
---|
204 | void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
|
---|
205 | # endif /* !QT_MAC_USE_COCOA */
|
---|
206 |
|
---|
207 | # ifdef DEBUG
|
---|
208 | void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
|
---|
209 | # endif
|
---|
210 |
|
---|
211 | #endif /* !__OBJC__ */
|
---|
212 |
|
---|
213 | #endif /* __VBoxUtils_darwin_h */
|
---|
214 |
|
---|