ShowMeHowItWorks.st
changeset 3787 7b01435dcf25
parent 3784 f6654cc10071
child 3790 a28f8340a3eb
equal deleted inserted replaced
3786:30b4d8d63f81 3787:7b01435dcf25
    93 
    93 
    94     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
    94     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
    95     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
    95     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
    96 !
    96 !
    97 
    97 
    98 do:specArray withUI:withUIBoolean
    98 do:specArray from:startLabelOrNil withUI:withUIBoolean
    99     "spec contains a list of action commands (show: / moveTo: etc.)"
    99     "spec contains a list of action commands (show: / moveTo: etc.)"
   100 
   100 
   101     self new do:specArray withUI:withUIBoolean
   101     self new 
       
   102         do:specArray 
       
   103         from:startLabelOrNil
       
   104         withUI:withUIBoolean
   102 
   105 
   103     "
   106     "
   104      ShowMeHowItWorks 
   107      ShowMeHowItWorks 
   105         do:#(
   108         do:#(
   106             (language: de)
   109             (language: de)
   111         withUI:true
   114         withUI:true
   112     "
   115     "
   113 
   116 
   114     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
   117     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
   115     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
   118     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
       
   119 !
       
   120 
       
   121 do:specArray withUI:withUIBoolean
       
   122     "spec contains a list of action commands (show: / moveTo: etc.)"
       
   123 
       
   124     self new do:specArray withUI:withUIBoolean
       
   125 
       
   126     "
       
   127      ShowMeHowItWorks 
       
   128         do:#(
       
   129             (language: de)
       
   130             (show: 'üben üben üben')
       
   131             (wait: 0.5)
       
   132             (moveTo: NameOfComponent)
       
   133         )
       
   134         withUI:true
       
   135     "
       
   136 
       
   137     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
       
   138     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
   116 ! !
   139 ! !
   117 
   140 
   118 !ShowMeHowItWorks methodsFor:'accessing'!
   141 !ShowMeHowItWorks methodsFor:'accessing'!
   119 
   142 
   120 application:anApplication
   143 application:anApplication
   140     self tell:(self class classResources 
   163     self tell:(self class classResources 
   141                 string:'You can stop this show, by pressing the SHIFT key').
   164                 string:'You can stop this show, by pressing the SHIFT key').
   142 
   165 
   143     "Created: / 19-07-2019 / 15:49:19 / Claus Gittinger"
   166     "Created: / 19-07-2019 / 15:49:19 / Claus Gittinger"
   144     "Modified: / 23-07-2019 / 11:06:13 / Claus Gittinger"
   167     "Modified: / 23-07-2019 / 11:06:13 / Claus Gittinger"
       
   168 !
       
   169 
       
   170 label:nameOfLabel
       
   171     <action>
       
   172 
       
   173     "/ skipped here; see goto
   145 !
   174 !
   146 
   175 
   147 language:lang
   176 language:lang
   148     <action>
   177     <action>
   149 
   178 
   329     |endTime|
   358     |endTime|
   330 
   359 
   331     verifying ifTrue:[^ self].
   360     verifying ifTrue:[^ self].
   332 
   361 
   333     endTime := Timestamp now + seconds.
   362     endTime := Timestamp now + seconds.
   334     [
   363     [   
   335         (self findComponent:componentName) notNil ifTrue:[
   364         (self findComponent:componentName inAllApplications:true ifMultiple:nil) notNil ifTrue:[
   336             ^ self
   365             ^ self
   337         ].
   366         ].
   338         Delay waitForSeconds:0.05.
   367         Delay waitForSeconds:0.05.
   339         Timestamp now > endTime ifTrue:[
   368         Timestamp now > endTime ifTrue:[
   340             self error:('component %1 not present after %2' bindWith:componentName with:seconds)
   369             self error:('component %1 not present after %2' bindWith:componentName with:seconds)
   406     ^ self click:1 inComponent:(self componentNamed:componentName)
   435     ^ self click:1 inComponent:(self componentNamed:componentName)
   407 
   436 
   408     "Created: / 19-07-2019 / 16:09:58 / Claus Gittinger"
   437     "Created: / 19-07-2019 / 16:09:58 / Claus Gittinger"
   409 !
   438 !
   410 
   439 
       
   440 drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where
       
   441     "drag an item (by index or label) from the current treeView,
       
   442      into another component.
       
   443      where is one of: #top, #center or #bottom.
       
   444      allowed after moving to:
       
   445         aSelectionInHierarchyView
       
   446     "    
       
   447 
       
   448     <action>
       
   449 
       
   450     |sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen
       
   451      targetPos targetPosOnScreen targetPosInSource|
       
   452 
       
   453     self assert:( #(top center bottom) includes:where).
       
   454 
       
   455     verifying ifTrue:[^ self].
       
   456 
       
   457     targetComponent := self findComponent:targetComponentName.
       
   458     self assert:targetComponent notNil.
       
   459 
       
   460     ((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
       
   461         sourceComponent := sourceComponent scrolledView.
       
   462     ].
       
   463 
       
   464     (sourceComponent isKindOf:HierarchicalListView) ifTrue:[
       
   465         where == #top ifTrue:[
       
   466             targetPos := targetComponent topCenter. 
       
   467         ] ifFalse:[
       
   468             where == #center ifTrue:[
       
   469                 targetPos := targetComponent center
       
   470             ] ifFalse:[
       
   471                 where == #bottom ifTrue:[
       
   472                     targetPos := targetComponent bottomCenter - (0 @ 1)
       
   473                 ].
       
   474             ].
       
   475         ].
       
   476 
       
   477         itemsIndexOrLabelOrPattern isInteger ifTrue:[
       
   478             idx := itemsIndexOrLabelOrPattern
       
   479         ] ifFalse:[
       
   480             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
       
   481                 idx := sourceComponent indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
       
   482             ] ifFalse:[
       
   483                 idx := sourceComponent indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
       
   484             ].
       
   485             idx == 0 ifTrue:[
       
   486                 self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
       
   487             ].
       
   488         ].
       
   489         yPos := sourceComponent yVisibleOfLine:idx.
       
   490         self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)).
       
   491         Delay waitForSeconds:0.5.
       
   492         sourcePosOnScreen := Display pointerPosition.
       
   493         sourcePos := Display translatePoint:sourcePosOnScreen from:nil to:sourceComponent.
       
   494 
       
   495         targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
       
   496         targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
       
   497 
       
   498         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
       
   499         Delay waitForSeconds:0.5.
       
   500         self movePointerToComponent:targetComponent offset:targetPos.
       
   501         sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false.
       
   502         sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:false.
       
   503 self halt.
       
   504         sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false.
       
   505         Delay waitForSeconds:0.5.
       
   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
       
   516     ].
       
   517 
       
   518     self error:'cannot expand in this component'
       
   519 
       
   520     "Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
       
   521     "Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
       
   522 !
       
   523 
       
   524 expand:itemsIndexOrLabelOrPattern
       
   525     "expand an item in a treeView by label,
       
   526      allowed after moving to:
       
   527         aSelectionInHierarchyView
       
   528     "    
       
   529 
       
   530     <action>
       
   531 
       
   532     |component|
       
   533 
       
   534     verifying ifTrue:[^ self].
       
   535 
       
   536     ((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
       
   537         component := component scrolledView.
       
   538     ].
       
   539 
       
   540     (component isKindOf:HierarchicalListView) ifTrue:[
       
   541         |idx yPos|
       
   542 
       
   543         itemsIndexOrLabelOrPattern isInteger ifTrue:[
       
   544             idx := itemsIndexOrLabelOrPattern
       
   545         ] ifFalse:[
       
   546             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
       
   547                 idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
       
   548             ] ifFalse:[
       
   549                 idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
       
   550             ].
       
   551             idx == 0 ifTrue:[
       
   552                 self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
       
   553             ].
       
   554         ].
       
   555         yPos := component yVisibleOfLine:idx.
       
   556         self movePointerToComponent:component offset:(0 @ (yPos + 3)).
       
   557         Delay waitForSeconds:0.5.
       
   558         (component listAt:idx) expand.
       
   559         ^ self
       
   560     ].
       
   561 
       
   562     self error:'cannot expand in this component'
       
   563 
       
   564     "Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
       
   565     "Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
       
   566 !
       
   567 
   411 fastMoveTo:componentName
   568 fastMoveTo:componentName
   412     "move the mouse to componentName without circling"
   569     "move the mouse to componentName without circling"
   413 
   570 
   414     <action>
   571     <action>
   415 
   572 
   443 
   600 
   444     "Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
   601     "Created: / 19-07-2019 / 11:20:42 / Claus Gittinger"
   445     "Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger"
   602     "Modified: / 19-07-2019 / 15:38:11 / Claus Gittinger"
   446 !
   603 !
   447 
   604 
   448 select:itemsLabel
   605 select:itemsIndexOrLabelOrPattern
   449     "select an item by label,
   606     "select an item by label,
   450      allowed after moving to:
   607      allowed after moving to:
   451         aComboBox
   608         aComboBox
   452         aSelectionInListView
   609         aSelectionInListView
   453     "    
   610     "    
   465     (component isKindOf:ComboView) ifTrue:[
   622     (component isKindOf:ComboView) ifTrue:[
   466         "/ click on the menubutton
   623         "/ click on the menubutton
   467         self movePointerToComponent:component menuButton.
   624         self movePointerToComponent:component menuButton.
   468         self click:1 inComponent:component menuButton.
   625         self click:1 inComponent:component menuButton.
   469         Delay waitForSeconds:0.3.
   626         Delay waitForSeconds:0.3.
   470         (idx := component list indexOf:itemsLabel ifAbsent:[nil]) isNil ifTrue:[
   627         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   471             self error:'no such item in comboList: ',itemsLabel
   628             idx := itemsIndexOrLabelOrPattern
       
   629         ] ifFalse:[
       
   630             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
       
   631                 idx := component list findFirst:[:lbl | itemsIndexOrLabelOrPattern match:lbl]
       
   632             ] ifFalse:[
       
   633                 idx := component list indexOf:itemsIndexOrLabelOrPattern.
       
   634             ].
       
   635             idx == 0 ifTrue:[
       
   636                 self error:'no such item in comboList: ',itemsIndexOrLabelOrPattern
       
   637             ].
   472         ].
   638         ].
   473         component select:idx.
   639         component select:idx.
   474         Delay waitForSeconds:0.3.
   640         Delay waitForSeconds:0.3.
   475         component shownMenu notNil ifTrue:[
   641         component shownMenu notNil ifTrue:[
   476             component shownMenu hide.
   642             component shownMenu hide.
   477         ].    
   643         ].    
   478         ^ self
   644         ^ self
   479     ].    
   645     ].    
   480     (component isKindOf:HierarchicalListView) ifTrue:[
   646     (component isKindOf:HierarchicalListView) ifTrue:[
   481         component 
   647         |idx yPos|
   482             selectElementForWhich:[:el |
   648 
   483                 el label string = itemsLabel
   649         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   484             ] 
   650             idx := itemsIndexOrLabelOrPattern
   485             ifAbsent:[
   651         ] ifFalse:[
   486                 self error:'no such item in hierarchicalList: ',itemsLabel
   652             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
       
   653                 idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
       
   654             ] ifFalse:[
       
   655                 idx := component indexOfElementForWhich:[:el | el label string = itemsIndexOrLabelOrPattern].
   487             ].
   656             ].
       
   657             idx == 0 ifTrue:[
       
   658                 self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
       
   659             ].
       
   660         ].
       
   661         yPos := component yVisibleOfLine:idx.
       
   662         self movePointerToComponent:component offset:(0 @ (yPos + 3)).
       
   663         component simulateButtonPress:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
       
   664         Delay waitForSeconds:0.1.
       
   665         component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
       
   666         "/ component selection:idx.
   488         ^ self
   667         ^ self
   489     ].
   668     ].
   490 
   669 
   491     self error:'cannot select this component'
   670     self error:'cannot select this component'
   492 
   671 
   531         self movePointerToComponent:widget menuButton.
   710         self movePointerToComponent:widget menuButton.
   532         self click:1 inComponent:widget menuButton.
   711         self click:1 inComponent:widget menuButton.
   533         Delay waitForSeconds:0.5.
   712         Delay waitForSeconds:0.5.
   534         widget select:itemsIndex.
   713         widget select:itemsIndex.
   535         Delay waitForSeconds:0.5.
   714         Delay waitForSeconds:0.5.
   536 self halt.
       
   537         ^ self
   715         ^ self
   538     ].    
   716     ].    
   539     (widget isKindOf:SelectionInListView) ifTrue:[
   717     (widget isKindOf:SelectionInListView) ifTrue:[
   540         (widget isLineVisible:itemsIndex) ifFalse:[
   718         (widget isLineVisible:itemsIndex) ifFalse:[
   541             widget scrollToLine:itemsIndex
   719             widget scrollToLine:itemsIndex
   773 
   951 
   774 findComponent:componentName
   952 findComponent:componentName
   775     "find a component by name - in the active and possibly in any app.
   953     "find a component by name - in the active and possibly in any app.
   776      Can return either a view or a menu item"
   954      Can return either a view or a menu item"
   777     
   955     
   778     |component candidates modalGroup|
   956     ^ self 
   779 
   957         findComponent:componentName
   780     application notNil ifTrue:[ 
   958         inAllApplications:true
   781         (component := self findComponent:componentName in:application) notNil ifTrue:[
   959         ifMultiple:[
   782             ^ component.
   960             self proceedableError:('multiple components found by name: ',componentName).
   783         ].
   961             nil
   784     ].
   962         ].
   785     candidates := OrderedCollection new.
   963 
   786 
   964     "
   787     "/ is there a modal dialog open for the app?
   965      ShowMeHowItWorks basicNew findComponent:'Classes'
   788     (modalGroup := application windowGroup modalGroup) notNil ifTrue:[
   966      ShowMeHowItWorks basicNew findComponent:'Klassen'
   789         modalGroup topViews do:[:eachModalTopView |
   967     "
   790             component := self findComponent:componentName in:eachModalTopView.
   968 
   791             component notNil ifTrue:[ 
   969     "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
   792                 candidates add:component
   970     "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
   793             ].
   971     "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
   794         ].
   972 !
   795         candidates size == 1 ifTrue:[
   973 
   796             ^ candidates first
   974 findComponent:componentName ifMultiple:exceptionalValue
   797         ].
   975     "find a component by name - in the active and possibly in any app.
   798     ].
   976      Can return either a view or a menu item"
   799     true "application isNil" ifTrue:[
   977     
   800         "/ search through all current applications
   978     ^ self
   801         WindowGroup scheduledWindowGroups do:[:eachWG |
   979         findComponent:componentName
   802             |eachApp|
   980         inAllApplications:true
   803 
   981         ifMultiple:exceptionalValue
   804             (eachApp := eachWG application) notNil ifTrue:[
       
   805                 component := self findComponent:componentName in:eachApp.
       
   806                 component notNil ifTrue:[ 
       
   807                     candidates add:component
       
   808                 ].
       
   809             ].
       
   810         ].
       
   811 
       
   812         candidates size == 1 ifTrue:[
       
   813             ^ candidates first
       
   814         ].
       
   815         candidates notEmpty ifTrue:[
       
   816             "/ multiple elements (probably there are multiple topviews open...
       
   817             "/ check the current windowGroup
       
   818             self error:'multiple components found by name: ',componentName.
       
   819         ].
       
   820     ].
       
   821 
       
   822     ^ nil
       
   823 
   982 
   824     "
   983     "
   825      ShowMeHowItWorks basicNew findComponent:'Classes'
   984      ShowMeHowItWorks basicNew findComponent:'Classes'
   826      ShowMeHowItWorks basicNew findComponent:'Klassen'
   985      ShowMeHowItWorks basicNew findComponent:'Klassen'
   827     "
   986     "
   952 
  1111 
   953     "Created: / 19-07-2019 / 11:36:21 / Claus Gittinger"
  1112     "Created: / 19-07-2019 / 11:36:21 / Claus Gittinger"
   954     "Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger"
  1113     "Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger"
   955 !
  1114 !
   956 
  1115 
       
  1116 findComponent:componentName inAllApplications:inAllApplicationsBool ifMultiple:exceptionalValue
       
  1117     "find a component by name - in the active and possibly in any app.
       
  1118      Can return either a view or a menu item"
       
  1119     
       
  1120     |component candidates modalGroup|
       
  1121 
       
  1122     application notNil ifTrue:[ 
       
  1123         (component := self findComponent:componentName in:application) notNil ifTrue:[
       
  1124             ^ component.
       
  1125         ].
       
  1126     ].
       
  1127     candidates := OrderedCollection new.
       
  1128 
       
  1129     "/ is there a modal dialog open for the app?
       
  1130     (modalGroup := application windowGroup modalGroup) notNil ifTrue:[
       
  1131         modalGroup topViews do:[:eachModalTopView |
       
  1132             component := self findComponent:componentName in:eachModalTopView.
       
  1133             component notNil ifTrue:[ 
       
  1134                 candidates add:component
       
  1135             ].
       
  1136         ].
       
  1137         candidates size == 1 ifTrue:[
       
  1138             ^ candidates first
       
  1139         ].
       
  1140     ].
       
  1141     inAllApplicationsBool ifTrue:[
       
  1142         "/ search through all current applications
       
  1143         WindowGroup scheduledWindowGroups do:[:eachWG |
       
  1144             |eachApp|
       
  1145 
       
  1146             (eachApp := eachWG application) notNil ifTrue:[
       
  1147                 component := self findComponent:componentName in:eachApp.
       
  1148                 component notNil ifTrue:[ 
       
  1149                     candidates add:component
       
  1150                 ].
       
  1151             ].
       
  1152         ].
       
  1153 
       
  1154         candidates size == 1 ifTrue:[
       
  1155             ^ candidates first
       
  1156         ].
       
  1157         candidates notEmpty ifTrue:[
       
  1158             "/ multiple elements (probably there are multiple topviews open...
       
  1159             "/ check the current windowGroup
       
  1160             ^ exceptionalValue value
       
  1161         ].
       
  1162     ].
       
  1163 
       
  1164     ^ nil
       
  1165 
       
  1166     "
       
  1167      ShowMeHowItWorks basicNew findComponent:'Classes'
       
  1168      ShowMeHowItWorks basicNew findComponent:'Klassen'
       
  1169     "
       
  1170 
       
  1171     "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
       
  1172     "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
       
  1173     "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
       
  1174 !
       
  1175 
   957 screenBoundsOfComponent:aWidgetOrMenuItem
  1176 screenBoundsOfComponent:aWidgetOrMenuItem
   958     aWidgetOrMenuItem isView ifTrue:[
  1177     aWidgetOrMenuItem isView ifTrue:[
   959         ^ aWidgetOrMenuItem screenBounds
  1178         ^ aWidgetOrMenuItem screenBounds
   960     ].
  1179     ].
   961     (aWidgetOrMenuItem askFor:#isMenuItem) ifTrue:[
  1180     (aWidgetOrMenuItem askFor:#isMenuItem) ifTrue:[
  1027     screen := Screen current.
  1246     screen := Screen current.
  1028     position := screen pointerPosition.
  1247     position := screen pointerPosition.
  1029     x := position x.
  1248     x := position x.
  1030     y := position y.
  1249     y := position y.
  1031     
  1250     
  1032     self movePointerToScreenPosition:position.
  1251     "/ self movePointerToScreenPosition:position.
  1033 
  1252 
  1034     false "OperatingSystem isOSXlike" ifTrue:[
  1253     false "OperatingSystem isOSXlike" ifTrue:[
  1035         |osxPos|
  1254         |osxPos|
  1036 
  1255 
  1037         osxPos := OperatingSystem getMousePosition.
  1256         osxPos := OperatingSystem getMousePosition.
  1058     screen := Screen current.
  1277     screen := Screen current.
  1059     position := screen pointerPosition.
  1278     position := screen pointerPosition.
  1060     x := position x.
  1279     x := position x.
  1061     y := position y.
  1280     y := position y.
  1062     
  1281     
  1063     self movePointerToScreenPosition:position.
  1282     "/ self movePointerToScreenPosition:position.
  1064 
  1283 
  1065     false "OperatingSystem isOSXlike" ifTrue:[
  1284     false "OperatingSystem isOSXlike" ifTrue:[
  1066         |osxPos|
  1285         |osxPos|
  1067 
  1286 
  1068         osxPos := OperatingSystem getMousePosition.
  1287         osxPos := OperatingSystem getMousePosition.
  1167 
  1386 
  1168     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
  1387     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
  1169     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
  1388     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
  1170 !
  1389 !
  1171 
  1390 
       
  1391 movePointerToComponent:aWidgetOrMenuItem rightBottomOffset:offset
       
  1392     "move the mouse to position inside aWidget's.
       
  1393      Offset is from the rightBottom"
       
  1394     
       
  1395     |bounds|
       
  1396 
       
  1397     bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
       
  1398     self movePointerToScreenPosition:(bounds corner - offset) rounded.
       
  1399 
       
  1400     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
       
  1401     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
       
  1402 !
       
  1403 
       
  1404 movePointerToComponent:aWidgetOrMenuItem rightOffset:offset
       
  1405     "move the mouse to position inside aWidget's.
       
  1406      Offset is from the rightTop (i.e. x is subtracted, y is added)"
       
  1407     
       
  1408     |bounds pos|
       
  1409 
       
  1410     bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
       
  1411     pos := (bounds right - offset x) @ (bounds top + offset y).
       
  1412     self movePointerToScreenPosition:pos rounded.
       
  1413 
       
  1414     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
       
  1415     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
       
  1416 !
       
  1417 
  1172 movePointerToComponent:aWidgetOrMenuItem speed:pixelsPerSecond
  1418 movePointerToComponent:aWidgetOrMenuItem speed:pixelsPerSecond
  1173     "move the mouse to aWidget's center"
  1419     "move the mouse to aWidget's center"
  1174 
  1420 
  1175     |bounds position|
  1421     |bounds position|
  1176     
  1422     
  1231 
  1477 
  1232 do:specArray
  1478 do:specArray
  1233     "must run as a separate process;
  1479     "must run as a separate process;
  1234      otherwise - if started by the app itself -
  1480      otherwise - if started by the app itself -
  1235      no events will be processed while running"
  1481      no events will be processed while running"
  1236 
  1482     |startLabel|
  1237     |wasActive|
  1483 
  1238 
  1484     startLabel := 'start'.
  1239     (wasActive := ActiveHelp isActive) ifTrue:[
  1485     self do:specArray from:startLabel
  1240         ActiveHelp stop.
  1486 
  1241     ].
       
  1242     self prepare.
       
  1243 
       
  1244     "/ run pnce in verifying mode
       
  1245     [
       
  1246         self verify:specArray.
       
  1247     ] ensure:[
       
  1248         wasActive ifTrue:[ActiveHelp start].
       
  1249     ].
       
  1250 
       
  1251     [
       
  1252         ActiveHelp stop.
       
  1253         [
       
  1254             Error handle:[:ex |
       
  1255                 Dialog warn:(self class classResources 
       
  1256                                     stringWithCRs:'An error was encountered in the show:\\%1' 
       
  1257                                     with:ex description withCRs)
       
  1258             ] do:[
       
  1259                 self doStream:(specArray readStream)
       
  1260             ].
       
  1261         ] ensure:[
       
  1262             wasActive ifTrue:[ActiveHelp start].
       
  1263         ].
       
  1264     ] fork.
       
  1265 
  1487 
  1266     "
  1488     "
  1267      ShowMeHowItWorks do:
  1489      ShowMeHowItWorks do:
  1268         #(
  1490         #(
  1269             (show: 'blah blah')
  1491             (show: 'blah blah')
  1273 
  1495 
  1274     "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
  1496     "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
  1275     "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
  1497     "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
  1276 !
  1498 !
  1277 
  1499 
       
  1500 do:specArray from:startLabelOrNil withUI:withUIBoolean
       
  1501     "must run as a separate process;
       
  1502      otherwise - if started by the app itself -
       
  1503      no events will be processed while running"
       
  1504 
       
  1505     withUIBoolean ifTrue:[
       
  1506         ui := ShowMeHowItWorksRunner openOn:self.
       
  1507     ].
       
  1508     self do:specArray from:startLabelOrNil
       
  1509 
       
  1510     "
       
  1511      ShowMeHowItWorks 
       
  1512         do:#(
       
  1513             (show: 'blah blah')
       
  1514             (moveTo: NameOfComponent)
       
  1515         )
       
  1516         withUI:true
       
  1517     "
       
  1518 
       
  1519     "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
       
  1520     "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
       
  1521 !
       
  1522 
  1278 do:specArray withUI:withUIBoolean
  1523 do:specArray withUI:withUIBoolean
  1279     "must run as a separate process;
  1524     "must run as a separate process;
  1280      otherwise - if started by the app itself -
  1525      otherwise - if started by the app itself -
  1281      no events will be processed while running"
  1526      no events will be processed while running"
  1282 
  1527 
  1283     withUIBoolean ifTrue:[
  1528     withUIBoolean ifTrue:[
  1284         ui := ShowMeHowItWorksRunner openOn:self.
  1529         ui := ShowMeHowItWorksRunner openOn:self.
  1285     ].
  1530     ].
  1286     self do:specArray
  1531     self do:specArray from:nil
  1287 
  1532 
  1288     "
  1533     "
  1289      ShowMeHowItWorks 
  1534      ShowMeHowItWorks 
  1290         do:#(
  1535         do:#(
  1291             (show: 'blah blah')
  1536             (show: 'blah blah')
  1330         verifying := false.
  1575         verifying := false.
  1331     ].
  1576     ].
  1332 ! !
  1577 ! !
  1333 
  1578 
  1334 !ShowMeHowItWorks methodsFor:'running - private'!
  1579 !ShowMeHowItWorks methodsFor:'running - private'!
       
  1580 
       
  1581 do:specArray from:startLabelOrNil
       
  1582     "must run as a separate process;
       
  1583      otherwise - if started by the app itself -
       
  1584      no events will be processed while running"
       
  1585 
       
  1586     |wasActive|
       
  1587 
       
  1588     (wasActive := ActiveHelp isActive) ifTrue:[
       
  1589         ActiveHelp stop.
       
  1590     ].
       
  1591     self prepare.
       
  1592 
       
  1593     "/ run once in verifying mode
       
  1594     [
       
  1595         self verify:specArray.
       
  1596     ] ensure:[
       
  1597         wasActive ifTrue:[ActiveHelp start].
       
  1598     ].
       
  1599 
       
  1600     [
       
  1601         ActiveHelp stop.
       
  1602         [
       
  1603             Error handle:[:ex |
       
  1604                 Dialog warn:(self class classResources 
       
  1605                                     stringWithCRs:'An error was encountered in the show:\\%1' 
       
  1606                                     with:ex description withCRs)
       
  1607             ] do:[
       
  1608                 self doStream:(specArray readStream) from:startLabelOrNil
       
  1609             ].
       
  1610         ] ensure:[
       
  1611             wasActive ifTrue:[ActiveHelp start].
       
  1612         ].
       
  1613     ] fork.
       
  1614 
       
  1615     "
       
  1616      ShowMeHowItWorks do:
       
  1617         #(
       
  1618             (show: 'blah blah')
       
  1619             (moveTo: NameOfComponent)
       
  1620         )    
       
  1621     "
       
  1622 
       
  1623     "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
       
  1624     "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
       
  1625 !
  1335 
  1626 
  1336 doCommand:op
  1627 doCommand:op
  1337     "execute a single command"
  1628     "execute a single command"
  1338     
  1629     
  1339     |numArgs sel args method|
  1630     |numArgs sel args method|
  1394     "Created: / 19-07-2019 / 15:34:55 / Claus Gittinger"
  1685     "Created: / 19-07-2019 / 15:34:55 / Claus Gittinger"
  1395     "Modified: / 23-07-2019 / 09:14:26 / Claus Gittinger"
  1686     "Modified: / 23-07-2019 / 09:14:26 / Claus Gittinger"
  1396 !
  1687 !
  1397 
  1688 
  1398 doStream:specStream
  1689 doStream:specStream
  1399     |previousStream resources|
  1690     self doStream:specStream from:nil
  1400 
       
  1401     resources := self class classResources.
       
  1402 
       
  1403     streamStack isNil ifTrue:[ streamStack := OrderedCollection new ].
       
  1404     streamStack add:opStream.
       
  1405 
       
  1406     previousStream := opStream.
       
  1407     [
       
  1408         opStream := specStream.
       
  1409         [opStream atEnd] whileFalse:[
       
  1410             self nextCommand.
       
  1411             Display shiftDown ifTrue:[
       
  1412                 (IntroShownCount ? 0) > 3 ifFalse:[
       
  1413                     self tell:(self possiblyTranslate:'You pressed the SHIFT key.').
       
  1414                 ].    
       
  1415                 self tell:(self possiblyTranslate:'Do you want to stop the show?').
       
  1416                 (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?'))
       
  1417                 ifTrue:[
       
  1418                     self tell:(self possiblyTranslate:'OK,').
       
  1419                     self tell:(self possiblyTranslate:(self randomThankYou)).
       
  1420                     ^ AbortOperationRequest raise
       
  1421                 ].    
       
  1422             ].    
       
  1423         ].    
       
  1424     ] ensure:[
       
  1425         streamStack removeLast.
       
  1426         opStream := previousStream
       
  1427     ].
       
  1428     
  1691     
  1429 "<<END
  1692 "<<END
  1430      ShowMeHowItWorks do:#(
  1693      ShowMeHowItWorks do:#(
  1431         showing: 'Choose the number of arguments'
  1694         showing: 'Choose the number of arguments'
  1432         do: (
  1695         do: (
  1456 
  1719 
  1457     "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
  1720     "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
  1458     "Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger"
  1721     "Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger"
  1459 !
  1722 !
  1460 
  1723 
  1461 nextCommand
  1724 doStream:specStream from:startLabelOrNil
  1462     self doCommand:(opStream next).
  1725     |previousStream resources|
  1463 
  1726 
       
  1727     resources := self class classResources.
       
  1728 
       
  1729     streamStack isNil ifTrue:[ streamStack := OrderedCollection new ].
       
  1730     streamStack add:opStream.
       
  1731 
       
  1732     previousStream := opStream.
       
  1733     [
       
  1734         |nextCommand|
       
  1735 
       
  1736         opStream := specStream.
       
  1737         startLabelOrNil notNil ifTrue:[
       
  1738             |found|
       
  1739 
       
  1740             "/ skip for that label
       
  1741             found := false.
       
  1742             [ found ] whileFalse:[
       
  1743                 |cmd|
       
  1744 
       
  1745                 cmd := opStream nextOrNil.
       
  1746                 cmd isNil ifTrue:[
       
  1747                     self proceedableError:'label not found: ',startLabelOrNil.
       
  1748                     ^ self.
       
  1749                 ].
       
  1750                 (cmd = 'label:') ifTrue:[
       
  1751                     found := (opStream next = startLabelOrNil)
       
  1752                 ].
       
  1753             ].
       
  1754         ].
       
  1755 
       
  1756         [opStream atEnd] whileFalse:[
       
  1757             nextCommand := opStream next.
       
  1758             self doCommand:nextCommand.
       
  1759 
       
  1760             Display shiftDown ifTrue:[
       
  1761                 (IntroShownCount ? 0) > 3 ifFalse:[
       
  1762                     self tell:(self possiblyTranslate:'You pressed the SHIFT key.').
       
  1763                 ].    
       
  1764                 self tell:(self possiblyTranslate:'Do you want to stop the show?').
       
  1765                 (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?'))
       
  1766                 ifTrue:[
       
  1767                     self tell:(self possiblyTranslate:'OK,').
       
  1768                     self tell:(self possiblyTranslate:(self randomThankYou)).
       
  1769                     ^ AbortOperationRequest raise
       
  1770                 ].    
       
  1771             ].    
       
  1772         ].    
       
  1773     ] ensure:[
       
  1774         streamStack removeLast.
       
  1775         opStream := previousStream
       
  1776     ].
       
  1777     
  1464 "<<END
  1778 "<<END
  1465      ShowMeHowItWorks do:#(
  1779      ShowMeHowItWorks do:#(
  1466         showing: 'Choose the number of arguments'
  1780         showing: 'Choose the number of arguments'
  1467         do: (
  1781         do: (
  1468             moveTo: NumberOfArguments
  1782             moveTo: NumberOfArguments
  1487             enter: '100'
  1801             enter: '100'
  1488         )
  1802         )
  1489      )
  1803      )
  1490 END"
  1804 END"
  1491 
  1805 
  1492     "Created: / 19-07-2019 / 10:54:04 / Claus Gittinger"
  1806     "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger"
  1493     "Modified: / 19-07-2019 / 15:35:15 / Claus Gittinger"
  1807     "Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger"
  1494 !
  1808 !
  1495 
  1809 
  1496 possiblyTranslate:aString
  1810 possiblyTranslate:aString
  1497     translate ifTrue:[^ self class classResources string:aString].
  1811     translate ifTrue:[^ self class classResources string:aString].
  1498     ^ aString
  1812     ^ aString