Drawing an NSView into an NSGraphicsContext
Drawing an NSView into an NSGraphicsContext
- Subject: Drawing an NSView into an NSGraphicsContext
- From: Brian Postow <email@hidden>
- Date: Mon, 1 Mar 2010 12:01:04 -0500
I have a CGContext, which I can turn into an NSGraphicsContext. I have an NSWindow with a clipRect for the context.
I want to put a scrollview into the context and then some other view into the scrollview so I can put an image into it... However, I can't figure out how to attach the scrollview into the context.
Eventually the view will probably be coming from a nib, but I don't see how that would matter.
I've seen this thread, (http://lists.apple.com/archives/quartz-dev/2006/Nov/msg00010.html) But they seem to leave off the step of how to attach the view into the context, unless there's something obvious I'm missing.
The reason I'm in this situation is that I'm writing a Mozilla Plugin. The browser gives me a CGContext (Quartz) and a WindowRef (QuickDraw). I can turn the CGContext into an NSGraphicsContext, and I can turn the windowRef into an NSWindow. From another data structure I also have the clipping rectangle...
I'm trying to draw an image into that context, with scrollbars as needed, and buttons and other UI elements... so I need (want) an NSView...
I'm currently thinking that I can't actually really do this the way I want to. My current plan is to make a NIB with the two views (NSScroll and IKImageVIew probably) and instantiate that. Then, draw it into the context with some method that takes a snapshot of the view. At that point I'll need to capture all events myself and translate them back to the view(s) and re-snapshot the view to put it back in the context.
Is there a better way to do this?
Brian Postow
Senior Software Engineer
Acordex Imaging Systems
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden