#!/usr/bin/perl use strict; use warnings; package MyFrame; use Wx; use base qw(Wx::Frame); sub new { my $class = shift; my $self = $class->SUPER::new( undef, # parent window -1, # ID -1 means any 'wxPerl rules', # title [-1, -1], # default position [100, 200], # size ); my $panel = Wx::Panel->new( $self, # parent window -1, # ID ); my $vlistbox = MyWxVListBox->new( $self, -1, [-1, -1], [100, 200] ); return $self; } package MyApp; use base qw(Wx::App); sub OnInit { my $class = shift; my $frame = MyFrame->new(); $frame->Show( 1 ); } package MyWxVListBox; use base qw(Wx::PlVListBox); use Wx; sub new { my( $class, @args ) = @_; my $self = $class->SUPER::new( @args ); $self->SetItemCount( 10 ); return $self; } sub OnDrawItem { my( $self, $dc, $rect, $item ) = @_; print "Drawing item\n"; $dc->DrawText( $item, $rect->x + 1, $rect->y + 1); } sub OnMeasureItem { my( $self, $item ) = @_; return 20; } package main; my $app = MyApp->new(); $app->MainLoop;