Re: Zooming a view, that is contained in an NSScrollView
Re: Zooming a view, that is contained in an NSScrollView
- Subject: Re: Zooming a view, that is contained in an NSScrollView
- From: Graham Cox <email@hidden>
- Date: Tue, 18 Oct 2011 10:41:37 +1100
On 18/10/2011, at 5:59 AM, John Pannell wrote:
> Hi Nick-
>
> There is some composition of views needed to make this work. Within GCDrawKit, find the GCZoomView class… make your custom view a subview of this (to adopt all of its zoomy goodness). Then, make your custom drawing view the documentView of an NSScrollView.
>
> You'll now need to wire up some controls in the UI (i.e. some menu items or buttons) to call the various zooming methods that your view has now inherited from GCZoomView. Once you're wired up correctly, everything will "just work" - the scroll view will respond to the size changes of your document, and your drawing will now scale up and down per the user's use of the controls you've provided.
>
> It is a really nice bit of code (thanks Graham!)
Thanks ; you're welcome :)
GCZoomView is independent of DrawKit, and can be downloaded and deployed separately: http://apptree.net/gczoomview.htm
There may be small differences between this and the version you get in DK however - DK's copy is possibly slightly more up to date.
> The problem is i don't know how would it be right to implement Zooming
> (similar to how graphics editors do it - by allowing the user to
> select some area of the view with a selection rectangle, and, after
> the mouseUp event happens, zoom in or out the view that is contained
> within an NSScrollView.
GCZoomView will help you do this, but it doesn't implement the mouse dragging part, you'll have to do that yourself in order to define the rectangle, then you can use [GCZoomView zoomViewToRect:] to adjust the zoom scale and scroll to that rectangle. The zooming does not change the coordinate system of the view itself, the view content is not aware of the zoom unless you deliberately code it to be so.
--Graham_______________________________________________
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