Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / August 2005



Tip: Looking for answers? Try searching our database.

How to flush window in drawRect

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wiley - 22 Aug 2005 15:24 GMT
I want to flush the window an an [NSView -drawRect] routine.  This would
be helpful for debugging because I could easily correlate drawing commands
with *which* object on the screen they produce (I have draw many similar
objects in my present program).  But the window's flushing appears to be
disabled in drawRect.

So what do I do?  This would greatly aid debugging.  In Carbon I would
call QDFlushPortBuffer to do this.

Thanks.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
glenn andreas - 22 Aug 2005 16:38 GMT
> I want to flush the window an an [NSView -drawRect] routine.  This would
> be helpful for debugging because I could easily correlate drawing commands
[quoted text clipped - 4 lines]
> So what do I do?  This would greatly aid debugging.  In Carbon I would
> call QDFlushPortBuffer to do this.

Have you tried running Quartz Debug (found in
/Developer/Applications/Performance Tools/)?

It not only allows you to enable/disable automatic flushing, but it will
show you what area needs to be flushed, etc...
Keith Wiley - 23 Aug 2005 15:15 GMT
Cool.  Forgot about that utility.

>> I want to flush the window an an [NSView -drawRect] routine.  This would
>> be helpful for debugging because I could easily correlate drawing commands
[quoted text clipped - 10 lines]
> It not only allows you to enable/disable automatic flushing, but it will
> show you what area needs to be flushed, etc...

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Simon Slavin - 24 Aug 2005 23:28 GMT
On 22/08/2005, Keith Wiley wrote in message
<Pine.LNX.4.60.0508220822200.24122@callisto.cs.unm.edu>:

> I want to flush the window an an [NSView -drawRect] routine.  This would
> be helpful for debugging because I could easily correlate drawing
> commands  with *which* object on the screen they produce (I have draw
> many similar  objects in my present program).  But the window's flushing
> appears to be  disabled in drawRect.

in addition to the useful comments on Quartz Debug ...

Check the NSWindow's status.  Make sure it isn't set to 'buffered'.
You can set this status if you define the window in IB but it can
be set or modified using Cocoa.  If the status is Buffered (which
is the default because it's fastest and gives the best look) then
no matter when you draw, the commands can be delayed until later.

Simon.
Signature

Using pre-release version of newsreader.
Please tell me if it does weird things.

John C. Randolph From: - 25 Aug 2005 10:48 GMT
>I want to flush the window an an [NSView -drawRect] routine.  This would
>be helpful for debugging because I could easily correlate drawing commands
>with *which* object on the screen they produce (I have draw many similar
>objects in my present program).  But the window's flushing appears to be
>disabled in drawRect.

>So what do I do?  This would greatly aid debugging.  In Carbon I would
>call QDFlushPortBuffer to do this.

If you just want to see what parts of a window are getting update, use
/Developer/Applications/Performance Tools/Quartz Debug.

Window flushing isn't disabled in drawrect, it just doesn't happen until
your -drawRect: method exits, and the process gets back to the main event loop.

-jcr
Keith Wiley - 25 Aug 2005 18:15 GMT
On Thu, 25 Aug 2005 John C. Randolph From wrote:

> Window flushing isn't disabled in drawrect, it just doesn't happen until
> your -drawRect: method exits, and the process gets back to the main event loop.

There is an NSWindow function that asks if flushing is disabled
(-isFlushWindowDisabled).  When called in drawRect, it returns true.
Under most other circumstances it returns false.  I think flushing is
actually temporarily turned off in drawRect, for whatever reason.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
John C. Randolph From: - 26 Aug 2005 09:24 GMT
>On Thu, 25 Aug 2005 John C. Randolph From wrote:

>> Window flushing isn't disabled in drawrect, it just doesn't happen until
>> your -drawRect: method exits, and the process gets back to the main event loop.

>There is an NSWindow function that asks if flushing is disabled
>(-isFlushWindowDisabled).  When called in drawRect, it returns true.
>Under most other circumstances it returns false.  I think flushing is
>actually temporarily turned off in drawRect, for whatever reason.

Umm... To be precise, it's turned off in the  _recursiveDisplayRect... methods. That's
not necessarily the only way that your -drawRect: method will be invoked.

-jcr
Keith Wiley - 26 Aug 2005 16:06 GMT
On Fri, 26 Aug 2005 John C. Randolph From wrote:

>> On Thu, 25 Aug 2005 John C. Randolph From wrote:
>
[quoted text clipped - 8 lines]
> Umm... To be precise, it's turned off in the  _recursiveDisplayRect... methods. That's
> not necessarily the only way that your -drawRect: method will be invoked.

Thanks.  The whole buffered window thing, which I grant is fantastic as an
end-application feature, is annoying as a debugging feature.  At least
Quartz degub is there, and on certain occasions flushing the window
works...but on others it doesn't and you have to turn on Quartz debug...as
stated in my original post to this thread.

Oh well, I think I get it.  Thanks.

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.