--- a/ProgressIndicator.st Fri Sep 30 18:13:53 2005 +0200
+++ b/ProgressIndicator.st Tue Oct 04 21:57:58 2005 +0200
@@ -386,6 +386,43 @@
!ProgressIndicator class methodsFor:'instance creation'!
+displayBusyIndicator:aLabel at:aPoint during:aBlock
+ "easy interface - show progress while evaluating aBlock.
+ The block is passed a valueHolder, which is to be set to values from
+ startValue to endValue during the blocks evaluation.
+ This is scaled to 0..100% completion.
+ Set the valueHolder to nil, to get a busy-indicator"
+
+ |p|
+
+ p := self
+ inBoxWithLabel:aLabel
+ icon:nil
+ text:aLabel
+ abortable:false
+ view:nil
+ closeWhenDone:true.
+
+ p showBusyIndication:true.
+ p showBusyIndicatorDuring:[
+ CannotReturnError handle:[:ex |
+ ] do:[
+ aBlock value.
+ ]
+ ]
+
+ "
+ ProgressIndicator
+ displayBusyIndicator:'doobidoobidoo...'
+ at:(Screen default center)
+ during:[
+ 200 to:400 by:5 do:[:i |
+ Delay waitForSeconds:0.1.
+ ]
+ ].
+ "
+!
+
displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock
"easy interface - show progress while evaluating aBlock.
The block is passed a valueHolder, which is to be set to values from
@@ -935,6 +972,82 @@
!ProgressIndicator methodsFor:'showing progress'!
+showBusyIndicatorDuring:aBlock
+ "show progress, while evaluating aBlock.
+ If the receiver has been created with inBox, show the
+ box centered on the screen. If not, the view is assumed to
+ be contained in another view, and no special startup actions
+ are performed.
+
+ Caveat: cannot (currently) suppress close of the box ..."
+
+ |labelValue p|
+
+ connectedLabel notNil ifTrue:[
+ labelValue := (connectedLabel label ? '') asValue.
+ connectedLabel
+ model:labelValue;
+ aspect:#value;
+ labelMessage:#value.
+ ] ifFalse:[
+ labelValue := '' asValue.
+ ].
+
+
+ "/ the worker process
+
+ p := [
+ [
+ WindowGroup windowGroupQuerySignal handle:[:ex |
+ ex proceedWith:self topView windowGroup
+ ] do:[
+ aBlock value
+ ]
+ ] ensure:[
+ p := nil.
+ closeTopWhenDone ifTrue:[
+ connectedTop hide
+ ].
+ finishAction value
+ ]
+ ] newProcess.
+
+ Processor activeProcess
+ withPriority:(Processor activePriority + 1)
+ do:[
+ p resume.
+ self topView show.
+ ].
+ p notNil ifTrue:[p terminate].
+
+ "
+ |p|
+
+ p := ProgressIndicator inBox.
+ p showBusyIndication:true.
+ p showProgressOf:
+ [:progressValue :currentAction |
+ 1 to:200 do:[:percent |
+ (Delay forSeconds:0.05) wait.
+ progressValue value:percent
+ ].
+ ].
+
+ 'it can be reused ...'.
+ p showBusyIndication:false.
+ p showProgressOf:
+ [:progressValue :currentAction |
+ 1 to:100 by:5 do:[:percent |
+ (Delay forSeconds:0.05) wait.
+ progressValue value:percent
+ ].
+ ].
+
+ "
+
+ "Modified: / 21.10.1998 / 17:37:00 / cg"
+!
+
showProgressOf:aBlock
"show progress, while evaluating aBlock.
If the receiver has been created with inBox, show the
@@ -1024,5 +1137,5 @@
!ProgressIndicator class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.48 2005-07-26 08:50:54 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.49 2005-10-04 19:57:58 cg Exp $'
! !