File Coverage

blib/lib/Wx/DemoModules/wxSpinCtrl.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/wxSpinCtrl.pm
3             ## Purpose: wxPerl demo helper for Wx::SpinCtrl
4             ## Author: Mattia Barbon
5             ## Modified by:
6             ## Created: 13/08/2006
7             ## RCS-ID: $Id: wxSpinCtrl.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::wxSpinCtrl;
14              
15 1     1   1470 use strict;
  1         2  
  1         44  
16 1     1   6 use base qw(Wx::DemoModules::lib::BaseModule Class::Accessor::Fast);
  1         2  
  1         93  
17              
18             use Wx qw(:spinctrl);
19             use Wx::Event qw(EVT_SPINCTRL EVT_SPIN EVT_SPIN_DOWN EVT_SPIN_UP);
20              
21             __PACKAGE__->mk_accessors( qw(spinctrl) );
22              
23             sub styles {
24             my( $self ) = @_;
25              
26             return ( [ wxSP_ARROW_KEYS, 'Allow arrow keys' ],
27             [ wxSP_WRAP, 'Wrap' ],
28             );
29             }
30              
31             sub commands {
32             my( $self ) = @_;
33              
34             return ( { with_value => 1,
35             label => 'Set Value',
36             action => sub { $self->spinctrl->SetValue( $_[0] ) },
37             },
38             { with_value => 2,
39             label => 'Set Range',
40             action => sub { $self->spinctrl->SetRange( $_[0], $_[1] ) },
41             },
42             );
43             }
44              
45             sub create_control {
46             my( $self ) = @_;
47              
48             my $spinctrl = Wx::SpinCtrl->new( $self, -1, 0, [-1, -1], [-1, -1],
49             $self->style );
50             $spinctrl->SetRange( 10, 30 );
51             $spinctrl->SetValue( 15 );
52              
53             EVT_SPINCTRL( $self, $spinctrl, \&OnSpinCtrl );
54              
55             return $self->spinctrl( $spinctrl );
56             }
57              
58             sub OnSpinCtrl {
59             my( $self, $event ) = @_;
60              
61             Wx::LogMessage( "Spin ctrl changed: now %d (from event %d)",
62             $self->spinctrl->GetValue,
63             $event->GetInt );
64             }
65              
66             sub add_to_tags { qw(controls) }
67             sub title { 'wxSpinCtrl' }
68              
69             1;