Re: Drawing a selection rectangle
Re: Drawing a selection rectangle
- Subject: Re: Drawing a selection rectangle
- From: Izidor Jerebic <email@hidden>
- Date: Mon, 2 Feb 2004 11:07:38 +0100
On Jan 30, 2004, at 7:03 AM, Jeffrey Mattox wrote:
Is there an efficient way to display a selection rectangle in a view
without having to keep redrawing the stuff the rectangle passes over?
Currently, I'm just drawing a dashed box as I drag the mouse, but as
the rectangle moves, I need to redraw the old region (or the lazy way,
redraw the entire view).
I'd like a way, for example, to add a drawing "layer" that contains
only the selection rectangle, and then simply redraw that layer. Seems
like a common thing to do.
Tips?
Hello!
Did you look at [NSWindow cacheImageInRect:] ? I use it for exactly
this purpose...
izidor
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSWindow.html#//apple_ref/doc/uid/
20000013/BCIDFEII
- (void)cacheImageInRect:(NSRect)aRect
Stores the receivers raster image from aRect, which is expressed in
the receivers base coordinate system. This method allows the receiver
to perform temporary drawing, such as a band around the selection as
the user drags the mouse, and to quickly restore the previous image by
invoking restoreCachedImage andflushWindowIfNeeded. The next time the
window displays, it discards its cached image rectangles. You can also
explicitly use discardCachedImage to free the memory occupied by cached
image rectangles. aRect is made integral before caching the image to
avoid antialiasing artifacts.
Only the last cached rectangle is remembered and can be restored.
_______________________________________________
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.