| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::GUI::checkbox; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
614
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
HTML::GUI::checkbox - Create and control a checkbox input for webapp |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.01 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
459
|
use HTML::GUI::input; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @ISA = qw(HTML::GUI::input); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 CHECKBOX |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The checkbox widget is the specialisation of the input |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 PUBLIC ATTRIBUTES |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 new |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Parameters : |
|
45
|
|
|
|
|
|
|
params : widget : |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
|
|
|
|
|
|
my($class, |
|
52
|
|
|
|
|
|
|
$params, # widget : |
|
53
|
|
|
|
|
|
|
) = @_; |
|
54
|
|
|
|
|
|
|
$params->{type} = "checkbox"; |
|
55
|
|
|
|
|
|
|
my $this = $class->SUPER::new($params); |
|
56
|
|
|
|
|
|
|
if (!$this){ |
|
57
|
|
|
|
|
|
|
return undef; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
bless($this, $class); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head3 setValue |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Parameters : |
|
68
|
|
|
|
|
|
|
The new value of the checkbox value |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Return : |
|
71
|
|
|
|
|
|
|
nothing |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Description : |
|
74
|
|
|
|
|
|
|
a checkbox can only contain a boolean value 1 or 0. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub setValue |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
|
|
|
|
|
|
my($self,$newValue) = @_; |
|
81
|
|
|
|
|
|
|
$self->{value} = defined $newValue && $newValue? 1 : 0; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head3 getNudeHtml |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Description : |
|
89
|
|
|
|
|
|
|
Return the html of the widget to be inserted in a tag or a a table. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub getNudeHtml |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
|
|
|
|
|
|
my($self) = @_; |
|
96
|
|
|
|
|
|
|
my %tagProp=(); |
|
97
|
|
|
|
|
|
|
my %styleProp=(); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
if (exists $self->{display} && 0==$self->{display}){ |
|
101
|
|
|
|
|
|
|
$styleProp{display} = 'none'; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$tagProp{style} = $self->getStyleContent(\%styleProp); |
|
105
|
|
|
|
|
|
|
$tagProp{type} = 'checkbox'; |
|
106
|
|
|
|
|
|
|
$tagProp{name} = $tagProp{id} = $self->{id}; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$tagProp{class} = 'ckbx'; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#the value is not really useful for combo |
|
111
|
|
|
|
|
|
|
#so we use an arbitrary value |
|
112
|
|
|
|
|
|
|
$tagProp{value} = 'on'; |
|
113
|
|
|
|
|
|
|
#checked if the value is true |
|
114
|
|
|
|
|
|
|
if ($self->getValue()){ |
|
115
|
|
|
|
|
|
|
$tagProp{checked} = 'checked'; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
return $self->getHtmlTag("input", \%tagProp); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=pod |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 setValueFromParams |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Parameters : |
|
126
|
|
|
|
|
|
|
-params : a hash ref |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Description : |
|
129
|
|
|
|
|
|
|
look for a value coresponding to the checkbox in $params hash; |
|
130
|
|
|
|
|
|
|
if no value is found, the widget value is 0 |
|
131
|
|
|
|
|
|
|
if a value is found, the widget value is 1 |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub setValueFromParams |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
|
|
|
|
|
|
my($self,$params) = @_; |
|
138
|
|
|
|
|
|
|
my $id = $self->getId(); |
|
139
|
|
|
|
|
|
|
if (defined $params->{$id} |
|
140
|
|
|
|
|
|
|
&& $params->{$id} eq 'on'){ |
|
141
|
|
|
|
|
|
|
$self->setValue(1); |
|
142
|
|
|
|
|
|
|
}else{ |
|
143
|
|
|
|
|
|
|
$self->setValue(0); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Jean-Christian Hassler, C<< >> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 BUGS |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
154
|
|
|
|
|
|
|
C, or through the web interface at |
|
155
|
|
|
|
|
|
|
L. |
|
156
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
157
|
|
|
|
|
|
|
your bug as I make changes. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SUPPORT |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
perldoc HTML::GUI::widget |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
You can also look for information at: |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over 4 |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * Search CPAN |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Copyright 2007 Jean-Christian Hassler, all rights reserved. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
194
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; # End of HTML::GUI::checkbox |