Wx::Perl::ListCtrl - a sensible API for Wx::ListCtrl
use Wx::Perl::ListCtrl; my $lc = Wx::Perl::ListCtrl->new( $parent, -1 ); # add columns... # get/set item text easily $lc->InsertStringItem( 0, 'dummy' ); $lc->SetItemText( 0, 0, 'row 0, col 0' ); $lc->SetItemText( 0, 1, 'row 0, col 1' ); $lc->GetItemText( 0, 1 ) # 'row 0, col 1' # use structured data, not plain integers $lc->SetItemData( 0, { complex =>1, data => 2 } ); my $data = $lc->GetItemData( 0 ); # sensible way of getting the selection my $selection = $lc->GetSelection; # single selection my @selections = $lc->GetSelections; # multiple selections
The Wx::ListCtrl API is terrible. This module goes further than Wx::ListView in providing a sane api for Wx::ListCtrl.
Wx::ListCtrl
Wx::ListView
This module is not a drop-in replacement for Wx::ListCtrl and Wx::ListView .
Wx::Perl::ListCtrl derives from Wx::ListView, however some of Wx::ListView/Wx::ListCtrl methods are overridden with more sensible, and sometimes API-incompatible, implementations.
Wx::Perl::ListCtrl
Wx::ListView/Wx::ListCtrl
my $selection = $lc->GetSelection;
Returns the single selected line. Only works with a single-selection list control.
my @selections = $lc->GetSelections;
Returns a list with all the selected lines. Only works with a multi-selection list control.
my $text = $lc->GetItemText( $row, $col );
WARNING: incompatible with Wx::ListCtrl . Returns the text of the given item.
$lc->SetItemText( $row, $col, 'Text' );
WARNING: incompatible with Wx::ListCtrl . Sets the text of the given item.
$lc->SetItemData( $item, { complex => [ qw(data is allowed) ] } );
Sets the client data for the given row. Complex data structures are allowed. Setting the data to undef deletes the data for the given row.
undef
my $data = $lc->GetItemData( $data );
Retrieves the data set with $lc-SetItemData>.
$lc-
Calling SetItemData too many times will crash after about 2^31 per-object calls (with 32 bit integers).
SetItemData
Mattia Barbon <mbarbon@cpan.org>
Copyright (c) 2005, 2007 Mattia Barbon <mbarbon@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself
To install Wx::Perl::ListCtrl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wx::Perl::ListCtrl
CPAN shell
perl -MCPAN -e shell install Wx::Perl::ListCtrl
For more information on module installation, please visit the detailed CPAN module installation guide.