ModalBox.st
changeset 7981 d3b4f232af3b
parent 7891 8cc23e3f937f
child 8464 0af00aa05d74
equal deleted inserted replaced
7980:c7b42695fdc9 7981:d3b4f232af3b
   431     "resize myself to make everything visible, AND possibly change the origin
   431     "resize myself to make everything visible, AND possibly change the origin
   432      to have the mouse pointer stay within my bounds.
   432      to have the mouse pointer stay within my bounds.
   433      This is used for self-resizing enterBoxes, to avoid moving
   433      This is used for self-resizing enterBoxes, to avoid moving
   434      the box away from the cursor."
   434      the box away from the cursor."
   435 
   435 
   436     |newExtent newLeft delta screenWidth|
   436     |newExtent newWidth newHeight newLeft newRight newTop newBottom delta screenWidth|
   437 
   437 
   438     newExtent := self preferredExtent.
   438     newExtent := self preferredExtent.
   439     newExtent = self extent ifTrue:[^ self].
   439     newExtent = self extent ifTrue:[^ self].
   440 
   440 
   441     shown ifTrue:[
   441     shown ifTrue:[
   442         delta := width - newExtent x.
   442         "/ new code (after 15.3.2017)
   443         newLeft := left + delta.
   443         
   444         (((newLeft @ top) extent:newExtent) containsPoint:device pointerPosition
   444         newWidth := newExtent x.
   445         ) ifFalse:[
   445         newHeight := newExtent y.
   446             newLeft := left
   446         newLeft := left.
       
   447         newTop := top.
       
   448         newRight := left + newWidth.
       
   449         newBottom := top + newHeight.
       
   450         newRight > device usableWidth ifTrue:[
       
   451             newLeft := device usableWidth - newWidth.
       
   452             newLeft < 0 ifTrue:[
       
   453                 newLeft := 0.
       
   454                 newRight := newWidth := device usableWidth.
       
   455             ].    
   447         ].
   456         ].
   448         newLeft < 0 ifTrue:[newLeft := 0].
   457         newBottom > device usableHeight ifTrue:[
   449         screenWidth := device usableWidth.
   458             newTop := device usableHeight - newHeight.
   450         newLeft + newExtent x > screenWidth ifTrue:[
   459             newTop < 0 ifTrue:[
   451             newLeft := screenWidth - newExtent x
   460                 newTop := 0.
       
   461                 newBottom := newHeight := device usableHeight.
       
   462             ].    
   452         ].
   463         ].
       
   464         newExtent := newWidth @ newHeight.
       
   465 
       
   466 "/ old code (before 15.3.2017).        
       
   467 "/        delta := width - newExtent x.
       
   468 "/        newLeft := left + delta.
       
   469 "/        (((newLeft @ top) extent:newExtent) containsPoint:device pointerPosition
       
   470 "/        ) ifFalse:[
       
   471 "/            newLeft := left
       
   472 "/        ].
       
   473 "/        newLeft < 0 ifTrue:[newLeft := 0].
       
   474 "/        screenWidth := device usableWidth.
       
   475 "/        newLeft + newExtent x > screenWidth ifTrue:[
       
   476 "/            newLeft := screenWidth - newExtent x
       
   477 "/        ].
   453         shadowView notNil ifTrue:[
   478         shadowView notNil ifTrue:[
   454             shadowView unmap.
   479             shadowView unmap.
   455         ].
   480         ].
   456         self origin:(newLeft @ top) extent:newExtent.
   481         self origin:(newLeft @ newTop) extent:newExtent.
   457         shadowView notNil ifTrue:[
   482         shadowView notNil ifTrue:[
   458             shadowView realize.
   483             shadowView realize.
   459             self raise.
   484             self raise.
   460         ].
   485         ].
   461     ] ifFalse:[
   486     ] ifFalse:[
   462         self extent:newExtent.
   487         self extent:newExtent.
   463     ].
   488     ].
   464 
   489 
   465     "Modified: 6.9.1995 / 15:31:21 / claus"
   490     "Modified: / 06-09-1995 / 15:31:21 / claus"
   466     "Modified: 3.5.1996 / 23:48:17 / stefan"
   491     "Modified: / 03-05-1996 / 23:48:17 / stefan"
       
   492     "Modified (comment): / 15-03-2017 / 19:37:03 / cg"
   467 ! !
   493 ! !
   468 
   494 
   469 !ModalBox methodsFor:'move & resize'!
   495 !ModalBox methodsFor:'move & resize'!
   470 
   496 
   471 doMove
   497 doMove