#!/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.10

=cut

=head1 SYNOPSIS

    PerlAPP / PDK assistant

    At the start of your script ...
    
    #!c:/path/to/perl.exe
    use Wx::Perl::Packager;
    .....
    
    or if you use threads with your application
    #!c:/path/to/perl.exe
    use threads;
    use threads::shared;
    use Wx::Perl::Packager;
    
    Wx::Perl::Packager must be loaded before any part of Wx so should appear at the
    top of your main script. If you load any part of Wx in a BEGIN block, then you
    must load Wx::Perl::Packager before it in your first BEGIN block. This may cause
    you problems if you use threads within your Wx application. The threads
    documentation advises against loading threads in a BEGIN block - so don't do it.

    Then to start perlapp run 'wxpdk'

=cut

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

my $VERSION = 0.10;

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__


