Go to the first, previous, next, last section, table of contents.

5.1 The alignment widget

5.1.1 Description

The alignment widget is a container (see section 5.13 The container widget) derived from the bin widget (see section 5.4 The bin widget). Its entire purpose is to give the programmer flexibility in how the child it manages is positioned when a window is resized.

Normally, a widget is allocated at least as much size as it requests. (see section 5.13 The container widget for a discussion of geometry management). When a widget is allocated more size than it requests there is a question of how the widget should expand. By convention, most GTK widgets expand to fill their allocated space. Sometimes this behavior is not desired. The alignment widget allows the programmer to specify how a widget should expand and position itself to fill the area it is allocated.

5.1.2 Options

User Option: xscale
User Option: yscale
The xscale and yscale options specify how to scale the child widget. If the scale value is 0.0, the child widget is allocated exactly the size it requested in that dimension. If the scale value is 1.0, the child widget is allocated all of the space in a dimension. A scale value of 1.0 for both x and y is equivalent to not using an alignment widget.

User Option: xalign
User Option: yalign
The xalign and yalign options specify how to position the child widget when it is not allocated all the space available to it (because the xscale and/or yscale options are less than 1.0). If an alignment value is 0.0 the widget is positioned to the left (or top) of its allocated space. An alignment value of 1.0 positions the widget to the right (or bottom) of its allocated space. A common usage is to specify xalign and yalign to be 0.5 which causes the widget to be centered within its allocated area.

5.1.3 Signals

5.1.4 Functions

Function: guint gtk_alignment_get_type (void)
Returns the GtkAlignment type identifier.

Function: GtkWidget* gtk_alignment_new (gfloat xalign, gfloat yalign, gfloat xscale, gfloat yscale)
Create a new GtkAlignment object and initialize it with the values xalign, yalign, xscale and yscale. The new widget is returned as a pointer to a GtkWidget object. NULL is returned on failure.

Function: void gtk_alignment_set (GtkAlignment *alignment, gfloat xalign, gfloat yalign, gfloat xscale, gfloat yscale)
Set the xalign, yalign, xscale and yscale options of an alignment widget. It is important to not set the fields of the GtkAlignment structure directly (or, for that matter, any type derived from GtkObject).

@gtkstdmacros{Alignment, ALIGNMENT}

Go to the first, previous, next, last section, table of contents.