blib/lib/ChordPro/Wx/RenderDialog.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 77 CC 3 SCAR 11.2
CC
3
Cov
0%
new
6.0
OnAccept
6.0
refresh
2.0
CRAP 3.1
1 #! perl
2  
3 use strict;
4 use warnings;
5 use utf8;
6  
7 package ChordPro::Wx::RenderDialog;
8  
9 use parent qw( ChordPro::Wx::RenderDialog_wxg );
10  
11 use Wx qw[:everything];
12 use Wx::Locale gettext => '_T';
13 use ChordPro::Wx::Config;
14 use ChordPro::Wx::Utils;
15  
16 sub new {
17 my $self = shift->SUPER::new(@_);
18  
19 if ( %{$state{presets}{tasks}} ) {
20 $self->{l_customtasks}->Show(1);
21 my $index = 0;
22 for my $task ( sort keys %{$state{presets}{tasks}} ) {
23 my $id = Wx::NewId();
24 $self->{sz_customtasks}->Add
25 ( $self->{"cb_customtask_$index"} = Wx::CheckBox->new
26 ($self, $id, $state{presets}{tasks}{$task}->{title} ),
27 0, 0, 0 );
28 $index++;
29 }
30 $self->{sz_customtasks}->Layout;
31 $self->{sz_prefs_inner}->Fit($self);
32 }
33 $state{"xpose_$_"} ||= 0
34 for qw( enabled semitones accidentals );
35  
36 $self->refresh;
37 $self;
38 }
39  
40 sub refresh {
41 my ( $self ) = @_;
42 $self->{cb_xpose}->SetValue( $state{xpose_enabled} );
43 $self->OnCbTranspose(undef);
44 }
45  
46 ################ Event handlers ################
47  
48 sub OnAccept {
49 my ( $self, $event ) = @_;
50 $state{xpose_enabled} = $self->{cb_xpose}->IsChecked;
51 $state{xpose_semitones} = $self->{sp_xpose}->GetValue
52 * ( $self->{ch_xpose_dir}->GetSelection ? -1 : 1 );
53 $state{xpose_accidentals} = $self->{ch_acc}->GetSelection;
54 $event->Skip;
55 }
56  
57 sub OnCancel {
58 my ( $self, $event ) = @_;
59 $event->Skip;
60 }
61  
62 sub OnCbTranspose {
63 my ( $self, $event ) = @_;
64 my $n = $self->{cb_xpose}->IsChecked;
65 $self->{$_}->Enable($n)
66 for qw ( sp_xpose ch_xpose_dir ch_acc );
67 }
68  
69 1;