Faster drawing NSButtons
Faster drawing NSButtons
- Subject: Faster drawing NSButtons
- From: Steve Gehrman <email@hidden>
- Date: Sat, 19 Oct 2002 15:32:59 -0700
Drawing NSButtons is way too slow. Drawing the background image and
the text takes too long.
I would like to subclass NSButton and do something like...
- (void)drawRect:(NSRect)rect;
{
if (!_cachedImage)
{
_cachedImage = [[NSImage alloc] initWithSize:rect.size];
[_cachedImage lockFocus];
// draw the NSButton in the NSImage
[super drawRect:rect];
[_cachedImage unlockFocus];
}
[_cachedImage compositeToPoint:rect.origin
operation:NSCompositeSourceOver];
}
This almost works, but the image doesn't look right. I've tried all
the obvious solutions and couldn't make this work.
When I resize my window, 10% of the time is spent redrawing simple
NSButtons!
-steve
_______________________________________________
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.