| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
########################################## |
|
2
|
|
|
|
|
|
|
########################################## |
|
3
|
|
|
|
|
|
|
## ## |
|
4
|
|
|
|
|
|
|
## WaitBoxFixed - a reusable Tk-widget ## |
|
5
|
|
|
|
|
|
|
## Wait Dialog ## |
|
6
|
|
|
|
|
|
|
## ## |
|
7
|
|
|
|
|
|
|
## Version 1.6 ## |
|
8
|
|
|
|
|
|
|
## ## |
|
9
|
|
|
|
|
|
|
## Brent B. Powers (B2Pi) ## |
|
10
|
|
|
|
|
|
|
## Powers@B2Pi.com ## |
|
11
|
|
|
|
|
|
|
## ## |
|
12
|
|
|
|
|
|
|
########################################## |
|
13
|
|
|
|
|
|
|
########################################## |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
############################################################################### |
|
16
|
|
|
|
|
|
|
############################################################################### |
|
17
|
|
|
|
|
|
|
## WaitBoxFixed |
|
18
|
|
|
|
|
|
|
## Object Oriented Wait Dialog for TkPerl |
|
19
|
|
|
|
|
|
|
## (Apologies to John Stoffel and Stephen O. Lidie) |
|
20
|
|
|
|
|
|
|
## |
|
21
|
|
|
|
|
|
|
## Changes: |
|
22
|
|
|
|
|
|
|
## Ver 1.1 Changed show to Show, unshow to unShow, and general |
|
23
|
|
|
|
|
|
|
## cleanup for perl5.002 gamma |
|
24
|
|
|
|
|
|
|
## Ver 1.2 Changed to general distribution, add VERSION and Version |
|
25
|
|
|
|
|
|
|
## Ver 1.3 Added -takefocus param, on suggestion of Ben Hochstedler |
|
26
|
|
|
|
|
|
|
## , some other stuff |
|
27
|
|
|
|
|
|
|
## Ver 1.4 Cavac: Added some fixes |
|
28
|
|
|
|
|
|
|
## Ver 1.5 Cavac: Added some fixes |
|
29
|
|
|
|
|
|
|
## Ver 1.6 Cavac, ASB: fixes and cleanup of POD |
|
30
|
|
|
|
|
|
|
## |
|
31
|
|
|
|
|
|
|
############################################################################### |
|
32
|
|
|
|
|
|
|
############################################################################### |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package Tk::WaitBoxFixed; |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
12887
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
37
|
1
|
|
|
1
|
|
220
|
use Tk::Toplevel; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
@Tk::WaitBoxFixed::ISA = qw (Tk::Toplevel); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Tk::Widget->Construct('WaitBoxFixed'); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$Tk::WaitBoxFixed::VERSION = '1.6'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
### A couple of convenience variables |
|
46
|
|
|
|
|
|
|
my(@wd_fullpack) = (-expand => 1, -fill => 'both'); |
|
47
|
|
|
|
|
|
|
my(@wd_packtop) = (-side => 'top'); |
|
48
|
|
|
|
|
|
|
my(@wd_packleft) = (-side => 'left'); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub Populate { |
|
51
|
|
|
|
|
|
|
### Wait box constructor. Uses new inherited from base class |
|
52
|
|
|
|
|
|
|
my($cw, $wdtop, $fm, $bitmap, $txt1, $uframe, $txt2); |
|
53
|
|
|
|
|
|
|
$cw = shift; |
|
54
|
|
|
|
|
|
|
$cw->SUPER::Populate(@_); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
## Create the toplevel window |
|
57
|
|
|
|
|
|
|
$cw->withdraw; |
|
58
|
|
|
|
|
|
|
$cw->protocol('WM_DELETE_WINDOW' => sub {}); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# See http://cpanratings.perl.org/dist/Tk-WaitBox |
|
61
|
|
|
|
|
|
|
#$cw->transient($cw->toplevel); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
### Set up the status |
|
64
|
|
|
|
|
|
|
$cw->{Shown} = 0; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
### Set up the cancel button and text |
|
67
|
|
|
|
|
|
|
$cw->{cancelroutine} = undef if !defined($cw->{cancelroutine}); |
|
68
|
|
|
|
|
|
|
$cw->{canceltext} = 'Cancel' if !defined($cw->{canceltext}); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
### OK, create the dialog |
|
71
|
|
|
|
|
|
|
### Start with the upper frame (which contains two messages) |
|
72
|
|
|
|
|
|
|
## And maybe more.... |
|
73
|
|
|
|
|
|
|
$wdtop = $cw->Frame->pack(@wd_fullpack, @wd_packtop); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$fm = $wdtop->Frame(-borderwidth => 2, -relief => 'raised') |
|
76
|
|
|
|
|
|
|
->pack(@wd_packleft, -ipadx => 20, @wd_fullpack); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$bitmap = $fm->Label(Name => 'bitmap') |
|
79
|
|
|
|
|
|
|
->pack(@wd_packleft, -ipadx => 36, @wd_fullpack); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
## Text Frame |
|
82
|
|
|
|
|
|
|
$fm = $wdtop->Frame(-borderwidth => 2, -relief => 'raised') |
|
83
|
|
|
|
|
|
|
->pack(@wd_packleft, -ipadx => 20, @wd_fullpack); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$txt1 = $fm->Label(-wraplength => '3i', -justify => 'center', |
|
86
|
|
|
|
|
|
|
-textvariable => \$cw->{Configure}{-txt1}) |
|
87
|
|
|
|
|
|
|
->pack(@wd_packtop, -pady => 3, @wd_fullpack); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
### Eventually, I want to create a user configurable frame |
|
90
|
|
|
|
|
|
|
### in between the two frames |
|
91
|
|
|
|
|
|
|
$uframe = $fm->Frame |
|
92
|
|
|
|
|
|
|
->pack(@wd_packtop); |
|
93
|
|
|
|
|
|
|
$cw->Advertise(uframe => $uframe); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$cw->{Configure}{-txt2} = "Please Wait" |
|
96
|
|
|
|
|
|
|
unless defined($cw->{Configure}{-txt2}); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$txt2 = $fm->Label(-textvariable => \$cw->{Configure}{-txt2}) |
|
99
|
|
|
|
|
|
|
->pack(@wd_packtop, @wd_fullpack, -pady => 9); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
### We'll let the cancel frame and button wait until Show time |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
### Set up configuration |
|
104
|
|
|
|
|
|
|
$cw->ConfigSpecs(-bitmap => [$bitmap, undef, undef, 'hourglass'], |
|
105
|
|
|
|
|
|
|
-foreground=> [[$txt1,$txt2], 'foreground','Foreground','black'], |
|
106
|
|
|
|
|
|
|
-background=> ['DESCENDANTS', 'background', 'Background',undef], |
|
107
|
|
|
|
|
|
|
-font => [$txt1,'font','Font','-Adobe-Helvetica-Bold-R-Normal--*-180-*'], |
|
108
|
|
|
|
|
|
|
-canceltext=> ['PASSIVE', undef, undef, 'Cancel'], |
|
109
|
|
|
|
|
|
|
-cancelroutine=> ['PASSIVE', undef, undef, undef], |
|
110
|
|
|
|
|
|
|
-txt1 => ['PASSIVE', undef, undef, undef], |
|
111
|
|
|
|
|
|
|
-txt2 => ['PASSIVE',undef,undef,undef], |
|
112
|
|
|
|
|
|
|
-resizeable => ['PASSIVE',undef,undef,1], |
|
113
|
|
|
|
|
|
|
-takefocus => ['SELF', undef, undef, 1]); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub Version {return $Tk::WaitBoxFixed::VERSION;} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub Show { |
|
121
|
|
|
|
|
|
|
## Do last minute configuration and Show the dialog |
|
122
|
|
|
|
|
|
|
my($wd, @args) = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
if ( defined($wd->{Configure}{-cancelroutine}) && |
|
125
|
|
|
|
|
|
|
!defined($wd->{CanFrame})) { |
|
126
|
|
|
|
|
|
|
my($canFrame) = $wd->Frame (-background => $wd->cget('-background')); |
|
127
|
|
|
|
|
|
|
$wd->{CanFrame} = $canFrame; |
|
128
|
|
|
|
|
|
|
$canFrame->pack(-side => 'top', @wd_packtop, -fill => 'both'); |
|
129
|
|
|
|
|
|
|
$canFrame->configure(-cursor => 'top_left_arrow'); |
|
130
|
|
|
|
|
|
|
$canFrame->Button(-text => $wd->{Configure}{-canceltext}, |
|
131
|
|
|
|
|
|
|
-command => $wd->{Configure}{-cancelroutine}) |
|
132
|
|
|
|
|
|
|
->pack(-padx => 5, -pady => 5, |
|
133
|
|
|
|
|
|
|
-ipadx => 5, -ipady => 5); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
## Grab the input queue and focus |
|
137
|
|
|
|
|
|
|
$wd->parent->configure(-cursor => 'watch') if $wd->{Configure}{-takefocus}; |
|
138
|
|
|
|
|
|
|
$wd->configure(-cursor => 'watch'); |
|
139
|
|
|
|
|
|
|
$wd->update; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my($x) = int( ($wd->screenwidth |
|
142
|
|
|
|
|
|
|
- $wd->reqwidth)/2 |
|
143
|
|
|
|
|
|
|
- $wd->vrootx); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my($y) = int( ($wd->screenheight |
|
146
|
|
|
|
|
|
|
- $wd->reqheight)/2 |
|
147
|
|
|
|
|
|
|
- $wd->vrooty); |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$wd->geometry("+$x+$y"); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$wd->{Shown} = 1; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$wd->deiconify; |
|
154
|
|
|
|
|
|
|
$wd->tkwait('visibility', $wd); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
if ($wd->{Configure}{-takefocus}) { |
|
157
|
|
|
|
|
|
|
$wd->grab(); |
|
158
|
|
|
|
|
|
|
$wd->focus(); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
$wd->update; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return $wd; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub unShow { |
|
167
|
|
|
|
|
|
|
my($wd) = @_; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
return unless $wd->{Shown}; |
|
170
|
|
|
|
|
|
|
$wd->{CanFrame}->destroy if defined($wd->{CanFrame}); |
|
171
|
|
|
|
|
|
|
$wd->{CanFrame} = undef; |
|
172
|
|
|
|
|
|
|
$wd->parent->configure(-cursor => 'top_left_arrow'); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$wd->grab('release'); |
|
175
|
|
|
|
|
|
|
$wd->withdraw; |
|
176
|
|
|
|
|
|
|
$wd->parent->update; |
|
177
|
|
|
|
|
|
|
$wd->{Shown} = 0; |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
return; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
__END__ |