line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12014
|
use v5.6; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
15
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
4
|
use Tie::Scalar; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
794
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Tie::Wx::Widget; |
7
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
8
|
|
|
|
|
|
|
our @ISA = 'Tie::Scalar'; |
9
|
|
|
|
|
|
|
our $complainmethod = 'die'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
50
|
33
|
1
|
|
20
|
sub import { $complainmethod = 'warn_mode' if defined $_[1] and $_[1] eq 'warn'} |
12
|
0
|
|
|
0
|
0
|
|
sub die_mode { $complainmethod = 'die'} |
13
|
0
|
|
|
0
|
0
|
|
sub warn_mode{ $complainmethod = 'warn'} |
14
|
0
|
0
|
|
0
|
0
|
|
sub complain { $complainmethod eq 'die' ? die $_[0] : warn $_[0] } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub TIESCALAR { |
17
|
0
|
|
|
0
|
|
|
my ($self, $widget, $store, $fetch) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
0
|
|
|
|
if (not ref $widget) {complain("$widget isn't even a referece, has to a Wx object")} |
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
elsif (index($widget, '=') == -1) {complain("$widget isn't even an object, has to a Wx object")} |
21
|
0
|
|
|
|
|
|
elsif (not $widget->isa('Wx::Control')) {complain("$widget is no Wx widget")} |
22
|
0
|
|
|
|
|
|
elsif (not $widget->can('GetValue')) {complain("$widget has no method: GetValue")} |
23
|
0
|
|
|
|
|
|
elsif (not $widget->can('SetValue')) {complain("$widget has no method: SetValue")} |
24
|
0
|
|
|
|
|
|
elsif (defined $store and ref $store ne 'CODE'){complain("no coderef as STORE callback")} |
25
|
|
|
|
|
|
|
elsif (defined $fetch and ref $fetch ne 'CODE'){complain("no coderef as FETCH callback")} |
26
|
|
|
|
|
|
|
else { |
27
|
0
|
|
|
|
|
|
my %hash = ('w' => $widget, 'widget' => $widget); |
28
|
0
|
0
|
|
|
|
|
$hash{'store'} = $store if defined $store; |
29
|
0
|
0
|
|
|
|
|
$hash{'fetch'} = $fetch if defined $fetch; |
30
|
0
|
|
|
|
|
|
return bless \%hash, $self; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
return 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub FETCH { |
35
|
0
|
0
|
|
0
|
|
|
if (exists $_[0]->{'fetch'}) { &{$_[0]->{'fetch'}}( $_[0]->{'w'} ) } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
else { return $_[0]->{'w'}->GetValue } |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
sub STORE { |
39
|
0
|
0
|
|
0
|
|
|
return 0 if ref $_[1]; |
40
|
0
|
0
|
|
|
|
|
if (exists $_[0]->{'store'}) { &{$_[0]->{'store'}}( $_[0]->{'w'}, $_[1] ) } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
else { return $_[0]->{'w'}->SetValue( $_[1] ) } |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
0
|
|
|
sub UNTIE {} # to prevent crashes if called |
44
|
0
|
|
|
0
|
|
|
sub DESTROY {} # to prevent crashes if called |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
'one'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |