line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::GUI::button; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4720
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
HTML::GUI::button - Create and control a button 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
|
|
620
|
use HTML::GUI::input; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @ISA = qw(HTML::GUI::input); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 BUTTON |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The button widget is the specialisation of the input |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 PUBLIC ATTRIBUTES |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
#array of string : list of all specifric public properties of the widget |
35
|
|
|
|
|
|
|
my @GHW_publicPropList = qw/nextScreen btnAction/; |
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} = "button"; |
55
|
|
|
|
|
|
|
my $this = $class->SUPER::new($params); |
56
|
|
|
|
|
|
|
if (!$this){ |
57
|
|
|
|
|
|
|
return undef; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
#default value, means we stay on the |
60
|
|
|
|
|
|
|
#same screen |
61
|
|
|
|
|
|
|
$this->{nextScreen} = ''; |
62
|
|
|
|
|
|
|
#by default, no work to do |
63
|
|
|
|
|
|
|
$this->{btnAction} = ''; |
64
|
|
|
|
|
|
|
$this->{btnActionFunc} = undef; |
65
|
|
|
|
|
|
|
bless($this, $class); |
66
|
|
|
|
|
|
|
if (exists $params->{nextScreen}){ |
67
|
|
|
|
|
|
|
$this->setProp({'nextScreen',$params->{nextScreen}}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
if (exists $params->{btnAction}){ |
70
|
|
|
|
|
|
|
$this->setProp({'btnAction',$params->{btnAction}}); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
return $this; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head3 setProp |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Description : |
82
|
|
|
|
|
|
|
specialized version of widget::setProp for managing |
83
|
|
|
|
|
|
|
functions associated qith the button |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
sub setProp |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
my($self, |
89
|
|
|
|
|
|
|
$params, # hash ref : defines params value |
90
|
|
|
|
|
|
|
) = @_; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if (exists $params->{btnAction} |
93
|
|
|
|
|
|
|
&& $params->{btnAction}){ |
94
|
|
|
|
|
|
|
my $functionRef = $self->getFunctionFromName($params->{btnAction}); |
95
|
|
|
|
|
|
|
if ($functionRef){ |
96
|
|
|
|
|
|
|
$self->{btnActionFunc} = $functionRef; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
$self->SUPER::setProp($params); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 getPubPropHash |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns : |
105
|
|
|
|
|
|
|
propHash : hash : a hash containing the value '1' pour each public propertie |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $pubPropHash = undef; |
111
|
|
|
|
|
|
|
sub getPubPropHash |
112
|
|
|
|
|
|
|
{ |
113
|
|
|
|
|
|
|
my($self) = @_; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return $pubPropHash if (defined $pubPropHash); |
116
|
|
|
|
|
|
|
my $widgetPropRef = $self->SUPER::getPubPropHash(); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#we want a deep copy of the hash |
119
|
|
|
|
|
|
|
my %btnProp = %$widgetPropRef; |
120
|
|
|
|
|
|
|
$btnProp{nextScreen} = 1; |
121
|
|
|
|
|
|
|
$btnProp{btnAction} = 1; |
122
|
|
|
|
|
|
|
$btnProp{btnActionFunc} = 1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$pubPropHash = \%btnProp; |
125
|
|
|
|
|
|
|
return $pubPropHash; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=pod |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head3 getDefinitionData |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This method is the specialisation of the widget.pm method, refer to the widget.pm manual for more information. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub getDefinitionData($) |
137
|
|
|
|
|
|
|
{ |
138
|
|
|
|
|
|
|
my ($self) = @_; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $publicProperties = $self->SUPER::getDefinitionData(); |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
return $self->SUPER::getDefinitionData($publicProperties, |
143
|
|
|
|
|
|
|
undef,\@GHW_publicPropList); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=pod |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head3 setLabel |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Parameters : |
151
|
|
|
|
|
|
|
The new label of the button |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Return : |
154
|
|
|
|
|
|
|
nothing |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Description : |
157
|
|
|
|
|
|
|
The label of a button is also it's value |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub setLabel |
162
|
|
|
|
|
|
|
{ |
163
|
|
|
|
|
|
|
my($self,$newValue) = @_; |
164
|
|
|
|
|
|
|
$self->setValue($newValue); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=pod |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head3 getHtml |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Description : |
172
|
|
|
|
|
|
|
Return the html of the widget. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub getHtml |
177
|
|
|
|
|
|
|
{ |
178
|
|
|
|
|
|
|
my($self) = @_; |
179
|
|
|
|
|
|
|
my %tagProp=(); |
180
|
|
|
|
|
|
|
my %styleProp=(); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
if (exists $self->{display} && 0==$self->{display}){ |
184
|
|
|
|
|
|
|
$styleProp{display} = 'none'; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
$tagProp{style} = $self->getStyleContent(\%styleProp); |
188
|
|
|
|
|
|
|
$tagProp{type} = 'submit'; |
189
|
|
|
|
|
|
|
$tagProp{name} = $tagProp{id} = $self->{id}; |
190
|
|
|
|
|
|
|
$tagProp{value} = $self->getValue(); |
191
|
|
|
|
|
|
|
$tagProp{class} = 'btn'; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
return $self->getHtmlTag("input", \%tagProp) ; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head3 fired |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Parameters : |
199
|
|
|
|
|
|
|
$params : the hash ref containing the POST key-value pairs. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Decription : |
202
|
|
|
|
|
|
|
Return TRUE if the current button was fired by the user |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Returns : |
205
|
|
|
|
|
|
|
- 1 if the current button was fired |
206
|
|
|
|
|
|
|
- 0 otherwise |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
209
|
|
|
|
|
|
|
sub fired |
210
|
|
|
|
|
|
|
{ |
211
|
|
|
|
|
|
|
my($self,$params) = @_; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
my $id = $self->getId(); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
if (exists $params->{$id} && defined $params->{$id}){ |
216
|
|
|
|
|
|
|
return 1; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
return 0; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 AUTHOR |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Jean-Christian Hassler, C<< >> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 BUGS |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
228
|
|
|
|
|
|
|
C, or through the web interface at |
229
|
|
|
|
|
|
|
L. |
230
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
231
|
|
|
|
|
|
|
your bug as I make changes. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 SUPPORT |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
perldoc HTML::GUI::widget |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
You can also look for information at: |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * CPAN Ratings |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * Search CPAN |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=back |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Copyright 2007 Jean-Christian Hassler, all rights reserved. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
268
|
|
|
|
|
|
|
under the same terms as Perl itself. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
1; # End of HTML::GUI::button |