UIObjectView.st
changeset 3445 bd1aa4795dcf
parent 3395 818e06192ffc
child 3451 1c9aad7b074f
equal deleted inserted replaced
3444:4d705dd47c2d 3445:bd1aa4795dcf
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1995 by eXept Software AG
     4  COPYRIGHT (c) 1995 by eXept Software AG
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  2591         self layoutChanged
  2593         self layoutChanged
  2592     ]
  2594     ]
  2593 !
  2595 !
  2594 
  2596 
  2595 centerSelection:aOneArgBlockXorY orientation:orientation
  2597 centerSelection:aOneArgBlockXorY orientation:orientation
  2596     "center selection horizontal or vertical dependant on the block result( x or y).
  2598     "center selection horizontally or vertically depending on the block result (x or y).
  2597      The argument to the block is the point.
  2599      The argument to the block is the point.
  2598     "
  2600     "
  2599     |superview min max delta val|
  2601     |superview min max delta val|
  2600 
  2602 
  2601     (self moveableSelection) isNil ifTrue:[
  2603     (self moveableSelection) isNil ifTrue:[
  2602 	^ self
  2604         ^ self
  2603     ].
  2605     ].
  2604 
  2606 
  2605     self withSelectionHiddenDo:[
  2607     self withSelectionHiddenDo:[
  2606 	max := 0.
  2608         max := 0.
  2607 
  2609 
  2608 	self selectionDo:[:aView |
  2610         self selectionDo:[:aView |
  2609 	    superview isNil ifTrue:[
  2611             superview isNil ifTrue:[
  2610 		superview := self findContainerOfView:aView
  2612                 superview := self findContainerOfView:aView
  2611 	    ] ifFalse:[
  2613             ] ifFalse:[
  2612 		(self findContainerOfView:aView) == superview ifFalse:[
  2614                 (self findContainerOfView:aView) == superview ifFalse:[
  2613 		    ^ self notify:'views must have same superview'.
  2615                     ^ self notify:'views must have same superview'.
  2614 		]
  2616                 ]
  2615 	    ].
  2617             ].
  2616 	    val := aOneArgBlockXorY value:(aView computeOrigin).    
  2618             val := aOneArgBlockXorY value:(aView computeOrigin).
  2617 
  2619 
  2618 	    min isNil ifTrue:[min := val]
  2620             min isNil ifTrue:[min := val]
  2619 		     ifFalse:[min := min min:val].
  2621                      ifFalse:[min := min min:val].
  2620 
  2622 
  2621 	    val := aOneArgBlockXorY value:(aView computeCorner).
  2623             val := aOneArgBlockXorY value:(aView computeCorner).
  2622 	    max := max max:val.
  2624             max := max max:val.
  2623 	].
  2625         ].
  2624 
  2626 
  2625 	val := aOneArgBlockXorY value:(superview computeExtent).
  2627         val := aOneArgBlockXorY value:(superview computeExtent).
  2626 	max := (min + val - max) // 2.
  2628         max := (min + val - max) // 2.
  2627 
  2629 
  2628 	max == min ifFalse:[
  2630         max == min ifFalse:[
  2629 	    |type|
  2631             |type|
  2630 	    (orientation == #y) ifTrue:[type := #centerVertical]
  2632             (orientation == #y) ifTrue:[type := #centerVertical]
  2631 			       ifFalse:[type := #centerHorizontal].
  2633                                ifFalse:[type := #centerHorizontal].
  2632 	    delta := max - min.
  2634             delta := max - min.
  2633 
  2635 
  2634 	    self transaction:type selectionDo:[:v|
  2636             self transaction:type selectionDo:[:v|
  2635 		orientation == #y ifTrue:[
  2637                 orientation == #y ifTrue:[
  2636 		    self shiftLayout:v top:delta bottom:delta
  2638                     self shiftLayout:v top:delta bottom:delta
  2637 		] ifFalse:[
  2639                 ] ifFalse:[
  2638 		    self shiftLayout:v left:delta right:delta
  2640                     self shiftLayout:v left:delta right:delta
  2639 		]
  2641                 ]
  2640 	    ]
  2642             ]
  2641 	].
  2643         ].
  2642 	self layoutChanged
  2644         self layoutChanged
  2643     ]
  2645     ]
  2644 
  2646 
  2645 
  2647     "Modified (format): / 16-05-2017 / 17:45:24 / mawalch"
  2646 !
  2648 !
  2647 
  2649 
  2648 centerSelectionHor
  2650 centerSelectionHor
  2649     "center selection horizontal
  2651     "center selection horizontal
  2650     "
  2652     "