line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/wxBitmapButton.pm |
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper for Wx::BitmapButton |
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 13/08/2006 |
7
|
|
|
|
|
|
|
## RCS-ID: $Id: wxBitmapButton.pm 2189 2007-08-21 18:15:31Z mbarbon $ |
8
|
|
|
|
|
|
|
## Copyright: (c) 2000, 2003, 2005-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::wxBitmapButton; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1357
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
16
|
1
|
|
|
1
|
|
5
|
use base qw(Wx::DemoModules::lib::BaseModule Class::Accessor::Fast); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
131
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Wx qw(:icon wxTheApp wxNullBitmap); |
19
|
|
|
|
|
|
|
use Wx::Event qw(EVT_BUTTON); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(button) ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub commands { |
24
|
|
|
|
|
|
|
my( $self ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $bmp1 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_INFORMATION ) ); |
27
|
|
|
|
|
|
|
my $bmp2 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_WARNING ) ); |
28
|
|
|
|
|
|
|
my $bmp3 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_QUESTION ) ); |
29
|
|
|
|
|
|
|
my $null = wxNullBitmap; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return ( { label => 'Clear bitmap', |
32
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapLabel( $null ) }, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
{ label => 'Set bitmap', |
35
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapLabel( $bmp1 ) }, |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
{ label => 'Clear selected bitmap', |
38
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapSelected( $null ) }, |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
{ label => 'Set selected bitmap', |
41
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapSelected( $bmp2 ) }, |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
{ label => 'Clear focus bitmap', |
44
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapFocus( $null ) }, |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
{ label => 'Set focus bitmap', |
47
|
|
|
|
|
|
|
action => sub { $self->button->SetBitmapFocus( $bmp3 ) }, |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub create_control { |
53
|
|
|
|
|
|
|
my( $self ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $bmp1 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_INFORMATION ) ); |
56
|
|
|
|
|
|
|
my $bmp2 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_WARNING ) ); |
57
|
|
|
|
|
|
|
my $bmp3 = Wx::Bitmap->new( wxTheApp->GetStdIcon( wxICON_QUESTION ) ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $button = Wx::BitmapButton->new( $self, -1, $bmp1, [-1, -1] ); |
60
|
|
|
|
|
|
|
$button->SetBitmapSelected( $bmp2 ); |
61
|
|
|
|
|
|
|
$button->SetBitmapFocus( $bmp3 ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
EVT_BUTTON( $self, $button, \&on_click ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return $self->button( $button ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub on_click { |
69
|
|
|
|
|
|
|
my( $self, $event ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Wx::LogMessage( 'Button clicked' ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub add_to_tags { qw(controls) } |
75
|
|
|
|
|
|
|
sub title { 'wxBitmapButton' } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |