author | Claus Gittinger <cg@exept.de> |
Wed, 14 Sep 2011 18:41:21 +0200 | |
changeset 4078 | 91d764cf9cbd |
parent 4077 | 221b121afa23 |
child 4079 | 29b468da8728 |
permissions | -rw-r--r-- |
62 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2563 | 12 |
"{ Package: 'stx:libwidg2' }" |
1789 | 13 |
|
50 | 14 |
View subclass:#ProgressIndicator |
826 | 15 |
instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
16 |
connectedLabel collector finishAction closeTopWhenDone showBusy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
17 |
busyPosition busyDelta busyIndicationProcess' |
183 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Misc' |
|
50 | 21 |
! |
22 |
||
334 | 23 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 24 |
|
62 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
50 | 39 |
documentation |
40 |
" |
|
41 |
a view showing a rectangle filled according the percentage value. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
42 |
Can be used as a progress indicator a la MSwindows; |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
43 |
it can also be configured as a non-percentage busy indication |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
44 |
via the showBusyIndication flag (a la netscape). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
45 |
|
574 | 46 |
Can be used as a widget within an application, or |
47 |
via the convenient #inBox: instance creation messages, |
|
48 |
which shows a progressDisplay in a modalBox, while some |
|
49 |
action is performed. |
|
50 |
See examples. |
|
183 | 51 |
|
52 |
[author:] |
|
2563 | 53 |
Claus Gittinger |
183 | 54 |
|
55 |
[see also:] |
|
2563 | 56 |
ActionWaitBox AnimatedLabel |
50 | 57 |
" |
58 |
! |
|
59 |
||
60 |
examples |
|
61 |
" |
|
62 | 62 |
basic (internal) interface |
63 |
(if progress indicator is to be used in a complex box ...): |
|
50 | 64 |
|
183 | 65 |
Before you get frustrated - see the convenient-interface examples |
66 |
at the end ;-) |
|
67 |
||
2563 | 68 |
[exBegin] |
50 | 69 |
|top p h| |
70 |
||
62 | 71 |
top := ModalBox new. |
50 | 72 |
top extent:300@100. |
73 |
top label:'Progress'. |
|
74 |
p := ProgressIndicator in:top. |
|
75 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
76 |
p level:-1. |
|
62 | 77 |
h := p preferredExtent y. |
50 | 78 |
p topInset:(h // 2) negated; |
2563 | 79 |
bottomInset:(h // 2) negated; |
80 |
leftInset:5; |
|
81 |
rightInset:5. |
|
50 | 82 |
|
83 |
[ |
|
2563 | 84 |
1 to:100 do:[:val | |
85 |
(Delay forSeconds:0.05) wait. |
|
86 |
p percentage:val |
|
87 |
]. |
|
88 |
top hide. |
|
62 | 89 |
] fork. |
90 |
top open. |
|
2563 | 91 |
[exEnd] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
92 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
93 |
as a busy indicator |
2563 | 94 |
[exBegin] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
95 |
|top p h| |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
96 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
97 |
top := ModalBox new. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
98 |
top extent:300@100. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
99 |
top label:'Busy'. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
100 |
p := ProgressIndicator in:top. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
101 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
102 |
p level:-1. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
103 |
h := p preferredExtent y. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
104 |
p topInset:(h // 2) negated; |
2563 | 105 |
bottomInset:(h // 2) negated; |
106 |
leftInset:5; |
|
107 |
rightInset:5. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
108 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
109 |
p showBusyIndication:true. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
110 |
[ |
2563 | 111 |
'do something here ....'. |
112 |
(Delay forSeconds:5) wait. |
|
113 |
top hide. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
114 |
] fork. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
115 |
top open. |
2563 | 116 |
[exEnd] |
50 | 117 |
|
118 |
changing colors, turning percentage display off: |
|
2563 | 119 |
[exBegin] |
50 | 120 |
|top p h| |
121 |
||
122 |
top := StandardSystemView new. |
|
123 |
top extent:300@100. |
|
124 |
top label:'Progress'. |
|
125 |
p := ProgressIndicator in:top. |
|
126 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
127 |
p level:-1. |
|
128 |
p showPercentage:false. |
|
129 |
p foregroundColor:(Color red). |
|
130 |
h := 10. |
|
131 |
p topInset:(h // 2) negated; |
|
2563 | 132 |
bottomInset:(h // 2) negated; |
133 |
leftInset:5; |
|
134 |
rightInset:5. |
|
50 | 135 |
top open. |
136 |
[ |
|
2563 | 137 |
1 to:100 do:[:val | |
138 |
(Delay forSeconds:0.05) wait. |
|
139 |
p percentage:val |
|
140 |
] |
|
50 | 141 |
] fork |
2563 | 142 |
[exEnd] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
143 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
144 |
as a busy indicator and percentage display (as in netscape) |
2563 | 145 |
[exBegin] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
146 |
|top p h| |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
147 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
148 |
top := ModalBox new. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
149 |
top extent:300@60. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
150 |
top label:'Busy'. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
151 |
p := ProgressIndicator in:top. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
152 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
153 |
p level:-1. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
154 |
p showPercentage:false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
155 |
p backgroundColor:(Color cyan). |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
156 |
h := p preferredExtent y. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
157 |
p topInset:(h // 3) negated; |
2563 | 158 |
bottomInset:(h // 3) negated; |
159 |
leftInset:5; |
|
160 |
rightInset:5. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
161 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
162 |
p showBusyIndication:true. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
163 |
[ |
2563 | 164 |
top label:'Busy'. |
165 |
1 to:100 do:[:i | |
|
166 |
(Delay forSeconds:0.05) wait. |
|
167 |
]. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
168 |
|
2563 | 169 |
top label:'Percentage'. |
170 |
p showBusyIndication:false. |
|
171 |
1 to:100 do:[:i | |
|
172 |
(Delay forSeconds:0.05) wait. |
|
173 |
p percentage:i. |
|
174 |
]. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
175 |
|
2563 | 176 |
top hide. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
177 |
] fork. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
178 |
top open. |
2563 | 179 |
[exEnd] |
50 | 180 |
|
181 |
with border (2D look): |
|
2563 | 182 |
[exBegin] |
50 | 183 |
|top p h| |
184 |
||
185 |
top := StandardSystemView new. |
|
186 |
top extent:300@100. |
|
187 |
top label:'Progress'. |
|
188 |
p := ProgressIndicator in:top. |
|
189 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
190 |
p borderWidth:1. |
|
62 | 191 |
h := p preferredExtent y. |
50 | 192 |
p topInset:(h // 2) negated; |
2563 | 193 |
bottomInset:(h // 2) negated; |
194 |
leftInset:5; |
|
195 |
rightInset:5. |
|
50 | 196 |
top open. |
197 |
[ |
|
2563 | 198 |
1 to:100 do:[:val | |
199 |
(Delay forSeconds:0.05) wait. |
|
200 |
p percentage:val |
|
201 |
] |
|
50 | 202 |
] fork |
2563 | 203 |
[exEnd] |
50 | 204 |
|
205 |
||
206 |
getting progress from a model: |
|
2563 | 207 |
[exBegin] |
50 | 208 |
|model top p h| |
209 |
||
210 |
model := 0 asValue. |
|
211 |
||
212 |
top := StandardSystemView new. |
|
213 |
top extent:300@100. |
|
214 |
top label:'Progress'. |
|
215 |
p := ProgressIndicator in:top. |
|
216 |
p model:model. |
|
217 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
218 |
p level:-1. |
|
62 | 219 |
h := p preferredExtent y. |
50 | 220 |
p topInset:(h // 2) negated; |
2563 | 221 |
bottomInset:(h // 2) negated; |
222 |
leftInset:5; |
|
223 |
rightInset:5. |
|
50 | 224 |
top open. |
225 |
||
226 |
[ |
|
2563 | 227 |
1 to:100 do:[:val | |
228 |
(Delay forSeconds:0.05) wait. |
|
229 |
model value:val |
|
230 |
] |
|
50 | 231 |
] fork |
2563 | 232 |
[exEnd] |
50 | 233 |
|
62 | 234 |
|
50 | 235 |
concrete example: |
236 |
search all files in the source directory for a string |
|
237 |
using grep. Show progress while doing so. |
|
2563 | 238 |
[exBegin] |
50 | 239 |
|top p h names done| |
240 |
||
241 |
top := StandardSystemView new. |
|
242 |
top extent:300@100. |
|
243 |
top label:'Searching ...'. |
|
244 |
p := ProgressIndicator in:top. |
|
245 |
p origin:(0.0@0.5) corner:(1.0@0.5). |
|
246 |
p level:-1. |
|
62 | 247 |
h := p preferredExtent y. |
50 | 248 |
p topInset:(h // 2) negated; |
2563 | 249 |
bottomInset:(h // 2) negated; |
250 |
leftInset:5; |
|
251 |
rightInset:5. |
|
50 | 252 |
top openWithPriority:(Processor activePriority + 1). |
253 |
||
254 |
names := 'source' asFilename directoryContents. |
|
255 |
done := 0. |
|
256 |
names do:[:aName | |
|
2563 | 257 |
|fn stream line| |
50 | 258 |
|
2563 | 259 |
p percentage:(done / names size * 100). |
260 |
fn := ('source/' , aName) asFilename. |
|
261 |
fn isDirectory ifFalse:[ |
|
262 |
stream := fn readStream. |
|
263 |
[stream atEnd] whileFalse:[ |
|
264 |
line := stream nextLine. |
|
265 |
(line findString:'subclass:') ~~ 0 ifTrue:[ |
|
266 |
Transcript showCR:line |
|
267 |
]. |
|
268 |
]. |
|
269 |
stream close. |
|
270 |
]. |
|
271 |
done := done + 1 |
|
50 | 272 |
]. |
273 |
||
274 |
top destroy |
|
2563 | 275 |
[exEnd] |
62 | 276 |
|
277 |
||
278 |
using the convenient inBox-interface |
|
279 |
||
280 |
(this creates a box and an activity label and evaluates a block |
|
281 |
to indicate ...) |
|
282 |
||
283 |
basic interface demonstration: |
|
2563 | 284 |
[exBegin] |
62 | 285 |
|p| |
286 |
||
287 |
p := ProgressIndicator |
|
2563 | 288 |
inBoxWithLabel:'doing something ...' |
289 |
abortable:true. |
|
62 | 290 |
p showProgressOf: |
2563 | 291 |
[:progressValue :currentAction | |
62 | 292 |
|
2563 | 293 |
1 to:100 do:[:val | |
294 |
(Delay forSeconds:0.05) wait. |
|
295 |
val == 25 ifTrue:[ |
|
296 |
currentAction value:'still going ...' |
|
297 |
]. |
|
298 |
val == 50 ifTrue:[ |
|
299 |
currentAction value:'halfway through ...' |
|
300 |
]. |
|
301 |
val == 75 ifTrue:[ |
|
302 |
currentAction value:'almost finished ...' |
|
303 |
]. |
|
304 |
progressValue value:val |
|
305 |
] |
|
306 |
] |
|
307 |
[exEnd] |
|
62 | 308 |
|
309 |
||
310 |
above search example using this convenient interface: |
|
2563 | 311 |
[exBegin] |
62 | 312 |
|p| |
313 |
||
183 | 314 |
p := ProgressIndicator |
2563 | 315 |
inBoxWithLabel:'searching files ...' |
316 |
abortable:false. |
|
62 | 317 |
p showProgressOf: |
2563 | 318 |
[:progressValue :currentAction | |
319 |
|names nDone| |
|
62 | 320 |
|
2563 | 321 |
names := 'source' asFilename directoryContents. |
322 |
nDone := 0. |
|
323 |
names do:[:aName | |
|
324 |
|fn stream line| |
|
183 | 325 |
|
2563 | 326 |
progressValue value:(nDone / names size * 100). |
327 |
currentAction value:'searching ' , 'source/' , aName , ' ...'. |
|
62 | 328 |
|
2563 | 329 |
fn := ('source/' , aName) asFilename. |
330 |
fn isDirectory ifFalse:[ |
|
331 |
stream := fn readStream. |
|
332 |
[stream atEnd] whileFalse:[ |
|
333 |
line := stream nextLine. |
|
334 |
(line findString:'subclass:') ~~ 0 ifTrue:[ |
|
335 |
Transcript showCR:line |
|
336 |
]. |
|
337 |
]. |
|
338 |
stream close. |
|
339 |
]. |
|
340 |
nDone := nDone + 1 |
|
341 |
]. |
|
342 |
]. |
|
343 |
[exEnd] |
|
62 | 344 |
|
345 |
||
346 |
a nice example: copying files a la windows ... |
|
183 | 347 |
the following copies all files to /dev/null. |
2563 | 348 |
[exBegin] |
62 | 349 |
|p| |
350 |
||
351 |
(ProgressIndicator |
|
2563 | 352 |
inBoxWithLabel:'copy files to /dev/null ...' |
353 |
abortable:true) |
|
354 |
showProgressOf: |
|
355 |
[:progressValue :currentAction | |
|
356 |
|files nFiles nDone| |
|
62 | 357 |
|
2563 | 358 |
files := '.' asFilename directoryContents. |
359 |
nFiles := files size. |
|
360 |
nDone := 0. |
|
361 |
files do:[:aFileName | |
|
362 |
|percent| |
|
50 | 363 |
|
2563 | 364 |
nDone := nDone + 1. |
365 |
percent := nDone / nFiles * 100. |
|
366 |
progressValue value:percent. |
|
367 |
aFileName asFilename isDirectory ifTrue:[ |
|
368 |
Transcript showCR:('skipping ' , aFileName , ' ...'). |
|
369 |
currentAction value:('skipping ' , aFileName , ' ...'). |
|
370 |
] ifFalse:[ |
|
371 |
Transcript showCR:('copying ' , aFileName , ' ...'). |
|
372 |
currentAction value:('copying ' , aFileName , ' ...'). |
|
373 |
Object errorSignal handle:[:ex | |
|
374 |
self warn:'an error occurred while copying ' , aFileName. |
|
375 |
ex return |
|
376 |
] do:[ |
|
377 |
aFileName asFilename copyTo:'/dev/null'. |
|
378 |
] |
|
379 |
]. |
|
380 |
]. |
|
381 |
]. |
|
382 |
[exEnd] |
|
183 | 383 |
" |
50 | 384 |
! ! |
385 |
||
334 | 386 |
!ProgressIndicator class methodsFor:'instance creation'! |
62 | 387 |
|
388 |
inBox |
|
574 | 389 |
"create a topView containing an instance of myself, |
390 |
for later use with #showProgressOf:" |
|
391 |
||
392 |
^ self inBoxWithLabel:'executing ...' abortable:false |
|
393 |
||
394 |
"Modified: 22.10.1997 / 21:08:37 / cg" |
|
62 | 395 |
! |
396 |
||
397 |
inBoxWithLabel:aLabel |
|
398 |
"create a topView containing an instance of myself, |
|
399 |
for later use with #showProgressOf:" |
|
400 |
||
401 |
^ self inBoxWithLabel:aLabel abortable:false |
|
402 |
! |
|
403 |
||
404 |
inBoxWithLabel:aLabel abortable:abortable |
|
405 |
"create a topView containing an instance of myself, |
|
406 |
for later use with #showProgressOf:" |
|
407 |
||
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
408 |
^ self |
634 | 409 |
inBoxWithLabel:aLabel |
410 |
text:'' |
|
411 |
abortable:abortable |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
412 |
|
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
413 |
"Modified: 17.7.1996 / 15:14:58 / cg" |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
414 |
! |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
415 |
|
237 | 416 |
inBoxWithLabel:aLabel icon:anIcon text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean |
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
417 |
"create a topView containing an instance of myself, |
3542 | 418 |
return the new instance, for later use with #showProgressOf:" |
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
419 |
|
2436 | 420 |
|top p l y y2| |
62 | 421 |
|
422 |
top := Dialog new. |
|
423 |
top label:aLabel. |
|
424 |
top cursor:(Cursor wait). |
|
3542 | 425 |
|
826 | 426 |
y2 := 0. |
237 | 427 |
anIcon notNil ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
428 |
y := top yPosition. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
429 |
l := top addTextLabel:anIcon. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
430 |
l borderWidth:0. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
431 |
l adjust:#left. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
432 |
l cursor:(Cursor wait). |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
433 |
y2 := top yPosition. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
434 |
top yPosition:y. |
237 | 435 |
]. |
436 |
||
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
437 |
l := top addTextLabel:text. |
62 | 438 |
l borderWidth:0. |
74 | 439 |
l adjust:#left. |
62 | 440 |
l cursor:(Cursor wait). |
826 | 441 |
anIcon notNil ifTrue: [l leftInset:(anIcon width + 10)]. |
237 | 442 |
|
443 |
top yPosition:(top yPosition max:y2). |
|
62 | 444 |
|
445 |
top addVerticalSpace. |
|
446 |
||
447 |
p := ProgressIndicator new. |
|
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
448 |
p extent:(1.0 @ p preferredHeight). |
62 | 449 |
p level:-1. |
450 |
p leftInset:5; |
|
451 |
rightInset:5. |
|
452 |
p cursor:(Cursor wait). |
|
237 | 453 |
p closeTopWhenDone:closeWhenDoneBoolean. |
62 | 454 |
p connectToTop:top label:l. |
455 |
||
456 |
top addComponent:p. |
|
457 |
||
237 | 458 |
additionalView notNil ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
459 |
top addComponent:additionalView. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
460 |
additionalView extent:(1.0 @ additionalView preferredHeight). |
237 | 461 |
]. |
462 |
||
62 | 463 |
abortable ifTrue:[ |
3425
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
464 |
top addVerticalSpace. |
20459e327062
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
2931
diff
changeset
|
465 |
top addAbortButton |
62 | 466 |
]. |
3542 | 467 |
abortable ifFalse:[ |
468 |
"/ top beUndecorated. -- buggy for now; sets wrong height (caption not included ?) |
|
469 |
"/ would need the following kludge: |
|
470 |
"/ top preferredExtent:(top preferredExtent + (0@30)). |
|
471 |
]. |
|
62 | 472 |
|
473 |
^ p |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
474 |
|
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
475 |
"Created: 17.7.1996 / 15:14:33 / cg" |
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
476 |
"Modified: 17.7.1996 / 15:16:58 / cg" |
237 | 477 |
! |
478 |
||
479 |
inBoxWithLabel:aLabel text:text abortable:abortable |
|
480 |
"create a topView containing an instance of myself, |
|
481 |
for later use with #showProgressOf:" |
|
482 |
||
483 |
^ self |
|
634 | 484 |
inBoxWithLabel:aLabel |
485 |
text:text |
|
486 |
abortable:abortable |
|
487 |
view:nil |
|
237 | 488 |
|
489 |
! |
|
490 |
||
491 |
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView |
|
492 |
"create a topView containing an instance of myself, |
|
493 |
for later use with #showProgressOf:" |
|
494 |
||
495 |
^ self |
|
634 | 496 |
inBoxWithLabel:aLabel |
497 |
text:text |
|
498 |
abortable:abortable |
|
499 |
view:additionalView |
|
500 |
closeWhenDone:true |
|
237 | 501 |
|
502 |
! |
|
503 |
||
504 |
inBoxWithLabel:aLabel text:text abortable:abortable view:additionalView closeWhenDone:closeWhenDoneBoolean |
|
505 |
"create a topView containing an instance of myself, |
|
506 |
for later use with #showProgressOf:" |
|
507 |
||
508 |
^ self |
|
634 | 509 |
inBoxWithLabel:aLabel |
510 |
icon:nil |
|
511 |
text:text |
|
512 |
abortable:abortable |
|
513 |
view:additionalView |
|
514 |
closeWhenDone:closeWhenDoneBoolean |
|
237 | 515 |
|
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
516 |
! |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
517 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
518 |
progressOpenOn:progressModel label:aLabel |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
519 |
"create and open a progressIndicator dialog window, |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
520 |
bit do not open it modal; instead, it is opened modeless |
1834
ba170c21ed76
defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
521 |
and control returns to the caller. |
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
522 |
The models value is assumed to be 0..1 |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
523 |
(which is for compatibility and different from ST/X's percentage use) |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
524 |
Added for VW compatibility (RB)." |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
525 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
526 |
|p ra| |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
527 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
528 |
p := self |
2563 | 529 |
inBoxWithLabel:aLabel |
530 |
icon:nil |
|
531 |
text:aLabel |
|
532 |
abortable:false |
|
533 |
view:nil |
|
534 |
closeWhenDone:false. |
|
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
535 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
536 |
ra := RangeAdaptor on:progressModel start:0 stop:0.01 grid:nil. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
537 |
p model:ra. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
538 |
|
2132 | 539 |
p topView openModeless; waitUntilVisible. |
1681
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
540 |
^ p. |
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
541 |
|
9ef9e8ec0f43
progressOpenOn:label: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
1463
diff
changeset
|
542 |
"Modified: / 4.2.2000 / 01:25:55 / cg" |
62 | 543 |
! ! |
544 |
||
3999 | 545 |
!ProgressIndicator class methodsFor:'simple public API'! |
3542 | 546 |
|
547 |
displayBusyIndicator:aLabel abortable:abortable at:aPoint during:aBlock |
|
548 |
"easy interface - show progress while evaluating aBlock. |
|
549 |
The block is passed the progressIndicator as argument |
|
550 |
so the block can change the label and/or change the progress value." |
|
551 |
||
3967 | 552 |
^ self |
553 |
displayBusyIndicator:aLabel |
|
554 |
message:aLabel |
|
555 |
abortable:abortable |
|
556 |
at:aPoint |
|
557 |
during:aBlock |
|
558 |
||
559 |
" |
|
560 |
ProgressIndicator |
|
561 |
displayBusyIndicator:'doobidoobidoo...' |
|
562 |
abortable:true |
|
563 |
at:(Screen default center) |
|
564 |
during:[ |
|
565 |
200 to:400 by:5 do:[:i | |
|
566 |
Delay waitForSeconds:0.1. |
|
567 |
] |
|
568 |
]. |
|
569 |
||
570 |
ProgressIndicator |
|
571 |
displayBusyIndicator:'doobidoobidoo...' |
|
572 |
abortable:true |
|
573 |
at:(Screen default center) |
|
574 |
during:[ |
|
575 |
Delay waitForSeconds:3. |
|
576 |
]. |
|
577 |
" |
|
578 |
||
579 |
"Modified: / 12-11-2010 / 18:59:45 / cg" |
|
580 |
! |
|
581 |
||
582 |
displayBusyIndicator:aLabel at:aPoint during:aBlock |
|
583 |
"easy interface - show progress while evaluating aBlock. |
|
584 |
The block is passed a valueHolder, which is to be set to values from |
|
585 |
startValue to endValue during the blocks evaluation. |
|
586 |
This is scaled to 0..100% completion. |
|
587 |
Set the valueHolder to nil, to get a busy-indicator" |
|
588 |
||
589 |
self |
|
590 |
displayBusyIndicator:aLabel |
|
591 |
abortable:false |
|
592 |
at:aPoint |
|
593 |
during:aBlock |
|
594 |
||
595 |
" |
|
596 |
ProgressIndicator |
|
597 |
displayBusyIndicator:'doobidoobidoo...' |
|
598 |
at:(Screen default center) |
|
599 |
during:[ |
|
600 |
200 to:400 by:5 do:[:i | |
|
601 |
Delay waitForSeconds:0.1. |
|
602 |
] |
|
603 |
]. |
|
604 |
" |
|
605 |
! |
|
606 |
||
607 |
displayBusyIndicator:aLabel message:messageString abortable:abortable at:aPoint during:aBlock |
|
608 |
"easy interface - show progress while evaluating aBlock. |
|
609 |
The block is passed the progressIndicator as argument |
|
610 |
so the block can change the label and/or change the progress value." |
|
611 |
||
3542 | 612 |
|p| |
613 |
||
614 |
p := self |
|
615 |
inBoxWithLabel:aLabel |
|
616 |
icon:nil |
|
3967 | 617 |
text:messageString |
3542 | 618 |
abortable:abortable |
619 |
view:nil |
|
620 |
closeWhenDone:true. |
|
621 |
||
622 |
p showBusyIndication:true. |
|
623 |
p showBusyIndicatorDuring:[ |
|
624 |
CannotReturnError catch:[ |
|
625 |
aBlock valueWithOptionalArgument:p. |
|
626 |
] |
|
627 |
] |
|
628 |
||
629 |
" |
|
630 |
ProgressIndicator |
|
631 |
displayBusyIndicator:'doobidoobidoo...' |
|
632 |
abortable:true |
|
633 |
at:(Screen default center) |
|
634 |
during:[ |
|
635 |
200 to:400 by:5 do:[:i | |
|
636 |
Delay waitForSeconds:0.1. |
|
637 |
] |
|
638 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
639 |
|
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
640 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
641 |
displayBusyIndicator:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
642 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
643 |
at:(Screen default center) |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
644 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
645 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
646 |
]. |
3542 | 647 |
" |
3967 | 648 |
|
649 |
"Created: / 12-11-2010 / 18:59:13 / cg" |
|
3542 | 650 |
! |
651 |
||
3967 | 652 |
displayBusyIndicator:aLabel message:messageString at:aPoint during:aBlock |
3542 | 653 |
"easy interface - show progress while evaluating aBlock. |
654 |
The block is passed a valueHolder, which is to be set to values from |
|
655 |
startValue to endValue during the blocks evaluation. |
|
656 |
This is scaled to 0..100% completion. |
|
657 |
Set the valueHolder to nil, to get a busy-indicator" |
|
658 |
||
659 |
self |
|
3967 | 660 |
displayBusyIndicator:aLabel |
661 |
message:messageString |
|
3542 | 662 |
abortable:false |
663 |
at:aPoint |
|
664 |
during:aBlock |
|
665 |
||
666 |
" |
|
667 |
ProgressIndicator |
|
668 |
displayBusyIndicator:'doobidoobidoo...' |
|
669 |
at:(Screen default center) |
|
670 |
during:[ |
|
671 |
200 to:400 by:5 do:[:i | |
|
672 |
Delay waitForSeconds:0.1. |
|
673 |
] |
|
674 |
]. |
|
675 |
" |
|
3967 | 676 |
|
677 |
"Created: / 12-11-2010 / 19:01:12 / cg" |
|
3542 | 678 |
! |
679 |
||
680 |
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock |
|
681 |
"easy interface - show progress while evaluating aBlock. |
|
682 |
The block is passed a valueHolder, which is to be set to values from |
|
683 |
startValue to endValue during the blocks evaluation. |
|
684 |
This is scaled to 0..100% completion. |
|
685 |
Set the valueHolder to nil, to get a busy-indicator" |
|
686 |
||
3967 | 687 |
^ self |
688 |
displayProgress:aLabel |
|
689 |
message:aLabel |
|
690 |
at:aPoint |
|
691 |
from:startValue |
|
692 |
to:endValue |
|
693 |
during:aBlock |
|
694 |
||
695 |
" |
|
696 |
ProgressIndicator |
|
697 |
displayProgress:'doobidoobidoo...' |
|
698 |
at:(Screen default center) |
|
699 |
from:200 to:400 |
|
700 |
during:[:val | |
|
701 |
200 to:400 by:5 do:[:i | |
|
702 |
val value:i. |
|
703 |
Delay waitForSeconds:0.1. |
|
704 |
] |
|
705 |
]. |
|
706 |
" |
|
707 |
||
708 |
"Modified: / 12-11-2010 / 19:02:27 / cg" |
|
709 |
! |
|
710 |
||
711 |
displayProgress:aLabel message:messageString at:aPoint from:startValue to:endValue during:aBlock |
|
712 |
"easy interface - show progress while evaluating aBlock. |
|
713 |
The block is passed a valueHolder, which is to be set to values from |
|
714 |
startValue to endValue during the blocks evaluation. |
|
715 |
This is scaled to 0..100% completion. |
|
716 |
Set the valueHolder to nil, to get a busy-indicator" |
|
717 |
||
3542 | 718 |
|p| |
719 |
||
720 |
p := self |
|
721 |
inBoxWithLabel:aLabel |
|
722 |
icon:nil |
|
3967 | 723 |
text:messageString |
3542 | 724 |
abortable:false |
725 |
view:nil |
|
726 |
closeWhenDone:true. |
|
727 |
||
728 |
p showProgressOf:[:progressValue :currentAction | |
|
729 |
|scaler| |
|
730 |
||
731 |
scaler := [:scaledValue | |
|
732 |
|newPercentage oldPercentage oldLabel| |
|
733 |
||
734 |
scaledValue isNil ifTrue:[ |
|
735 |
p showBusyIndication:true |
|
736 |
] ifFalse:[ |
|
737 |
p showBusyIndication:false. |
|
738 |
oldPercentage := progressValue value. |
|
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
739 |
endValue = startValue ifTrue:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
740 |
newPercentage := 0. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
741 |
] ifFalse:[ |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
742 |
newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100. |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
743 |
]. |
3542 | 744 |
newPercentage ~= oldPercentage ifTrue:[ |
745 |
progressValue value:newPercentage. |
|
746 |
]. |
|
747 |
oldLabel := currentAction value. |
|
748 |
oldLabel ~= aLabel ifTrue:[ |
|
749 |
currentAction value:aLabel. |
|
750 |
] |
|
751 |
] |
|
752 |
]. |
|
753 |
CannotReturnError catch:[ |
|
754 |
aBlock valueWithOptionalArgument:scaler and:p. |
|
755 |
] |
|
756 |
] |
|
757 |
||
758 |
" |
|
759 |
ProgressIndicator |
|
760 |
displayProgress:'doobidoobidoo...' |
|
761 |
at:(Screen default center) |
|
762 |
from:200 to:400 |
|
763 |
during:[:val | |
|
764 |
200 to:400 by:5 do:[:i | |
|
765 |
val value:i. |
|
766 |
Delay waitForSeconds:0.1. |
|
767 |
] |
|
768 |
]. |
|
769 |
" |
|
3967 | 770 |
|
771 |
"Created: / 12-11-2010 / 19:01:38 / cg" |
|
3542 | 772 |
! |
773 |
||
774 |
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock |
|
775 |
"easy interface - show progress as provided by progressNotifications |
|
776 |
while evaluating aBlock. |
|
777 |
The block is passed the progressIndicator as optional argument, |
|
778 |
however, progressNotifications are handled and update the percentage." |
|
779 |
||
3967 | 780 |
^ self |
781 |
displayProgressNotifications:aLabel |
|
782 |
message:aLabel |
|
783 |
abortable:abortable |
|
784 |
at:aPointOrNil |
|
785 |
during:aBlock |
|
786 |
||
787 |
||
788 |
" |
|
789 |
ProgressIndicator |
|
790 |
displayProgressNotifications:'doobidoobidoo...' |
|
791 |
abortable:true |
|
792 |
at:nil |
|
793 |
during:[ |
|
794 |
200 to:400 by:5 do:[:i | |
|
795 |
Delay waitForSeconds:0.1. |
|
796 |
ProgressNotification progressPercentage:(i / 4). |
|
797 |
] |
|
798 |
]. |
|
799 |
" |
|
800 |
" |
|
801 |
ProgressIndicator |
|
802 |
displayProgressNotifications:'doobidoobidoo...' |
|
803 |
abortable:true |
|
804 |
at:nil |
|
805 |
during:[ |
|
806 |
Delay waitForSeconds:3. |
|
807 |
]. |
|
808 |
" |
|
809 |
||
810 |
"Modified: / 12-11-2010 / 19:03:09 / cg" |
|
811 |
! |
|
812 |
||
813 |
displayProgressNotifications:aLabel message:messageString abortable:abortable at:aPointOrNil during:aBlock |
|
814 |
"easy interface - show progress as provided by progressNotifications |
|
815 |
while evaluating aBlock. |
|
816 |
The block is passed the progressIndicator as optional argument, |
|
817 |
however, progressNotifications are handled and update the percentage." |
|
818 |
||
3542 | 819 |
|p| |
820 |
||
821 |
p := self |
|
822 |
inBoxWithLabel:aLabel |
|
823 |
icon:nil |
|
3967 | 824 |
text:messageString |
3542 | 825 |
abortable:abortable |
826 |
view:nil |
|
827 |
closeWhenDone:true. |
|
828 |
||
829 |
p showBusyIndicatorDuring:[ |
|
830 |
CannotReturnError catch:[ |
|
831 |
ProgressNotification handle:[:ex | |
|
832 |
p percentage:ex progressValue. |
|
833 |
ex proceed. |
|
834 |
] do:[ |
|
835 |
aBlock valueWithOptionalArgument:p. |
|
836 |
]. |
|
837 |
] |
|
838 |
] |
|
839 |
||
840 |
" |
|
841 |
ProgressIndicator |
|
842 |
displayProgressNotifications:'doobidoobidoo...' |
|
843 |
abortable:true |
|
844 |
at:nil |
|
845 |
during:[ |
|
846 |
200 to:400 by:5 do:[:i | |
|
847 |
Delay waitForSeconds:0.1. |
|
848 |
ProgressNotification progressPercentage:(i / 4). |
|
849 |
] |
|
850 |
]. |
|
851 |
" |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
852 |
" |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
853 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
854 |
displayProgressNotifications:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
855 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
856 |
at:nil |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
857 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
858 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
859 |
]. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
860 |
" |
3967 | 861 |
|
862 |
"Created: / 12-11-2010 / 19:02:43 / cg" |
|
3542 | 863 |
! ! |
864 |
||
183 | 865 |
!ProgressIndicator methodsFor:'accessing'! |
866 |
||
334 | 867 |
percentage:aNumber |
868 |
"set the percentage" |
|
237 | 869 |
|
183 | 870 |
|newPercentage| |
871 |
||
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
872 |
aNumber < 0 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
873 |
newPercentage := -1. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
874 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
875 |
newPercentage := ((aNumber max:0) min:100) rounded. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
876 |
]. |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
877 |
newPercentage ~= percentage ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
878 |
percentage := newPercentage. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
879 |
self invalidateRepairNow:true. |
183 | 880 |
] |
334 | 881 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
882 |
"Modified: / 6.6.1998 / 19:43:56 / cg" |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
883 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
884 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
885 |
showBusyIndication:aBooleanHolder |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
886 |
"switch between percentage mode (if false) and busy indication (if true)" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
887 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
888 |
aBooleanHolder ~~ showBusy ifTrue:[ |
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
889 |
showBusy notNil ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
890 |
showBusy removeDependent:self. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
891 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
892 |
showBusy := aBooleanHolder. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
893 |
showBusy isValueModel ifTrue:[showBusy addDependent:self]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
894 |
(showBusy value) ifTrue:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
895 |
self startBusyIndicationProcess. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
896 |
] ifFalse:[ |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
897 |
self stopBusyIndicationProcess |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
898 |
]. |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
899 |
shown ifTrue:[self redraw] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
900 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
901 |
|
3969
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
902 |
"Created: / 21-10-1998 / 17:35:16 / cg" |
fa06bc0686ed
changed: #showBusyIndication:
Claus Gittinger <cg@exept.de>
parents:
3967
diff
changeset
|
903 |
"Modified: / 17-11-2010 / 13:43:51 / cg" |
334 | 904 |
! ! |
905 |
||
2404 | 906 |
!ProgressIndicator methodsFor:'accessing-behavior'! |
907 |
||
908 |
closeTopWhenDone:aBoolean |
|
909 |
"set/clear the close-topView-when-done flag" |
|
910 |
||
911 |
closeTopWhenDone := aBoolean |
|
912 |
||
913 |
"Created: 3.9.1996 / 14:22:03 / cg" |
|
914 |
"Modified: 29.3.1997 / 16:08:19 / cg" |
|
915 |
! |
|
916 |
||
917 |
finishAction:aBlock |
|
918 |
"define an action to be performed when finished" |
|
919 |
||
920 |
finishAction := aBlock |
|
921 |
||
922 |
"Created: 3.9.1996 / 14:15:15 / cg" |
|
923 |
"Modified: 29.3.1997 / 16:08:35 / cg" |
|
924 |
! ! |
|
925 |
||
926 |
!ProgressIndicator methodsFor:'accessing-look'! |
|
334 | 927 |
|
826 | 928 |
backgroundColor |
929 |
"return the percentage displays background color" |
|
930 |
||
931 |
^ bgColor |
|
932 |
||
933 |
! |
|
934 |
||
935 |
backgroundColor:aColor |
|
936 |
"set the percentage displays background color" |
|
937 |
||
993 | 938 |
aColor ~= bgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
939 |
bgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
940 |
self invalidateRepairNow:true |
826 | 941 |
]. |
942 |
||
993 | 943 |
"Modified: / 20.7.1998 / 23:32:48 / cg" |
826 | 944 |
! |
945 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
946 |
foregroundColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
947 |
"return the percentage displays foreground color" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
948 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
949 |
^ fgColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
950 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
951 |
"Created: 29.3.1997 / 16:12:28 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
952 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
953 |
|
334 | 954 |
foregroundColor:aColor |
955 |
"set the percentage displays foreground color" |
|
956 |
||
993 | 957 |
aColor ~= fgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
958 |
fgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
959 |
self invalidateRepairNow:true |
336 | 960 |
]. |
334 | 961 |
|
993 | 962 |
"Modified: / 20.7.1998 / 23:27:47 / cg" |
183 | 963 |
! |
964 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
965 |
showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
966 |
"return the flag controlling if the percentage is to be shown numerically" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
967 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
968 |
^ showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
969 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
970 |
"Created: 29.3.1997 / 16:12:39 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
971 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
972 |
|
183 | 973 |
showPercentage:aBoolean |
334 | 974 |
"set/clear the flag controlling if the percentage is to be shown numerically" |
975 |
||
336 | 976 |
showPercentage := aBoolean. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
977 |
self invalidateRepairNow:true |
334 | 978 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
979 |
"Modified: / 6.6.1998 / 19:28:44 / cg" |
183 | 980 |
! ! |
981 |
||
982 |
!ProgressIndicator methodsFor:'change & update'! |
|
983 |
||
984 |
update:aspect with:aParameter from:changedObject |
|
574 | 985 |
"react upon value changes of my model" |
986 |
||
183 | 987 |
(aspect == aspectMsg |
988 |
and:[changedObject == model]) ifTrue:[ |
|
3748 | 989 |
self percentage:(model perform:aspectMsg). |
990 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
991 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
992 |
changedObject == showBusy ifTrue:[ |
3748 | 993 |
showBusy value |
994 |
ifTrue:[self startBusyIndicationProcess] |
|
995 |
ifFalse:[self stopBusyIndicationProcess]. |
|
996 |
self redraw. |
|
997 |
^ self |
|
183 | 998 |
]. |
999 |
^ super update:aspect with:aParameter from:changedObject |
|
574 | 1000 |
|
3748 | 1001 |
"Modified: / 21-10-1998 / 18:01:52 / cg" |
1002 |
"Modified: / 01-11-2006 / 08:40:50 / janfrog" |
|
183 | 1003 |
! ! |
1004 |
||
1005 |
!ProgressIndicator methodsFor:'drawing'! |
|
1006 |
||
1007 |
redraw |
|
574 | 1008 |
"redraw the percentage bar and optional percentage string" |
1009 |
||
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1010 |
|s lx rx sx sy sw m2 m w h doBusy| |
183 | 1011 |
|
3748 | 1012 |
self shown ifFalse:[^self]. |
1013 |
||
183 | 1014 |
m := margin + 1. |
863 | 1015 |
m2 := m*2. |
1016 |
||
1017 |
w := width - m2. |
|
1018 |
h := height - m2. |
|
183 | 1019 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
1020 |
"/ self clear. |
863 | 1021 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1022 |
doBusy := showBusy value. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1023 |
doBusy ifFalse:[ |
3748 | 1024 |
percentage value < 0 ifTrue:[ |
1025 |
self startBusyIndicationProcess. |
|
1026 |
doBusy := true. |
|
1027 |
]. |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1028 |
]. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1029 |
|
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1030 |
doBusy ifTrue:[ |
3748 | 1031 |
self paint:bgColor. |
1032 |
self fillRectangleX:m y:m width:w height:h. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1033 |
|
3748 | 1034 |
lx := (w * busyPosition / 100) rounded. |
1035 |
rx := (w * (busyPosition + 20) / 100) rounded. |
|
1036 |
rx := rx min:w. |
|
1037 |
lx := lx max:m. |
|
1038 |
self paint:fgColor. |
|
1039 |
self fillRectangleX:lx y:m width:(rx - lx) height:h. |
|
1040 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1041 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1042 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1043 |
self stopBusyIndicationProcess. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
1044 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1045 |
rx := (w * percentage / 100) rounded. |
826 | 1046 |
self paint:bgColor. |
843 | 1047 |
self fillRectangleX:m+rx y:m width:w-rx height:h. |
183 | 1048 |
|
1049 |
showPercentage ifTrue:[ |
|
3748 | 1050 |
s := percentage printString , ' %'. |
1051 |
font := font onDevice:device. |
|
1052 |
sw := font widthOf:s . |
|
1053 |
sx := (width - sw) // 2. |
|
1054 |
sy := height // 2 + font descent + 2. |
|
347 | 1055 |
|
3748 | 1056 |
rx <= (sx+sw) ifTrue:[ |
1057 |
self paint:Color black. |
|
1058 |
self displayString:s x:sx y:sy. |
|
1059 |
] |
|
183 | 1060 |
]. |
1061 |
||
1062 |
self paint:fgColor. |
|
1063 |
self fillRectangleX:m y:m width:rx height:h. |
|
1064 |
||
1065 |
showPercentage ifTrue:[ |
|
3748 | 1066 |
rx >= sx ifTrue:[ |
1067 |
self clippingRectangle:(m@m corner:rx+1 @ h). |
|
1068 |
self paint:Color white. |
|
1069 |
self displayString:s x:sx y:sy. |
|
1070 |
self clippingRectangle:nil |
|
1071 |
] |
|
183 | 1072 |
] |
347 | 1073 |
|
3748 | 1074 |
"Modified: / 21-10-1998 / 18:01:58 / cg" |
1075 |
"Modified: / 12-12-2006 / 18:26:02 / janfrog" |
|
863 | 1076 |
! |
1077 |
||
1078 |
sizeChanged:how |
|
1079 |
super sizeChanged:how. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1080 |
self invalidate |
863 | 1081 |
|
1082 |
"Created: / 18.4.1998 / 02:34:37 / cg" |
|
865 | 1083 |
"Modified: / 18.4.1998 / 14:09:40 / cg" |
183 | 1084 |
! ! |
1085 |
||
2501 | 1086 |
!ProgressIndicator methodsFor:'initialization & release'! |
183 | 1087 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1088 |
destroy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1089 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1090 |
self stopBusyIndicationProcess |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1091 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1092 |
super destroy. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1093 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1094 |
"Created: / 21.10.1998 / 17:29:58 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1095 |
"Modified: / 21.10.1998 / 17:30:36 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1096 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1097 |
|
574 | 1098 |
initStyle |
1099 |
"initialize styleSheet values" |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1100 |
|
575 | 1101 |
<resource: #style (#'progressIndicator.viewBackground' |
2921 | 1102 |
#'progressIndicator.foregroundColor')> |
574 | 1103 |
|
1104 |
super initStyle. |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1105 |
|
347 | 1106 |
self is3D ifTrue:[ |
2921 | 1107 |
self level:-1 |
347 | 1108 |
]. |
1109 |
||
826 | 1110 |
bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white. |
574 | 1111 |
fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue. |
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1112 |
fgColor := fgColor onDevice:device. |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
1113 |
|
183 | 1114 |
showPercentage := true. |
574 | 1115 |
! |
1116 |
||
1117 |
initialize |
|
826 | 1118 |
|
574 | 1119 |
super initialize. |
826 | 1120 |
|
574 | 1121 |
percentage := 0. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1122 |
showBusy := false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1123 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1124 |
"Modified: / 21.10.1998 / 17:33:02 / cg" |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1125 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1126 |
|
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1127 |
mapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1128 |
super mapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1129 |
(showBusy value) ifTrue:[ |
2563 | 1130 |
self startBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1131 |
]. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1132 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1133 |
|
3970 | 1134 |
release |
1135 |
super release. |
|
1136 |
showBusy notNil ifTrue:[showBusy removeDependent:self]. |
|
1137 |
||
1138 |
"Created: / 17-11-2010 / 13:44:45 / cg" |
|
1139 |
! |
|
1140 |
||
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1141 |
unmapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1142 |
super unmapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1143 |
(showBusy value) ifTrue:[ |
2563 | 1144 |
self stopBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
1145 |
]. |
574 | 1146 |
! ! |
1147 |
||
1148 |
!ProgressIndicator methodsFor:'private'! |
|
1149 |
||
1150 |
connectToTop:top label:label |
|
1151 |
connectedTop := top. |
|
1152 |
connectedLabel := label |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1153 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1154 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1155 |
startBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1156 |
busyIndicationProcess isNil ifTrue:[ |
2563 | 1157 |
busyPosition := 0. |
1158 |
busyDelta := 5. |
|
1159 |
busyIndicationProcess := [ |
|
1160 |
[self realized] whileTrue:[ |
|
1161 |
Delay waitForSeconds:0.2. |
|
1162 |
self shown ifTrue:[ |
|
1163 |
self updateBusyIndicatorPosition. |
|
1164 |
] |
|
1165 |
]. |
|
1166 |
busyIndicationProcess := nil. |
|
1167 |
] fork. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1168 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1169 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1170 |
"Created: / 21.10.1998 / 18:02:35 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1171 |
"Modified: / 21.10.1998 / 18:03:49 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1172 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1173 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1174 |
stopBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1175 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1176 |
busyIndicationProcess terminate. |
1177 |
busyIndicationProcess := nil |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1178 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1179 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1180 |
"Created: / 21.10.1998 / 17:30:19 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1181 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1182 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1183 |
updateBusyIndicatorPosition |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1184 |
busyPosition := busyPosition + busyDelta. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1185 |
busyPosition >= 80 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1186 |
busyDelta > 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1187 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1188 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1189 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1190 |
busyPosition <= 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1191 |
busyDelta < 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1192 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1193 |
] |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1194 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1195 |
]. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1196 |
self invalidate |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1197 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1198 |
"Created: / 21.10.1998 / 17:33:28 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1199 |
"Modified: / 21.10.1998 / 17:58:58 / cg" |
183 | 1200 |
! ! |
1201 |
||
1202 |
!ProgressIndicator methodsFor:'queries'! |
|
1203 |
||
1204 |
preferredExtent |
|
574 | 1205 |
"return my preferred extent" |
1206 |
||
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1207 |
"/ If I have an explicit preferredExtent.. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1208 |
explicitExtent notNil ifTrue:[ |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1209 |
^ explicitExtent |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1210 |
]. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1211 |
|
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1212 |
"/ If I have a cached preferredExtent value.. |
334 | 1213 |
preferredExtent notNil ifTrue:[ |
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1214 |
^ preferredExtent |
334 | 1215 |
]. |
183 | 1216 |
^ 100 @ (font height + font descent + ((margin + 1) * 2)) |
334 | 1217 |
|
574 | 1218 |
"Modified: 22.10.1997 / 21:07:17 / cg" |
183 | 1219 |
! ! |
1220 |
||
62 | 1221 |
!ProgressIndicator methodsFor:'showing progress'! |
1222 |
||
4078 | 1223 |
new_showProgressOf:aBlock |
1224 |
"show progress, while evaluating aBlock. |
|
1225 |
If the receiver has been created with inBox, show the |
|
1226 |
box centered on the screen. If not, the view is assumed to |
|
1227 |
be contained in another view, and no special startup actions |
|
1228 |
are performed. |
|
1229 |
||
1230 |
The block is passed two arguments, the progressValue, |
|
1231 |
which should be set to the percentage from time-to-time |
|
1232 |
within the block and an action value, which should be set to |
|
1233 |
the currently performed action (a string) from time to time. |
|
1234 |
The second valueHolder can be left unchanged. |
|
1235 |
||
1236 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1237 |
||
1238 |
|progressValue labelValue p aborted| |
|
1239 |
||
1240 |
progressValue := 0 asValue. |
|
1241 |
aborted := false. |
|
1242 |
||
1243 |
connectedLabel notNil ifTrue:[ |
|
1244 |
labelValue := (connectedLabel label ? '') asValue. |
|
1245 |
connectedLabel |
|
1246 |
model:labelValue; |
|
1247 |
aspect:#value; |
|
1248 |
labelMessage:#value. |
|
1249 |
] ifFalse:[ |
|
1250 |
labelValue := '' asValue. |
|
1251 |
]. |
|
1252 |
||
1253 |
self model:progressValue. |
|
1254 |
||
1255 |
"/ the display process |
|
1256 |
p := [ |
|
1257 |
self topView show. |
|
1258 |
] fork. |
|
1259 |
||
1260 |
"/ WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1261 |
"/ ex proceedWith:self topView windowGroup |
|
1262 |
"/ ] do:[ |
|
1263 |
[ |
|
1264 |
aBlock value:progressValue value:labelValue |
|
1265 |
] ensure:[ |
|
1266 |
p terminate. |
|
1267 |
p := nil. |
|
1268 |
closeTopWhenDone ifTrue:[ |
|
1269 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1270 |
connectedTop hide |
|
1271 |
]. |
|
1272 |
self topView hide. |
|
1273 |
finishAction value |
|
1274 |
]. |
|
1275 |
"/ ]. |
|
1276 |
||
1277 |
" |
|
1278 |
|p| |
|
1279 |
||
1280 |
p := ProgressIndicator inBox. |
|
1281 |
p showBusyIndication:true. |
|
1282 |
p showProgressOf: |
|
1283 |
[:progressValue :currentAction | |
|
1284 |
1 to:200 do:[:percent | |
|
1285 |
(Delay forSeconds:0.05) wait. |
|
1286 |
progressValue value:percent |
|
1287 |
]. |
|
1288 |
]. |
|
1289 |
||
1290 |
'it can be reused ...'. |
|
1291 |
p showBusyIndication:false. |
|
1292 |
p showProgressOf: |
|
1293 |
[:progressValue :currentAction | |
|
1294 |
1 to:100 by:5 do:[:percent | |
|
1295 |
(Delay forSeconds:0.05) wait. |
|
1296 |
progressValue value:percent |
|
1297 |
]. |
|
1298 |
]. |
|
1299 |
||
1300 |
" |
|
1301 |
||
1302 |
"Created: / 14-09-2011 / 11:02:21 / cg" |
|
1303 |
! |
|
1304 |
||
1305 |
old_showProgressOf:aBlock |
|
1306 |
"show progress, while evaluating aBlock. |
|
1307 |
If the receiver has been created with inBox, show the |
|
1308 |
box centered on the screen. If not, the view is assumed to |
|
1309 |
be contained in another view, and no special startup actions |
|
1310 |
are performed. |
|
1311 |
||
1312 |
The block is passed two arguments, the progressValue, |
|
1313 |
which should be set to the percentage from time-to-time |
|
1314 |
within the block and an action value, which should be set to |
|
1315 |
the currently performed action (a string) from time to time. |
|
1316 |
The second valueHolder can be left unchanged. |
|
1317 |
||
1318 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1319 |
||
1320 |
|progressValue labelValue p aborted| |
|
1321 |
||
1322 |
progressValue := 0 asValue. |
|
1323 |
aborted := false. |
|
1324 |
||
1325 |
connectedLabel notNil ifTrue:[ |
|
1326 |
labelValue := (connectedLabel label ? '') asValue. |
|
1327 |
connectedLabel |
|
1328 |
model:labelValue; |
|
1329 |
aspect:#value; |
|
1330 |
labelMessage:#value. |
|
1331 |
] ifFalse:[ |
|
1332 |
labelValue := '' asValue. |
|
1333 |
]. |
|
1334 |
||
1335 |
self model:progressValue. |
|
1336 |
||
1337 |
"/ the worker process |
|
1338 |
||
1339 |
p := [ |
|
1340 |
[ |
|
1341 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1342 |
ex proceedWith:self topView windowGroup |
|
1343 |
] do:[ |
|
1344 |
AbortSignal handle:[:ex | |
|
1345 |
aborted := true |
|
1346 |
] do:[ |
|
1347 |
aBlock value:progressValue value:labelValue |
|
1348 |
] |
|
1349 |
] |
|
1350 |
] ensure:[ |
|
1351 |
p := nil. |
|
1352 |
closeTopWhenDone ifTrue:[ |
|
1353 |
connectedTop sensor pushEvent:(WindowEvent terminateView:connectedTop). |
|
1354 |
connectedTop hide |
|
1355 |
]. |
|
1356 |
finishAction value |
|
1357 |
] |
|
1358 |
] newProcess. |
|
1359 |
||
1360 |
Processor activeProcess |
|
1361 |
withHigherPriorityDo:[ |
|
1362 |
p resume. |
|
1363 |
self topView show. |
|
1364 |
]. |
|
1365 |
p notNil ifTrue:[p terminate]. |
|
1366 |
aborted ifTrue:[ |
|
1367 |
AbortSignal raiseRequest |
|
1368 |
]. |
|
1369 |
||
1370 |
" |
|
1371 |
|p| |
|
1372 |
||
1373 |
p := ProgressIndicator inBox. |
|
1374 |
p showBusyIndication:true. |
|
1375 |
p showProgressOf: |
|
1376 |
[:progressValue :currentAction | |
|
1377 |
1 to:200 do:[:percent | |
|
1378 |
(Delay forSeconds:0.05) wait. |
|
1379 |
progressValue value:percent |
|
1380 |
]. |
|
1381 |
]. |
|
1382 |
||
1383 |
'it can be reused ...'. |
|
1384 |
p showBusyIndication:false. |
|
1385 |
p showProgressOf: |
|
1386 |
[:progressValue :currentAction | |
|
1387 |
1 to:100 by:5 do:[:percent | |
|
1388 |
(Delay forSeconds:0.05) wait. |
|
1389 |
progressValue value:percent |
|
1390 |
]. |
|
1391 |
]. |
|
1392 |
||
1393 |
" |
|
1394 |
||
1395 |
"Modified: / 12-09-2011 / 09:57:03 / cg" |
|
1396 |
"Created: / 14-09-2011 / 11:00:12 / cg" |
|
1397 |
! |
|
1398 |
||
2850 | 1399 |
showBusyIndicatorDuring:aBlock |
1400 |
"show progress, while evaluating aBlock. |
|
1401 |
If the receiver has been created with inBox, show the |
|
1402 |
box centered on the screen. If not, the view is assumed to |
|
1403 |
be contained in another view, and no special startup actions |
|
1404 |
are performed. |
|
1405 |
||
1406 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1407 |
||
1408 |
|labelValue p| |
|
1409 |
||
1410 |
connectedLabel notNil ifTrue:[ |
|
1411 |
labelValue := (connectedLabel label ? '') asValue. |
|
1412 |
connectedLabel |
|
1413 |
model:labelValue; |
|
1414 |
aspect:#value; |
|
1415 |
labelMessage:#value. |
|
1416 |
] ifFalse:[ |
|
1417 |
labelValue := '' asValue. |
|
1418 |
]. |
|
1419 |
||
1420 |
||
1421 |
"/ the worker process |
|
1422 |
||
1423 |
p := [ |
|
1424 |
[ |
|
1425 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1426 |
ex proceedWith:self topView windowGroup |
|
1427 |
] do:[ |
|
1428 |
aBlock value |
|
1429 |
] |
|
1430 |
] ensure:[ |
|
1431 |
p := nil. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1432 |
self stopBusyIndicationProcess. |
2850 | 1433 |
closeTopWhenDone ifTrue:[ |
1434 |
connectedTop hide |
|
1435 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1436 |
finishAction value. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1437 |
|
2850 | 1438 |
] |
1439 |
] newProcess. |
|
1440 |
||
1441 |
Processor activeProcess |
|
2878 | 1442 |
withHigherPriorityDo: |
1443 |
[ |
|
1444 |
p resume. |
|
1445 |
self topView show. |
|
1446 |
]. |
|
2850 | 1447 |
p notNil ifTrue:[p terminate]. |
1448 |
||
1449 |
" |
|
1450 |
|p| |
|
1451 |
||
1452 |
p := ProgressIndicator inBox. |
|
1453 |
p showBusyIndication:true. |
|
1454 |
p showProgressOf: |
|
1455 |
[:progressValue :currentAction | |
|
1456 |
1 to:200 do:[:percent | |
|
1457 |
(Delay forSeconds:0.05) wait. |
|
1458 |
progressValue value:percent |
|
1459 |
]. |
|
1460 |
]. |
|
1461 |
||
1462 |
'it can be reused ...'. |
|
1463 |
p showBusyIndication:false. |
|
1464 |
p showProgressOf: |
|
1465 |
[:progressValue :currentAction | |
|
1466 |
1 to:100 by:5 do:[:percent | |
|
1467 |
(Delay forSeconds:0.05) wait. |
|
1468 |
progressValue value:percent |
|
1469 |
]. |
|
1470 |
]. |
|
1471 |
||
1472 |
" |
|
1473 |
||
1474 |
"Modified: / 21.10.1998 / 17:37:00 / cg" |
|
1475 |
! |
|
1476 |
||
62 | 1477 |
showProgressOf:aBlock |
1478 |
"show progress, while evaluating aBlock. |
|
1479 |
If the receiver has been created with inBox, show the |
|
1480 |
box centered on the screen. If not, the view is assumed to |
|
1481 |
be contained in another view, and no special startup actions |
|
1482 |
are performed. |
|
1483 |
||
1484 |
The block is passed two arguments, the progressValue, |
|
1485 |
which should be set to the percentage from time-to-time |
|
1486 |
within the block and an action value, which should be set to |
|
1487 |
the currently performed action (a string) from time to time. |
|
1488 |
The second valueHolder can be left unchanged. |
|
1489 |
||
1490 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1491 |
||
4078 | 1492 |
"/ ^ self old_showProgressOf:aBlock |
1493 |
^ self new_showProgressOf:aBlock |
|
62 | 1494 |
|
1495 |
" |
|
1496 |
|p| |
|
1497 |
||
1498 |
p := ProgressIndicator inBox. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1499 |
p showBusyIndication:true. |
62 | 1500 |
p showProgressOf: |
2837 | 1501 |
[:progressValue :currentAction | |
1502 |
1 to:200 do:[:percent | |
|
1503 |
(Delay forSeconds:0.05) wait. |
|
1504 |
progressValue value:percent |
|
1505 |
]. |
|
1506 |
]. |
|
62 | 1507 |
|
1508 |
'it can be reused ...'. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1509 |
p showBusyIndication:false. |
62 | 1510 |
p showProgressOf: |
2837 | 1511 |
[:progressValue :currentAction | |
1512 |
1 to:100 by:5 do:[:percent | |
|
1513 |
(Delay forSeconds:0.05) wait. |
|
1514 |
progressValue value:percent |
|
1515 |
]. |
|
1516 |
]. |
|
62 | 1517 |
|
1518 |
" |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
1519 |
|
4078 | 1520 |
"Modified: / 14-09-2011 / 17:03:08 / cg" |
62 | 1521 |
! ! |
1522 |
||
334 | 1523 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 1524 |
|
183 | 1525 |
version |
4078 | 1526 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.67 2011-09-14 16:41:21 cg Exp $' |
3827
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1527 |
! |
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1528 |
|
ec0aed04e61f
changed: #displayProgress:at:from:to:during:
Claus Gittinger <cg@exept.de>
parents:
3748
diff
changeset
|
1529 |
version_CVS |
4078 | 1530 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.67 2011-09-14 16:41:21 cg Exp $' |
50 | 1531 |
! ! |