Blitz3D+ Command Reference

SetGadgetLayout gadget,left,right,top,bottom

Parameters

gadget - gadget whose layout rules to set

left - rule for the left edge

right - rule for the right edge

top - rule for the top edge

bottom - rule for the bottom edge

Each edge rule is one of:
0: unchanged - the gadget keeps its size on that axis and drifts with the group's centre
1: anchored - the edge keeps a fixed distance from the matching group edge
2: proportional - the edge moves in proportion to the group's new size

Description

Sets how a gadget's edges follow its group when the group is resized.

Requires Extended language mode.

This is what makes a resizable editor window feel right. Without rules, gadgets stay where they were created; with rules, they stretch and stick as the window (or panel, group box, splitter pane, tabber page) changes size. The classic recipes:

SetGadgetLayout toolbar,1,1,1,0 - stick to the top, stretch across
SetGadgetLayout mainView,1,1,1,1 - fill and stretch with the window
SetGadgetLayout okButton,0,1,0,1 - hug the bottom-right corner, fixed size

Rule 1 anchors an edge at its current distance from the same edge of the group: left/top anchor to the group's left/top, right/bottom to its right/bottom. Rule 2 keeps the edge at the same proportional position. Rule 0 keeps the gadget's size on that axis; with both edges 0 it drifts to stay centred.

The rules take the gadget's current shape and the group's current client size as their baseline - and calling SetGadgetShape re-baselines them - so set the shape first, then the layout. Everything is measured in 96-DPI logical pixels; the GUI scales for the monitor itself.

See it working in the layout and controls sample.

See also: SetGadgetShape, ClientWidth, ClientHeight, SetMinWindowSize, CreateWindow.

Index