I tried ActiveState Perl build 817, with wxPerl from
http://www.gigi.co.uk/ppms/Wx-UNICODE.ppd /
http://www.gigi.co.uk/ppms/Wx-ANSI.ppd
The behaviour is the same :(
Then I recompiled: Perl from AP817, wxWidgets (2.6.3) from CVS, wxPerl (0.28)
from CVS (UNICODE build). The same result :(
After that, looking at listctrl sample from wxWidgets, I noticed that, for
getting the width of a column in dragging events, can be used
$event->GetItem->GetWidth
or
$this->GetColumnWidth($event->GetColumn)
I don't know how this behaves on Windows XP, but on Windows 2003 SP1 I can get
the real size after the drag operation only with $event->GetItem->GetWidth;
this is for all combination of wxWidgets / wxPerl I have tried, even with
only wxWidgets (listctrl sample, see above).
If $this->GetColumnWidth($event->GetColumn) is working in other windows'es (XP
Prof SP2), then I guess is related to another version of comctl32.dll
(perhaps less buggier ?)
On Linux, it seems that the situation is inversed: I can get the width only
with $this->GetColumnWidth($event->GetColumn), $event->GetItem->GetWidth
returning 0 (I'm using Perl 5.8.7, wxGTK 2.6.2, wxPerl 0.27, Gentoo Linux).
So, because I need to know cols dimension in a ListCtrl after drag-header
operations, for resizing consequently others controls on page, I ended with
next workaround for OnColEndDrag sub:
#-------- code -------------
#...
sub OnColEndDrag {
my ( $this, $event ) = @_;
my $col = $event->GetColumn;
my $item = $event->GetItem;
#print "\tend drag col: $col - column size: " .
#$this->GetColumnWidth($col) . "; item size: " . $item->GetWidth .
#"\n\n";
if (Wx::wxMSW) {
$this->GetParent->resize_reditor( $col, $item->GetWidth );
}
else { # wxGTK (and others ???)
$this->GetParent->resize_reditor( $col, $this->GetColumnWidth($col) );
}
$event->Skip;
}
#...
#-------- code -------------
Thanks,
Lucian Dragus
> #-------- code -------------
>
> use strict;
> use Wx;
>
> package MyFrame;
> use base qw(Wx::Frame);
> use Wx qw(wxVERTICAL wxTOP wxLIST_FORMAT_LEFT wxLIST_FORMAT_RIGHT
> wxRIGHT wxLEFT
> wxEXPAND wxBOTTOM wxADJUST_MINSIZE );
>
> sub new{
> if(not exists $_[4]){ $_[4] = [1,1];}
> if(not exists $_[5]){ $_[5] = [515,445];}
> my( $this ) = shift->SUPER::new( @_ );
> $this->{lvwMain} = MYListview->new($this,-1,[3,3],[20,20]);
> $this->{lvwMain}->Show(1);
> $this->{szvMain} = Wx::BoxSizer->new(wxVERTICAL);
>
>
> $this->{szvMain}->Add($this->{lvwMain},1,wxTOP|wxLEFT|wxBOTTOM|wxRIGHT|wxEX
>PAND|wxADJUST_MINSIZE,0); $this->SetSizer($this->{szvMain});
> $this->SetAutoLayout(1);
> $this->Layout();
> $this->Refresh();
> $this->{lvwMain}->ClearAll;
> $this->{lvwMain}->InsertColumn( 0, "First Column",
> wxLIST_FORMAT_LEFT, 100 );
> $this->{lvwMain}->InsertColumn( 1, "Second Column",
> wxLIST_FORMAT_LEFT, 100 );
> $this->{lvwMain}->InsertColumn( 2, "Third Column",
> wxLIST_FORMAT_LEFT, 100 );
> $this->Centre();
> return $this;
> }
>
>
> package MYListview;
> use base qw(Wx::ListCtrl);
> use Wx qw(wxLC_REPORT );
> use Wx::Event qw(EVT_LIST_COL_END_DRAG EVT_LIST_COL_BEGIN_DRAG );
>
> sub new{
> if(not exists $_[3]){ $_[3] = [0,0];}
> if(not exists $_[4]){ $_[4] = [416,296];}
> if(not exists $_[5]){ $_[5] = wxLC_REPORT;}
> my( $this ) = shift->SUPER::new( @_ );
>
> EVT_LIST_COL_BEGIN_DRAG($this,$this,\&OnListColBeginDrag);
> EVT_LIST_COL_END_DRAG($this,$this,\&OnListColEndDrag);
>
> $this->Refresh();
> return $this;
> }
>
> sub OnListColEndDrag{
> my( $this,$event) = @_;
> my $col = $event->GetColumn;
> print "\tend drag col: $col - size: " . $this->GetColumnWidth($col)
> . "\n\n";
> $event->Skip;
>
> }
>
> sub OnListColBeginDrag{
> my( $this,$event) = @_;
> my $col = $event->GetColumn;
> print "\tbegin drag col: $col - size: " . $this->GetColumnWidth($col)
> . "\n";
> $event->Skip;
> }
>
> package MyApp;
>
> use base qw(Wx::App);
>
> sub OnInit {
> Wx::InitAllImageHandlers();
> my( $this ) = shift;
> my( $frame ) = MyFrame->new(undef, -1);
> $frame->Show(1);
> return 1;
> }
>
>
> package main;
>
> my( $app ) = MyApp->new();
> $app->MainLoop();
>
> #------------------ the end --------------------
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
|