line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxSingleChoiceDialog.pm |
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for Wx::SingleChoiceDialog |
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 11/02/2001 |
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxSingleChoiceDialog.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::wxSingleChoiceDialog; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1420
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
16
|
1
|
|
|
1
|
|
6
|
use base qw(Wx::DemoModules::lib::BaseModule Class::Accessor::Fast); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
130
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Wx qw(:id); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub commands { |
21
|
|
|
|
|
|
|
my( $self ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return ( { label => 'Single choice dialog', |
24
|
|
|
|
|
|
|
action => \&single_choice_dialog, |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
{ label => 'Get single choice (index)', |
27
|
|
|
|
|
|
|
action => \&get_single_choice_index, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
{ label => 'Get single choice (string)', |
30
|
|
|
|
|
|
|
action => \&get_single_choice_string, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
{ label => 'Get single choice (data)', |
33
|
|
|
|
|
|
|
action => \&get_single_choice_data, |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $choices = [ 'Apple', 'Orange', 'Banana', 'Pear', 'Cranberry' ]; |
39
|
|
|
|
|
|
|
my $data = [ '1 - apple', '2 - orange', '3 - banana', '4 - pear', |
40
|
|
|
|
|
|
|
'5 - cranberry' ]; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_single_choice_string { |
43
|
|
|
|
|
|
|
my( $self ) = @_; |
44
|
|
|
|
|
|
|
my $string = Wx::GetSingleChoice( 'Make a choice', 'Choose', |
45
|
|
|
|
|
|
|
$choices, $self ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Wx::LogMessage( "The choice is: '%s'", $string ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub get_single_choice_index { |
51
|
|
|
|
|
|
|
my( $self ) = @_; |
52
|
|
|
|
|
|
|
my $index = Wx::GetSingleChoiceIndex( 'Make a choice', 'Choose', |
53
|
|
|
|
|
|
|
$choices, $self ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Wx::LogMessage( "The choice is: %d", $index ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get_single_choice_data { |
59
|
|
|
|
|
|
|
my( $self ) = @_; |
60
|
|
|
|
|
|
|
my $clientdata = Wx::GetSingleChoiceData( 'Make a choice', 'Choose', |
61
|
|
|
|
|
|
|
$choices, $data, $self ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Wx::LogMessage( "The choice is: '%s'", $clientdata ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub single_choice_dialog { |
67
|
|
|
|
|
|
|
my( $this ) = @_; |
68
|
|
|
|
|
|
|
my $dialog = Wx::SingleChoiceDialog->new |
69
|
|
|
|
|
|
|
( $this, "Make a choice", "Choose", $choices, $data ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if( $dialog->ShowModal == wxID_CANCEL ) { |
72
|
|
|
|
|
|
|
Wx::LogMessage( "User cancelled the dialog" ); |
73
|
|
|
|
|
|
|
} else { |
74
|
|
|
|
|
|
|
Wx::LogMessage( "Selection: %d", $dialog->GetSelection ); |
75
|
|
|
|
|
|
|
Wx::LogMessage( "String: %s", $dialog->GetStringSelection ); |
76
|
|
|
|
|
|
|
Wx::LogMessage( "Client data: %s", $dialog->GetSelectionClientData ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$dialog->Destroy; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub add_to_tags { qw(dialogs) } |
83
|
|
|
|
|
|
|
sub title { 'wxSingleChoiceDialog' } |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |