File Coverage

blib/lib/Wx/DemoModules/wxFileDialog.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             #############################################################################
2             ## Name: lib/Wx/DemoModules/wxFileDialog.pm
3             ## Purpose: wxPerl demo helper for Wx::FileDialog
4             ## Author: Mattia Barbon
5             ## Modified by:
6             ## Created: 11/02/2001
7             ## RCS-ID: $Id: wxFileDialog.pm 2189 2007-08-21 18:15:31Z mbarbon $
8             ## Copyright: (c) 2001, 2003, 2006 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::wxFileDialog;
14              
15 1     1   1278 use strict;
  1         3  
  1         33  
16 1     1   5 use base qw(Wx::DemoModules::lib::BaseModule Class::Accessor::Fast);
  1         2  
  1         682  
17              
18             use Wx qw(:id :filedialog);
19              
20             __PACKAGE__->mk_accessors( qw(previous_directory previous_file) );
21              
22             sub commands {
23             my( $self ) = @_;
24              
25             return ( { label => 'File dialog',
26             action => \&file_dialog,
27             },
28             );
29             }
30              
31             sub file_dialog {
32             my( $self ) = @_;
33             my $dialog = Wx::FileDialog->new
34             ( $self, "Select a file", $self->previous_directory || '',
35             $self->previous_file || '',
36             ( join '|', 'BMP files (*.bmp)|*.bmp', 'Text files (*.txt)|*.txt',
37             'Foo files (*.foo)|*.foo', 'All files (*.*)|*.*' ),
38             wxFD_OPEN|wxFD_MULTIPLE );
39              
40             if( $dialog->ShowModal == wxID_CANCEL ) {
41             Wx::LogMessage( "User cancelled the dialog" );
42             } else {
43             Wx::LogMessage( "Wildcard: %s", $dialog->GetWildcard);
44             my @paths = $dialog->GetPaths;
45              
46             if( @paths > 0 ) {
47             Wx::LogMessage( "File: $_" ) foreach @paths;
48             } else {
49             Wx::LogMessage( "No files" );
50             }
51              
52             $self->previous_directory( $dialog->GetDirectory );
53             }
54              
55             $dialog->Destroy;
56             }
57              
58             sub add_to_tags { qw(dialogs) }
59             sub title { 'wxFileDialog' }
60              
61             1;