The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tickit::Widget::GridBox - lay out a set of child widgets in a grid

SYNOPSIS

 use Tickit:
 use Tickit::Widget::GridBox;
 use Tickit::Widget::Static;

 my $gridbox = Tickit::Widget::GridBox->new(
    col_spacing => 2,
    row_spacing => 1,
 );

 $gridbox->add( 0, 0, Tickit::Widget::Static->new( text => "top left" ) );
 $gridbox->add( 0, 1, Tickit::Widget::Static->new( text => "top right" ) );
 $gridbox->add( 1, 0, Tickit::Widget::Static->new( text => "bottom left" ) );
 $gridbox->add( 1, 1, Tickit::Widget::Static->new( text => "bottom right" ) );

 $tickit->set_row_spacing( $gridbox );

 Tickit->new( root => $gridbox )->run;

DESCRIPTION

This container widget holds a set of child widgets distributed in a regular grid shape across rows and columns.

STYLE

The default style pen is used as the widget pen.

CONSTRUCTOR

$gridbox = Tickit::Widget::GridBox->new( %args )

Constructs a new Tickit::Widget::GridBox object.

Takes the following named arguments:

col_spacing => INT
row_spacing => INT

Optional. Initial values for the col_spacing and row_spacing attributes.

ACCESSORS

$spacing = $gridbox->row_spacing

$gridbox->set_row_spacing( $spacing )

Return or set the number of lines of inter-row spacing.

$spacing = $gridbox->col_spacing

$gridbox->set_col_spacing( $spacing )

Return or set the number of lines of inter-column spacing.

METHODS

$gridbox->add( $row, $col, $child, %opts )

Sets the child widget to display in the given grid cell. Cells do not need to be explicitly constructed; the grid will automatically expand to the size required. This method can also be used to replace an existing child at the given cell location. To remove a cell entirely, use the remove method.

The following options are recognised:

col_expand => INT
row_expand => INT

Values for the expand setting for this column or row of the table. The largest expand setting for any cell in a given column or row sets the value used to distribute space to that column or row.

$gridbox->remove( $row, $col )

Removes the child widget on display in the given cell. May shrink the grid if this was the last child widget in the given row or column.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>