All of the objects that you interact with on your computer screen are displayed within windows. This includes what we consider “normal” windows (those with titlebars and controls), as well as menu items, pop-up contextual menus, floating palettes, sheets, drawers, and the Dock.
Two interacting systems create and manage Cocoa windows. On one hand, Mac OS X’s window server creates a window and displays it on screen. The window server is a process that uses Quartz—the low-level drawing system—to draw, resize, hide, and move windows. As depicted in Figure 6-1, the window server also detects users events (such as mouse clicks or keyboard key presses) and forwards them to applications.
Figure 6-1. Cocoa and the window server
On the other hand, the window created by the window server is paired
with an object supplied by the AppKit—an instance of the
NSWindow class. Each physical window in a Cocoa
program is managed by an instance of
NSWindow or a
subclass. As shown in Figure 6-2, when an
NSWindow object is created, the window server
creates the physical window being managed. The window server
references the window by its window number and the
NSWindow object instance by its own identifier.
Figure 6-2. NSWindow objects and ...