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 |
|
---|
47 | # ifdef QT_MAC_USE_COCOA
|
---|
48 | /* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
|
---|
49 | typedef void *NativeWindowRef;
|
---|
50 | typedef void *NativeViewRef;
|
---|
51 | # else /* QT_MAC_USE_COCOA */
|
---|
52 | # include <Carbon/Carbon.h>
|
---|
53 | typedef WindowRef NativeWindowRef;
|
---|
54 | typedef 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 | ********************************************************************************/
|
---|
65 | NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView);
|
---|
66 |
|
---|
67 | /********************************************************************************
|
---|
68 | *
|
---|
69 | * Simple setter methods (OS System native)
|
---|
70 | *
|
---|
71 | ********************************************************************************/
|
---|
72 | void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled);
|
---|
73 | void 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 | */
|
---|
90 | NativeViewRef 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 | */
|
---|
98 | NativeWindowRef 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 | */
|
---|
109 | NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
|
---|
110 |
|
---|
111 | /********************************************************************************
|
---|
112 | *
|
---|
113 | * Simple setter methods (Qt Wrapper)
|
---|
114 | *
|
---|
115 | ********************************************************************************/
|
---|
116 | void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
|
---|
117 | void darwinDisableIconsInMenus (void);
|
---|
118 |
|
---|
119 | /********************************************************************************
|
---|
120 | *
|
---|
121 | * Simple helper methods (Qt Wrapper)
|
---|
122 | *
|
---|
123 | ********************************************************************************/
|
---|
124 | QString darwinSystemLanguage (void);
|
---|
125 | QPixmap 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>
|
---|
138 | class 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 */
|
---|
146 | CGImageRef darwinToCGImageRef (const QImage *aImage);
|
---|
147 | CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
|
---|
148 | CGImageRef 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 | */
|
---|
156 | DECLINLINE(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 | */
|
---|
167 | DECLINLINE(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 */
|
---|
173 | OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
|
---|
174 |
|
---|
175 | /* Handler for the OpenGL overlay window stuff & the possible messages. */
|
---|
176 | enum
|
---|
177 | {
|
---|
178 | /* Event classes */
|
---|
179 | kEventClassVBox = 'vbox',
|
---|
180 | /* Event kinds */
|
---|
181 | kEventVBoxShowWindow = 'swin',
|
---|
182 | kEventVBoxMoveWindow = 'mwin',
|
---|
183 | kEventVBoxResizeWindow = 'rwin',
|
---|
184 | kEventVBoxUpdateDock = 'udck'
|
---|
185 | };
|
---|
186 | OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
|
---|
187 |
|
---|
188 | bool darwinIsMenuOpen (void);
|
---|
189 |
|
---|
190 | void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
|
---|
191 | # endif /* !QT_MAC_USE_COCOA */
|
---|
192 |
|
---|
193 | # ifdef DEBUG
|
---|
194 | void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
|
---|
195 | # endif
|
---|
196 |
|
---|
197 | #endif /* !__OBJC__ */
|
---|
198 |
|
---|
199 | #endif /* __VBoxUtils_darwin_h */
|
---|
200 |
|
---|