UIObjectView.st
changeset 1581 d7afe06ebbae
parent 1577 9dddcd2d77ab
child 1672 5e89f5959780
equal deleted inserted replaced
1580:c606e46c4420 1581:d7afe06ebbae
    87 
    87 
    88     type   := self layoutType:aView.
    88     type   := self layoutType:aView.
    89     layout := aView geometryLayout.
    89     layout := aView geometryLayout.
    90 
    90 
    91     layout isNil ifTrue:[
    91     layout isNil ifTrue:[
    92 	type == #Extent ifTrue:[
    92         type == #Extent ifTrue:[
    93 	    layout := aView bounds asLayout
    93             layout := aView bounds asLayout
    94 	]
    94         ]
    95     ].
    95     ].
    96 
    96 
    97     (type isNil or:[layout isNil]) ifTrue:[
    97     (type isNil or:[layout isNil]) ifTrue:[
    98 	^ nil
    98         ^ nil
    99     ].
    99     ].
   100 
   100 
   101     type == #LayoutFrame ifTrue:[
   101     type == #LayoutFrame ifTrue:[
   102 	^ layout copy
   102         ^ layout copy
   103     ].
   103     ].
   104 
   104 
   105     layout isLayout ifFalse:[
   105     layout isLayout ifFalse:[
   106 	type == #Rectangle ifTrue:[
   106         type == #Rectangle ifTrue:[
   107 	    lO := layout left.
   107             lO := layout left.
   108 	    tO := layout top.
   108             tO := layout top.
   109 	    rO := layout right.
   109             rO := layout right.
   110 	    bO := layout bottom.
   110             bO := layout bottom.
   111 	] ifFalse:[
   111         ] ifFalse:[
   112 	    lO := layout x.
   112             lO := layout x.
   113 	    tO := layout y.
   113             tO := layout y.
   114 	    rO := lO + aView extent x.
   114             rO := lO + aView extent x.
   115 	    bO := tO + aView extent y.
   115             bO := tO + aView extent y.
   116 	].
   116         ].
   117 
   117 
   118 	^ LayoutFrame leftFraction:0 offset:lO  rightFraction:0 offset:rO
   118         ^ LayoutFrame 
   119 		       topFraction:0 offset:tO bottomFraction:0 offset:bO
   119                 leftFraction:0 offset:lO  
       
   120                 rightFraction:0 offset:rO
       
   121                 topFraction:0 offset:tO 
       
   122                 bottomFraction:0 offset:bO
   120     ].
   123     ].
   121 
   124 
   122     lF := layout leftFraction.
   125     lF := layout leftFraction.
   123     lO := layout leftOffset.
   126     lO := layout leftOffset.
   124     tF := layout topFraction.
   127     tF := layout topFraction.
   126     bF := tF.
   129     bF := tF.
   127     bO := tO + aView extent y.
   130     bO := tO + aView extent y.
   128     rF := lF.
   131     rF := lF.
   129     rO := lO + aView extent x.
   132     rO := lO + aView extent x.
   130 
   133 
   131     newLyt := LayoutFrame leftFraction:lF offset:lO  rightFraction:rF offset:rO
   134     newLyt := LayoutFrame 
   132 			   topFraction:tF offset:tO bottomFraction:bF offset:bO.
   135                 leftFraction:lF offset:lO  
       
   136                 rightFraction:rF offset:rO
       
   137                 topFraction:tF offset:tO 
       
   138                 bottomFraction:bF offset:bO.
   133 
   139 
   134     (    (type == #AlignmentOrigin)
   140     (    (type == #AlignmentOrigin)
   135      and:[layout leftAlignmentFraction ~~ 0
   141      and:[layout leftAlignmentFraction ~~ 0
   136       or:[layout topAlignmentFraction  ~~ 0]]
   142       or:[layout topAlignmentFraction  ~~ 0]]
   137     ) ifTrue:[
   143     ) ifTrue:[
   138 	|svRc prBd dlta|
   144         |svRc prBd dlta|
   139 
   145 
   140 	svRc := aView superView viewRectangle.
   146         svRc := aView superView viewRectangle.
   141 	prBd := aView preferredBounds.
   147         prBd := aView preferredBounds.
   142 	dlta := (  ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
   148         dlta := (  ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
   143 		 - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
   149                  - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
   144 		) rounded.
   150                 ) rounded.
   145 
   151 
   146 	newLyt leftOffset:(lO + dlta x).
   152         newLyt 
   147 	newLyt rightOffset:(rO + dlta x).
   153             leftOffset:(lO + dlta x)
   148 	newLyt topOffset:(tO + dlta y).
   154             rightOffset:(rO + dlta x)
   149 	newLyt bottomOffset:(bO + dlta y).
   155             topOffset:(tO + dlta y)
       
   156             bottomOffset:(bO + dlta y).
   150     ].
   157     ].
   151   ^ newLyt.
   158   ^ newLyt.
   152 
   159 
   153     "Modified: 28.3.1997 / 19:52:48 / cg"
   160     "Modified: 28.3.1997 / 19:52:48 / cg"
   154 ! !
   161 ! !
  1962      of one selection the object is aligned to the left of its superview
  1969      of one selection the object is aligned to the left of its superview
  1963     "
  1970     "
  1964     |lmost delta sel|
  1971     |lmost delta sel|
  1965 
  1972 
  1966     (sel := self moveableSelection) notNil ifTrue:[
  1973     (sel := self moveableSelection) notNil ifTrue:[
  1967 	self withSelectionHiddenDo:[
  1974         self withSelectionHiddenDo:[
  1968 	    self numberOfSelections > 1 ifTrue:[
  1975             self numberOfSelections > 1 ifTrue:[
  1969 		lmost := (sel first) computeOrigin x.
  1976                 lmost := (sel first) computeOrigin x.
  1970 
  1977 
  1971 		self transaction:#alignLeft selectionDo:[:v|
  1978                 self transaction:#alignLeft selectionDo:[:v|
  1972 		    (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1979                     (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1973 			self shiftLayout:v left:delta right:delta
  1980                         self shiftLayout:v left:delta right:delta
  1974 		    ]
  1981                     ]
  1975 		]
  1982                 ]
  1976 	    ] ifFalse:[
  1983             ] ifFalse:[
  1977 		self extentToFrame:#Left do:[:aLayout|
  1984                 self extentToFrame:#Left do:[:aLayout|
  1978 		    aLayout leftOffset:0.
  1985                     aLayout leftFraction:0.0 offset:0.
  1979 		    aLayout leftFraction:0.0.
  1986                 ]
  1980 		]
  1987             ]
  1981 	    ]
  1988         ].
  1982 	].
  1989         self layoutChanged
  1983 	self layoutChanged
       
  1984     ]
  1990     ]
  1985 !
  1991 !
  1986 
  1992 
  1987 alignSelectionLeftAndRight
  1993 alignSelectionLeftAndRight
  1988     "align selection to the left/right of the first object in the selection; in case
  1994     "align selection to the left/right of the first object in the selection; in case
  1989      of one selection the object is aligned to the left/right of its superview
  1995      of one selection the object is aligned to the left/right of its superview
  1990     "
  1996     "
  1991     |lmost rmost sel|
  1997     |lmost rmost sel|
  1992 
  1998 
  1993     (sel := self moveableSelection) notNil ifTrue:[
  1999     (sel := self moveableSelection) notNil ifTrue:[
  1994 	self withSelectionHiddenDo:[
  2000         self withSelectionHiddenDo:[
  1995 	    self numberOfSelections > 1 ifTrue:[
  2001             self numberOfSelections > 1 ifTrue:[
  1996 		lmost := (sel first) computeOrigin x.
  2002                 lmost := (sel first) computeOrigin x.
  1997 		rmost := (sel first) computeCorner x.
  2003                 rmost := (sel first) computeCorner x.
  1998 
  2004 
  1999 		self transaction:#alignLeftRight selectionDo:[:aView|
  2005                 self transaction:#alignLeftRight selectionDo:[:aView|
  2000 		    |layout|
  2006                     |layout|
  2001 		    layout := self class asLayoutFrameFromView:aView.
  2007                     layout := self class asLayoutFrameFromView:aView.
  2002 
  2008 
  2003 		    layout notNil ifTrue:[
  2009                     layout notNil ifTrue:[
  2004 			self createUndoLayout:aView.
  2010                         self createUndoLayout:aView.
  2005 			aView geometryLayout:layout.
  2011                         aView geometryLayout:layout.
  2006 
  2012 
  2007 			undoHistory withoutTransactionDo:[    
  2013                         undoHistory withoutTransactionDo:[    
  2008 			    self shiftLayout:aView left:(lmost - (aView computeOrigin x))
  2014                             self shiftLayout:aView left:(lmost - (aView computeOrigin x))
  2009 						  right:(rmost - (aView computeCorner x)).
  2015                                                   right:(rmost - (aView computeCorner x)).
  2010 			].
  2016                         ].
  2011 			self elementChangedSize:aView
  2017                         self elementChangedSize:aView
  2012 		    ]
  2018                     ]
  2013 		]
  2019                 ]
  2014 	    ] ifFalse:[
  2020             ] ifFalse:[
  2015 		self extentToFrame:#LeftRight do:[:aLayout|
  2021                 self extentToFrame:#LeftRight do:[:aLayout|
  2016 		    aLayout leftOffset:0.
  2022                     aLayout leftFraction:0.0 offset:0.
  2017 		    aLayout leftFraction:0.0.
  2023                     aLayout rightFraction:1.0 offset:0.
  2018 		    aLayout rightOffset:0.
  2024                 ]
  2019 		    aLayout rightFraction:1.0.
  2025             ]
  2020 		]
  2026         ].
  2021 	    ]
  2027         self layoutChanged
  2022 	].
  2028     ].
  2023 	self layoutChanged
       
  2024     ].
       
  2025 
       
  2026 !
  2029 !
  2027 
  2030 
  2028 alignSelectionRight
  2031 alignSelectionRight
  2029     "align selection to the right of the first object in the selection; in case
  2032     "align selection to the right of the first object in the selection; in case
  2030      of one selection the object is aligned to the right of its superview
  2033      of one selection the object is aligned to the right of its superview