
the window’ right edge. If you know the X-coordinate of the right edges
and the center it’ easy to calculate the X-coordinate of the left edge., s
T better understand how constraints work together to describe a windowo ,
try building and running the example application LA OUT in the directoryY
EXAMPLES\OWL\OWLAPI\LA OUT. This application has a number ofY
child windows in a layout window. A dialog box you can access from the
menu lets you change the constraints of each of the windows and then see
the results as the windows are laid out. Be careful, though. If you specify a
set of layout constraints that doesn’t fully describe a window the,
application will probably crash, or if diagnostics are on, a check will occur, .
The reason for this is discussed in the next section.
Y u must be careful about how you specify your layout constraints. Theo
Indeterminate
constraints available in the TLayoutMetrics class give you the ability to fully
constraints
describe a window. But they do not guarantee that the constraints you use
will fully describe a window. In cases where the constraints do not fully
describe a window the most likely result is an application crash.,
Once you’ e set up layout constraints, you’re ready to create a layoutv
Using layout
window to lay the children out in. Here’ the constructor fors
windows
TLayoutWindow:
TLayoutWindow(TWindow* parent,
const char far* title = 0,
TModule* module = 0);
where:
■ parent is the layout window’ parent window.s
■ title is the layout window’ title. This parameter defaults to a null string.s
■ module is passed to the TWindow base class constructor as the TModule
parameter for that constructor This parameter defaults to 0..
After the layout window is constructed and displayed, there are a number
of functions you can call:
■ The Layout function returns void and takes no parameters. This function
tells the layout window to look at all its child windows and lay them out
again. Y u can call this to force the window to recalculate the boundarieso
and locations of each child window. Y u usually want to call Layout aftero
you’ e moved a child window resized the layout window or anythingv , ,
else that could affect the constraints of the child windows.
Note that TLayoutWindow overrides the TWindow version of EvSize to call
Layout automatically whenever a WM_SIZE event is caught. If you
160
OWL P ogrammer’ Guider s