GCZoomView is a simple NSView subclass that adds a set of standard zoom commands, such as Zoom In, Zoom Out, Zoom To Fit, Zoom to any arbitrary scale, Zoom with the mouse scrollwheel, Zoom to a given rect, etc.
NSView has the ability to zoom built-in, using the scaleUnitSquareToSize: method. However, there are a few kinks involved and no user-level commands provided. This class addresses that. By basing your view classes on this instead of NSView directly, you gain zooming no matter what your view content actually displays. The data model doesn't need to know about the zooming - it just works. GCZoomView should generally be used inside an NSScrollView. Scrollbars and rulers automatically take account of the zooming.
Note that the screenshot here shows GCZoomView used within an application that draws a drawing grid and text in the view, and also has a zoom pop-up menu. GCZoomView doesn't provide these features - it only provides the essential ability to zoom. However, implementing these other things becomes straightforward once you have the view handling the zooming.
© 2006-2008 Graham Cox