O'Reilly logo

Learning Cocoa with Objective-C, 2nd Edition by James Duncan Davidson, Apple Computer Inc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Windows, Views, and Controls

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.

Windows and the Window System

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.

Cocoa and the window server

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.

NSWindow objects and window server windows

Figure 6-2. NSWindow objects and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required