NAME

LibUI::Grid - Control Container to Arrange Containing Controls in a Grid

SYNOPSIS

use LibUI ':all';
use LibUI::Grid;
use LibUI::Window;
use LibUI::Align qw[Center Fill];
use LibUI::At    qw[Bottom];
use LibUI::Label;
Init && die;
my $window = LibUI::Window->new( 'Hi', 320, 100, 0 );
$window->setMargined( 1 );
my $grid   = LibUI::Grid->new();
my $lbl    = LibUI::Label->new('Top Left');
$grid->append( $lbl,                           0, 0, 1, 1, 1, Fill, 1, Fill );
$grid->append( LibUI::Label->new('Top Right'), 1, 0, 1, 1, 1, Fill, 1, Fill );
$grid->insertAt( LibUI::Label->new('Bottom Center and Span two cols'),
    $lbl, Bottom, 2, 1, 1, Center, 1, Center );
$window->setChild($grid);
$window->onClosing(
    sub {
        Quit();
        return 1;
    },
    undef
);
$window->show;
Main();

DESCRIPTION

A LibUI::Grid object represents a control container to arrange containing controls in a grid.

Contained controls are arranged on an imaginary grid of rows and columns. Controls can be placed anywhere on this grid, spanning multiple rows and/or columns.

Additionally placed controls can be programmed to expand horizontally and/or vertically, sharing the remaining space among other expanded controls.

Alignment options are available via LibUI::Align attributes to determine the controls placement within the reserved area, should the area be bigger than the control itself.

Controls can also be placed in relation to other controls using LibUI::At attributes.

Functions

Not a lot here but... well, it's just a tab box.

new( ... )

my $grid = LibUI::Grid->new( );

Creates a new form.

append( ... )

$grid->append( LibUI::Label->new('Top Left'),
    0, 0, 1, 1, 1, Fill, 1, Fill );
$grid->append( LibUI::Label->new('Top Right'),
    1, 0, 1, 1, 1, Fill, 1, Fill );

Appends a control to the grid.

Expected parameters include:

$child - LibUI::Control instance to insert
$left - Placement as number of columns from left
$top - Placement as number of rows from the top
$xspan - Number of columns to span
$yspan - Number of rows to span
$hexpand - Boolean value; true to expand reserved area horizontally; otherwise false
$halign - Horizontal alignment of the control within the reserved space
$vexpand - Bolean value; true to expand reserved area vertically; otherwise false
$valign - Vertical alignment of the control within the reserved space

See LibUI::Align for possible values of $halign and $valign.

insertAt( ... )

my $grid   = LibUI::Grid->new();
my $lbl    = LibUI::Label->new('Top Left');
$grid->append( $lbl, 0, 0, 1, 1, 1, Fill, 1, Fill );
$grid->append( LibUI::Label->new('Top Right'),
    1, 0, 1, 1, 1, Fill, 1, Fill );
# Insert below $lbl and span two columns
$grid->insertAt( LibUI::Label->new('Bottom Center and Stretch'),
    $lbl, Bottom, 2, 1, 1, Center, 1, Center );

Appends a control to the grid.

Expected parameters include:

$child - LibUI::Control instance to insert
$existing - The existing LibUI::Control instance to position relatively to
$at - Placement specifier in relation to $existing control
$xspan - Number of columns to span
$yspan - Number of rows to span
$hexpand - Boolean value; true to expand reserved area horizontally; otherwise false
$halign - Horizontal alignment of the control within the reserved space
$vexpand - Bolean value; true to expand reserved area vertically; otherwise false
$valign - Vertical alignment of the control within the reserved space

See LibUI::Align for possible values of $halign and $valign.

See LibUI::At for possible values of $at.

padded( )

if( $grid->padded ) {
    ...;
}

Returns whether or not controls within the grid are padded.

Padding is defined as space between individual controls.

setPadded( ... )

$grid->setPadded( 1 );

Sets whether or not controls within the grid are padded.

Padding is defined as space between individual controls. The padding size is determined by the OS defaults.

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>