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

Name

VBox - tile interactors vertically

Synopsis

#include <ivplus/box.h>

Description

VBox is a scene of interactors that are tiled top-to-bottom in the available space.

The natural size of a vbox is the sum of its elements along the major axis, and the maximum along its minor axis. A vbox will try to stretch or shrink the interactors inside it to fit the available space.

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

Class Hierarchy

VBox->Box->Scene->Interactor

Constructors

VBox()

Creates a new empty box. Interactors can then be added using the Insert() operation.

VBox(Interactor*,...)

Creates a new box. Up to seven interactors may be passed as arguments. The interactors are inserted into the box in the order that they are passed. More interactors can be added using the Insert() operation.

Public Operations

void Box::Align(Alignment)

Sets the alignment mode that the box uses to place elements along the minor axis. The default alignment for a vbox is Left. Other valid choices are Right and Center.

void Box::Draw()

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

void Box::GetComponents(Interactor**, int, 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 in the box.

void Scene::Insert(Interactor*)

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

void Scene::Change(Interactor* = nil)

Notifies a vbox 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 vbox 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 Scene::Remove(Interactor*)

Removes an element from the 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 Remove() operations to update the component positions.

Protected Operations

void ComputeShape(Shape*)

Computes the shape of the box by adding the dimensions of all the components contained within the box. 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.

void PlaceElement(Interactor*, IntCoord y, int length, int size, int width)

Places an interactor at a certain coordinate within the box. The value of y is adjusted using the length, size and width. 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


//                          VBox Example
#include <ivplus/box.h>
#include <ivplus/button.h>
#include <ivplus/frame.h>
#include <ivplus/glue.h>
#include <ivplus/world.h>
int main(int argc, char **argv)
{
   // Create the world to get the connection with the display.
   World* world = new World("MyApp", argc, argv);
   // Create three push buttons.
   PushButton* btn1 = new PushButton("Button1", new ButtonState(0), 1);
   PushButton* btn2 = new PushButton("Button2", new ButtonState(0), 1);
   PushButton* btn3 = new PushButton("Button3", new ButtonState(0), 1);
   // Create a vertical box with btn1, btn2 and vglue.
   VBox* btnbox = new VBox(new VGlue, btn1, new VGlue, btn2, new VGlue);
   // Insert btn3, vglue in the btnbox using function Insert().
   btnbox->Insert(btn3);
   btnbox->Insert(new VGlue);
   // For the btnbox, set the horizontal alignment to center.
   btnbox->Align(Center);
   // Remove an element from the box and inform scene to recompute its
   // shape. 
   btnbox->Remove(btn2);
   btnbox->Change();
  
   // Map the window.
   world->InsertApplication(new Frame(btnbox, 1, BevelOut));
   // Enter the event loop.
   world->Run();
   return 0;
}

Files


box.h

See Also

Box(3X) , Glue(3X) , HBox(3X) , Interactor(3X) , Scene(3X) , Shape(3X) , VGlue(3X) .


Table of Contents