# wx.lib.ogl.composit.CompositeShape¶

The CompositeShape is a shape with a list of child objects, and a list of size and positioning constraints between the children.

## Class Hierarchy¶

Inheritance diagram for class CompositeShape:

## Known Subclasses¶

wx.lib.ogl.composit.DivisionShape

## Known Superclasses¶

wx.lib.ogl.basic.RectangleShape

## Methods Summary¶

 __init__ Default class constructor. AddChild Add a shape to the composite. If addAfter is not None, the shape AddConstraint Adds a constraint to the composite. AddSimpleConstraint Add a constraint of the given type to the composite. CalculateSize Calculates the size and position of the composite based on Constrain Constrain the children. ContainsDivision Check if division is descendant. Delete Fully disconnect this shape from parents, children, the DeleteConstraint Deletes constraint from composite. DeleteConstraintsInvolvingChild This function deletes constraints which mention the given child. FindConstraint Finds the constraint with the given id. FindContainerImage Finds the image used to visualize a container. This is any child of GetConstraints Return the list of constraints. GetDivisions Return the list of divisions. MakeContainer Makes this composite into a container by creating one child OnBeginDragLeft The begin drag left handler. OnCreateDivision Create division handler. OnDragLeft The drag left handler. OnDraw The draw handler. OnDrawContents The draw contents handler. OnEndDragLeft The end drag left handler. OnErase The erase handler. OnMovePre The move ‘pre’ handler. OnRightClick The right click handler. Recompute Recomputes any constraints associated with the object. If False is RemoveChild Removes the child from the composite and any constraint RemoveChildFromConstraints Removes the child from the constraints. SetSize Set the size.

## Class API¶

class CompositeShape(RectangleShape)

The CompositeShape is a shape with a list of child objects, and a list of size and positioning constraints between the children.

### Methods¶

__init__(self)

Default class constructor.

AddChild(self, child, addAfter = None)

Add a shape to the composite. If addAfter is not None, the shape will be added after addAfter.

Parameters
• child – an instance of Shape

• addAfter – an instance of Shape

AddConstraint(self, constraint)

Adds a constraint to the composite.

Parameters

constraint – an instance of Shape

AddSimpleConstraint(self, type, constraining, constrained)

Add a constraint of the given type to the composite.

Parameters
• type – see ConstraintType for valid types

• constraining – the constraining Shape

• constrained – the constrained Shape

CalculateSize(self)

Calculates the size and position of the composite based on child sizes and positions.

Constrain(self)

Constrain the children.

Returns

True if constained otherwise False

ContainsDivision(self, division)

Check if division is descendant.

Parameters

division – divison to check

Returns

True if division is a descendant of this container.

Delete(self)

Fully disconnect this shape from parents, children, the canvas, etc.

DeleteConstraint(self, constraint)

Deletes constraint from composite.

Parameters

constraint – the constraint to delete

DeleteConstraintsInvolvingChild(self, child)

This function deletes constraints which mention the given child.

Used when deleting a child from the composite.

Parameters

child – an instance of Shape

FindConstraint(self, cId)

Finds the constraint with the given id.

Parameters

cId – The constraint id to find.

Returns

None or a tuple of the constraint and the actual composite the constraint was in, in case that composite was a descendant of this composit.

FindContainerImage(self)

Finds the image used to visualize a container. This is any child of the composite that is not in the divisions list.

GetConstraints(self)

Return the list of constraints.

GetDivisions(self)

Return the list of divisions.

MakeContainer(self)

Makes this composite into a container by creating one child DivisionShape.

OnBeginDragLeft(self, x, y, keys = 0, attachment = 0)

The begin drag left handler.

OnCreateDivision(self)

Create division handler.

OnDragLeft(self, draw, x, y, keys = 0, attachment = 0)

The drag left handler.

OnDraw(self, dc)

The draw handler.

OnDrawContents(self, dc)

The draw contents handler.

OnEndDragLeft(self, x, y, keys = 0, attachment = 0)

The end drag left handler.

OnErase(self, dc)

The erase handler.

OnMovePre(self, dc, x, y, old_x, old_y, display = True)

The move ‘pre’ handler.

OnRightClick(self, x, y, keys = 0, attachment = 0)

The right click handler.

Note

If we get a ctrl-right click, this means send the message to the division, so we can invoke a user interface for dealing with regions.

Recompute(self)

Recomputes any constraints associated with the object. If False is returned, the constraints could not be satisfied (there was an inconsistency).

RemoveChild(self, child)

Removes the child from the composite and any constraint relationships, but does not delete the child.

Parameters

child – an instance of Shape

RemoveChildFromConstraints(self, child)

Removes the child from the constraints.

Parameters

child – an instance of Shape

SetSize(self, w, h, recursive = True)

Set the size.

Parameters
• w – the width

• h – the heigth

• recursive – size the children recursively