line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UI::Various::Check; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Author, Copyright and License: see end of file |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UI::Various::Check - general checkbox widget of L |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use UI::Various; |
12
|
|
|
|
|
|
|
my $main = UI::Various::main(); |
13
|
|
|
|
|
|
|
my $variable = 0; |
14
|
|
|
|
|
|
|
$main->window(... |
15
|
|
|
|
|
|
|
UI::Various::Check->new(text => 'special mode', |
16
|
|
|
|
|
|
|
var => \$variable), |
17
|
|
|
|
|
|
|
...); |
18
|
|
|
|
|
|
|
$main->mainloop(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 ABSTRACT |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This module defines the general checkbox widget of an application using |
23
|
|
|
|
|
|
|
L. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Besides the common attributes inherited from C the |
28
|
|
|
|
|
|
|
C widget knows only two additional attributes: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 Attributes |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
######################################################################### |
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
8
|
|
78
|
use v5.14; |
|
8
|
|
|
|
|
19
|
|
39
|
8
|
|
|
8
|
|
55
|
use strictures; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
34
|
|
40
|
8
|
|
|
8
|
|
1115
|
no indirect 'fatal'; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
53
|
|
41
|
8
|
|
|
8
|
|
399
|
no multidimensional; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
32
|
|
42
|
8
|
|
|
8
|
|
596
|
use warnings 'once'; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
419
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
45
|
|
|
|
|
|
|
|
46
|
8
|
|
|
8
|
|
42
|
use UI::Various::core; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
41
|
|
47
|
8
|
|
|
8
|
|
42
|
use UI::Various::widget; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
487
|
|
48
|
8
|
|
|
8
|
|
68
|
BEGIN { require 'UI/Various/' . UI::Various::core::using() . '/Check.pm'; } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
require Exporter; |
51
|
|
|
|
|
|
|
our @ISA = qw(UI::Various::widget); |
52
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
######################################################################### |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item text [rw, fixed, recommended] |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
the text as string or variable reference |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Note that the reference will be dereferenced during initialisation. Later |
61
|
|
|
|
|
|
|
changes will be ignored, as not all possible UIs would support that change. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub text($;$) |
66
|
|
|
|
|
|
|
{ |
67
|
3
|
|
|
3
|
1
|
7
|
return access('text', undef, @_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item var [rw, recommended] |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
a variable reference for the checkbox |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The variable will switched on (C<1>) and off (C<0>) by the checkbox. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Note that the initial values for the variable will be changed to C<0> or |
77
|
|
|
|
|
|
|
C<1> according Perl's standard true/false conversions. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub var($;$) |
82
|
|
|
|
|
|
|
{ |
83
|
7
|
|
|
7
|
1
|
17
|
local $_ = access_varref('var', @_); |
84
|
7
|
100
|
100
|
|
|
30
|
defined $_[1] and ref($_[1]) eq 'SCALAR' and ${$_[1]} = ${$_[1]} ? 1 : 0; |
|
2
|
100
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
85
|
7
|
|
|
|
|
26
|
return $_; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
######################################################################### |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
# internal constants and data: |
91
|
|
|
|
|
|
|
|
92
|
8
|
|
|
|
|
664
|
use constant ALLOWED_PARAMETERS => |
93
|
8
|
|
|
8
|
|
62
|
(UI::Various::widget::COMMON_PARAMETERS, qw(text var)); |
|
8
|
|
|
|
|
13
|
|
94
|
8
|
|
|
8
|
|
45
|
use constant DEFAULT_ATTRIBUTES => (text => '', var => dummy_varref()); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
32
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
######################################################################### |
97
|
|
|
|
|
|
|
######################################################################### |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Besides the accessors (attributes) described above and by |
104
|
|
|
|
|
|
|
L and the methods |
105
|
|
|
|
|
|
|
inherited from L only the |
106
|
|
|
|
|
|
|
constructor is provided by the C class itself: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
######################################################################### |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 B - constructor |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
see L
|
115
|
|
|
|
|
|
|
constructor for UI elements> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub new($;\[@$]) |
122
|
|
|
|
|
|
|
{ |
123
|
4
|
|
|
4
|
1
|
655
|
debug(3, __PACKAGE__, '::new'); |
124
|
4
|
|
|
|
|
33
|
return construct({ DEFAULT_ATTRIBUTES }, |
125
|
|
|
|
|
|
|
'^(?:' . join('|', ALLOWED_PARAMETERS) . ')$', |
126
|
|
|
|
|
|
|
@_); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
######################################################################### |
132
|
|
|
|
|
|
|
######################################################################### |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 LICENSE |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Copyright (C) Thomas Dorner. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
143
|
|
|
|
|
|
|
under the same terms as Perl itself. See LICENSE file for more details. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Thomas Dorner Edorner (at) cpan (dot) orgE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |