Re: Question regarding NSView's drawRect
Re: Question regarding NSView's drawRect
- Subject: Re: Question regarding NSView's drawRect
- From: Ricky Sharp <email@hidden>
- Date: Mon, 30 Oct 2006 07:40:47 -0600
On Oct 30, 2006, at 2:21 AM, Dominik Pich wrote:
DrawRect will be called whenever at least a portion of a view is
visible (e.g. if it WAS hidden by an overlapping window)
Try not to intercept those calls but always honor draw requests.
Exactly.
If you really draw the same very often, cache your drawing in an
NSImage and then blit only that onscreen.
Or, since the original poster was concerned about memory usage, you
can always have drawRect: do this:
- (void)drawRect:(NSRect)aRect
{
// load all images here and build up drawing objects (colors,
attributes for text, etc.)
// do drawing
// release images, drawing objects, etc.
}
This, of course, will incur a performance penalty.
--
Am Oct 30, 2006 um 8:28 AM schrieb David Chan:
Hi all, I have a question regarding NSView. I have an application
that
keep many subclassed NSView objects. Users shall be able to navigate
around and depending on their action, certain NSView objects will be
shown and other will be hidden or moved to other window
Now.. I actually only need to use drawRect once for every object -
when I first created the objects. I will neither need to scroll
nor do
anything that will require redrawing of the NSView objects. By right,
it should be safe to release all the image data objects I use after
the drawRect returns; and that is my intention in order to minimize
the memory usage. But it seems that there are certain occasions where
the Application would call drawRect on its own. This will be a
problem
because all the image data will no longer be there.
So my question is.. Is it possible for me to intercept this so that
the drawRect will not be called? Or maybe there can be other
workaround so that my App will not need to redraw the NSView
unnecessarily?
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden