Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 1 - Introduction to QuickDraw

Multiple Screens

A video device is a piece of hardware, such as a plug-in video card or a built-in video interface, that controls a screen. To use more than one screen, a user may have more than one video device installed on their computer.

In a drawing environment with multiple screens, the one with the menu bar is the main screen. Color QuickDraw maps the (0,0) origin point of the global coordinate plane to the main screen's upper-left corner, and other screens are positioned adjacent to it. In Figure 1-16, a full-page screen sits next to the main screen. Remember that each window--even a window that overlaps two screens--has its own local coordinate system with a (0,0) point at its upper-left corner.

Figure 1-16 A two-screen system

Color QuickDraw stores state information for a video device in a GDevice record. (Color QuickDraw creates GDevice records--basic QuickDraw does not, nor does basic QuickDraw support multiple screens.) When a computer supporting Color QuickDraw starts up, it allocates and initializes a handle to a GDevice record for each video device it finds. The firmware in the ROM for each video device supplies information about whether the device uses indexed or direct colors, how much video RAM is available, and so on. Some of this information is stored in the GDevice record, where it is available to the entire graphics system.

As illustrated in Figure 1-17, when your application opens a color window, the CGrafPort record for the window contains a handle to a PixMap record contained in the main screen's GDevice record. The PixMap record for your window thereby contains the correct pixel specifications for the main screen. Color QuickDraw internally calculates the changes required for drawing to any other screens.

Figure 1-17 The GDevice record and pixel map for a 4-bit video card

When a multiscreen system starts up, one of the screens is the startup screen, the screen on which the "happy Macintosh" appears. By default, the main screen is the startup screen. However, by using the Monitors control panel, the user can specify a different startup screen.

During the startup of a multiscreen environment, system software calls the Window Manager procedure InitWindows to create a region that is the union of all the active screens (minus the menu bar and the rounded corners on the outermost screens). The Window Manager saves this region, called the gray region, as the global variable GrayRgn. The gray region describes and defines the desktop: the area in which the user can drag windows.

Users can drag windows from one screen to another and even across multiple screens. Color QuickDraw calculates the global coordinates of the rectangle into which it must draw and issues the drawing command to each video device that the rectangle intersects.

For many applications, Color QuickDraw provides a device-independent interface; your application can draw images in a color graphics port for a window, and Color QuickDraw automatically manages the screen display--even if the user has multiple screens. Your application generally never needs to create GDevice records. However, you may find it useful for your application to examine GDevice records to determine the capabilities of the user's screens. When zooming a window, for example, your application can use GDevice records to determine which screen contains the largest area of a window, and then determine the ideal window size for that screen.

You may also wish to use the DeviceLoop procedure to optimize your application's drawing for screens with different capabilities. The DeviceLoop procedure searches for video devices that intersect your graphics port's drawing region, and it informs your application of each video device it finds. The DeviceLoop procedure provides your application with information about the pixel depth and other attributes of the video device on which drawing is currently taking place. Your application can then choose what drawing technique to use for the current device. When highlighting, for example, your application might invert black and white when drawing onto a 1-bit video device but use magenta as the highlight color on a color screen.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996