Changeset 30122 in vbox for trunk/include/VBox
- Timestamp:
- Jun 9, 2010 1:50:26 PM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxCocoa.h
r30114 r30122 1 1 /** @file 2 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"):4 3 * VBoxCocoa Helper 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2009 Oracle Corporation7 * Copyright (C) 2009-2010 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 16 */ 18 17 19 #ifndef __ _darwin_VBoxCocoaHelper_h20 #define __ _darwin_VBoxCocoaHelper_h18 #ifndef __VBoxCocoa_h__ 19 #define __VBoxCocoa_h__ 21 20 22 21 /* Macro which add a typedef of the given Cocoa class in an appropriate form … … 39 38 #ifdef __OBJC__ 40 39 41 /* System includes */ 42 #import <AppKit/NSImage.h> 40 /* Global includes */ 43 41 #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 }81 42 82 43 /* Helper class for automatic creation & destroying of a cocoa auto release … … 100 61 #endif /* __OBJC__ */ 101 62 102 #endif /* __ _darwin_VBoxCocoaHelper_h*/63 #endif /* __VBoxCocoa_h__ */ 103 64
Note:
See TracChangeset
for help on using the changeset viewer.