When the user clicks a window's zoom box, a window zooms between two states, the user state and the standard state. The user state is any size and position in which the user can place the window on the desktop. The standard state is the size and position that the application defines as being best for the display of the data contained in the window. There are human interface guidelines, described in Window Zooming , that describe how best to determine a window's standard state, based upon its current user state, but prior to Mac OS 8.5 there were no system-supplied functions that enforced these guidelines for your application.
With Mac OS 8.5, you can use the Window Manager function ZoomWindowIdeal instead of the older function ZoomWindow to zoom a window. When your application calls ZoomWindowIdeal , it automatically conforms to the human interface guidelines for determining a window's standard state. Using ZoomWindowIdeal in conjunction with the Mac OS 8.5 Window Manager functions SetWindowIdealUserState and GetWindowIdealUserState also ensures that the user state is tracked accurately, as well as giving your application access to a window's user state in a Carbon-compliant manner.
Note that if your application uses ZoomWindowIdeal , the WStateData structure is superseded, and the result of the FindWindow function should be ignored when determining whether a particular user click on the zoom box is a request to zoom in or out. When you adopt ZoomWindowIdeal and your application receives a result of either inZoomIn or inZoomOut from FindWindow , your application should use the function IsWindowInStandardState and code such as that in Listing 2-9 to determine the appropriate part code to pass into the partCode parameter.
Listing 2-9 Determining the appropriate part code to supply to ZoomWindowIdeal
switch (FindWindow(myEvent.where, &window))
{
// If FindWindow returns a part code for the zoom box, don't rely on it;
// call IsWindowInStandardState with your application-defined ideal
// window size to figure out whether the window is currently zoomed in or
// out and, therefore, what the part code should be
case inZoomIn:
case inZoomOut:
{
int part;
Point idealSize = MyFigureWindowIdealSize(window);
// If IsWindowInStandardState returns true, the window is
// currently zoomed out to the standard state, so the mouse-down
// event in the zoom box should be interpreted as inZoomIn
if (IsWindowInStandardState(window, &idealSize, NULL))
{
part = inZoomIn;
}
else
{
// If IsWindowInStandardState returns false, the window is
// currently zoomed in to the user state, so the mouse-down event
// in the zoom box should be interpreted as inZoomOut
part = inZoomOut;
}
// If TrackBox confirms that the mouse-up event occurred while
// the cursor was still over the zoom box, give ZoomWindowIdeal
// the real part code, so it can get on with zooming
if (TrackBox(window, myEvent.where, part))
{
ZoomWindowIdeal(window, part, &idealSize);
}
break;
}
}