ShowMeHowItWorks.st
changeset 3790 a28f8340a3eb
parent 3787 7b01435dcf25
child 3791 471326a17840
equal deleted inserted replaced
3789:fac47345f7ba 3790:a28f8340a3eb
     6 
     6 
     7 Object subclass:#ShowMeHowItWorks
     7 Object subclass:#ShowMeHowItWorks
     8 	instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
     8 	instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
     9 		lastResult voice translate language verifying
     9 		lastResult voice translate language verifying
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui'
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui'
    11 	classVariableNames:'IntroShownCount DebugMode'
    11 	classVariableNames:'IntroShownCount DebugMode StartLabel'
    12 	poolDictionaries:''
    12 	poolDictionaries:''
    13 	category:'Interface-Help'
    13 	category:'Interface-Help'
    14 !
    14 !
    15 
    15 
    16 !ShowMeHowItWorks class methodsFor:'documentation'!
    16 !ShowMeHowItWorks class methodsFor:'documentation'!
   445         aSelectionInHierarchyView
   445         aSelectionInHierarchyView
   446     "    
   446     "    
   447 
   447 
   448     <action>
   448     <action>
   449 
   449 
       
   450     self drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:nil
       
   451 !
       
   452 
       
   453 drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:textWhenDroppingOrNil
       
   454     "drag an item (by index or label) from the current treeView,
       
   455      into another component.
       
   456      where is one of: #top, #center or #bottom.
       
   457      allowed after moving to:
       
   458         aSelectionInHierarchyView
       
   459     "    
       
   460 
       
   461     <action>
       
   462 
   450     |sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen
   463     |sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen
   451      targetPos targetPosOnScreen targetPosInSource|
   464      targetPos targetPosOnScreen targetPosInSource dNdMgr|
   452 
       
   453     self assert:( #(top center bottom) includes:where).
       
   454 
   465 
   455     verifying ifTrue:[^ self].
   466     verifying ifTrue:[^ self].
   456 
   467 
   457     targetComponent := self findComponent:targetComponentName.
   468     targetComponent := self findComponent:targetComponentName.
   458     self assert:targetComponent notNil.
   469     self assert:targetComponent notNil.
   459 
   470 
   460     ((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
   471     ((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
   461         sourceComponent := sourceComponent scrolledView.
   472         sourceComponent := sourceComponent scrolledView.
   462     ].
   473     ].
   463 
   474 
   464     (sourceComponent isKindOf:HierarchicalListView) ifTrue:[
   475     where == #topLeft ifTrue:[
   465         where == #top ifTrue:[
   476         targetPos := targetComponent topLeft + (1@1). 
   466             targetPos := targetComponent topCenter. 
   477     ] ifFalse:[
       
   478         where == #topCenter ifTrue:[
       
   479             targetPos := targetComponent topCenter + (0@1). 
   467         ] ifFalse:[
   480         ] ifFalse:[
   468             where == #center ifTrue:[
   481             where == #center ifTrue:[
   469                 targetPos := targetComponent center
   482                 targetPos := targetComponent center
   470             ] ifFalse:[
   483             ] ifFalse:[
   471                 where == #bottom ifTrue:[
   484                 where == #bottomCenter ifTrue:[
   472                     targetPos := targetComponent bottomCenter - (0 @ 1)
   485                     targetPos := targetComponent bottomCenter - (0 @ 1)
       
   486                 ] ifFalse:[
       
   487                     where == #bottomLeft ifTrue:[
       
   488                         targetPos := targetComponent bottomLeft + (1 @ -1)
       
   489                     ] ifFalse:[
       
   490                         self error:'where is this'
       
   491                     ].
   473                 ].
   492                 ].
   474             ].
   493             ].
   475         ].
   494         ].
       
   495     ].
       
   496 
       
   497     (sourceComponent isKindOf:HierarchicalListView) ifTrue:[
   476 
   498 
   477         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   499         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   478             idx := itemsIndexOrLabelOrPattern
   500             idx := itemsIndexOrLabelOrPattern
   479         ] ifFalse:[
   501         ] ifFalse:[
   480             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   502             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   494 
   516 
   495         targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
   517         targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
   496         targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
   518         targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
   497 
   519 
   498         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
   520         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
   499         Delay waitForSeconds:0.5.
   521         dNdMgr := sourceComponent startDragAt:sourcePos.
       
   522 
       
   523         textWhenDroppingOrNil notNil ifTrue:[
       
   524             self show:textWhenDroppingOrNil.
       
   525         ].
       
   526 
       
   527         Delay waitForSeconds:1.
   500         self movePointerToComponent:targetComponent offset:targetPos.
   528         self movePointerToComponent:targetComponent offset:targetPos.
   501         sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false.
   529         Delay waitForSeconds:1.
   502         sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:false.
   530         dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent.
   503 self halt.
   531 
   504         sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false.
   532         sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:true.
   505         Delay waitForSeconds:0.5.
   533         dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent.
   506         sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:true.
       
   507 
       
   508 "/        self movePointerToComponent:targetComponent offset:targetPos.
       
   509 "/        Delay waitForSeconds:2.
       
   510 "/        self press:1.
       
   511 "/        Delay waitForSeconds:2.
       
   512 "/        self release:1.
       
   513 "/        Delay waitForSeconds:0.5.
       
   514         self halt.
       
   515         ^ self
   534         ^ self
   516     ].
   535     ].
   517 
   536 
   518     self error:'cannot expand in this component'
   537     self error:'cannot expand in this component'
   519 
   538 
  1477 
  1496 
  1478 do:specArray
  1497 do:specArray
  1479     "must run as a separate process;
  1498     "must run as a separate process;
  1480      otherwise - if started by the app itself -
  1499      otherwise - if started by the app itself -
  1481      no events will be processed while running"
  1500      no events will be processed while running"
  1482     |startLabel|
  1501 
  1483 
  1502     "/ StartLabel := nil.
  1484     startLabel := 'start'.
  1503     "/ StartLabel := 'start'.
  1485     self do:specArray from:startLabel
  1504     self do:specArray from:StartLabel
  1486 
  1505 
  1487 
  1506 
  1488     "
  1507     "
  1489      ShowMeHowItWorks do:
  1508      ShowMeHowItWorks do:
  1490         #(
  1509         #(
  1581 do:specArray from:startLabelOrNil
  1600 do:specArray from:startLabelOrNil
  1582     "must run as a separate process;
  1601     "must run as a separate process;
  1583      otherwise - if started by the app itself -
  1602      otherwise - if started by the app itself -
  1584      no events will be processed while running"
  1603      no events will be processed while running"
  1585 
  1604 
  1586     |wasActive|
  1605     |wasFlyByActive|
  1587 
  1606 
  1588     (wasActive := ActiveHelp isActive) ifTrue:[
  1607     (wasFlyByActive := FlyByHelp isSuspended) ifFalse:[
  1589         ActiveHelp stop.
  1608         FlyByHelp suspend.
  1590     ].
  1609     ].
       
  1610 
  1591     self prepare.
  1611     self prepare.
  1592 
  1612 
  1593     "/ run once in verifying mode
  1613     "/ run once in verifying mode
  1594     [
  1614     [
  1595         self verify:specArray.
  1615         self verify:specArray.
  1596     ] ensure:[
  1616     ] ensure:[
  1597         wasActive ifTrue:[ActiveHelp start].
  1617         wasFlyByActive ifTrue:[FlyByHelp resume].
  1598     ].
  1618     ].
  1599 
  1619 
  1600     [
  1620     [
  1601         ActiveHelp stop.
  1621         FlyByHelp suspend.
       
  1622 
  1602         [
  1623         [
  1603             Error handle:[:ex |
  1624             Error handle:[:ex |
  1604                 Dialog warn:(self class classResources 
  1625                 Dialog warn:(self class classResources 
  1605                                     stringWithCRs:'An error was encountered in the show:\\%1' 
  1626                                     stringWithCRs:'An error was encountered in the show:\\%1' 
  1606                                     with:ex description withCRs)
  1627                                     with:ex description withCRs)
  1607             ] do:[
  1628             ] do:[
  1608                 self doStream:(specArray readStream) from:startLabelOrNil
  1629                 self doStream:(specArray readStream) from:startLabelOrNil
  1609             ].
  1630             ].
  1610         ] ensure:[
  1631         ] ensure:[
  1611             wasActive ifTrue:[ActiveHelp start].
  1632             wasFlyByActive ifTrue:[FlyByHelp resume].
  1612         ].
  1633         ].
  1613     ] fork.
  1634     ] fork.
  1614 
  1635 
  1615     "
  1636     "
  1616      ShowMeHowItWorks do:
  1637      ShowMeHowItWorks do: