DeviceWorkstation.st
changeset 8157 d6cd40e86fb6
parent 8124 bbab46e21769
child 8233 36ee1511bafd
equal deleted inserted replaced
8156:13f21ca2c852 8157:d6cd40e86fb6
   992 !
   992 !
   993 
   993 
   994 zoom:startRect to:endRect
   994 zoom:startRect to:endRect
   995     "animate a rubber-rectangle from startRect to endRect.
   995     "animate a rubber-rectangle from startRect to endRect.
   996      Can be used by buttons, which open some dialog for nicer user feedback.
   996      Can be used by buttons, which open some dialog for nicer user feedback.
   997      Notice: since the displays window manager typically allows a topWindow
   997      Notice: since the display's window manager typically allows a topWindow
   998 	     to be placed by the user, this should not be used for modeless
   998              to be placed by the user, this should not be used for modeless
   999 	     topViews.
   999              topViews.
  1000     "
  1000     "
  1001 
  1001 
  1002     ^ self zoom:startRect to:endRect duration:300
  1002     ^ self zoom:startRect to:endRect duration:300
  1003 
  1003 
  1004     "
  1004     "
  1005      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000)
  1005      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000)
  1006      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20)
  1006      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20)
  1007     "
  1007     "
  1008 
  1008 
  1009     "Modified: 27.1.1997 / 18:20:11 / cg"
  1009     "Modified: / 27-01-1997 / 18:20:11 / cg"
       
  1010     "Modified (comment): / 01-09-2017 / 09:57:09 / cg"
  1010 !
  1011 !
  1011 
  1012 
  1012 zoom:startRect to:endRect duration:milliseconds
  1013 zoom:startRect to:endRect duration:milliseconds
  1013     "animate a rubber-rectangle from startRect to endRect.
  1014     "animate a rubber-rectangle from startRect to endRect.
  1014      Can be used by buttons, which open some dialog for nicer user feedback.
  1015      Can be used by buttons, which open some dialog for nicer user feedback.
  1015      Notice: since the displays window manager typically allows a topWindow
  1016      Notice: since the display's window manager typically allows a topWindow
  1016 	     to be placed by the user, this should not be used for modeless
  1017              to be placed by the user, this should not be used for modeless
  1017 	     topViews.
  1018              topViews.
  1018     "
  1019     "
  1019 
  1020 
  1020     |steps dExt dOrg org ext root|
  1021     |steps dExt dOrg org ext root|
  1021 
  1022 
  1022     root := self rootView.
  1023     root := self rootView.
  1023 
  1024 
  1024     steps := 10.
  1025     steps := 10.
  1025     dExt := (endRect extent - startRect extent) / steps.
  1026     dExt := (endRect extent - startRect extent) / steps.
  1026     dOrg := (endRect origin - startRect origin) / steps.
  1027     dOrg := (endRect origin - startRect origin) / steps.
  1027     0 to:steps do:[:step |
  1028     0 to:steps do:[:step |
  1028 	org := (startRect origin + (dOrg * step)) rounded.
  1029         org := (startRect origin + (dOrg * step)) rounded.
  1029 	ext := (startRect extent + (dExt * step)) rounded.
  1030         ext := (startRect extent + (dExt * step)) rounded.
  1030 	root clippedByChildren:false.
  1031         root clippedByChildren:false.
  1031 	root xoring:[
  1032         root xoring:[
  1032 	    root displayRectangleX:org x y:org y width:ext x height:ext y
  1033             root displayRectangleX:org x y:org y width:ext x height:ext y
  1033 	].
  1034         ].
  1034 	Delay waitForMilliseconds:(milliseconds // steps).
  1035         Delay waitForMilliseconds:(milliseconds // steps).
  1035 	root xoring:[
  1036         root xoring:[
  1036 	    root displayRectangleX:org x y:org y width:ext x height:ext y
  1037             root displayRectangleX:org x y:org y width:ext x height:ext y
  1037 	].
  1038         ].
  1038     ].
  1039     ].
  1039     root clippedByChildren:true.
  1040     root clippedByChildren:true.
  1040 
  1041 
  1041     "
  1042     "
  1042      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000
  1043      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000
  1043      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) duration:1000
  1044      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) duration:1000
  1044     "
  1045     "
  1045 
  1046 
  1046     "Created: 27.1.1997 / 18:19:35 / cg"
  1047     "Created: / 27-01-1997 / 18:19:35 / cg"
       
  1048     "Modified (comment): / 01-09-2017 / 09:57:12 / cg"
  1047 !
  1049 !
  1048 
  1050 
  1049 zoom:startRect to:endRect speed:pixelsPerSecond
  1051 zoom:startRect to:endRect speed:pixelsPerSecond
  1050     "animate a rubber-rectangle from startRect to endRect.
  1052     "animate a rubber-rectangle from startRect to endRect.
  1051      Can be used by buttons, which open some dialog for nicer user feedback.
  1053      Can be used by buttons, which open some dialog for nicer user feedback.
  1052      The speed is computed for the longest edge to run at the given speed.
  1054      The speed is computed for the longest edge to run at the given speed.
  1053      Notice: since the displays window manager typically allows a topWindow
  1055      Notice: since the display's window manager typically allows a topWindow
  1054 	     to be placed by the user, this should not be used for modeless
  1056              to be placed by the user, this should not be used for modeless
  1055 	     topViews.
  1057              topViews.
  1056     "
  1058     "
  1057 
  1059 
  1058     |maxDistance|
  1060     |maxDistance|
  1059 
  1061 
  1060     maxDistance := (endRect origin - startRect origin).
  1062     maxDistance := (endRect origin - startRect origin).
  1061     maxDistance := maxDistance max:(endRect topRight - startRect topRight).
  1063     maxDistance := maxDistance max:(endRect topRight - startRect topRight).
  1062     maxDistance := maxDistance max:(endRect bottomLeft - startRect bottomLeft).
  1064     maxDistance := maxDistance max:(endRect bottomLeft - startRect bottomLeft).
  1063     maxDistance := maxDistance max:(endRect corner - startRect corner).
  1065     maxDistance := maxDistance max:(endRect corner - startRect corner).
  1064     maxDistance := maxDistance x max:(maxDistance y).
  1066     maxDistance := maxDistance x max:(maxDistance y).
  1065     ^ self
  1067     ^ self
  1066 	zoom:startRect to:endRect duration:(maxDistance abs / pixelsPerSecond * 1000)
  1068         zoom:startRect to:endRect duration:(maxDistance abs / pixelsPerSecond * 1000)
  1067 
  1069 
  1068     "
  1070     "
  1069      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) speed:1000
  1071      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) speed:1000
  1070      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:10
  1072      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:10
  1071     "
  1073     "
  1072 
  1074 
  1073     "Created: 27.1.1997 / 18:19:35 / cg"
  1075     "Created: / 27-01-1997 / 18:19:35 / cg"
  1074     "Modified: 27.1.1997 / 18:24:58 / cg"
  1076     "Modified (comment): / 01-09-2017 / 09:57:16 / cg"
  1075 ! !
  1077 ! !
  1076 
  1078 
  1077 !DeviceWorkstation methodsFor:'Compatibility-Squeak'!
  1079 !DeviceWorkstation methodsFor:'Compatibility-Squeak'!
  1078 
  1080 
  1079 border:aRectangle width:bw
  1081 border:aRectangle width:bw
  1545 
  1547 
  1546 translatePoint:aPoint from:windowId1 to:windowId2
  1548 translatePoint:aPoint from:windowId1 to:windowId2
  1547     "given a point in window1 (defined by its id), return the coordinate of
  1549     "given a point in window1 (defined by its id), return the coordinate of
  1548      aPoint in window2 (defined by its id).
  1550      aPoint in window2 (defined by its id).
  1549      Use to xlate points from a window to rootwindow, mainly for rubber-line
  1551      Use to xlate points from a window to rootwindow, mainly for rubber-line
  1550      drawing on the displays root window."
  1552      drawing on the display's root window."
  1551 
  1553 
  1552     "This method has to be reimplemented in concrete display classes."
  1554     "This method has to be reimplemented in concrete display classes."
  1553 
  1555 
  1554     ^ self subclassResponsibility
  1556     ^ self subclassResponsibility
  1555 
  1557 
  1583 
  1585 
  1584      root clippedByChildren:false.
  1586      root clippedByChildren:false.
  1585      root displayLineFrom:p1 to:p2.
  1587      root displayLineFrom:p1 to:p2.
  1586      root clippedByChildren:true.
  1588      root clippedByChildren:true.
  1587     "
  1589     "
       
  1590 
       
  1591     "Modified (comment): / 01-09-2017 / 09:56:54 / cg"
  1588 !
  1592 !
  1589 
  1593 
  1590 translatePoint:aPoint fromView:window1 toView:window2
  1594 translatePoint:aPoint fromView:window1 toView:window2
  1591     "given a point in window1, return the coordinate of aPoint in window2.
  1595     "given a point in window1, return the coordinate of aPoint in window2.
  1592      Either window argument may be nil to specify the root window (screen)
  1596      Either window argument may be nil to specify the root window (screen)
  1593      Use to xlate points from a window to another window (or from a window
  1597      Use to xlate points from a window to another window (or from a window
  1594      to the rootwindow), mainly for rubber-line drawing on the displays root window."
  1598      to the rootwindow), mainly for rubber-line drawing on the display's root window."
  1595 
  1599 
  1596     |w1 w2 devicePoint offset1 offset2|
  1600     |w1 w2 devicePoint offset1 offset2|
  1597 
  1601 
  1598     w1 := window1 ? self rootView.
  1602     w1 := window1 ? self rootView.
  1599     w2 := window2 ? self rootView.
  1603     w2 := window2 ? self rootView.
  1603         ^ aPoint
  1607         ^ aPoint
  1604     ].
  1608     ].
  1605     w1 isView ifTrue:[
  1609     w1 isView ifTrue:[
  1606         offset1 := 0
  1610         offset1 := 0
  1607     ] ifFalse:[
  1611     ] ifFalse:[
       
  1612         "/ can be a graphic element inside a view
  1608         offset1 := w1 origin.
  1613         offset1 := w1 origin.
  1609         w1 := w1 container.
  1614         w1 := w1 container.
  1610     ].
  1615     ].
  1611     w2 isView ifTrue:[
  1616     w2 isView ifTrue:[
  1612         offset2 := 0
  1617         offset2 := 0
  1613     ] ifFalse:[
  1618     ] ifFalse:[
       
  1619         "/ can be a graphic element inside a view
  1614         offset2 := w2 origin.
  1620         offset2 := w2 origin.
  1615         w2 := w2 container.
  1621         w2 := w2 container.
  1616     ].
  1622     ].
  1617     devicePoint := self translatePoint:aPoint from:(w1 drawableId) to:(w2 drawableId).
  1623     devicePoint := self translatePoint:aPoint from:(w1 drawableId) to:(w2 drawableId).
  1618     devicePoint isNil ifTrue:[ ^ aPoint].
  1624     devicePoint isNil ifTrue:[ ^ aPoint].
  1619     ^ devicePoint + offset1 - offset2
  1625     ^ devicePoint + offset1 - offset2
  1620 
  1626 
  1621     "Modified: / 27-10-2007 / 13:04:09 / cg"
  1627     "Modified: / 27-10-2007 / 13:04:09 / cg"
       
  1628     "Modified (comment): / 01-09-2017 / 09:55:46 / cg"
  1622 !
  1629 !
  1623 
  1630 
  1624 translatePointFromRoot:aPoint toView:window
  1631 translatePointFromRoot:aPoint toView:window
  1625     "given a point as absolute root-window coordinate, return the coordinate within the window.
  1632     "given a point as absolute root-window coordinate, return the coordinate within the window.
  1626      Use to xlate points from the rootWindow to a window."
  1633      Use to xlate points from the rootWindow to a window."
  1631 !
  1638 !
  1632 
  1639 
  1633 translatePointToRoot:aPoint fromView:window1
  1640 translatePointToRoot:aPoint fromView:window1
  1634     "given a point in window1, return the absolute root-window coordinate.
  1641     "given a point in window1, return the absolute root-window coordinate.
  1635      Use to xlate points from a window to the rootwindow,
  1642      Use to xlate points from a window to the rootwindow,
  1636      mainly for rubber-line drawing on the displays root window."
  1643      mainly for rubber-line drawing on the display's root window."
  1637 
  1644 
  1638     ^ self translatePoint:aPoint fromView:window1 toView:nil
  1645     ^ self translatePoint:aPoint fromView:window1 toView:nil
  1639 
  1646 
  1640     "Modified: / 10.10.2001 / 14:09:22 / cg"
  1647     "Modified: / 10-10-2001 / 14:09:22 / cg"
       
  1648     "Modified (comment): / 01-09-2017 / 09:56:59 / cg"
  1641 !
  1649 !
  1642 
  1650 
  1643 viewFromPoint:aScreenPoint
  1651 viewFromPoint:aScreenPoint
  1644     "given a point on the screen, return the ST/X view in which that
  1652     "given a point on the screen, return the ST/X view in which that
  1645      point is (this may be a subview).
  1653      point is (this may be a subview).
  2621 ! !
  2629 ! !
  2622 
  2630 
  2623 !DeviceWorkstation methodsFor:'accessing-display geometry'!
  2631 !DeviceWorkstation methodsFor:'accessing-display geometry'!
  2624 
  2632 
  2625 boundingBox
  2633 boundingBox
  2626     "return a rectangle representing the displays bounding box.
  2634     "return a rectangle representing the display's bounding box.
  2627      For Smalltalk-80 2.x compatibility"
  2635      For Smalltalk-80 2.x compatibility"
  2628 
  2636 
  2629     ^ self bounds
  2637     ^ self bounds
       
  2638 
       
  2639     "Modified (comment): / 01-09-2017 / 09:56:23 / cg"
  2630 !
  2640 !
  2631 
  2641 
  2632 bounds
  2642 bounds
  2633     "return a rectangle representing the displays bounding box.
  2643     "return a rectangle representing the display's bounding box.
  2634      For Smalltalk-80 4.x compatibility"
  2644      For Smalltalk-80 4.x compatibility"
  2635 
  2645 
  2636     ^ Rectangle left:0 top:0 width:width-1 height:height-1
  2646     ^ Rectangle left:0 top:0 width:width-1 height:height-1
  2637 
  2647 
  2638     "
  2648     "
  2641     "/ that's the same as:
  2651     "/ that's the same as:
  2642     "
  2652     "
  2643      Display bounds
  2653      Display bounds
  2644     "
  2654     "
  2645 
  2655 
  2646     "Modified: 8.5.1996 / 20:58:26 / cg"
  2656     "Modified: / 08-05-1996 / 20:58:26 / cg"
       
  2657     "Modified (comment): / 01-09-2017 / 09:56:27 / cg"
  2647 !
  2658 !
  2648 
  2659 
  2649 captionHeight
  2660 captionHeight
  2650     "return the height in pixels of the caption
  2661     "return the height in pixels of the caption
  2651      (i.e. title bar) of topWindows.
  2662      (i.e. title bar) of topWindows.