NAME
LibUI::Area - Control Representing a Canvas You May Draw On
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::Area object represents a control you may draw on. It receives keyboard and mouse events, supports scrolling, is DPI aware, and has several other useful features. The control consists of the drawing area itself and horizontal and vertical scrollbars.
A LibUI::Area is driven by an area handler.
Functions
Not a lot here but... well, it's just a, interactive box.
new( ... )
my $area = LibUI::Area->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>