Fwd: saveGraphicsState vs. lockFocus
Fwd: saveGraphicsState vs. lockFocus
- Subject: Fwd: saveGraphicsState vs. lockFocus
- From: "Shawn Erickson" <email@hidden>
- Date: Wed, 3 May 2006 09:30:56 -0700
Oops meant to send this to the list.
---------- Forwarded message ----------
From: Shawn Erickson <email@hidden>
Date: May 2, 2006 1:20 PM
Subject: Re: saveGraphicsState vs. lockFocus
To: Eric Lin <email@hidden>
On 5/2/06, Eric Lin <email@hidden> wrote:
I'm a bit confused as to what's the difference between calling
saveGraphicsState (NSGraphicsContext) and lockFocus (NSView). They
appear to be doing something quite similar. Does lockFocus simply
invoke saveGraphicsState?
They do different things... lockFocus makes the graphic context
related to a particular view, etc. the current graphics context (among
other things... like locking the context to prevent concurrency).
And when should saveGraphicsState and lockFocus be called? (whenever
I use functions like NSRectFill() and matrix transformation matrix?)
If you are doing drawing in a drawRect: of a NSView subclass then
lockFocus was effectively already called before drawRect: was called.
You can use save/restoreGraphicsState as needed to help bound
adjustments to the current graphics state. Similar to lockFocus you
don't need to worry about saving and restoring the initial graphics
state in drawRect:.
Apples documentation is rather good on this subject, I suggest starting here..
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/index.html>
-Shawn
_______________________________________________
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