3
#include "ApplicationServices/ApplicationServices.h"
4
#include "Carbon/Carbon.h"
6
#define DOCK_FONT_NAME "LucidaGrande-Bold"
7
#define DOCK_FONT_SIZE 24
9
static NMRec bounceRec;
12
* Converts a QString to a CoreFoundation string, preserving Unicode.
14
* \param s the string to be converted.
15
* \return a reference to a CoreFoundation string.
17
/*static CFStringRef qString2CFString(const QString& s)
22
ushort* buffer = new ushort[s.length()];
23
for (unsigned int i = 0; i < s.length(); ++i)
24
buffer[i] = s[i].unicode();
25
CFStringRef result = CFStringCreateWithBytes ( NULL,
27
s.length()*sizeof(ushort),
28
kCFStringEncodingUnicode, false);
34
void MacDock::startBounce()
37
bounceRec.qType = nmType;
39
NMInstall(&bounceRec);
44
void MacDock::stopBounce()
52
void MacDock::overlay(const QString& text)
56
RestoreApplicationDockTileImage();
61
CGContextRef context = BeginCGContextForApplicationDockTile();
66
// Add some subtle drop down shadow
67
// FIXME: Disabled because 10.2 doesn't support it
68
//CGSize s = { 2.0, -4.0 };
69
//CGContextSetShadow(context,s,5.0);
73
CGContextBeginPath(context);
74
CGContextAddArc(context, 95.0, 95.0, 25.0, 0.0, 2 * M_PI, true);
75
CGContextClosePath(context);
76
CGContextSetRGBFillColor(context, 1, 0.0, 0.0, 1);
77
CGContextFillPath(context);
79
// Set the clipping path to the same circle
80
CGContextBeginPath(context);
81
CGContextAddArc(context, 95.0, 95.0, 25.0, 0.0, 2 * M_PI, true);
82
CGContextClip(context);
85
// FIXME: Disabled because 10.2 doesn't support it
86
//CGSize s = { 0.0, -0.0 };
87
//CGContextSetShadowWithColor(context, s, 0, NULL);
89
// Select the appropriate font
90
CGContextSelectFont(context,DOCK_FONT_NAME, DOCK_FONT_SIZE, kCGEncodingMacRoman);
91
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
93
// Draw the text invisible
94
CGPoint begin = CGContextGetTextPosition(context);
95
CGContextSetTextDrawingMode(context, kCGTextInvisible);
96
CGContextShowTextAtPoint(context, begin.x, begin.y, text.latin1(), text.length());
97
CGPoint end = CGContextGetTextPosition(context);
100
CGContextSetTextDrawingMode(context, kCGTextFill);
101
CGContextShowTextAtPoint(context, 95 - (end.x - begin.x)/2, 95 - 8, text.latin1(), text.length());
104
CGContextFlush(context);
105
EndCGContextForApplicationDockTile(context);
108
bool MacDock::isBouncing = false;
109
bool MacDock::overlayed = false;