Re: Equivelent to drawRect: for drawing after sub views are drawn
Re: Equivelent to drawRect: for drawing after sub views are drawn
- Subject: Re: Equivelent to drawRect: for drawing after sub views are drawn
- From: George Lawrence Storm <email@hidden>
- Date: Tue, 5 Oct 2004 00:14:48 -0700
On Sep 29, 2004, at 11:28 PM, George Lawrence Storm wrote:
I need to perform the equivalent to NSView's drawRect:, however I need
it to be called AFTER its sub views are drawn.
Is there a method I can override for such a purpose?
I need to draw a transparent overlay & some guidelines which will
overlap some of those sub views.
After receiving only one response which seemed a bit more involved than
I feel it should be I started to play around.
I viewed the stack calling my drawRect: and found it is being called
from _recursiveDisplayAllDirtyWithLockFocus:visRect:
Based on its position in the stack and its label I assume it sets up
its clip and focus, calls drawRect: then recursively calls its sub
views before returning.
I decided to live dangerously and overrode it as follows:
- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)fp8
visRect:(struct _NSRect)fp12
{
[super _recursiveDisplayAllDirtyWithLockFocus:fp8 visRect:fp12];
[self drawPostRect];
}
I also tried wrapping my drawPostRect: function with no difference in
results.
[self lockFocus];
[self drawPostRect];
[self unlockFocus];
This almost works, however it appears that in the supers method it sets
its clipping region prior to calling drawRect: and on exit it restores
its clipping region to that of only the visible rect. This creates a
problem when the view is in a scroller, in that my drawPostRect: is
being clipped to the visible rect unlike the drawRect: which is clipped
to the scrolling view.
First question: How could I change the clipping area so it matches what
was set prior to the drawRect: and if I do, should I restore it and how
do I do so.
Second question: other than speculation (yes I KNOW it's undocumented /
does anyone have first hand knowledge of this method), can anyone tell
me why I cannot use this, assuming I can fix the clipping issue it
vastly simplifies the drawing of guidelines and overlays without having
to resort to overlay views.
-----
Based on this little experiment it seems that adding a "drawPostRect:"
method (with it being passed a NSRect and the ability to call
getRectsBeingDrawn:count: and needsToDrawRect: the same as drawRect:)
would be of benefit. Alternatively if the private method I am
overriding could be made public and properly documented it would be
appreciated.
-----
George Lawrence Storm
Macintosh Applications Development
Snohomish (Seattle), Washington
E-mail: <email@hidden>
_______________________________________________
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