[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    Box(3X) manual page Table of Contents

Name

Box - tile interactors edge to edge

Synopsis

#include <ivplus/box.h>

Description

Box is a Scene which tiles its components edge to edge. The natural size of a box is the sum of its elements’ size along the major axis, and the maximum of its elements along its minor axis. A box will try to stretch or shrink the interactors inside it to fit the available space.

A box’s stretchability (shrinkability) is the sum of its elements’ stretchability (shrinkability) along its major axis and the minimum of its elements along its minor axis.

Box is an abstract base class. There are two classes derived from Box: HBox and VBox.

Class Hierarchy

Box -> Scene -> Interactor

Constructors

Box()

Creates a new empty box. Interactors can then be added using the Insert() operation. Since Box is an abstract base class, this constructor is protected.

Public Operations

void Align(Alignment)

Sets the alignment mode that the box uses to place elements along the minor axis. The default alignment for HBox is Bottom; other valid choices are Top and Center. The default alignment for VBox is Left; other choices are Right and Center.

void Scene::Change(Interactor* = nil)

Notifies a box that one or more of its components has changed. A component may have been resized, inserted, or removed. The change will not become apparent until Change() is called on the box containing the changed component. The given interactor is not used.

If the propagation flag is set to true (see Propagate() in Scene(3X) ), Change() will be called on successive parents until the top level scene or a scene with the propagation flag set to false is reached. At that point, a Resize() traversal is begun and the changes will become visible.

void Draw()

Calls Draw() on each child contained within the Box.

void GetComponents(Interactor**, int len, Interactor**&, int&)

Constructs an array of pointers to the interactors contained within the box. The first and second parameters specify an array of interactors that is already allocated. This array is used if it is large enough to hold the results, otherwise a new array is allocated from free store. The third and fourth parameters return which array was used and the actual number of components.

void Resize()

Allocates the available canvas space among all of its components according to their desired natural size, stretchability and shrinkability and places them accordingly.

void Scene::Insert(Interactor*)

Appends an interactor to the box. Components of an hbox will appear left-to-right. Components of a vbox will appear top-to-bottom. Interactors appear in the order in which they are inserted.

void Scene::Remove(Interactor*)

Removes an element from a box. Remove() does not cause any immediate change to the other components in the box. The Change() operation must be called after one or more calls to Remove() to update the component positions.

Protected Data

Alignment align

Holds the current alignment for the box along its minor axis.

Protected Operations

void ComputeShape(Shape*)

Computes the shape of the hbox or vbox by adding the dimensions of all the components contained within the box. The shape of an hbox is determined by adding the width of all components contained within the hbox and taking the height of the object with the largest height. The shape of a vbox is determined by adding the height of all the components contained within the vbox and taking the width of the object with the largest width.

void GetActual(int& major, int& minor)

Returns the size of the canvas along the major and minor axes.

void GetCanonical(Shape*, BoxCanonical&)

Calculates the combined dimensions of all the components in the box. The width, height, shrink and stretch values of Shape* are placed in the passed BoxCanonical parameter. A BoxCanonical is made up of two BoxDimensions for major and minor dimensions. A BoxDimension contains values for natural, shrink and stretch values. In a vbox, height, vshrink and vstretch are used for major dimensions and width, hshrink and hstretch are used for minor dimensions. For an hbox the width, hshrink, and hstretch are used for major dimensions while height, vshrink and vstretch are used for minor dimensions.

void PlaceElement(Interactor*, IntCoord, int, int, int)

Places an interactor at a certain coordinate within the box. The value of IntCoord is adjusted using the length, size and width (VBox) or height (HBox). The new set of IntCoords for starting and ending x and y are also calculated. Once the new IntCoords are calculated, the Scene::Place() operation is called.

X Resources

None.

Examples

No example for this abstract base class. See HBox(3X) and VBox(3X) for examples.

Files


box.h

See Also

Glue(3X) , HBox(3X) , Interactor(3X) , Scene(3X) , Shape(3X) , VBox(3X) .


Table of Contents