Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 13 Custom Views Cocoa's AppKit provides a lot of very flexible view objects. Some more are pro- vided by additional frameworks on OS X, such as the people view from the Address Book framework. For a lot of applications, these are enough to define the user interface. Sometimes, however, you need to define new views. A view has two main responsibilities, drawing and event handling. We created a simple new view in Chapter 8, although this glossed over most of the complicated aspects of defining a new view. Cocoa uses a variant of the PostScript drawing model. Traditional PostScript drawing is based around the idea of a path, which is a sequence of curve and line segments. Text was rendered in PostScript by defining a path for each character in a particular font. This is extended in the Portable Document Format (PDF ) to provide better support for raster images, including transparency, and for text. Cocoa uses something a lot closer to the PDF display model than PostScript, but the foundations of both are very similar. The basic components in Cocoa drawing