~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** @file
2
 
 *
3
 
 * VBox frontends: Qt GUI ("VirtualBox"):
4
 
 * Declarations of utility classes and functions for handling Darwin Cocoa
5
 
 * specific tasks
6
 
 */
7
 
 
8
 
/*
9
 
 * Copyright (C) 2009 Sun Microsystems, Inc.
10
 
 *
11
 
 * This file is part of VirtualBox Open Source Edition (OSE), as
12
 
 * available from http://www.virtualbox.org. This file is free software;
13
 
 * you can redistribute it and/or modify it under the terms of the GNU
14
 
 * General Public License (GPL) as published by the Free Software
15
 
 * Foundation, in version 2 as it comes in the "COPYING" file of the
16
 
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17
 
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18
 
 *
19
 
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20
 
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21
 
 * additional information or have any questions.
22
 
 */
23
 
 
24
 
#include "VBoxUtils-darwin.h"
25
 
 
26
 
#include <iprt/assert.h>
27
 
 
28
 
#import <AppKit/NSEvent.h>
29
 
#import <AppKit/NSColor.h>
30
 
 
31
 
NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
32
 
{
33
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
34
 
 
35
 
    NativeWindowRef window = NULL;
36
 
    if (aView)
37
 
        window = [aView window];
38
 
    
39
 
    [pool release];
40
 
    return window;
41
 
}
42
 
 
43
 
NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow)
44
 
{
45
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
46
 
 
47
 
    NativeViewRef view = NULL;
48
 
    if (aWindow)
49
 
        view = [aWindow contentView];   
50
 
 
51
 
    [pool release];
52
 
    return view;
53
 
}
54
 
 
55
 
void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
56
 
{
57
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
58
 
 
59
 
    [aWindow setShowsToolbarButton:aEnabled];
60
 
 
61
 
    [pool release];
62
 
}
63
 
 
64
 
void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled)
65
 
{
66
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
67
 
 
68
 
    [aWindow setShowsResizeIndicator:aEnabled];
69
 
 
70
 
    [pool release];
71
 
}
72
 
 
73
 
void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow)
74
 
{
75
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
76
 
 
77
 
    NSButton *closeButton = [aWindow standardWindowButton:NSWindowCloseButton];
78
 
    if (closeButton != Nil)
79
 
        [closeButton setHidden:YES];
80
 
    NSButton *minButton = [aWindow standardWindowButton:NSWindowMiniaturizeButton];
81
 
    if (minButton != Nil)
82
 
        [minButton setHidden:YES];
83
 
    NSButton *zoomButton = [aWindow standardWindowButton:NSWindowZoomButton];
84
 
    if (zoomButton != Nil)
85
 
        [zoomButton setHidden:YES];
86
 
    NSButton *iconButton = [aWindow standardWindowButton:NSWindowDocumentIconButton];
87
 
    if (iconButton != Nil)
88
 
        [iconButton setHidden:YES];
89
 
 
90
 
    [pool release];
91
 
}
92
 
 
93
 
void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled)
94
 
{
95
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
96
 
 
97
 
    if (aEnabled)
98
 
    {
99
 
        [aWindow setOpaque:NO];
100
 
        [aWindow setBackgroundColor:[NSColor clearColor]];
101
 
        [aWindow setHasShadow:NO];
102
 
    }
103
 
    else
104
 
    {
105
 
        [aWindow setOpaque:YES];
106
 
        [aWindow setBackgroundColor:[NSColor windowBackgroundColor]];
107
 
        [aWindow setHasShadow:YES];
108
 
    }
109
 
 
110
 
    [pool release];
111
 
}
112
 
 
113
 
/**
114
 
 * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
115
 
 *
116
 
 * @param   fEnabled    Whether to enable or disable coalescing.
117
 
 */
118
 
void darwinSetMouseCoalescingEnabled (bool aEnabled)
119
 
{
120
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
121
 
 
122
 
    [NSEvent setMouseCoalescingEnabled:aEnabled];
123
 
 
124
 
    [pool release];
125
 
}
126
 
 
127
 
void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height)
128
 
{
129
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
130
 
 
131
 
    /* It seems that Qt doesn't return the height of the window with the
132
 
     * toolbar height included. So add this size manually. Could easily be that
133
 
     * the Trolls fix this in the final release. */
134
 
    NSToolbar *toolbar = [aWindow toolbar];
135
 
    NSRect windowFrame = [aWindow frame];
136
 
    int toolbarHeight = 0;
137
 
    if(toolbar && [toolbar isVisible])
138
 
        toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]);
139
 
    int h = height + toolbarHeight;
140
 
    int h1 = h - NSHeight (windowFrame);
141
 
    windowFrame.size.height = h;
142
 
    windowFrame.origin.y -= h1;
143
 
 
144
 
    [aWindow setFrame:windowFrame display:YES animate:YES];
145
 
 
146
 
    [pool release];
147
 
}
148
 
 
149
 
void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow)
150
 
{
151
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
152
 
 
153
 
    [aWindow invalidateShadow];
154
 
 
155
 
    [pool release];
156
 
}
157