Prima
view release on metacpan or search on metacpan
examples/listbox.pl view on Meta::CPAN
#
# Example of listbox extended usage
#
=pod
=head1 NAME
examples/listbox.pl - Prima listbox, combobox and widget example
=head1 FEATURES
Demonstrates the usage of Prima::Edit, Prima::ComboBox
and Prima::ListBox widgets.
=cut
use strict;
use warnings;
use Prima qw( ComboBox Edit Application );
package TestWindow;
use vars qw(@ISA);
@ISA = qw(Prima::MainWindow);
sub create_menu
{
return [
[ "~ListBox" => [
["~Add text" => "AddItem"],
["~Delete current" => sub{$_[0]-> ListBox1-> delete_items( $_[0]-> ListBox1-> focusedItem);}],
["Delete a~ll" => sub{$_[0]-> ListBox1-> delete_items(0..$_[0]-> ListBox1-> count )}],
[],
["~Print all" => "PrintAll"],
["Print ~selected" => sub{foreach (@{$_[0]-> ListBox1-> selectedItems}){print "$_\n"};}],
["Print ~focused" => sub{ print $_[0]-> ListBox1-> focusedItem."\n";}],
[],
["Toggle ~extended selection"=> sub{$_[0]-> ListBox1-> extendedSelect(!$_[0]-> ListBox1-> extendedSelect)}],
["Toggle ~multiple selection"=> sub{$_[0]-> ListBox1-> multiSelect(!$_[0]-> ListBox1-> multiSelect)}],
["~Increase item height"=>sub{$_[0]-> ListBox1-> itemHeight($_[0]-> ListBox1-> itemHeight+2)}],
["~Decrease item height"=>sub{$_[0]-> ListBox1-> itemHeight($_[0]-> ListBox1-> itemHeight-2)}],
[],
['Ali~gn' => [
['~Left' => sub { shift->ListBox1->align(ta::Left) }],
['~Right' => sub { shift->ListBox1->align(ta::Right) }],
['~Center' => sub { shift->ListBox1->align(ta::Center) }],
]],
[],
["Add~itional"=> sub {
my $box = $_[0]-> ListBox1;
$box-> add_items( 'Hello', 'user', 'from', 'Perl');
}]
]],
[
"~Edit" => [
["~VScroll" => sub{$_[0]-> Edit1-> vScroll(!$_[0]-> Edit1-> vScroll)}],
["~HScroll" => sub{$_[0]-> Edit1-> hScroll(!$_[0]-> Edit1-> hScroll)}],
["B~oth" => sub{
$_[0]-> Edit1-> set( hScroll => !$_[0]-> Edit1-> hScroll,
vScroll => !$_[0]-> Edit1-> vScroll)
}],
["~Border" => sub{$_[0]-> Edit1-> borderWidth(!$_[0]-> Edit1-> borderWidth)}],
]],
[ "~ComboBox" => [
["~Add text" => "AddItemC"],
["Delete a~ll" => sub{$_[0]-> ComboBox1-> List-> delete_items( 0..$_[0]-> ComboBox1-> List-> count) }],
["Print ~text" => sub{ print $_[0]-> ComboBox1-> text."\n";}],
[],
( run in 2.420 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )