[previous] [up] [next]     [index]
Next: Defining New Types of Up: Geometry Management Previous: Containees

Containers

A container has the following properties:

These properties are factored into the container's calculation of its own size and the arrangement of its children. For a container that is also a containee (e.g., a panel), the container's requested minimum size and stretchability are the same as for its containee aspect.

A containee's parent container is specified when the containee is created, and the parent cannot be changed. However, a containee window can be hidden or inactive within its parent container:[footnote]

When a child is created, it is initially shown and active. An inactive child is subject to garbage collection when no external reference to the child exists. A list of active children (hidden or not) is available from a container through its get-children method.

The order of the children in a container's active list is significant. For example, a vertical panel puts the first child in its list at the top of the panel, and so on. When a new child is created, it is put at the end of its container's list of children. The order of a container's list can be changed dynamically via the change-children method. (The change-children method can also be used to activate or deactive children.)

The (graphical) minimum size of a container is calculated by combining the minimum sizes of its children (summing them or taking the maximum, as appropriate to the layout strategy of the container) along with the spacing and border margins of the container. A larger miniumum may be specified by the programmer using min-width and min-height methods; when the computed minimum for a container is larger than the programmer-specified minimum, then the programmer-specified minimum is ignored.

A container's spacing determines the amount of whitespace left between adjacent children in the container, in addition to any whitespace required by the children's margins. A container's border margin determines the amount of whitespace to add around the collection of children; it effectively decreases the area within the container where children can be placed. A programmer can adjust a container's border and spacing dynamically via the border and spacing methods. The default border and spacing are 0 for all container types.

Because a panel or pane is a containee as well as a container, it has a containee margin in addition to its border margin. For a panel, these margins are not redundant because the panel can have a graphical border; the border is drawn inside the panel's containee margin, but outside the panel's border margin.

For a top-level-window container, such as a frame or dialog, the container's stretchability determines whether the user can resize the window to something larger than its minimum size. Thus, the user cannot resize a frame that is not stretchable. For other types of containers (i.e., panels and panes), the container's stretachability is its stretchability as a containee in some other container. All types of containers are initially stretchable in both directions,[footnote] but a programmer can change the stretchability of an area at any time via the stretchable-width and stretchable-height methods.

The alignment specification for a container determines how it positions its children when the container has leftover space. (A container can only have leftover space in a particular direction when none of its children are stretchable in that direction.) For example, when the container's horizontal alignment is 'left, the children are left-aligned in the container and leftover whitespace is accumulated to the right. When the container's horizontal alignment is 'center, each child is horizontally centered in the container. A container's alignment is changed with the set-alignment method.


[previous] [up] [next]     [index]
Next: Defining New Types of Up: Geometry Management Previous: Containees

PLT