~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxCocoaHelper.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 *
 
3
 * VBox frontends: Qt GUI ("VirtualBox"):
 
4
 * VBoxCocoa Helper
 
5
 */
 
6
 
 
7
/*
 
8
 * Copyright (C) 2009 Oracle Corporation
 
9
 *
 
10
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
11
 * available from http://www.virtualbox.org. This file is free software;
 
12
 * you can redistribute it and/or modify it under the terms of the GNU
 
13
 * General Public License (GPL) as published by the Free Software
 
14
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
15
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
16
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
17
 */
 
18
 
 
19
#ifndef ___darwin_VBoxCocoaHelper_h
 
20
#define ___darwin_VBoxCocoaHelper_h
 
21
 
 
22
/* Global includes */
 
23
#include <VBox/VBoxCocoa.h>
 
24
 
 
25
#ifdef __OBJC__
 
26
 
 
27
/* System includes */
 
28
#import <AppKit/NSImage.h>
 
29
#import <Foundation/NSAutoreleasePool.h>
 
30
#import <CoreFoundation/CFString.h>
 
31
 
 
32
/* Qt includes */
 
33
#include <QString>
 
34
#include <QVarLengthArray>
 
35
 
 
36
inline NSString *darwinQStringToNSString (const QString &aString)
 
37
{
 
38
    return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()),
 
39
                                                                             aString.length())) autorelease];
 
40
}
 
41
 
 
42
inline QString darwinNSStringToQString (const NSString *aString)
 
43
{
 
44
    CFStringRef str = reinterpret_cast<const CFStringRef> (aString);
 
45
    if(!str)
 
46
        return QString();
 
47
    CFIndex length = CFStringGetLength (str);
 
48
    const UniChar *chars = CFStringGetCharactersPtr (str);
 
49
    if (chars)
 
50
        return QString (reinterpret_cast<const QChar *> (chars), length);
 
51
 
 
52
    QVarLengthArray<UniChar> buffer (length);
 
53
    CFStringGetCharacters (str, CFRangeMake (0, length), buffer.data());
 
54
    return QString (reinterpret_cast<const QChar *> (buffer.constData()), length);
 
55
}
 
56
 
 
57
#endif /* __OBJC__ */
 
58
 
 
59
#endif /* ___darwin_VBoxCocoaHelper_h */
 
60