• 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: Stopping a NSView from drawing in -drawRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stopping a NSView from drawing in -drawRect


  • Subject: Re: Stopping a NSView from drawing in -drawRect
  • From: James Chen <email@hidden>
  • Date: Fri, 6 Feb 2004 20:20:08 +0800

On Feb 6, 2004, at 7:45 PM, Phillip Hutchings wrote:

That's what I thought, my current code is:

- (void)drawRect:(NSRect)rect
{
NSDisableScreenUpdates();
[self lockFocus];
[bgColour set];
[NSBezierPath fillRect:rect];
[fgColour set];

[trackTextView display];
First of all you send message -display to trackTextView here and I check the document for method -display:
------------------------------------------------------------------------ -
- (void)display
Displays the receiver ... , this method backs up the view hierarchy to the first opaque ancestor, calculates the portion of the opaque ancestor covered by the receiver, and begins displaying from there.
------------------------------------------------------------------------ -
Maybe this is the call which flush you background drawing.
Try to call -drawRect instead. [trackTextView drawRect: rect];
(Maybe a sanity check before drawing your text will gain better perforamce, such as:
if ([trackTextView needsToDrawRect: rect]) {
[trackTextView drawRect: rect];
}
)
if (gotImage == YES) {
[theArtwork compositeToPoint:imagePoint operation:NSCompositeCopy];
}
[self unlockFocus];
NSEnableScreenUpdates();
}

I never call display explicitly, only setNeedsDisplay. This is in a screensaver if it makes any difference.

On 7/02/2004, at 12:21 AM, James Chen wrote:

Hi,
It's a little weird.
The Window(Context) should be double buffered by default, unless you changing it in some ways.
If not, I think this could be fixed by drawing appropriately.
Could you give us more clues about how you draw those widgets, such as NSTextView, NSImage and background?
For example, Do you sending -display to your view during your drawing or something like that?
In my opinion, you might flush the port buffer during you drawing codes.
Hope this helps,
James

--
Phillip Hutchings
email@hidden
http://www.sitharus.com/

By the way, I don't think you have to call lockFocus/unlockFocus inside -drawRect since this is a NSView's subclass and Cocoa has did that for you.
Of course you don't need NSDisableScreenUpdates/NSEnableScreenUpdates anymore if all of these help.

Hope it works,
James
------------------------------------
Ulead Systems Inc.
James Chen
Software Engineer
Image Div.
------------------------------------
_______________________________________________
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.

References: 
 >Stopping a NSView from drawing in -drawRect (From: Phillip Hutchings <email@hidden>)
 >Re: Stopping a NSView from drawing in -drawRect (From: James Chen <email@hidden>)
 >Re: Stopping a NSView from drawing in -drawRect (From: Phillip Hutchings <email@hidden>)

  • Prev by Date: NSFontPanel disable items
  • Next by Date: Cocoa version of the fstream lib?
  • Previous by thread: Re: Stopping a NSView from drawing in -drawRect
  • Next by thread: Re: Stopping a NSView from drawing in -drawRect
  • Index(es):
    • Date
    • Thread