| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ############################################################################# | 
| 2 |  |  |  |  |  |  | ## Name:        lib/Wx/DemoModules/wxProgressDialog.pm | 
| 3 |  |  |  |  |  |  | ## Purpose:     wxPerl demo helper for Wx::ProgressDialog | 
| 4 |  |  |  |  |  |  | ## Author:      Mattia Barbon | 
| 5 |  |  |  |  |  |  | ## Modified by: | 
| 6 |  |  |  |  |  |  | ## Created:     28/08/2002 | 
| 7 |  |  |  |  |  |  | ## RCS-ID:      $Id: wxProgressDialog.pm 3488 2013-04-16 22:02:47Z mdootson $ | 
| 8 |  |  |  |  |  |  | ## Copyright:   (c) 2002, 2005-2006, 2013 Mattia Barbon | 
| 9 |  |  |  |  |  |  | ## Licence:     This program is free software; you can redistribute it and/or | 
| 10 |  |  |  |  |  |  | ##              modify it under the same terms as Perl itself | 
| 11 |  |  |  |  |  |  | ############################################################################# | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | package Wx::DemoModules::wxProgressDialog; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 |  |  | 1 |  | 1350 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 44 |  | 
| 16 | 1 |  |  | 1 |  | 6 | use base qw(Wx::Panel Class::Accessor::Fast); | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 721 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | use Wx qw(:progressdialog); | 
| 19 |  |  |  |  |  |  | use Wx::Event qw(EVT_BUTTON); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | __PACKAGE__->mk_ro_accessors( qw(max_progress) ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | my $ver29 = ( $Wx::wxVERSION >= 2.009001 ); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub new { | 
| 27 |  |  |  |  |  |  | my( $class, $parent ) = @_; | 
| 28 |  |  |  |  |  |  | my $self = $class->SUPER::new( $parent ); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | my $progress = Wx::Button->new( $self, -1, 'Progress dialog', | 
| 31 |  |  |  |  |  |  | [ 100, 10 ] ); | 
| 32 |  |  |  |  |  |  | $self->{max_progress} = Wx::TextCtrl->new( $self, -1, 20, [10, 10] ); | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | EVT_BUTTON( $self, $progress, \&on_progress ); | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | return $self; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub on_progress { | 
| 40 |  |  |  |  |  |  | my( $self, $event ) = @_; | 
| 41 |  |  |  |  |  |  | my( $max ) = $self->max_progress->GetValue; | 
| 42 |  |  |  |  |  |  | my $flags = wxPD_CAN_ABORT|wxPD_AUTO_HIDE|wxPD_APP_MODAL|wxPD_ELAPSED_TIME| | 
| 43 |  |  |  |  |  |  | wxPD_ESTIMATED_TIME|wxPD_REMAINING_TIME; | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | my $ver30 = ( $Wx::wxVERSION >= 2.009001 ); | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | if( $ver30 ) { | 
| 48 |  |  |  |  |  |  | $flags |= wxPD_CAN_SKIP; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | my $dialog = Wx::ProgressDialog->new( 'Progress dialog example', | 
| 52 |  |  |  |  |  |  | 'An informative message', | 
| 53 |  |  |  |  |  |  | $max, $self, $flags ); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | my $continue; | 
| 56 |  |  |  |  |  |  | foreach my $i ( 1 .. $max ) { | 
| 57 |  |  |  |  |  |  | sleep 1; | 
| 58 |  |  |  |  |  |  | if( $i == $max ) { | 
| 59 |  |  |  |  |  |  | $continue = $dialog->Update( $i, "That's all, folks!" ); | 
| 60 |  |  |  |  |  |  | } elsif( $i == int( $max / 2 ) ) { | 
| 61 |  |  |  |  |  |  | $continue = $dialog->Update( $i, "Only a half left" ); | 
| 62 |  |  |  |  |  |  | } else { | 
| 63 |  |  |  |  |  |  | $continue = $dialog->Update( $i ); | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  | last unless $continue; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | unless( $continue ) { | 
| 68 |  |  |  |  |  |  | if($ver30) { | 
| 69 |  |  |  |  |  |  | my $reason = ( $dialog->WasCancelled ) ? 'Cancelled' : 'Skipped'; | 
| 70 |  |  |  |  |  |  | my $remains = $dialog->GetValue; | 
| 71 |  |  |  |  |  |  | Wx::LogMessage(qq(User $reason Progress Dialog with value at $remains)); | 
| 72 |  |  |  |  |  |  | } else { | 
| 73 |  |  |  |  |  |  | Wx::LogMessage(qq(User Cancelled Progress Dialog)); | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  | } else { | 
| 76 |  |  |  |  |  |  | Wx::LogMessage( qq(Countdown from $max completed)); | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | $dialog->Destroy; | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | sub add_to_tags { qw(dialogs) } | 
| 85 |  |  |  |  |  |  | sub title { 'wxProgressDialog' } | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | 1; |