ShowMeHowItWorks.st
changeset 3796 4ed3796c2d60
parent 3795 0b36f57fd1c9
child 3797 5ab4b911e388
equal deleted inserted replaced
3795:0b36f57fd1c9 3796:4ed3796c2d60
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui
    11 		theShowFile'
    11 		theShowFile'
    12 	classVariableNames:'IntroShownCount DebugMode StartLabel'
    12 	classVariableNames:'IntroShownCount DebugMode StartLabel'
    13 	poolDictionaries:''
    13 	poolDictionaries:''
    14 	category:'Interface-Help'
    14 	category:'Interface-Help'
       
    15 !
       
    16 
       
    17 Object subclass:#ItemInView
       
    18 	instanceVariableNames:'view item boundsInView'
       
    19 	classVariableNames:''
       
    20 	poolDictionaries:''
       
    21 	privateIn:ShowMeHowItWorks
    15 !
    22 !
    16 
    23 
    17 !ShowMeHowItWorks class methodsFor:'documentation'!
    24 !ShowMeHowItWorks class methodsFor:'documentation'!
    18 
    25 
    19 documentation
    26 documentation
   546 
   553 
   547     ((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
   554     ((sourceComponent := lastComponent) isKindOf:ScrollableView) ifTrue:[
   548         sourceComponent := sourceComponent scrolledView.
   555         sourceComponent := sourceComponent scrolledView.
   549     ].
   556     ].
   550 
   557 
   551     where == #topLeft ifTrue:[
   558     targetPos := self where:where inComponent:targetComponent. 
   552         targetPos := targetComponent topLeft + (1@1). 
       
   553     ] ifFalse:[
       
   554         where == #topCenter ifTrue:[
       
   555             targetPos := targetComponent topCenter + (0@5). 
       
   556         ] ifFalse:[
       
   557             where == #center ifTrue:[
       
   558                 targetPos := targetComponent center
       
   559             ] ifFalse:[
       
   560                 where == #bottomCenter ifTrue:[
       
   561                     targetPos := targetComponent bottomCenter - (0 @ 5)
       
   562                 ] ifFalse:[
       
   563                     where == #bottomLeft ifTrue:[
       
   564                         targetPos := targetComponent bottomLeft + (1 @ -5)
       
   565                     ] ifFalse:[
       
   566                         self error:'where is this'
       
   567                     ].
       
   568                 ].
       
   569             ].
       
   570         ].
       
   571     ].
       
   572 
   559 
   573     (sourceComponent isKindOf:HierarchicalListView) ifTrue:[
   560     (sourceComponent isKindOf:HierarchicalListView) ifTrue:[
   574 
   561 
   575         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   562         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   576             idx := itemsIndexOrLabelOrPattern
   563             idx := itemsIndexOrLabelOrPattern
   582             ].
   569             ].
   583             idx == 0 ifTrue:[
   570             idx == 0 ifTrue:[
   584                 self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
   571                 self error:'no such item in hierarchicalList: ',itemsIndexOrLabelOrPattern
   585             ].
   572             ].
   586         ].
   573         ].
       
   574 
   587         yPos := sourceComponent yVisibleOfLine:idx.
   575         yPos := sourceComponent yVisibleOfLine:idx.
   588         self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)).
   576         self movePointerToComponent:sourceComponent rightOffset:(10 @ (yPos + 3)).
   589         Delay waitForSeconds:0.5.
   577         Delay waitForSeconds:0.5.
   590         sourcePosOnScreen := Display pointerPosition.
   578         sourcePosOnScreen := Display pointerPosition.
   591         sourcePos := Display translatePoint:sourcePosOnScreen from:nil to:sourceComponent.
   579         sourcePos := Display translatePoint:sourcePosOnScreen fromView:nil toView:sourceComponent.
   592 
   580 
   593         targetPosOnScreen := Display translatePoint:targetPos from:targetComponent to:nil.
   581         targetPosOnScreen := Display translatePoint:targetPos fromView:targetComponent toView:nil.
   594         targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent.
   582         targetPosInSource := Display translatePoint:targetPosOnScreen fromView:nil toView:sourceComponent.
   595 
   583 
       
   584         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:false.
   596         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
   585         sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true.
       
   586         Delay waitForSeconds:0.2.
       
   587 
   597         dNdMgr := sourceComponent startDragAt:sourcePos.
   588         dNdMgr := sourceComponent startDragAt:sourcePos.
   598 
   589 
   599         textWhenDroppingOrNil notNil ifTrue:[
   590         textWhenDroppingOrNil notNil ifTrue:[
   600             self show:textWhenDroppingOrNil.
   591             self show:textWhenDroppingOrNil.
   601         ].
   592         ].
   603         Delay waitForSeconds:1.
   594         Delay waitForSeconds:1.
   604         self movePointerToComponent:targetComponent offset:targetPos.
   595         self movePointerToComponent:targetComponent offset:targetPos.
   605         Delay waitForSeconds:1.
   596         Delay waitForSeconds:1.
   606         dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent.
   597         dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent.
   607 
   598 
   608         sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:true.
       
   609         dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent.
   599         dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent.
       
   600         sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:false.
   610         ^ self
   601         ^ self
   611     ].
   602     ].
   612 
   603 
   613     self error:'cannot expand in this component'
   604     self error:'cannot expand in this component'
   614 
   605 
  1184         anApplicationOrViewOrMenuItem isMenu ifFalse:[
  1175         anApplicationOrViewOrMenuItem isMenu ifFalse:[
  1185             self assert:false message:'container is not a menu'.
  1176             self assert:false message:'container is not a menu'.
  1186         ].
  1177         ].
  1187         idx := Integer readFrom:(componentNameOrPath withoutPrefix:'item[') readStream.
  1178         idx := Integer readFrom:(componentNameOrPath withoutPrefix:'item[') readStream.
  1188         item := anApplicationOrViewOrMenuItem itemAt:idx.
  1179         item := anApplicationOrViewOrMenuItem itemAt:idx.
  1189         ^ item
  1180         ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
       
  1181     ].
       
  1182     (componentNameOrPath matchesRegex:'tab\[[0-9]+\]') ifTrue:[
       
  1183         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifFalse:[
       
  1184             self assert:false message:'container is not a notebook'.
       
  1185         ].
       
  1186         idx := Integer readFrom:(componentNameOrPath withoutPrefix:'tab[') readStream.
       
  1187         item := anApplicationOrViewOrMenuItem tabAtIndex:idx.
       
  1188         ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
  1190     ].
  1189     ].
  1191 
  1190 
  1192     componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath.
  1191     componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath.
  1193 
  1192 
  1194     (app := anApplicationOrViewOrMenuItem) isView ifTrue:[
  1193     (app := anApplicationOrViewOrMenuItem) isView ifTrue:[
  1197     ].
  1196     ].
  1198     app isApplicationModel ifTrue:[
  1197     app isApplicationModel ifTrue:[
  1199         (component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component].
  1198         (component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component].
  1200         window := window ? app window.
  1199         window := window ? app window.
  1201     ] ifFalse:[
  1200     ] ifFalse:[
  1202         app isMenuItem ifTrue:[
  1201         (app askFor:#isMenuItem) ifTrue:[
  1203             window := app submenu.
  1202             window := app submenu.
  1204         ]
  1203         ]
  1205     ].
  1204     ].
  1206     window notNil ifTrue:[
  1205     window notNil ifTrue:[
  1207         window shown ifFalse:[^ nil].
  1206         window shown ifFalse:[^ nil].
  1368     "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
  1367     "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
  1369     "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
  1368     "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
  1370     "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
  1369     "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
  1371 !
  1370 !
  1372 
  1371 
  1373 screenBoundsOfComponent:aWidgetOrMenuItem
  1372 screenBoundsOfComponent:aWidgetOrMenuItemOrTab
  1374     aWidgetOrMenuItem isView ifTrue:[
  1373     |itemLayout|
  1375         ^ aWidgetOrMenuItem screenBounds
  1374 
  1376     ].
  1375     aWidgetOrMenuItemOrTab isView ifTrue:[
  1377     (aWidgetOrMenuItem askFor:#isMenuItem) ifTrue:[
  1376         ^ aWidgetOrMenuItemOrTab screenBounds
       
  1377     ].
       
  1378     (aWidgetOrMenuItemOrTab askFor:#isMenuItem) ifTrue:[
  1378         |menuPanel menuBounds|
  1379         |menuPanel menuBounds|
  1379 
  1380 
  1380         aWidgetOrMenuItem isVisible ifTrue:[
  1381         aWidgetOrMenuItemOrTab isVisible ifTrue:[
  1381             aWidgetOrMenuItem layout notNil ifTrue:[
  1382             (itemLayout := aWidgetOrMenuItemOrTab layout) notNil ifTrue:[
  1382                 menuPanel := aWidgetOrMenuItem menuPanel.
  1383                 menuPanel := aWidgetOrMenuItemOrTab menuPanel.
  1383                 menuPanel shown ifTrue:[
  1384                 menuPanel shown ifTrue:[
  1384                     menuBounds := menuPanel screenBounds.
  1385                     menuBounds := menuPanel screenBounds.
  1385                     ^ aWidgetOrMenuItem layout + menuBounds origin 
  1386                     ^ itemLayout + menuBounds origin 
  1386                 ].
  1387                 ].
  1387             ].
  1388             ].
  1388         ].
  1389         ].
       
  1390     ].
       
  1391     (aWidgetOrMenuItemOrTab askFor:#isNoteBookTab) ifTrue:[
       
  1392         (itemLayout := aWidgetOrMenuItemOrTab layout) notNil ifTrue:[
       
  1393             |notebook notebookBounds|
       
  1394 
       
  1395             notebook := aWidgetOrMenuItemOrTab view.
       
  1396             notebook shown ifTrue:[
       
  1397                 notebookBounds := notebook screenBounds.
       
  1398                 ^ itemLayout + notebookBounds origin 
       
  1399             ].
       
  1400         ]. 
       
  1401         self halt.
  1389     ].
  1402     ].
  1390     ^ nil.
  1403     ^ nil.
  1391 ! !
  1404 ! !
  1392 
  1405 
  1393 !ShowMeHowItWorks methodsFor:'helpers - mouse buttons'!
  1406 !ShowMeHowItWorks methodsFor:'helpers - mouse buttons'!
  1569 
  1582 
  1570     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
  1583     "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger"
  1571     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
  1584     "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger"
  1572 !
  1585 !
  1573 
  1586 
  1574 movePointerToComponent:aWidgetOrMenuItem speed:pixelsPerSecond
  1587 movePointerToComponent:aWidgetOrMenuItemOrTab speed:pixelsPerSecond
  1575     "move the mouse to aWidget's center"
  1588     "move the mouse to aWidget's center"
  1576 
  1589 
  1577     |bounds position|
  1590     |bounds position|
  1578     
  1591     
  1579     bounds := self screenBoundsOfComponent:aWidgetOrMenuItem.
  1592     bounds := self screenBoundsOfComponent:aWidgetOrMenuItemOrTab.
  1580     bounds isNil ifTrue:[
  1593     bounds isNil ifTrue:[
  1581         self error:'no bounds found for: ',aWidgetOrMenuItem printString.
  1594         self error:'no bounds found for: ',aWidgetOrMenuItemOrTab printString.
  1582     ].
  1595     ].
  1583     position := bounds center rounded.
  1596     position := bounds center rounded.
  1584     self movePointerToScreenPosition:position speed:pixelsPerSecond.
  1597     self movePointerToScreenPosition:position speed:pixelsPerSecond.
  1585 
  1598 
  1586     "Created: / 20-07-2019 / 08:12:49 / Claus Gittinger"
  1599     "Created: / 20-07-2019 / 08:12:49 / Claus Gittinger"
  1625         screen flush.
  1638         screen flush.
  1626         Delay waitFor:stepDelayTime.
  1639         Delay waitFor:stepDelayTime.
  1627     ].
  1640     ].
  1628 
  1641 
  1629     "Created: / 23-07-2019 / 09:36:45 / Claus Gittinger"
  1642     "Created: / 23-07-2019 / 09:36:45 / Claus Gittinger"
       
  1643 !
       
  1644 
       
  1645 where:where inComponent:aComponent
       
  1646     where == #center ifTrue:[
       
  1647         ^ aComponent center
       
  1648     ].
       
  1649     where == #leftCenter ifTrue:[
       
  1650         ^ aComponent leftCenter + (5@0). 
       
  1651     ].
       
  1652     where == #rightCenter ifTrue:[
       
  1653         ^ aComponent rightCenter - (5@0). 
       
  1654     ].
       
  1655     where == #topLeft ifTrue:[
       
  1656         ^ aComponent topLeft + (5@5). 
       
  1657     ].
       
  1658     where == #topCenter ifTrue:[
       
  1659         ^ aComponent topCenter + (0@5). 
       
  1660     ].
       
  1661     where == #topRight ifTrue:[
       
  1662         ^ aComponent topRight - (5@5). 
       
  1663     ].
       
  1664     where == #bottomCenter ifTrue:[
       
  1665         ^ aComponent bottomCenter - (0 @ 5)
       
  1666     ].
       
  1667     where == #bottomLeft ifTrue:[
       
  1668         ^ aComponent bottomLeft + (5 @ -5)
       
  1669     ].
       
  1670     where == #bottomRight ifTrue:[
       
  1671         ^ aComponent bottomLeft - (5 @ 5)
       
  1672     ].
       
  1673     self error:'where is this'
  1630 ! !
  1674 ! !
  1631 
  1675 
  1632 !ShowMeHowItWorks methodsFor:'running'!
  1676 !ShowMeHowItWorks methodsFor:'running'!
  1633 
  1677 
  1634 do:specArray
  1678 do:specArray
  1984     ^ aString
  2028     ^ aString
  1985 
  2029 
  1986     "Created: / 23-07-2019 / 11:48:17 / Claus Gittinger"
  2030     "Created: / 23-07-2019 / 11:48:17 / Claus Gittinger"
  1987 ! !
  2031 ! !
  1988 
  2032 
       
  2033 !ShowMeHowItWorks::ItemInView class methodsFor:'documentation'!
       
  2034 
       
  2035 documentation
       
  2036 "
       
  2037     documentation to be added.
       
  2038 
       
  2039     class:
       
  2040         <a short class summary here, describing what instances represent>
       
  2041 
       
  2042     responsibilities:    
       
  2043         <describing what my main role is>
       
  2044 
       
  2045     collaborators:    
       
  2046         <describing with whom and how I talk to>
       
  2047 
       
  2048     API:
       
  2049         <public api and main messages>
       
  2050         
       
  2051     example:
       
  2052         <a one-line examples on how to use - can also be in a separate example method>
       
  2053 
       
  2054     implementation:
       
  2055         <implementation points>
       
  2056 
       
  2057     [author:]
       
  2058         exept MBP
       
  2059 
       
  2060     [instance variables:]
       
  2061 
       
  2062     [class variables:]
       
  2063 
       
  2064     [see also:]
       
  2065 
       
  2066 "
       
  2067 ! !
       
  2068 
       
  2069 !ShowMeHowItWorks::ItemInView methodsFor:'accessing'!
       
  2070 
       
  2071 boundsInView
       
  2072     ^ boundsInView
       
  2073 !
       
  2074 
       
  2075 item
       
  2076     ^ item
       
  2077 !
       
  2078 
       
  2079 layout
       
  2080     ^ item layout
       
  2081 !
       
  2082 
       
  2083 view
       
  2084     ^ view
       
  2085 !
       
  2086 
       
  2087 view:viewArg item:itemArg boundsInView:boundsInViewArg 
       
  2088     view := viewArg.
       
  2089     item := itemArg.
       
  2090     boundsInView := boundsInViewArg.
       
  2091 ! !
       
  2092 
       
  2093 !ShowMeHowItWorks::ItemInView methodsFor:'testing'!
       
  2094 
       
  2095 isMenuItem
       
  2096     ^ item askFor:#isMenuItem
       
  2097 !
       
  2098 
       
  2099 isNoteBookTab
       
  2100     ^ item isKindOf:NoteBookView::Tab
       
  2101 ! !
       
  2102 
  1989 !ShowMeHowItWorks class methodsFor:'documentation'!
  2103 !ShowMeHowItWorks class methodsFor:'documentation'!
  1990 
  2104 
  1991 version_CVS
  2105 version_CVS
  1992     ^ '$Header$'
  2106     ^ '$Header$'
  1993 ! !
  2107 ! !