VBoxUtils-darwin.h revision 6869bae79c0d6d88f052db781de20ffcca7ac19b
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* Declarations of utility classes and functions for handling Darwin specific
* tasks
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* 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.
*/
#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 <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;
# endif /* QT_MAC_USE_COCOA */
#endif /* __OBJC__ */
#include "VBoxCocoaHelper.h"
#include <QRect>
/********************************************************************************
*
*
********************************************************************************/
/********************************************************************************
*
* Simple setter methods (OS System native)
*
********************************************************************************/
void darwinSetMouseCoalescingEnabled(bool aEnabled);
/********************************************************************************
*
* Simple helper methods (OS System native)
*
********************************************************************************/
float darwinSmallFontSize();
bool darwinSetFrontMostProcess();
void darwinCreateContextMenuEvent(void *pvWin, int x, int y);
/********************************************************************************
*
*
********************************************************************************/
const char *darwinEventTypeName(unsigned long eEvtType);
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;
}
/********************************************************************************
*
*
********************************************************************************/
/**
* 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
*/
#ifndef __OBJC__
/********************************************************************************
*
* 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
*/
#endif /* !__OBJC__ */
#endif /* !___VBoxUtils_darwin_h */