VirtualBox

Changeset 30122 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jun 9, 2010 1:50:26 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX/Global: Split the event handling methods and the Qt methods for usage without Qt.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxCocoa.h

    r30114 r30122  
    11/** @file
    22 *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    43 * VBoxCocoa Helper
    54 */
    65
    76/*
    8  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2009-2010 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1716 */
    1817
    19 #ifndef ___darwin_VBoxCocoaHelper_h
    20 #define ___darwin_VBoxCocoaHelper_h
     18#ifndef __VBoxCocoa_h__
     19#define __VBoxCocoa_h__
    2120
    2221/* Macro which add a typedef of the given Cocoa class in an appropriate form
     
    3938#ifdef __OBJC__
    4039
    41 /* System includes */
    42 #import <AppKit/NSImage.h>
     40/* Global includes */
    4341#import <Foundation/NSAutoreleasePool.h>
    44 #import <CoreFoundation/CFString.h>
    45 
    46 /* Qt includes */
    47 #include <QString>
    48 #include <QVarLengthArray>
    49 
    50 inline NSString *darwinQStringToNSString (const QString &aString)
    51 {
    52     return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()),
    53                                                                              aString.length())) autorelease];
    54 }
    55 
    56 inline QString darwinNSStringToQString (const NSString *aString)
    57 {
    58     CFStringRef str = reinterpret_cast<const CFStringRef> (aString);
    59     if(!str)
    60         return QString();
    61     CFIndex length = CFStringGetLength (str);
    62     const UniChar *chars = CFStringGetCharactersPtr (str);
    63     if (chars)
    64         return QString (reinterpret_cast<const QChar *> (chars), length);
    65 
    66     QVarLengthArray<UniChar> buffer (length);
    67     CFStringGetCharacters (str, CFRangeMake (0, length), buffer.data());
    68     return QString (reinterpret_cast<const QChar *> (buffer.constData()), length);
    69 }
    70 
    71 inline NSImage *darwinCGImageToNSImage (const CGImageRef aImage)
    72 {
    73     /* Create a bitmap rep from the image. */
    74     NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:aImage];
    75     /* Create an NSImage and add the bitmap rep to it */
    76     NSImage *image = [[NSImage alloc] init];
    77     [image addRepresentation:bitmapRep];
    78     [bitmapRep release];
    79     return image;
    80 }
    8142
    8243/* Helper class for automatic creation & destroying of a cocoa auto release
     
    10061#endif /* __OBJC__ */
    10162
    102 #endif /* ___darwin_VBoxCocoaHelper_h */
     63#endif /* __VBoxCocoa_h__ */
    10364
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette