Chapter 19. Zooming and Saving Graphics Files

This chapter shows how to do a few interesting things with NSViews. In the first part, we’ll show how to put a zoom pop-up menu in an NSScrollView. In the second part, we’ll show how to generate Encapsulated PostScript (EPS), PDF, or TIFF files from an NSView; how to save a graph into an EPS, PDF, or TIFF file; and how to add controls to a Save panel (dialog).

Adding a Zoom Button to GraphPaper

In the previous chapter, we arranged for the GraphView object to rescale its coordinate system when its containing window was resized. Although the scaled coordinate system is appropriate for our graphing application and is a good way to show how to catch resizing events, stretching an application’s window isn’t the right way for a user to get a magnified view of the window’s contents. Consider the Aqua interface standard: a window is supposed to be just that — a window into a page of a virtual document. The document itself shouldn’t get bigger or smaller when the window is resized; rather, a bigger or smaller window should let the user see more or less of a document.

Mac OS X applications should enable the user to see more detail using a zoom button — not the green zoom button in a window’s title bar, but a little pop-up menu button, typically located at the bottom of an NSScrollView, that allows you to change the magnification of the NSScrollView. Microsoft Word and Stone Design’s Create applications both have such a button (see Figure 19-1 ...

Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.