Chapter 55. Layout Container

Inheritance Hierarchy

Object
   +--- Widget
         +--- Container
               +--- Layout
         

The Layout container is similar to the Fixed container except that it implements an infinite scrolling area (where infinity is less than 2^32). The X window system has a limitation where windows can be at most 32767 pixels wide or tall. The Layout container gets around this limitation by doing some exotic stuff using window and bit gravities, so that you can have smooth scrolling even when you have many child widgets in your scrolling area.

A Layout container is created using:

$layout = new Gtk::Layout( $hadjustment, $vadjustment );

As you can see, you can optionally specify the Adjustment objects that the Layout widget will use for its scrolling.

You can add and move widgets in the Layout container using the following two functions:

$layout->put( $widget, $x, $y );

$layout->move( $widget, $x, $y );

The size of the Layout container can be set using the next function:

$layout->set_size( $width, $height );

Layout containers are one of the very few widgets in the GTK widget set that actively repaint themselves on screen as they are changed using the above functions (the vast majority of widgets queue requests which are then processed when control returns to main Gtk).

Because of this, when you want to make a large number of changes to a Layout container, you should use the following two functions to disable and re-enable this repainting functionality:

$layout->freeze();

$layout->thaw();

The final four functions for use with Layout widgets are for manipulating the horizontal and vertical adjustment widgets:

$layout->get_hadjustment();
$layout->get_vadjustment();

$layout->set_hadjustment( $adjustment );
$layout->set_vadjustment( $adjustment );