UICocoaDockIconPreview.mm revision 2dd7b4388106de88d20f33a8aa6c85c8babf507b
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* Cocoa helper for the dock icon preview
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/* VBox includes */
#include "UICocoaDockIconPreview.h"
#include "VBoxCocoaHelper.h"
/* System includes */
#import <Cocoa/Cocoa.h>
@interface UIDockTileMonitor: NSView
{
}
- (NSImageView*)screenContent;
@end
@interface UIDockTileOverlay: NSView
{
}
@end
@interface UIDockTile: NSView
{
}
- (void)destroy;
- (NSView*)screenContent;
- (void)cleanup;
- (void)restoreAppIcon;
- (void)updateAppIcon;
- (void)restoreMonitor;
@end
/*
* from any Cocoa class.
*/
class UICocoaDockIconPreviewPrivate: public UIAbstractDockIconPreviewHelper
{
public:
{
}
{
}
};
/*
* Cocoa wrapper for the abstract dock icon preview class
*/
{
}
{
delete d;
}
{
[d->mUIDockTile updateAppIcon];
}
{
}
{
}
{
}
/*
*/
{
{
p = parent;
/* The screen content view */
mScreenContent = [[NSImageView alloc] initWithFrame:NSRectFromCGRect(p->flipRect(p->m_updateRect))];
// [mScreenContent setImageAlignment: NSImageAlignCenter];
/* The state view */
mMonitorGlossy = [[NSImageView alloc] initWithFrame:NSRectFromCGRect(p->flipRect(p->m_monitorRect))];
}
return self;
}
{
[dockMonitor drawInRect:NSRectFromCGRect(p->flipRect(p->m_monitorRect)) fromRect:aRect operation:NSCompositeSourceOver fraction:1.0];
}
{
return mScreenContent;
}
{
/* Calculate the new size based on the aspect ratio of the original screen
size */
float w, h;
{
}
else
{
}
// printf("gui %f %f %f %f\n", r.origin.x, r.origin.y, r.size.width, r.size.height);
/* Center within the update rect */
}
@end
/*
* Simple implementation for the overlay of the OS & the state icon. Is used both
* in the application icon & preview mode.
*/
{
p = parent;
return self;
}
{
p->drawOverlayIcons (pCGContext);
}
@end
/*
* VirtualBox Dock Tile implementation. Manage the switching between the icon
* and preview mode & forwards all update request to the appropriate methods.
*/
{
{
p = parent;
/* Add self as the content view of the dock tile */
/* App icon is default */
/* The overlay */
mOverlay = [[UIDockTileOverlay alloc] initWithFrame:NSRectFromCGRect(p->flipRect (p->m_dockIconRect)) parent:p];
}
return self;
}
- (void)destroy
{
/* Remove all content from the application dock tile. */
/* Cleanup all other resources */
}
- (NSView*)screenContent
{
return [mMonitor screenContent];
}
- (void)cleanup
{
{
}
{
}
}
- (void)restoreAppIcon
{
{
}
}
- (void)updateAppIcon
{
}
- (void)restoreMonitor
{
{
p->initPreviewImages();
mMonitor = [[UIDockTileMonitor alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->m_dockIconRect)) parent:p];
}
}
{
}
{
}
@end