On Thu, Apr 29, 2010 at 10:28 PM, Graham Cox <graham....@bigpond.com> wrote:
> > On 30/04/2010, at 2:21 PM, danchik wrote: > > > mine did not, > > Did not what? > > > > so I think I might have used context incorrectly: > > > > I had a different context to draw into so the code was : > > > > [NSGraphicsContext saveGraphicsState]; > > [NSGraphicsContext setCurrentContext:MyActualContext]; > > > > // do the text draw/rotate > > > > [NSGraphicsContext restoreGraphicsState]; > > > > I was under impression that [... restoreGraphicsState] would restore > the last context at the time it was [... saveGraphicsState]ed? > > Or does each context have its own state stack? > > No. Each thread has its own state stack, so what you said is right - it > will restore the graphics context that was current when +saveGraphicsState > was invoked. > Well, each thread has a stack of contexts, and each context has a stack of states. +saveGraphicsState first pushes the state of the current context onto the stack of states in that context, then pushes the context itself onto the stack of contexts. > > > > Would the proper way to draw to a different context be to save the > current context first??? > > > > > Yes, which is what your code above will do. > > What it won't do is to 'undo' the transform of the second context. Rather > than bother doing that, it might be easier just to reset it at the start, or > use -set instead of -concat. If the second context has no other > transformations needed on it, (as a view's context must do) then that should > work. On the other hand, a view's context is always set up before -drawRect: > is called so you usually don't have to worry about undoing additional > transforms there either if nothing else draws following your rotated > drawing. > > To reset the transform completely: > > [[NSAffineTransform transform] set]; > > --Graham > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com > > This email sent to kenfe...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com