Please take our Survey
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: wxPliGuard kills my events: msg#00020

lang.perl.wxperl

Subject: Re: wxPliGuard kills my events

Simon Flack wrote:
I've attached a script that crashes on 0.22 but works on 0.19 and my bastardised 0.22. It requires Wx::Perl::VirtualTreeControl which is also attached. It's due for a CPAN release soon-ish (just waiting for work to sign it off).

To get crashtest.pl working, remove line 9 ("use IFL::FileIO") or use the version attached to this message.

--simonflk
#!/usr/bin/perl
# "wxPliGuard kills my events"
use strict;
use Cwd;
use Wx ':misc';
use Wx::Perl::VirtualTreeCtrl 'EVT_POPULATE_TREE_ITEM';
sub Wx::App::OnInit {1}
use File::Spec::Functions 'catfile';

# Standard stuff
my $app = Wx::App->new();
my $frame = Wx::Frame->new(undef, -1, "Events Crash Test");
$app->SetTopWindow($frame);
$frame->Show(1);

# custom control (a lazy tree control)
my $tree = Wx::Perl::VirtualTreeCtrl->new(
$frame, -1, wxDefaultPosition, [300,180]
);
$frame->SetClientSize($tree->GetSize);
my $root = $tree->AddRoot(cwd());
$tree->SetPlData($root, cwd());
$tree->SetItemHasChildren($root, 1);

# event fired when branches are expanded
EVT_POPULATE_TREE_ITEM($frame, $tree, \&onPopulateTree);
$tree->Expand($tree->GetRootItem);

# Go
$tree->SetFocus;
exit $app->MainLoop();

sub onPopulateTree {
my ($frame, $event) = @_;
my $tree = $event->GetEventObject;
my $parent = $event->GetItem;
return if $parent == -1 || !$parent->IsOk;
my $parent_folder = $tree->GetTree->GetPlData($parent);
TRACE("Expanding item: $parent_folder");

my $child = $tree->GetFirstChild($parent);
if ($child && $child != -1) {
TRACE("$parent_folder already has children, could update here")
} else {
local *DIR;
opendir DIR, $parent_folder or return;
my @dirs = grep {! /^\.\.?$/ && -d catfile($parent_folder, $_)}
readdir DIR;
closedir DIR;
TRACE("Adding " . scalar(@dirs) . " directories below $parent_folder");

foreach (@dirs) {
TRACE("\tAdding $_");
my $this_folder = catfile($parent_folder, $_);
$child = $tree->AppendItem($parent, $_, 0, 0);
$tree->SetPlData($child, $this_folder);
$tree->SetItemImage($child, 0);
$tree->SetItemHasChildren($child, 1); # let item be expanded
}
}
$event->Skip;
}

sub TRACE { 1 && print "@_\n" }
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | 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

Navigation