#!/usr/bin/perl

############################################################
#
# Simple assistant for use with wxPerl and PerlApp / PDK
#
# Copyright (c) 2006 Mark Dootson mdootson@cpan.org
#
############################################################

package PDKHelper;

=head1 NAME

wxpdk

=head1 VERSION

Version 0.09

=cut

=head1 SYNOPSIS

    PerlAPP / PDK assistant

    At the start of your script ...

    #!c:path/to/perl.exe
    BEGIN { use Wx::Perl::Packager; }
    .....

    Then to start perlapp run 'wxpdk'
    
    
=head1 DESCRIPTION

    A module to assist packaging Wx based applications with PAR, 
    ActiveState PerlApp / PDK and Perl2Exe. All that is needed is 
    that you include a 'use' statement as the first item in your 
    BEGIN blocks. For Perl2Exe, an additional 'use' statement 
    outside any BEGIN block ensures correct object cleanup.
    
    Also provided are:
    
    wxpdk
    wxpar
        
    which assist in packaging the wxWidgets DLLs. 
    

=cut

use strict;
use Wx qw( :everything );
use base 'Wx::App';

sub OnInit {
  my( $this ) = shift;
  $this->{_pdkexe} = undef;
  $this->{_pdkparams} = undef;
  require Wx::Perl::Packager::PDKWindow;
  Wx::InitAllImageHandlers();
  my( $mainwindow ) = Wx::Perl::Packager::PDKWindow->new(undef, -1);
  $this->SetTopWindow($mainwindow);
  $mainwindow->Show(1);
  return 1;
}

sub PDKExec {
    my $this = shift;
    if(@_) { $this->{_pdkexe} = shift; }
    return $this->{_pdkexe};
}

sub PDKParams {
    my $this = shift;
    if(@_) { $this->{_pdkparams} = shift; }
    return $this->{_pdkparams};
}


package main;

if( $^O !~ /^MSWin/ ) { die qq(This version of wxpdk only supports MSWin); }

my( $app ) = PDKHelper->new();
$app->MainLoop();

my $pdkexec = $app->PDKExec();
my $pdkparams = $app->PDKParams();

if($pdkexec) {
    print qq(Running $pdkexec $pdkparams ....\n\n);
    system($pdkexec, $pdkparams);
}


1;

__END__


