Programming with Quartz: 2D and PDF Graphics in Mac OS X

Although you can use the Quartz 2D API just as easily with the Carbon framework as you can with the Cocoa framework, the process of obtaining a graphics context differs depending on which framework you use. The Carbon framework has its origins in the pre Mac OS X APIs. Originally, Carbon was seen as a bridge between the Mac OS 9 and Mac OS X worlds, but today's Carbon framework is really a collection of C APIs that are used by C and C++ programmers to develop Mac OS X applications. The Carbon framework, unlike Cocoa, provides support for moving older QuickDraw-based applications to Quartz 2D. For that reason, there are two ways to get a Quartz graphics context from the Carbon framework.
The preferable way to obtain a graphics context is to use the HIView subcomponent of HIToolbox. Most of this chapter describes how to set up an HIView and get a graphics context from it. The sections "Setting Up a Carbon Window" (page 68), "Creating an Event Handler" (page 73), and "Examining the Drawing Output" (page 76) contain HIView and Quartz-specific information that works in Jaguar and later versions. If your application must run in versions prior to Jaguar, you instead need to call the QuickDraw functions QDBeginCGContext and QDEndCGContext, as described in "Using QDBeginCGContext" (page 79).
The first section in this chapter "Creating a Carbon Xcode Project" shows how to create a Carbon application in Xcode. Nothing in this section is specific to using Quartz in Carbon. Experienced...