ProgressIndicator.st
changeset 1462 e3c0a367a7e8
parent 1328 95a7d89cf335
child 1463 741925565153
equal deleted inserted replaced
1461:1508f35230e6 1462:e3c0a367a7e8
   382 "
   382 "
   383 ! !
   383 ! !
   384 
   384 
   385 !ProgressIndicator class methodsFor:'instance creation'!
   385 !ProgressIndicator class methodsFor:'instance creation'!
   386 
   386 
       
   387 displayProgress:aLabel at:aPoint from:startValue to:endValue during:aBlock
       
   388     "easy interface - show progress while evaluating aBlock.
       
   389      The block is passed a valueHolder, which is to be set to values from
       
   390      startValue to endValue during the blocks evaluation.
       
   391      This is scaled to 0..100% completion."
       
   392 
       
   393     |p|
       
   394 
       
   395     p := self
       
   396             inBoxWithLabel:aLabel 
       
   397             icon:nil
       
   398             text:aLabel
       
   399             abortable:false
       
   400             view:nil
       
   401             closeWhenDone:true.
       
   402 
       
   403     p showProgressOf:[:progressValue :currentAction |
       
   404         aBlock value:[:scaledValue | progressValue value:( scaledValue - startValue
       
   405                                                            / (endValue-startValue)
       
   406                                                            * 100)].    
       
   407     ]
       
   408 
       
   409     "
       
   410      ProgressIndicator
       
   411         displayProgress:'doobidoobidoo...'
       
   412         at:(Screen default center)
       
   413         from:200
       
   414         to:400
       
   415         during:[:val |
       
   416             200 to:400 by:2 do:[:i |
       
   417                 val value:i.
       
   418                 Delay waitForSeconds:0.1.
       
   419             ]
       
   420         ].
       
   421     "
       
   422 !
       
   423 
   387 inBox
   424 inBox
   388     "create a topView containing an instance of myself,
   425     "create a topView containing an instance of myself,
   389      for later use with #showProgressOf:"
   426      for later use with #showProgressOf:"
   390 
   427 
   391     ^ self inBoxWithLabel:'executing ...' abortable:false
   428     ^ self inBoxWithLabel:'executing ...' abortable:false
   910 ! !
   947 ! !
   911 
   948 
   912 !ProgressIndicator class methodsFor:'documentation'!
   949 !ProgressIndicator class methodsFor:'documentation'!
   913 
   950 
   914 version
   951 version
   915     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.26 1999-04-23 12:46:51 cg Exp $'
   952     ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.27 1999-07-27 11:22:37 cg Exp $'
   916 ! !
   953 ! !