author | Claus Gittinger <cg@exept.de> |
Fri, 18 Sep 2009 18:09:36 +0200 | |
changeset 3748 | 4d72710a919e |
parent 3626 | b2087f53346e |
child 3827 | ec0aed04e61f |
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 |
||
3542 | 545 |
!ProgressIndicator class methodsFor:'simple puplic API'! |
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 |
||
552 |
|p| |
|
553 |
||
554 |
p := self |
|
555 |
inBoxWithLabel:aLabel |
|
556 |
icon:nil |
|
557 |
text:aLabel |
|
558 |
abortable:abortable |
|
559 |
view:nil |
|
560 |
closeWhenDone:true. |
|
561 |
||
562 |
p showBusyIndication:true. |
|
563 |
p showBusyIndicatorDuring:[ |
|
564 |
CannotReturnError catch:[ |
|
565 |
aBlock valueWithOptionalArgument:p. |
|
566 |
] |
|
567 |
] |
|
568 |
||
569 |
" |
|
570 |
ProgressIndicator |
|
571 |
displayBusyIndicator:'doobidoobidoo...' |
|
572 |
abortable:true |
|
573 |
at:(Screen default center) |
|
574 |
during:[ |
|
575 |
200 to:400 by:5 do:[:i | |
|
576 |
Delay waitForSeconds:0.1. |
|
577 |
] |
|
578 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
579 |
|
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
580 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
581 |
displayBusyIndicator:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
582 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
583 |
at:(Screen default center) |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
584 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
585 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
586 |
]. |
3542 | 587 |
" |
588 |
! |
|
589 |
||
590 |
displayBusyIndicator:aLabel at:aPoint during:aBlock |
|
591 |
"easy interface - show progress while evaluating aBlock. |
|
592 |
The block is passed a valueHolder, which is to be set to values from |
|
593 |
startValue to endValue during the blocks evaluation. |
|
594 |
This is scaled to 0..100% completion. |
|
595 |
Set the valueHolder to nil, to get a busy-indicator" |
|
596 |
||
597 |
self |
|
598 |
displayBusyIndicator:aLabel |
|
599 |
abortable:false |
|
600 |
at:aPoint |
|
601 |
during:aBlock |
|
602 |
||
603 |
" |
|
604 |
ProgressIndicator |
|
605 |
displayBusyIndicator:'doobidoobidoo...' |
|
606 |
at:(Screen default center) |
|
607 |
during:[ |
|
608 |
200 to:400 by:5 do:[:i | |
|
609 |
Delay waitForSeconds:0.1. |
|
610 |
] |
|
611 |
]. |
|
612 |
" |
|
613 |
! |
|
614 |
||
615 |
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock |
|
616 |
"easy interface - show progress while evaluating aBlock. |
|
617 |
The block is passed a valueHolder, which is to be set to values from |
|
618 |
startValue to endValue during the blocks evaluation. |
|
619 |
This is scaled to 0..100% completion. |
|
620 |
Set the valueHolder to nil, to get a busy-indicator" |
|
621 |
||
622 |
|p| |
|
623 |
||
624 |
p := self |
|
625 |
inBoxWithLabel:aLabel |
|
626 |
icon:nil |
|
627 |
text:aLabel |
|
628 |
abortable:false |
|
629 |
view:nil |
|
630 |
closeWhenDone:true. |
|
631 |
||
632 |
p showProgressOf:[:progressValue :currentAction | |
|
633 |
|scaler| |
|
634 |
||
635 |
scaler := [:scaledValue | |
|
636 |
|newPercentage oldPercentage oldLabel| |
|
637 |
||
638 |
scaledValue isNil ifTrue:[ |
|
639 |
p showBusyIndication:true |
|
640 |
] ifFalse:[ |
|
641 |
p showBusyIndication:false. |
|
642 |
oldPercentage := progressValue value. |
|
643 |
newPercentage := (scaledValue - startValue) / (endValue-startValue) * 100. |
|
644 |
newPercentage ~= oldPercentage ifTrue:[ |
|
645 |
progressValue value:newPercentage. |
|
646 |
]. |
|
647 |
oldLabel := currentAction value. |
|
648 |
oldLabel ~= aLabel ifTrue:[ |
|
649 |
currentAction value:aLabel. |
|
650 |
] |
|
651 |
] |
|
652 |
]. |
|
653 |
CannotReturnError catch:[ |
|
654 |
aBlock valueWithOptionalArgument:scaler and:p. |
|
655 |
] |
|
656 |
] |
|
657 |
||
658 |
" |
|
659 |
ProgressIndicator |
|
660 |
displayProgress:'doobidoobidoo...' |
|
661 |
at:(Screen default center) |
|
662 |
from:200 to:400 |
|
663 |
during:[:val | |
|
664 |
200 to:400 by:5 do:[:i | |
|
665 |
val value:i. |
|
666 |
Delay waitForSeconds:0.1. |
|
667 |
] |
|
668 |
]. |
|
669 |
" |
|
670 |
! |
|
671 |
||
672 |
displayProgressNotifications:aLabel abortable:abortable at:aPointOrNil during:aBlock |
|
673 |
"easy interface - show progress as provided by progressNotifications |
|
674 |
while evaluating aBlock. |
|
675 |
The block is passed the progressIndicator as optional argument, |
|
676 |
however, progressNotifications are handled and update the percentage." |
|
677 |
||
678 |
|p| |
|
679 |
||
680 |
p := self |
|
681 |
inBoxWithLabel:aLabel |
|
682 |
icon:nil |
|
683 |
text:aLabel |
|
684 |
abortable:abortable |
|
685 |
view:nil |
|
686 |
closeWhenDone:true. |
|
687 |
||
688 |
p showBusyIndicatorDuring:[ |
|
689 |
CannotReturnError catch:[ |
|
690 |
ProgressNotification handle:[:ex | |
|
691 |
p percentage:ex progressValue. |
|
692 |
ex proceed. |
|
693 |
] do:[ |
|
694 |
aBlock valueWithOptionalArgument:p. |
|
695 |
]. |
|
696 |
] |
|
697 |
] |
|
698 |
||
699 |
" |
|
700 |
ProgressIndicator |
|
701 |
displayProgressNotifications:'doobidoobidoo...' |
|
702 |
abortable:true |
|
703 |
at:nil |
|
704 |
during:[ |
|
705 |
200 to:400 by:5 do:[:i | |
|
706 |
Delay waitForSeconds:0.1. |
|
707 |
ProgressNotification progressPercentage:(i / 4). |
|
708 |
] |
|
709 |
]. |
|
710 |
" |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
711 |
" |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
712 |
ProgressIndicator |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
713 |
displayProgressNotifications:'doobidoobidoo...' |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
714 |
abortable:true |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
715 |
at:nil |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
716 |
during:[ |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
717 |
Delay waitForSeconds:3. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
718 |
]. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
719 |
" |
3542 | 720 |
! ! |
721 |
||
183 | 722 |
!ProgressIndicator methodsFor:'accessing'! |
723 |
||
334 | 724 |
percentage:aNumber |
725 |
"set the percentage" |
|
237 | 726 |
|
183 | 727 |
|newPercentage| |
728 |
||
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
729 |
aNumber < 0 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
730 |
newPercentage := -1. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
731 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
732 |
newPercentage := ((aNumber max:0) min:100) rounded. |
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
733 |
]. |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
734 |
newPercentage ~= percentage ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
735 |
percentage := newPercentage. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
736 |
self invalidateRepairNow:true. |
183 | 737 |
] |
334 | 738 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
739 |
"Modified: / 6.6.1998 / 19:43:56 / cg" |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
740 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
741 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
742 |
showBusyIndication:aBooleanHolder |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
743 |
"switch between percentage mode (if false) and busy indication (if true)" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
744 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
745 |
aBooleanHolder ~~ showBusy ifTrue:[ |
2563 | 746 |
showBusy notNil ifTrue:[ |
747 |
showBusy removeDependent:self. |
|
748 |
]. |
|
749 |
showBusy := aBooleanHolder. |
|
750 |
showBusy addDependent:self. |
|
751 |
(showBusy value) ifTrue:[ |
|
752 |
self startBusyIndicationProcess. |
|
753 |
] ifFalse:[ |
|
754 |
self stopBusyIndicationProcess |
|
755 |
]. |
|
756 |
shown ifTrue:[self redraw] |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
757 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
758 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
759 |
"Created: / 21.10.1998 / 17:35:16 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
760 |
"Modified: / 21.10.1998 / 18:03:06 / cg" |
334 | 761 |
! ! |
762 |
||
2404 | 763 |
!ProgressIndicator methodsFor:'accessing-behavior'! |
764 |
||
765 |
closeTopWhenDone:aBoolean |
|
766 |
"set/clear the close-topView-when-done flag" |
|
767 |
||
768 |
closeTopWhenDone := aBoolean |
|
769 |
||
770 |
"Created: 3.9.1996 / 14:22:03 / cg" |
|
771 |
"Modified: 29.3.1997 / 16:08:19 / cg" |
|
772 |
! |
|
773 |
||
774 |
finishAction:aBlock |
|
775 |
"define an action to be performed when finished" |
|
776 |
||
777 |
finishAction := aBlock |
|
778 |
||
779 |
"Created: 3.9.1996 / 14:15:15 / cg" |
|
780 |
"Modified: 29.3.1997 / 16:08:35 / cg" |
|
781 |
! ! |
|
782 |
||
783 |
!ProgressIndicator methodsFor:'accessing-look'! |
|
334 | 784 |
|
826 | 785 |
backgroundColor |
786 |
"return the percentage displays background color" |
|
787 |
||
788 |
^ bgColor |
|
789 |
||
790 |
! |
|
791 |
||
792 |
backgroundColor:aColor |
|
793 |
"set the percentage displays background color" |
|
794 |
||
993 | 795 |
aColor ~= bgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
796 |
bgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
797 |
self invalidateRepairNow:true |
826 | 798 |
]. |
799 |
||
993 | 800 |
"Modified: / 20.7.1998 / 23:32:48 / cg" |
826 | 801 |
! |
802 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
803 |
foregroundColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
804 |
"return the percentage displays foreground color" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
805 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
806 |
^ fgColor |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
807 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
808 |
"Created: 29.3.1997 / 16:12:28 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
809 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
810 |
|
334 | 811 |
foregroundColor:aColor |
812 |
"set the percentage displays foreground color" |
|
813 |
||
993 | 814 |
aColor ~= fgColor ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
815 |
fgColor := aColor. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
816 |
self invalidateRepairNow:true |
336 | 817 |
]. |
334 | 818 |
|
993 | 819 |
"Modified: / 20.7.1998 / 23:27:47 / cg" |
183 | 820 |
! |
821 |
||
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
822 |
showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
823 |
"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
|
824 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
825 |
^ showPercentage |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
826 |
|
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
827 |
"Created: 29.3.1997 / 16:12:39 / cg" |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
828 |
! |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
829 |
|
183 | 830 |
showPercentage:aBoolean |
334 | 831 |
"set/clear the flag controlling if the percentage is to be shown numerically" |
832 |
||
336 | 833 |
showPercentage := aBoolean. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
834 |
self invalidateRepairNow:true |
334 | 835 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
836 |
"Modified: / 6.6.1998 / 19:28:44 / cg" |
183 | 837 |
! ! |
838 |
||
839 |
!ProgressIndicator methodsFor:'change & update'! |
|
840 |
||
841 |
update:aspect with:aParameter from:changedObject |
|
574 | 842 |
"react upon value changes of my model" |
843 |
||
183 | 844 |
(aspect == aspectMsg |
845 |
and:[changedObject == model]) ifTrue:[ |
|
3748 | 846 |
self percentage:(model perform:aspectMsg). |
847 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
848 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
849 |
changedObject == showBusy ifTrue:[ |
3748 | 850 |
showBusy value |
851 |
ifTrue:[self startBusyIndicationProcess] |
|
852 |
ifFalse:[self stopBusyIndicationProcess]. |
|
853 |
self redraw. |
|
854 |
^ self |
|
183 | 855 |
]. |
856 |
^ super update:aspect with:aParameter from:changedObject |
|
574 | 857 |
|
3748 | 858 |
"Modified: / 21-10-1998 / 18:01:52 / cg" |
859 |
"Modified: / 01-11-2006 / 08:40:50 / janfrog" |
|
183 | 860 |
! ! |
861 |
||
862 |
!ProgressIndicator methodsFor:'drawing'! |
|
863 |
||
864 |
redraw |
|
574 | 865 |
"redraw the percentage bar and optional percentage string" |
866 |
||
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
867 |
|s lx rx sx sy sw m2 m w h doBusy| |
183 | 868 |
|
3748 | 869 |
self shown ifFalse:[^self]. |
870 |
||
183 | 871 |
m := margin + 1. |
863 | 872 |
m2 := m*2. |
873 |
||
874 |
w := width - m2. |
|
875 |
h := height - m2. |
|
183 | 876 |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
865
diff
changeset
|
877 |
"/ self clear. |
863 | 878 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
879 |
doBusy := showBusy value. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
880 |
doBusy ifFalse:[ |
3748 | 881 |
percentage value < 0 ifTrue:[ |
882 |
self startBusyIndicationProcess. |
|
883 |
doBusy := true. |
|
884 |
]. |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
885 |
]. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
886 |
|
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
887 |
doBusy ifTrue:[ |
3748 | 888 |
self paint:bgColor. |
889 |
self fillRectangleX:m y:m width:w height:h. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
890 |
|
3748 | 891 |
lx := (w * busyPosition / 100) rounded. |
892 |
rx := (w * (busyPosition + 20) / 100) rounded. |
|
893 |
rx := rx min:w. |
|
894 |
lx := lx max:m. |
|
895 |
self paint:fgColor. |
|
896 |
self fillRectangleX:lx y:m width:(rx - lx) height:h. |
|
897 |
^ self |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
898 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
899 |
|
2040
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
900 |
self stopBusyIndicationProcess. |
702df7addef9
busy indicator when percentage is negative
Claus Gittinger <cg@exept.de>
parents:
1935
diff
changeset
|
901 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
902 |
rx := (w * percentage / 100) rounded. |
826 | 903 |
self paint:bgColor. |
843 | 904 |
self fillRectangleX:m+rx y:m width:w-rx height:h. |
183 | 905 |
|
906 |
showPercentage ifTrue:[ |
|
3748 | 907 |
s := percentage printString , ' %'. |
908 |
font := font onDevice:device. |
|
909 |
sw := font widthOf:s . |
|
910 |
sx := (width - sw) // 2. |
|
911 |
sy := height // 2 + font descent + 2. |
|
347 | 912 |
|
3748 | 913 |
rx <= (sx+sw) ifTrue:[ |
914 |
self paint:Color black. |
|
915 |
self displayString:s x:sx y:sy. |
|
916 |
] |
|
183 | 917 |
]. |
918 |
||
919 |
self paint:fgColor. |
|
920 |
self fillRectangleX:m y:m width:rx height:h. |
|
921 |
||
922 |
showPercentage ifTrue:[ |
|
3748 | 923 |
rx >= sx ifTrue:[ |
924 |
self clippingRectangle:(m@m corner:rx+1 @ h). |
|
925 |
self paint:Color white. |
|
926 |
self displayString:s x:sx y:sy. |
|
927 |
self clippingRectangle:nil |
|
928 |
] |
|
183 | 929 |
] |
347 | 930 |
|
3748 | 931 |
"Modified: / 21-10-1998 / 18:01:58 / cg" |
932 |
"Modified: / 12-12-2006 / 18:26:02 / janfrog" |
|
863 | 933 |
! |
934 |
||
935 |
sizeChanged:how |
|
936 |
super sizeChanged:how. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
937 |
self invalidate |
863 | 938 |
|
939 |
"Created: / 18.4.1998 / 02:34:37 / cg" |
|
865 | 940 |
"Modified: / 18.4.1998 / 14:09:40 / cg" |
183 | 941 |
! ! |
942 |
||
2501 | 943 |
!ProgressIndicator methodsFor:'initialization & release'! |
183 | 944 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
945 |
destroy |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
946 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 947 |
self stopBusyIndicationProcess |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
948 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
949 |
super destroy. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
950 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
951 |
"Created: / 21.10.1998 / 17:29:58 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
952 |
"Modified: / 21.10.1998 / 17:30:36 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
953 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
954 |
|
574 | 955 |
initStyle |
956 |
"initialize styleSheet values" |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
957 |
|
575 | 958 |
<resource: #style (#'progressIndicator.viewBackground' |
2921 | 959 |
#'progressIndicator.foregroundColor')> |
574 | 960 |
|
961 |
super initStyle. |
|
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
962 |
|
347 | 963 |
self is3D ifTrue:[ |
2921 | 964 |
self level:-1 |
347 | 965 |
]. |
966 |
||
826 | 967 |
bgColor := styleSheet colorAt:'progressIndicator.viewBackground' default:Color white. |
574 | 968 |
fgColor := styleSheet colorAt:'progressIndicator.foregroundColor' default:Color blue. |
335
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
969 |
fgColor := fgColor onDevice:device. |
6f007bdeae94
resource-tag & access methods.
Claus Gittinger <cg@exept.de>
parents:
334
diff
changeset
|
970 |
|
183 | 971 |
showPercentage := true. |
574 | 972 |
! |
973 |
||
974 |
initialize |
|
826 | 975 |
|
574 | 976 |
super initialize. |
826 | 977 |
|
574 | 978 |
percentage := 0. |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
979 |
showBusy := false. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
980 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
981 |
"Modified: / 21.10.1998 / 17:33:02 / cg" |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
982 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
983 |
|
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
984 |
mapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
985 |
super mapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
986 |
(showBusy value) ifTrue:[ |
2563 | 987 |
self startBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
988 |
]. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
989 |
! |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
990 |
|
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
991 |
unmapped |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
992 |
super unmapped. |
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
993 |
(showBusy value) ifTrue:[ |
2563 | 994 |
self stopBusyIndicationProcess. |
1935
a2338e64cf2f
terminate/recreate busyIndicator-animation process if unmapped/mapped
frank
parents:
1852
diff
changeset
|
995 |
]. |
574 | 996 |
! ! |
997 |
||
998 |
!ProgressIndicator methodsFor:'private'! |
|
999 |
||
1000 |
connectToTop:top label:label |
|
1001 |
connectedTop := top. |
|
1002 |
connectedLabel := label |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1003 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1004 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1005 |
startBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1006 |
busyIndicationProcess isNil ifTrue:[ |
2563 | 1007 |
busyPosition := 0. |
1008 |
busyDelta := 5. |
|
1009 |
busyIndicationProcess := [ |
|
1010 |
[self realized] whileTrue:[ |
|
1011 |
Delay waitForSeconds:0.2. |
|
1012 |
self shown ifTrue:[ |
|
1013 |
self updateBusyIndicatorPosition. |
|
1014 |
] |
|
1015 |
]. |
|
1016 |
busyIndicationProcess := nil. |
|
1017 |
] fork. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1018 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1019 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1020 |
"Created: / 21.10.1998 / 18:02:35 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1021 |
"Modified: / 21.10.1998 / 18:03:49 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1022 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1023 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1024 |
stopBusyIndicationProcess |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1025 |
busyIndicationProcess notNil ifTrue:[ |
2563 | 1026 |
busyIndicationProcess terminate. |
1027 |
busyIndicationProcess := nil |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1028 |
]. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1029 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1030 |
"Created: / 21.10.1998 / 17:30:19 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1031 |
! |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1032 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1033 |
updateBusyIndicatorPosition |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1034 |
busyPosition := busyPosition + busyDelta. |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1035 |
busyPosition >= 80 ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1036 |
busyDelta > 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1037 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1038 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1039 |
] ifFalse:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1040 |
busyPosition <= 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1041 |
busyDelta < 0 ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1042 |
busyDelta := busyDelta negated. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1043 |
] |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1044 |
] |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1045 |
]. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2563
diff
changeset
|
1046 |
self invalidate |
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1047 |
|
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1048 |
"Created: / 21.10.1998 / 17:33:28 / cg" |
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1049 |
"Modified: / 21.10.1998 / 17:58:58 / cg" |
183 | 1050 |
! ! |
1051 |
||
1052 |
!ProgressIndicator methodsFor:'queries'! |
|
1053 |
||
1054 |
preferredExtent |
|
574 | 1055 |
"return my preferred extent" |
1056 |
||
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1057 |
"/ If I have an explicit preferredExtent.. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1058 |
explicitExtent notNil ifTrue:[ |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1059 |
^ explicitExtent |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1060 |
]. |
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1061 |
|
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1062 |
"/ If I have a cached preferredExtent value.. |
334 | 1063 |
preferredExtent notNil ifTrue:[ |
3581
3a61a4e2a631
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3542
diff
changeset
|
1064 |
^ preferredExtent |
334 | 1065 |
]. |
183 | 1066 |
^ 100 @ (font height + font descent + ((margin + 1) * 2)) |
334 | 1067 |
|
574 | 1068 |
"Modified: 22.10.1997 / 21:07:17 / cg" |
183 | 1069 |
! ! |
1070 |
||
62 | 1071 |
!ProgressIndicator methodsFor:'showing progress'! |
1072 |
||
2850 | 1073 |
showBusyIndicatorDuring:aBlock |
1074 |
"show progress, while evaluating aBlock. |
|
1075 |
If the receiver has been created with inBox, show the |
|
1076 |
box centered on the screen. If not, the view is assumed to |
|
1077 |
be contained in another view, and no special startup actions |
|
1078 |
are performed. |
|
1079 |
||
1080 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1081 |
||
1082 |
|labelValue p| |
|
1083 |
||
1084 |
connectedLabel notNil ifTrue:[ |
|
1085 |
labelValue := (connectedLabel label ? '') asValue. |
|
1086 |
connectedLabel |
|
1087 |
model:labelValue; |
|
1088 |
aspect:#value; |
|
1089 |
labelMessage:#value. |
|
1090 |
] ifFalse:[ |
|
1091 |
labelValue := '' asValue. |
|
1092 |
]. |
|
1093 |
||
1094 |
||
1095 |
"/ the worker process |
|
1096 |
||
1097 |
p := [ |
|
1098 |
[ |
|
1099 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1100 |
ex proceedWith:self topView windowGroup |
|
1101 |
] do:[ |
|
1102 |
aBlock value |
|
1103 |
] |
|
1104 |
] ensure:[ |
|
1105 |
p := nil. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1106 |
self stopBusyIndicationProcess. |
2850 | 1107 |
closeTopWhenDone ifTrue:[ |
1108 |
connectedTop hide |
|
1109 |
]. |
|
3626
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1110 |
finishAction value. |
b2087f53346e
ensure that busyindicator process is terminated
Claus Gittinger <cg@exept.de>
parents:
3581
diff
changeset
|
1111 |
|
2850 | 1112 |
] |
1113 |
] newProcess. |
|
1114 |
||
1115 |
Processor activeProcess |
|
2878 | 1116 |
withHigherPriorityDo: |
1117 |
[ |
|
1118 |
p resume. |
|
1119 |
self topView show. |
|
1120 |
]. |
|
2850 | 1121 |
p notNil ifTrue:[p terminate]. |
1122 |
||
1123 |
" |
|
1124 |
|p| |
|
1125 |
||
1126 |
p := ProgressIndicator inBox. |
|
1127 |
p showBusyIndication:true. |
|
1128 |
p showProgressOf: |
|
1129 |
[:progressValue :currentAction | |
|
1130 |
1 to:200 do:[:percent | |
|
1131 |
(Delay forSeconds:0.05) wait. |
|
1132 |
progressValue value:percent |
|
1133 |
]. |
|
1134 |
]. |
|
1135 |
||
1136 |
'it can be reused ...'. |
|
1137 |
p showBusyIndication:false. |
|
1138 |
p showProgressOf: |
|
1139 |
[:progressValue :currentAction | |
|
1140 |
1 to:100 by:5 do:[:percent | |
|
1141 |
(Delay forSeconds:0.05) wait. |
|
1142 |
progressValue value:percent |
|
1143 |
]. |
|
1144 |
]. |
|
1145 |
||
1146 |
" |
|
1147 |
||
1148 |
"Modified: / 21.10.1998 / 17:37:00 / cg" |
|
1149 |
! |
|
1150 |
||
62 | 1151 |
showProgressOf:aBlock |
1152 |
"show progress, while evaluating aBlock. |
|
1153 |
If the receiver has been created with inBox, show the |
|
1154 |
box centered on the screen. If not, the view is assumed to |
|
1155 |
be contained in another view, and no special startup actions |
|
1156 |
are performed. |
|
1157 |
||
1158 |
The block is passed two arguments, the progressValue, |
|
1159 |
which should be set to the percentage from time-to-time |
|
1160 |
within the block and an action value, which should be set to |
|
1161 |
the currently performed action (a string) from time to time. |
|
1162 |
The second valueHolder can be left unchanged. |
|
1163 |
||
1164 |
Caveat: cannot (currently) suppress close of the box ..." |
|
1165 |
||
221 | 1166 |
|progressValue labelValue p| |
62 | 1167 |
|
1168 |
progressValue := 0 asValue. |
|
1169 |
||
1170 |
connectedLabel notNil ifTrue:[ |
|
2837 | 1171 |
labelValue := (connectedLabel label ? '') asValue. |
1172 |
connectedLabel |
|
1173 |
model:labelValue; |
|
1174 |
aspect:#value; |
|
1175 |
labelMessage:#value. |
|
1834
ba170c21ed76
defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1176 |
] ifFalse:[ |
2837 | 1177 |
labelValue := '' asValue. |
62 | 1178 |
]. |
1179 |
||
1834
ba170c21ed76
defaultExtent computation fixed
Claus Gittinger <cg@exept.de>
parents:
1789
diff
changeset
|
1180 |
|
62 | 1181 |
self model:progressValue. |
1182 |
||
221 | 1183 |
"/ the worker process |
1184 |
||
62 | 1185 |
p := [ |
2837 | 1186 |
[ |
1187 |
WindowGroup windowGroupQuerySignal handle:[:ex | |
|
1188 |
ex proceedWith:self topView windowGroup |
|
1189 |
] do:[ |
|
1190 |
aBlock value:progressValue value:labelValue |
|
1191 |
] |
|
1192 |
] ensure:[ |
|
1193 |
p := nil. |
|
1194 |
closeTopWhenDone ifTrue:[ |
|
1195 |
connectedTop hide |
|
1196 |
]. |
|
1197 |
finishAction value |
|
1198 |
] |
|
1850 | 1199 |
] newProcess. |
62 | 1200 |
|
237 | 1201 |
Processor activeProcess |
2878 | 1202 |
withHigherPriorityDo:[ |
2837 | 1203 |
p resume. |
1204 |
self topView show. |
|
1205 |
]. |
|
237 | 1206 |
p notNil ifTrue:[p terminate]. |
62 | 1207 |
|
1208 |
" |
|
1209 |
|p| |
|
1210 |
||
1211 |
p := ProgressIndicator inBox. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1212 |
p showBusyIndication:true. |
62 | 1213 |
p showProgressOf: |
2837 | 1214 |
[:progressValue :currentAction | |
1215 |
1 to:200 do:[:percent | |
|
1216 |
(Delay forSeconds:0.05) wait. |
|
1217 |
progressValue value:percent |
|
1218 |
]. |
|
1219 |
]. |
|
62 | 1220 |
|
1221 |
'it can be reused ...'. |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1222 |
p showBusyIndication:false. |
62 | 1223 |
p showProgressOf: |
2837 | 1224 |
[:progressValue :currentAction | |
1225 |
1 to:100 by:5 do:[:percent | |
|
1226 |
(Delay forSeconds:0.05) wait. |
|
1227 |
progressValue value:percent |
|
1228 |
]. |
|
1229 |
]. |
|
62 | 1230 |
|
1231 |
" |
|
219
44246b9b4288
use new windowGroupQuery for background process
Claus Gittinger <cg@exept.de>
parents:
201
diff
changeset
|
1232 |
|
1168
35e46761842f
added showBusyIndication mode
Claus Gittinger <cg@exept.de>
parents:
993
diff
changeset
|
1233 |
"Modified: / 21.10.1998 / 17:37:00 / cg" |
62 | 1234 |
! ! |
1235 |
||
334 | 1236 |
!ProgressIndicator class methodsFor:'documentation'! |
50 | 1237 |
|
183 | 1238 |
version |
3748 | 1239 |
^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.59 2009-09-18 16:09:36 cg Exp $' |
50 | 1240 |
! ! |