| 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
|
|
72
|
use v5.14; |
|
|
8
|
|
|
|
|
21
|
|
|
39
|
8
|
|
|
8
|
|
56
|
use strictures; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
33
|
|
|
40
|
8
|
|
|
8
|
|
1013
|
no indirect 'fatal'; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
27
|
|
|
41
|
8
|
|
|
8
|
|
342
|
no multidimensional; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
44
|
|
|
42
|
8
|
|
|
8
|
|
266
|
use warnings 'once'; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
353
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our $VERSION = '0.23'; |
|
45
|
|
|
|
|
|
|
|
|
46
|
8
|
|
|
8
|
|
53
|
use UI::Various::core; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
36
|
|
|
47
|
8
|
|
|
8
|
|
37
|
use UI::Various::widget; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
475
|
|
|
48
|
8
|
|
|
8
|
|
50
|
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, 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
|
6
|
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
|
18
|
local $_ = access_varref('var', @_); |
|
84
|
7
|
100
|
100
|
|
|
25
|
defined $_[1] and ref($_[1]) eq 'SCALAR' and ${$_[1]} = ${$_[1]} ? 1 : 0; |
|
|
2
|
100
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
5
|
|
|
85
|
7
|
|
|
|
|
22
|
return $_; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
######################################################################### |
|
89
|
|
|
|
|
|
|
# |
|
90
|
|
|
|
|
|
|
# internal constants and data: |
|
91
|
|
|
|
|
|
|
|
|
92
|
8
|
|
|
|
|
580
|
use constant ALLOWED_PARAMETERS => |
|
93
|
8
|
|
|
8
|
|
42
|
(UI::Various::widget::COMMON_PARAMETERS, qw(text var)); |
|
|
8
|
|
|
|
|
9
|
|
|
94
|
8
|
|
|
8
|
|
39
|
use constant DEFAULT_ATTRIBUTES => (text => '', var => dummy_varref()); |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
46
|
|
|
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
|
652
|
debug(3, __PACKAGE__, '::new'); |
|
124
|
4
|
|
|
|
|
31
|
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 |