VBoxUtils-darwin.h revision 83f490cd5eec4567f8ee5c9e481f9d9c739b3061
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* Declarations of utility classes and functions for handling Darwin specific
* tasks
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __VBoxUtils_darwin_h
#define __VBoxUtils_darwin_h
/*
* Here is some really magic in. The "OS System native" methods are implemented
* in the current OS specific way. This means either Carbon
* (VBoxUtils-darwin-carbon.cpp) or Cocoa (VBoxUtils-darwin-cocoa.m). The Qt
* wrapper methods handle the conversion from Q* data types to the native one
* (VBoxUtils-darwin.cpp).
*/
#ifdef __OBJC__
typedef NSWindow *NativeWindowRef;
typedef NSView *NativeViewRef;
#else
# include <qglobal.h> /* for QT_MAC_USE_COCOA */
# include <QRect>
# include <ApplicationServices/ApplicationServices.h>
# ifdef QT_MAC_USE_COCOA
/* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
typedef void *NativeWindowRef;
typedef void *NativeViewRef;
# else /* QT_MAC_USE_COCOA */
typedef WindowRef NativeWindowRef;
typedef HIViewRef NativeViewRef;
# endif /* QT_MAC_USE_COCOA */
#endif /* __OBJC__ */
/********************************************************************************
*
*
********************************************************************************/
/********************************************************************************
*
* Simple setter methods (OS System native)
*
********************************************************************************/
void darwinSetMouseCoalescingEnabled (bool aEnabled);
/********************************************************************************
*
* Simple helper methods (OS System native)
*
********************************************************************************/
#ifndef __OBJC__
/********************************************************************************
*
*
********************************************************************************/
/**
* Returns a reference to the native View of the QWidget.
*
* @returns either HIViewRef or NSView* of the QWidget.
* @param aWidget Pointer to the QWidget
*/
/**
* Returns a reference to the native Window of the QWidget.
*
* @returns either WindowRef or NSWindow* of the QWidget.
* @param aWidget Pointer to the QWidget
*/
/* This is necessary because of the C calling convention. Its a simple wrapper
for darwinToNativeWindowImpl to allow operator overloading which isn't
allowed in C. */
/**
* Returns a reference to the native Window of the View..
*
* @returns either WindowRef or NSWindow* of the View.
* @param aWidget Pointer to the native View
*/
/**
* Returns a reference to the native View of the Window.
*
* @returns either HIViewRef or NSView* of the Window.
* @param aWidget Pointer to the native Window
*/
/********************************************************************************
*
* Simple setter methods (Qt Wrapper)
*
********************************************************************************/
void darwinDisableIconsInMenus (void);
/********************************************************************************
*
* Simple helper methods (Qt Wrapper)
*
********************************************************************************/
QString darwinSystemLanguage (void);
/********************************************************************************
*
* Graphics stuff (Qt Wrapper)
*
********************************************************************************/
/**
* Returns a reference to the CGContext of the QWidget.
*
* @returns CGContextRef of the QWidget.
* @param aWidget Pointer to the QWidget
*/
DECLINLINE(CGRect) darwinToCGRect (const QRect& aRect) { return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height()); }
DECLINLINE(CGRect) darwinFlipCGRect (CGRect aRect, int aTargetHeight) { aRect.origin.y = aTargetHeight - aRect.origin.y - aRect.size.height; return aRect; }
DECLINLINE(CGRect) darwinFlipCGRect (CGRect aRect, const CGRect &aTarget) { return darwinFlipCGRect (aRect, aTarget.size.height); }
{
return aRect;
}
/********************************************************************************
*
* Old carbon stuff. Have to be converted soon!
*
********************************************************************************/
#include <QWidget>
# ifndef QT_MAC_USE_COCOA
/* Asserts if a != noErr and prints the error code */
# define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
/**
* Converts a QRect to a HIRect.
*
* @returns HIRect for the converted QRect.
* @param aRect the QRect to convert
*/
{
}
/* Experimental region handler for the seamless mode */
OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
/* Handler for the OpenGL overlay window stuff & the possible messages. */
enum
{
/* Event classes */
kEventClassVBox = 'vbox',
/* Event kinds */
kEventVBoxShowWindow = 'swin',
kEventVBoxHideWindow = 'hwin',
kEventVBoxMoveWindow = 'mwin',
kEventVBoxResizeWindow = 'rwin',
kEventVBoxDisposeWindow = 'dwin',
kEventVBoxUpdateDock = 'udck'
};
OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
bool darwinIsMenuOpen (void);
# endif /* !QT_MAC_USE_COCOA */
# ifdef DEBUG
# endif
#endif /* !__OBJC__ */
#endif /* __VBoxUtils_darwin_h */