logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Wx::ListCtrl, EVT_LIST_COL_END_DRAG and GetColumnWidth(): msg#00020

Subject: Re: Wx::ListCtrl, EVT_LIST_COL_END_DRAG and GetColumnWidth()
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


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
db.firebase.por...    text.xml.xalan....    qnx.openqnx.dev...    user-groups.zar...    internationaliz...    kde.devel.konve...    finance.e-gold....    emacs.latex.pre...    gis.therion/200...    web.webmin.gene...    yellowdog.gener...    vserver/2003-08...    redhat.release....    sysutils.tivoli...    xfree86.expert/...    mail.becky.user...    hardware.netapp...    netbsd.ports.xe...    python.distutil...    boot-loaders.gr...    culture.interne...    java.springfram...    activedir/2006-...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe