How a Window is Displayed
NSWindow object begins with the drawing performed by its view objects, which accumulates in the window’s display buffer or appears immediately on the screen. Windows, like
NSView objects, can be displayed unconditionally or merely marked as needing display, using the
setViewsNeedDisplay: methods, respectively. A
displayIfNeeded message causes the window’s views to display only if they’ve been marked as needing display. Normally, any time a view is marked as needing display, the window makes note of this fact and automatically displays itself shortly thereafter. This automatic display is typically performed on each pass through the event loop, but can be turned off using the
setAutodisplay: method. If you turn off autodisplay for a window, you’re then responsible for displaying it whenever necessary.
A window’s views can be drawn concurrently. You can use the methods
setAllowsConcurrentViewDrawing: to determine and set, respectively, whether or not a window draws its views concurrently. By default, a window’s views are drawn concurrently.
On each pass through the event loop, the application object invokes its
updateWindows method, which sends an
update message to each window. Subclasses of
NSWindow can override this method to examine the state of the application and change their own state or appearance accordingly—enabling or disabling menus, buttons, and other controls based on the object that’s selected, for example.
In addition to displaying itself on the screen, a window can print itself in its entirety, just as a view can. The
print: method runs the application’s Print panel and causes the window’s frame view to print itself.
dataWithEPSInsideRect: behaves similarly. For additional information see Printing Programming Guide for Mac.