Re: saveGraphicsState vs. lockFocus
Re: saveGraphicsState vs. lockFocus
- Subject: Re: saveGraphicsState vs. lockFocus
- From: "Eric Lin" <email@hidden>
- Date: Tue, 2 May 2006 13:40:36 -0700
Thanks for the document reference, for some reason I didn't come
across that. I'll give it a read and post back if I have any
questions.
Thanks
On 5/2/06, Shawn Erickson <email@hidden> wrote:
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