Drawing a *blue* ProgressIndicator on the Dock app icon in the background / offscreen drawing
Drawing a *blue* ProgressIndicator on the Dock app icon in the background / offscreen drawing
- Subject: Drawing a *blue* ProgressIndicator on the Dock app icon in the background / offscreen drawing
- From: Marc Liyanage <email@hidden>
- Date: Fri, 6 Feb 2004 03:01:44 +0100
I have a document window with a progress bar for a long-running
operation.
I use the following method in my document class to badge the progress
bar onto my application's icon in the Dock. It all works well and looks
great if the document's window is in the foreground.
However, the whole point of a progress indicator in the Dock icon is of
course that it's to be used when my document window is hidden /
minimized / not visible, i.e. *not* in the foreground. And that's
exactly when it does not work because as soon as my doc window is no
longer key or main, the progress indicator's color switches from blue
to gray, and that is impossible to see in the dock icon. I want the
completed portion of the progress indicator to stay blue no matter
what.
Is there a way to achieve this? Do I have to use a second progress bar
and draw that offscreen? How would I do this? As I understand it I
can't just alloc/init one and configure it, it needs to be part of the
view hierarchy, including a full window instance? Would that draw in
blue at all?
- (void)badgeAppIcon {
NSData *progressImageData = [progressIndicator
dataWithPDFInsideRect:[progressIndicator bounds]];
NSImage *progressImage = [[[NSImage alloc]
initWith
Data:progressImageData] autorelease];
[progressImage setScalesWhenResized:YES];
[progressImage lockFocus];
[[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationHigh];
[progressImage setSize:NSMakeSize(128.0, 20.0)];
[progressImage unlockFocus];
NSImage *appIcon = [[[NSImage imageNamed:@"NSApplicationIcon"]
copyWithZone:nil] autorelease];
[appIcon lockFocus];
[progressImage compositeToPoint:NSMakePoint(0, 0)
operation:NSCompositeSourceOver];
[appIcon unlockFocus];
[[NSApplication sharedApplication] setApplicationIconImage:appIcon];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.