OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Laying Out the Gadgets

To lay out a gadget window, call the TGadgetWindow::LayoutSession function.

virtual void LayoutSession();

The default behavior of LayoutSession is to determine if the window interface element is already created. If not, the function returns without taking any further action, and the window is laid out automatically when the window element is created. But if the window element has already been created, LayoutSession tiles the gadgets and then invalidates the modified area of the gadget window.

A layout session is typically initiated by one of several actions: changing margins, inserting or removing gadgets, or changing the size of a gadget or gadget window.

The actual work of tiling the gadgets is left to the function

TGadgetWindow::TileGadgets:
virtual TRect TileGadgets();

TileGadgets determines the space needed for each gadget and lays each gadget out in turn. It returns a TRect containing the area of the gadget window that was modified by laying out the gadgets.

TileGadgets calls the function TGadgetWindow::PositionGadget, which lets derived classes adjust the spacing between gadgets to help in implementing a custom layout scheme. The syntax of PositionGadget is

virtual void PositionGadget(TGadget* previous,
TGadget* next,
TPoint& point);

This function takes the gadgets pointed to by previous and next, figures the required spacing between the gadgets, and then fills in point. If tiling is horizontal, the relevant measure is contained in point.x. If tiling is vertical, the relevant measure is contained in point.y.