Drawing in a Window's Content Region

Your application and the Window Manager work together to display windows on the screen. Once you have created a window and made it visible, the Window Manager automatically draws the window's structure region (that is, its "frame") in the appropriate location. The Window Manager does not typically draw any content in a window; it only draws the color or pattern of the content region. Your application is responsible for drawing content such as text or graphics in the window's content region.

When the user exposes a window that has previously been obscured, the Window Manager redraws the exposed, invalid portions of the window. If some part of the window's content region is exposed, the Window Manager redraws it to the current content color and adds it to the window's update region.

You can set a window's content color by calling the function SetWindowContentColor . As shown in Listing 2-3 , when your application calls SetWindowContentColor , the Window Manager uses this content color to redraw the content region of the window. Your application can use the function SetWindowContentPattern to specify a pattern for the content region.

Listing 2-3 Setting the window's content color to red

static OSStatus MySetWindowContentColorToRed( WindowPtr window )
{
    RGBColor rgbRedColor = { 0xFFFF, 0, 0 }; // red, green, blue
    OSStatus outStatus;

    outStatus = SetWindowContentColor( window, &rgbRedColor );
    return outStatus;
}

None of the Mac OS 8.5 functions affect the window's graphics port's background color or pattern. However, SetWindowContentColor and SetWindowContentPattern do supersede the window color table structure, the 'wctb' resource, and the SetWinColor function, none of which are supported under Carbon.


� 1999 Apple Computer, Inc. – (Last Updated 18 March 99)