On 12 Jun '08, at 10:54 AM, Vikas wrote:

How the function knows about the drawing surface, in which window/ surface to paint?

There's always a current graphics context; it's global to each thread. (See NSGraphicsContext if you want to look at its API; but if you're looking for the low-level drawing primitives, they're defined in the CoreGraphics framework as CGContext functions. AppKit's drawing code is all wrappers around those.)

So basically, any code that wants to draw or alter the drawing state calls [NSGraphicsContext currentContext] to get the current context.

This is different than, say, Java, where the graphics context is associated with each view/component. Graphics contexts turn out to be expensive objects, and AppKit just uses one, and adjusts its state depending on what needs to be drawn. Mostly you don't need to worry about this. When a view's -drawReect: method is called, the graphics context has already been set up for drawing into that view.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to