NAME
Wx::Perl::ListCtrl - a sensible API for Wx::ListCtrl
SYNOPSIS
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
DESCRIPTION
The Wx::ListCtrl
API is terrible. This module goes further than Wx::ListView
in providing a sane api for Wx::ListCtrl
.
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.
METHODS
GetSelection
my $selection = $lc->GetSelection;
Returns the single selected line. Only works with a single-selection list control.
GetSelections
my @selections = $lc->GetSelections;
Returns a list with all the selected lines. Only works with a multi-selection list control.
GetItemText
my $text = $lc->GetItemText( $row, $col );
WARNING: incompatible with Wx::ListCtrl
. Returns the text of the given item.
SetItemText
$lc->SetItemText( $row, $col, 'Text' );
WARNING: incompatible with Wx::ListCtrl
. Sets the text of the given item.
SetItemData
$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.
GetItemData
my $data = $lc->GetItemData( $data );
Retrieves the data set with $lc-
SetItemData>.
BUGS
Calling SetItemData
too many times will crash after about 2^31 per-object calls (with 32 bit integers).
AUTHOR
Mattia Barbon <mbarbon@cpan.org>
LICENSE
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