File Coverage

blib/lib/Wx/DemoModules/wxSlider.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/wxSlider.pm
3             ## Purpose: wxPerl demo helper for Wx::Slider
4             ## Author: Mattia Barbon
5             ## Modified by:
6             ## Created: 13/08/2006
7             ## RCS-ID: $Id: wxSlider.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::wxSlider;
14              
15 1     1   1445 use strict;
  1         2  
  1         38  
16 1     1   5 use base qw(Wx::DemoModules::lib::BaseModule Class::Accessor::Fast);
  1         2  
  1         80  
17              
18             use Wx qw(:slider :font wxNOT_FOUND);
19             use Wx::Event qw(EVT_SLIDER);
20              
21             __PACKAGE__->mk_accessors( qw(slider) );
22              
23             sub styles {
24             my( $self ) = @_;
25              
26             return ( [ wxSL_HORIZONTAL, 'Horizontal' ],
27             [ wxSL_VERTICAL, 'Vertical' ],
28             [ wxSL_AUTOTICKS, 'Show ticks' ],
29             [ wxSL_LABELS, 'Show labels' ],
30             );
31             }
32              
33             sub commands {
34             my( $self ) = @_;
35              
36             return ( { with_value => 1,
37             label => 'Set Value',
38             action => sub { $self->slider->SetValue( $_[0] ) },
39             },
40             { with_value => 2,
41             label => 'Set Range',
42             action => sub { $self->slider->SetRange( $_[0], $_[1] ) },
43             },
44             );
45             }
46              
47             sub create_control {
48             my( $self ) = @_;
49              
50             my $size = [ ( $self->style & wxSL_HORIZONTAL ) ? 200 : -1,
51             ( $self->style & wxSL_VERTICAL ) ? 200 : -1 ];
52             my $slider = Wx::Slider->new( $self, -1, 0, 0, 200,
53             [-1, -1], $size,
54             $self->style );
55              
56             EVT_SLIDER( $self, $slider, \&OnSlider );
57              
58             return $self->slider( $slider );
59             }
60              
61             sub OnSlider {
62             my( $self, $event ) = @_;
63             my( $slider ) = $self->slider;
64              
65             Wx::LogMessage( join '', 'Event position: ', $event->GetInt );
66             Wx::LogMessage( join '', 'Slider position: ', $slider->GetValue );
67             }
68              
69             sub add_to_tags { qw(controls) }
70             sub title { 'wxSlider' }
71              
72             1;