Constraints overview

Classes: wxLayoutConstraints, wxIndividualLayoutConstraint.

Note: constraints are now deprecated and you should use sizers instead.

Objects of class wxLayoutConstraint can be associated with a window to define the way it is laid out, with respect to its siblings or the parent.

The class consists of the following eight constraints of class wxIndividualLayoutConstraint, some or all of which should be accessed directly to set the appropriate constraints.

The constraints are initially set to have the relationship wxUnconstrained, which means that their values should be calculated by looking at known constraints. To calculate the position and size of the control, the layout algorithm needs to know exactly 4 constraints (as it has 4 numbers to calculate from them), so you should always set exactly 4 of the constraints from the above table.

If you want the controls height or width to have the default value, you may use a special value for the constraint: wxAsIs. If the constraint is wxAsIs, the dimension will not be changed which is useful for the dialog controls which often have the default size (e.g. the buttons whose size is determined by their label).

The constrains calculation is done in wxWindow::Layout function which evaluates constraints. To call it you can either call wxWindow::SetAutoLayout if the parent window is a frame, panel or a dialog to tell default OnSize handlers to call Layout automatically whenever the window size changes, or override OnSize and call Layout yourself (note that you do have to call Layout yourself if the parent window is not a frame, panel or dialog).



ymasuda 平成17年11月19日