Xfce Foundation Classes
 « Main Page | Index

The Alignment Widget


The alignment widget allows you to place a widget within its window at a position and size relative to the size of the Alignment widget itself. For example, it can be very useful for centering a widget within the window.

There are only two constructors associated with the Alignment widget:

Alignment();

Alignment(float xalign, float yalign, float xscale = 0.0, float yscale = 0.0);

The first constructor creates an empty alignment, the second creates an Alignment with the specified parameters. To alter the parameters of an existing Alignment widget use the Gtk::Alignment::set() method.

void set(float xalign, float yalign, float xscale, float yscale);

The 'xalign' and 'yalign' arguments affect the position of the widget placed within the Alignment widget and can range from 0.0 (on the left) to 1.0 (on the right). The 'xscale' and 'yscale' arguments effect the amount of space allocated to the widget and can be 0.0 (never expand) to 1.0 (fully expand).

You can also add padding (or blank space) on the different sides of a widget:

void set_padding(unsigned int top, unsigned int bottom, unsigned int left, unsigned int right);

For example, you could indent a widget by adding padding on the left.

A child widget can be added to an Alignment widget using Gtk::Container::add():

alignment->add(*child_widget);

For an example of using an Alignment widget have a look at the Progress Bar example.


Copyright © 2004-2005 The XFC Development Team Top
XFC 4.4