Contents Up Previous Next

wxCompositeShape overview

Classes: wxCompositeShape, wxOGLConstraint

The wxCompositeShape allows fairly complex shapes to be created, and maintains a set of constraints which specify the layout and proportions of child shapes.

Add child shapes to a wxCompositeShape using AddChild, and add constraints using AddConstraint.

After children and shapes have been added, call Recompute which will return TRUE is the constraints could be satisfied, FALSE otherwise. If constraints have been correctly and consistently specified, this call will succeed.

If there is more than one child, constraints must be specified: OGL cannot calculate the size and position of children otherwise. Don't assume that children will simply move relative to the parent without the use of constraints.

To specify a constraint, you need three things:

  1. a constraint type, such as gyCONSTRAINT_CENTRED_VERTICALLY;
  2. a reference shape, with respect to which other shapes are going to be positioned - the constraining shape;
  3. a list of one or more shapes to be constrained: the constrained shapes.

The constraining shape can be either the parent of the constrained shapes, or a sibling. The constrained shapes must all be siblings of each other.

For an exhaustive list and description of the available constraint types, see the wxOGLConstraint constructor. Note that most constraints operate in one dimension only (vertically or horizontally), so you will usually need to specify constraints in pairs.

You can set the spacing between constraining and constrained shapes by calling wxOGLConstraint::SetSpacing.

Finally, a wxCompositeShape can have divisions, which are special child shapes of class wxDivisionShape (not to be confused with wxDividedShape). The purpose of this is to allow the composite to be divided into user-adjustable regions (divisions) into which other shapes can be dropped dynamically, given suitable application code. Divisons allow the child shapes to have an identity of their own - they can be manipulated independently of their container - but to behave as if they are contained with the division, moving with the parent shape. Divisions boundaries can themselves be moved using the mouse.

To create an initial division, call wxCompositeShape::MakeContainer. Make further divisions by calling wxDivisionShape::Divide.