LibUI::Grid - Control Container to Arrange Containing Controls in a Grid
use LibUI ':all'; use LibUI::Grid; use LibUI::Window; use LibUI::Align qw[Center Fill]; use LibUI::At qw[Bottom]; use LibUI::Label; Init( { Size => 1024 } ) && die; my $window = LibUI::Window->new( 'Hi', 320, 100, 0 ); 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();
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.
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
$left
$top
$xspan
$yspan
$hexpand
$halign
$vexpand
$valign
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 );
$existing
$at
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.
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sanko Robinson <sanko@cpan.org>
To install LibUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LibUI
CPAN shell
perl -MCPAN -e shell install LibUI
For more information on module installation, please visit the detailed CPAN module installation guide.