line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: ProgressSplash.pm,v 1.8 2005/07/19 23:22:26 eserte Exp $ |
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (C) 2001 Slaven Rezic. All rights reserved. |
8
|
|
|
|
|
|
|
# This package is free software; you can redistribute it and/or |
9
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
12
|
|
|
|
|
|
|
# WWW: http://www.rezic.de/eserte/ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Tk::ProgressSplash; |
16
|
|
|
|
|
|
|
#use strict;use vars qw($TK_VERSION $VERSION $firstupdatetime $lastcallindex); |
17
|
|
|
|
|
|
|
$VERSION = 0.03; |
18
|
|
|
|
|
|
|
$TK_VERSION = 800 if !defined $TK_VERSION; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub Show { |
21
|
1
|
|
|
1
|
1
|
763
|
my($pkg, @args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my @splash_arguments; |
24
|
1
|
|
|
|
|
2
|
my $splashtype = 'normal'; |
25
|
1
|
|
|
|
|
7
|
for(my $i=0; $i<=$#args; $i++) { |
26
|
5
|
100
|
|
|
|
18
|
if ($args[$i] eq '-splashtype') { |
|
|
50
|
|
|
|
|
|
27
|
1
|
|
|
|
|
2
|
$splashtype = $args[$i+1]; |
28
|
1
|
|
|
|
|
3
|
$i++; |
29
|
|
|
|
|
|
|
} elsif ($args[$i] =~ /^-/) { |
30
|
0
|
|
|
|
|
0
|
die "Unrecognized option $args[$i]"; |
31
|
|
|
|
|
|
|
} else { |
32
|
4
|
|
|
|
|
11
|
push @splash_arguments, $args[$i]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
2
|
my $self = {}; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
2
|
my $Splash; |
39
|
1
|
50
|
|
|
|
3
|
if ($splashtype eq 'fast') { |
40
|
1
|
|
|
|
|
1810
|
require Tk::FastSplash; |
41
|
1
|
|
|
|
|
3
|
$Splash = 'Tk::FastSplash'; |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
0
|
require Tk::Splash; |
44
|
0
|
|
|
|
|
0
|
$Splash = 'Tk::Splash'; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
6
|
my $splash = $Splash->Show(@splash_arguments); |
48
|
|
|
|
|
|
|
# XXX if fast |
49
|
1
|
|
|
|
|
2
|
my $f_path = '.splashframe'; |
50
|
1
|
|
|
|
|
1199
|
my $f = Tk::frame($splash, $f_path, |
51
|
|
|
|
|
|
|
-height => 10, |
52
|
|
|
|
|
|
|
-bg => 'blue', |
53
|
|
|
|
|
|
|
); |
54
|
0
|
0
|
|
|
|
|
if (!ref $f) { |
55
|
|
|
|
|
|
|
# >= Tk803 |
56
|
0
|
|
|
|
|
|
$f = Tk::Widget::Widget($splash, $f); |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
$f->{'_TkValue_'} = $f_path; |
59
|
0
|
|
|
|
|
|
bless $f, 'Tk::Widget'; |
60
|
0
|
|
|
|
|
|
Tk::pack($f, -anchor => 'w'); # , -padx => 2, -pady => 2); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$splash->{ProgressFrame} = $f; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$splash; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
|
|
sub Tk::Splash::Update { Tk::ProgressSplash::Update(@_) } |
68
|
0
|
|
|
0
|
0
|
|
sub Tk::FastSplash::Update { Tk::ProgressSplash::Update(@_) } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub Update { |
71
|
0
|
|
|
0
|
1
|
|
my($w, $frac) = @_; |
72
|
0
|
|
|
|
|
|
Tk::configure($w->{ProgressFrame}, -width => $w->{ImageWidth}*$frac); |
73
|
0
|
|
|
|
|
|
Tk::update($w); |
74
|
0
|
0
|
|
|
|
|
if ($ENV{TK_SPLASH_COMPUTE}) { |
75
|
0
|
0
|
|
|
|
|
if (!defined $lastcallindex) { |
76
|
0
|
|
|
|
|
|
$lastcallindex = 0; |
77
|
0
|
|
|
|
|
|
$firstupdatetime = Tk::timeofday(); |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
|
$lastcallindex++; |
80
|
0
|
|
|
|
|
|
my $time = Tk::timeofday() - $firstupdatetime; |
81
|
0
|
|
|
|
|
|
print " $time,\t# Update $lastcallindex\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Tk::ProgressSplash - create a starting splash screen with a progress bar |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
BEGIN { |
95
|
|
|
|
|
|
|
require Tk::ProgressSplash; |
96
|
|
|
|
|
|
|
$splash = Tk::ProgressSplash->Show(-splashtype => 'fast', |
97
|
|
|
|
|
|
|
$image, $width, $height, $title, |
98
|
|
|
|
|
|
|
$overrideredirect); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
... |
101
|
|
|
|
|
|
|
use Tk; |
102
|
|
|
|
|
|
|
... |
103
|
|
|
|
|
|
|
$splash->Update(0.1) if $splash; |
104
|
|
|
|
|
|
|
... |
105
|
|
|
|
|
|
|
$splash->Update(1.0) if $splash; |
106
|
|
|
|
|
|
|
... |
107
|
|
|
|
|
|
|
$splash->Destroy if $splash; |
108
|
|
|
|
|
|
|
MainLoop; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Create a splash screen with progress bar. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item Show |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The Show() method takes the same arguments as the Show() method of |
121
|
|
|
|
|
|
|
L. Additionally you can specify: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item -splashtype |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Set to "fast" if you want to use L instead of |
128
|
|
|
|
|
|
|
L as the underlying splash widget. "normal", "safe" or |
129
|
|
|
|
|
|
|
"slow" may be used for L. Default is "normal". |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item Update |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Advance the progressbar and make it visible, if it was not yet |
136
|
|
|
|
|
|
|
visible. The argument is a floating number between 0 and 1. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item Destroy |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Destroy the splash widget. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=back |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 BUGS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
See L and L. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Slaven Rezic (slaven@rezic.de) |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SEE ALSO |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L, L. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |