• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Equivelent to drawRect: for drawing after sub views are drawn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • [Wrap-up] Re: Equivelent to drawRect: for drawing after sub views are drawn
      • From: George Lawrence Storm <email@hidden>
    • Re: Equivelent to drawRect: for drawing after sub views are drawn
      • From: Izidor Jerebic <email@hidden>
    • Re: Equivelent to drawRect: for drawing after sub views are drawn
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: Help with crashing cocoa/CoreFoundation app
  • Next by Date: Re: How to avoid warning with objc_msgSend
  • Previous by thread: Re: Help with crashing cocoa/CoreFoundation app
  • Next by thread: Re: Equivelent to drawRect: for drawing after sub views are drawn
  • Index(es):
    • Date
    • Thread