1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VBoxDockIconPreview class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.215389.xyz. 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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef ___VBoxDockIconPreview_h___
|
---|
24 | #define ___VBoxDockIconPreview_h___
|
---|
25 |
|
---|
26 | #include <QObject> /* drag in QT_MAC_USE_COCOA */
|
---|
27 |
|
---|
28 | #ifdef QT_MAC_USE_COCOA
|
---|
29 | # include <ApplicationServices/ApplicationServices.h>
|
---|
30 | /** @todo include chocolatey headers... */
|
---|
31 | #else
|
---|
32 | # include <Carbon/Carbon.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | class VBoxConsoleWnd;
|
---|
36 | class VBoxFrameBuffer;
|
---|
37 |
|
---|
38 | class QPixmap;
|
---|
39 |
|
---|
40 | class VBoxDockIconPreview
|
---|
41 | {
|
---|
42 | public:
|
---|
43 | VBoxDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
|
---|
44 | ~VBoxDockIconPreview();
|
---|
45 |
|
---|
46 | void updateDockOverlay();
|
---|
47 | //#ifndef QT_MAC_USE_COCOA
|
---|
48 | void updateDockPreview (CGImageRef aVMImage);
|
---|
49 | //#endif
|
---|
50 | void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
|
---|
51 |
|
---|
52 | private:
|
---|
53 | //#ifdef QT_MAC_USE_COCOA
|
---|
54 | /** @todo Carbon -> Cocoa */
|
---|
55 | //#else
|
---|
56 | inline void initPreviewImages();
|
---|
57 | inline void initOverlayData (int aBitmapByteCount);
|
---|
58 | inline CGImageRef stateImage() const;
|
---|
59 | void drawOverlayIcons (CGContextRef aContext);
|
---|
60 |
|
---|
61 | /* Flipping is necessary cause the drawing context in Carbon is flipped by 180 degree */
|
---|
62 | inline CGRect flipRect (CGRect aRect) const { aRect.origin.y = mDockIconRect.size.height - aRect.origin.y - aRect.size.height; return aRect; }
|
---|
63 | inline CGRect centerRect (CGRect aRect) const { return centerRectTo (aRect, mDockIconRect); }
|
---|
64 | inline CGRect centerRectTo (CGRect aRect, const CGRect& aToRect) const
|
---|
65 | {
|
---|
66 | aRect.origin.x = aToRect.origin.x + (aToRect.size.width - aRect.size.width) / 2.0;
|
---|
67 | aRect.origin.y = aToRect.origin.y + (aToRect.size.height - aRect.size.height) / 2.0;
|
---|
68 | return aRect;
|
---|
69 | }
|
---|
70 | //#endif /* !QT_MAC_USE_COCOA */
|
---|
71 |
|
---|
72 | /* Private member vars */
|
---|
73 | VBoxConsoleWnd *mMainWnd;
|
---|
74 | //#ifdef QT_MAC_USE_COCOA
|
---|
75 | /** @todo Carbon -> Cocoa */
|
---|
76 | //#else
|
---|
77 | const CGRect mDockIconRect;
|
---|
78 |
|
---|
79 | CGImageRef mOverlayImage;
|
---|
80 | CGImageRef mDockMonitor;
|
---|
81 | CGImageRef mDockMonitorGlossy;
|
---|
82 |
|
---|
83 | void *mBitmapData;
|
---|
84 |
|
---|
85 | CGImageRef mStatePaused;
|
---|
86 | CGImageRef mStateSaving;
|
---|
87 | CGImageRef mStateRestoring;
|
---|
88 |
|
---|
89 | CGRect mUpdateRect;
|
---|
90 | CGRect mMonitorRect;
|
---|
91 | //#endif
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif /* !___VBoxDockIconPreview_h___ */
|
---|
95 |
|
---|