UIObjectView.st
changeset 128 9779b7459a1c
parent 123 421d412e797b
child 131 715b3dbba87d
equal deleted inserted replaced
127:95070ea7ae42 128:9779b7459a1c
    19 	classVariableNames:''
    19 	classVariableNames:''
    20 	poolDictionaries:''
    20 	poolDictionaries:''
    21 	privateIn:UIObjectView::UndoHistory
    21 	privateIn:UIObjectView::UndoHistory
    22 !
    22 !
    23 
    23 
       
    24 !UIObjectView class methodsFor:'documentation'!
       
    25 
       
    26 documentation
       
    27 "
       
    28     buildIn view used by the UIPainter; from this view, the layout of the
       
    29     new application derives from.
       
    30 
       
    31     [see also:]
       
    32         UIBuilder
       
    33         UIPainterView
       
    34 "
       
    35 
       
    36 ! !
    24 
    37 
    25 !UIObjectView class methodsFor:'conversion'!
    38 !UIObjectView class methodsFor:'conversion'!
    26 
    39 
    27 asLayoutFrameFromView:aView
    40 asLayoutFrameFromView:aView
    28     "convert layout from aView to a frameLayout. On success the frameLayout is
    41     "convert layout from aView to a frameLayout. On success the frameLayout is
   231 enabled:aState
   244 enabled:aState
   232     "set the modification / test mode
   245     "set the modification / test mode
   233     "
   246     "
   234     (aState == enableChannel value) ifFalse:[
   247     (aState == enableChannel value) ifFalse:[
   235         aState ifFalse:[
   248         aState ifFalse:[
   236             saveSelection := selection copy
   249             saveSelection := self selection copy.
   237         ].
       
   238         enableChannel value:aState.
       
   239 
       
   240         aState ifFalse:[
       
   241             self unselect.
   250             self unselect.
   242             inputView unrealize
   251             enableChannel value:aState.
       
   252             inputView unrealize.
   243         ] ifTrue:[
   253         ] ifTrue:[
   244             inputView raise.
   254             inputView raise.
   245             inputView realize.
   255             inputView realize.
       
   256             enableChannel value:aState.
   246             self select:saveSelection.
   257             self select:saveSelection.
   247         ]
   258         ]
   248     ]
   259     ]
   249 
   260 
   250 
   261 
   296 
   307 
   297 exposeX:x y:y width:w height:h
   308 exposeX:x y:y width:w height:h
   298     "handle an expose event from device; redraw selection
   309     "handle an expose event from device; redraw selection
   299     "
   310     "
   300     super exposeX:x y:y width:w height:h.
   311     super exposeX:x y:y width:w height:h.
   301 "/    selectionHiddenLevel == 0 ifTrue:[
   312     self selectionDo:[:v | self showSelected:v]
   302         self selectionDo:[:v | self showSelected:v]
       
   303 "/    ]
       
   304 
   313 
   305 !
   314 !
   306 
   315 
   307 keyPress:key x:x y:y
   316 keyPress:key x:x y:y
   308     "any key pressed
   317     "any key pressed
   313         ^ self deleteSelection
   322         ^ self deleteSelection
   314     ].
   323     ].
   315 
   324 
   316     key == #Copy  ifTrue:[ ^ self copySelection].
   325     key == #Copy  ifTrue:[ ^ self copySelection].
   317     key == #Paste ifTrue:[ ^ self pasteBuffer].
   326     key == #Paste ifTrue:[ ^ self pasteBuffer].
   318 
       
   319     super keyPress:key x:x y:y
       
   320 
       
   321 
       
   322 !
   327 !
   323 
   328 
   324 processEvent:anEvent
   329 processEvent:anEvent
   325     "catch expose events for components, and redraw its handles after
   330     "catch expose events for components, and redraw its handles after
   326      the redraw when this happens
   331      the redraw when this happens
   327     "
   332     "
   328     |view|
   333     (anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[
   329 
   334         self showSelected:(anEvent view)
   330     selection notNil ifTrue:[
       
   331         anEvent type == #damage ifTrue:[
       
   332             view := anEvent view.
       
   333             (selection == view
       
   334             or:[selection isCollection
       
   335                 and:[selection includes:view]]) ifTrue:[
       
   336                     self showSelected:view
       
   337             ]
       
   338         ]
       
   339     ].
   335     ].
   340     ^ false.
   336     ^ false.
   341 
   337 
   342 
   338 
   343 !
   339 !
   628 
   624 
   629 endObjectMove
   625 endObjectMove
   630     "cleanup after object(s) move
   626     "cleanup after object(s) move
   631     "
   627     "
   632     movedObject notNil ifTrue:[
   628     movedObject notNil ifTrue:[
   633         movedObject do:[:aView|
   629         movedObject do:[:aView|self invertOutlineOf:aView].
   634             self invertOutlineOf:aView
   630 
   635         ].
       
   636 
       
   637         movedObject do:[:aView|
       
   638             self showSelected:aView
       
   639         ].
       
   640         movedObject size == 1 ifTrue:[
   631         movedObject size == 1 ifTrue:[
   641             selection := movedObject at:1
   632             movedObject := movedObject first
   642         ] ifFalse:[
   633         ].
   643             selection := movedObject
   634 
   644         ].
   635         self setSelection:movedObject withRedraw:true.
   645 
       
   646         movedObject := nil.
   636         movedObject := nil.
   647         self setDefaultActions.
   637         self setDefaultActions.
   648         self changed:#layout.
   638         self changed:#layout.
   649     ].
   639     ].
   650 !
   640 !
   670 !
   660 !
   671 
   661 
   672 startObjectMoveAt:aPoint
   662 startObjectMoveAt:aPoint
   673     "start object(s) move at a point
   663     "start object(s) move at a point
   674     "
   664     "
   675     self startObjectMove:selection at:aPoint.
   665     self startObjectMove:(self selection) at:aPoint.
   676 
   666     movedObject := self selection.
   677     selection isCollection ifTrue:[
   667 
   678         movedObject := selection
   668     movedObject isCollection ifFalse:[
   679     ] ifFalse:[
   669         movedObject := Array with:movedObject
   680         movedObject := Array with:selection
   670     ].
   681     ].
   671     self setSelection:nil withRedraw:true.
   682     super unselect.
       
   683 
   672 
   684     moveDelta := movedObject collect:[:aView|
   673     moveDelta := movedObject collect:[:aView|
   685         aPoint - aView computeOrigin
   674         aPoint - aView computeOrigin
   686     ].
   675     ].
   687 
   676 
   736         (aView := self findObjectAt:aPoint) isNil ifTrue:[
   725         (aView := self findObjectAt:aPoint) isNil ifTrue:[
   737             ^ self unselect
   726             ^ self unselect
   738         ].
   727         ].
   739 
   728 
   740         (self canMove:aView) ifFalse:[
   729         (self canMove:aView) ifFalse:[
   741             super unselect.
   730             ^ self select:aView
   742           ^ self select:aView
       
   743         ]
   731         ]
   744     ].
   732     ].
   745 
   733 
   746     (self isSelected:aView) ifFalse:[
   734     (self isSelected:aView) ifFalse:[
   747         super unselect.
       
   748         self select:aView.
   735         self select:aView.
   749     ].
   736     ].
   750 
   737 
   751     (self numberOfSelections ~~ 1) ifTrue:[
   738     (self numberOfSelections ~~ 1) ifTrue:[
   752         releaseAction := [
   739         releaseAction := [
   815     actionData := nil.
   802     actionData := nil.
   816 
   803 
   817     self invertOutlineOf:object.
   804     self invertOutlineOf:object.
   818     self setDefaultActions.
   805     self setDefaultActions.
   819     self elementChangedSize:object.
   806     self elementChangedSize:object.
   820     super select:object.
   807     self setSelection:object withRedraw:true.
   821     self changed:#layout.
   808     self changed:#layout.
   822 !
   809 !
   823 
   810 
   824 startResizeBorder:b of:selection
   811 startResizeBorder:b of:selection
   825     "resize selected view
   812     "resize selected view
   830     self actionResize:object selector:b.
   817     self actionResize:object selector:b.
   831 
   818 
   832     self transaction:#resize selectionDo:[:aView|
   819     self transaction:#resize selectionDo:[:aView|
   833         self undoLayoutView:aView
   820         self undoLayoutView:aView
   834     ].
   821     ].
   835     super unselect.
   822     self setSelection:nil withRedraw:true.
   836 
   823 
   837     motionAction  := [:movePoint | self doDragResize:movePoint].
   824     motionAction  := [:movePoint | self doDragResize:movePoint].
   838     releaseAction := [self endResize].
   825     releaseAction := [self endResize].
   839     self invertOutlineOf:object
   826     self invertOutlineOf:object
   840 ! !
   827 ! !
  1211 
  1198 
  1212 ! !
  1199 ! !
  1213 
  1200 
  1214 !UIObjectView methodsFor:'selections'!
  1201 !UIObjectView methodsFor:'selections'!
  1215 
  1202 
  1216 addToSelection:something
  1203 addToSelection:anObject
  1217     "add something to selection
  1204     "add anObject to selection
  1218     "
  1205     "
  1219     (self canSelect:something) ifTrue:[
  1206     |coll|
  1220         super addToSelection:something.
  1207 
  1221         self selectionChanged.
  1208     self enabled ifTrue:[
  1222     ]
  1209         self hasSelection ifFalse:[
       
  1210              self select:anObject
       
  1211         ] ifTrue:[
       
  1212             (self isSelected:anObject) ifFalse:[
       
  1213                 (coll := self selection) isCollection ifFalse:[
       
  1214                     coll := OrderedCollection with:coll
       
  1215                 ].
       
  1216                 coll add:anObject.
       
  1217                 self setSelection:coll withRedraw:false.
       
  1218                 self showSelected:anObject.
       
  1219                 self selectionChanged.
       
  1220             ]
       
  1221         ]
       
  1222     ]
       
  1223 !
       
  1224 
       
  1225 moveableSelection
       
  1226     "tests whether all selected objects are moveable and in case
       
  1227      of true the selection is returned, otherwise nil
       
  1228     "
       
  1229     |coll|
       
  1230 
       
  1231     self hasSelection ifTrue:[
       
  1232         (self canMove:(coll := self selection)) ifTrue:[
       
  1233             ^ coll
       
  1234         ]
       
  1235     ].
       
  1236   ^ nil
  1223 !
  1237 !
  1224 
  1238 
  1225 numberOfSelections
  1239 numberOfSelections
  1226     "return the number of selected entries
  1240     "return the number of selected entries
  1227     "
  1241     "
  1228     |sz|
  1242     |coll size|
  1229 
  1243 
  1230     selection isNil ifTrue:[^ 0].
  1244     coll := self selection.
  1231 
  1245     size := coll size.
  1232     selection isCollection ifTrue:[^ selection size]
  1246 
  1233                           ifFalse:[^ 1 ]
  1247     (size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
  1234 !
  1248   ^ 1
  1235 
  1249 !
  1236 removeFromSelection:something
  1250 
  1237     "remove something from selection
  1251 removeFromSelection:anObject
  1238     "
  1252     "remove anObject from selection
  1239     something notNil ifTrue:[
  1253     "
  1240         super removeFromSelection:something.
  1254     |sel|
  1241         self selectionChanged
  1255 
  1242     ].
  1256     (self isSelected:anObject) ifFalse:[
  1243 
  1257         ^ self
       
  1258     ].
       
  1259 
       
  1260     sel := self selection.
       
  1261 
       
  1262     sel size > 1 ifTrue:[
       
  1263         sel := sel copy.
       
  1264         sel remove:anObject ifAbsent:nil.
       
  1265     ] ifFalse:[
       
  1266         sel := nil
       
  1267     ].
       
  1268     self setSelection:sel withRedraw:true.
       
  1269     self selectionChanged.
  1244 !
  1270 !
  1245 
  1271 
  1246 select:something
  1272 select:something
  1247     "change selection to something
  1273     "change selection to something
  1248     "
  1274     "
  1249     (self canSelect:something) ifTrue:[
  1275     (self enabled and:[something ~= self selection]) ifTrue:[
  1250         super select:something.
  1276         self setSelection:something withRedraw:true.
  1251         self selectionChanged
  1277         self selectionChanged
  1252     ]
  1278     ]
  1253 
  1279 
  1254 
  1280 
  1255 
  1281 
  1268     "
  1294     "
  1269     self subclassResponsibility
  1295     self subclassResponsibility
  1270 
  1296 
  1271 !
  1297 !
  1272 
  1298 
       
  1299 selectionDo:aBlock
       
  1300     "apply block to every selected object
       
  1301     "
       
  1302     self forEach:(self selection) do:aBlock
       
  1303 
       
  1304 
       
  1305 !
       
  1306 
       
  1307 setSelection:aNewSelection withRedraw:doRedraw
       
  1308     "set a new selection
       
  1309     "
       
  1310     doRedraw ifTrue:[
       
  1311         self hideSelection.
       
  1312         selection := aNewSelection.
       
  1313         self showSelection
       
  1314     ] ifFalse:[
       
  1315         selection := aNewSelection
       
  1316     ]
       
  1317 !
       
  1318 
  1273 showSelection
  1319 showSelection
       
  1320     "show the selection - draw handles
       
  1321     "
  1274     selectionHiddenLevel == 0 ifTrue:[
  1322     selectionHiddenLevel == 0 ifTrue:[
  1275         super showSelection.
  1323         self selectionDo:[:el| self showSelected:el ]
  1276     ].
  1324     ].
  1277 !
  1325 !
  1278 
  1326 
  1279 singleSelection
  1327 singleSelection
  1280     "returns single selection or nil
  1328     "returns single selection or nil
  1281     "
  1329     "
  1282     selection isCollection ifFalse:[
  1330     |coll|
  1283         ^ selection
  1331 
  1284     ].
  1332     (coll := self selection) isCollection ifFalse:[
  1285     selection size == 1 ifTrue:[ ^ selection at:1]
  1333         ^ coll
  1286                        ifFalse:[ ^ nil].
  1334     ].
       
  1335 
       
  1336     coll size == 1 ifTrue:[ ^ coll first].
       
  1337   ^ nil
  1287 !
  1338 !
  1288 
  1339 
  1289 singleSelectionDo:aBlock
  1340 singleSelectionDo:aBlock
  1290     "perform block with argument a view in case of one selection
  1341     "perform block with argument a view in case of one selection
  1291     "
  1342     "
  1297 !
  1348 !
  1298 
  1349 
  1299 unselect
  1350 unselect
  1300     "clear selection
  1351     "clear selection
  1301     "
  1352     "
  1302     selection notNil ifTrue:[
  1353     self select:nil
  1303         super unselect.
       
  1304         self selectionChanged
       
  1305     ]
       
  1306 
       
  1307 
       
  1308 !
  1354 !
  1309 
  1355 
  1310 withSelectionHiddenDo:aBlock
  1356 withSelectionHiddenDo:aBlock
  1311     "apply block with selection hidden (no handles)
  1357     "apply block with selection hidden (no handles)
  1312     "
  1358     "
  1336 withoutSelectionDo:aBlock
  1382 withoutSelectionDo:aBlock
  1337     "evaluate aBlock while selection is nilled
  1383     "evaluate aBlock while selection is nilled
  1338     "
  1384     "
  1339     |sel|
  1385     |sel|
  1340 
  1386 
  1341     selection isNil ifTrue:[
  1387     self hasSelection ifFalse:[
  1342         aBlock value
  1388         aBlock value
  1343     ] ifFalse:[
  1389     ] ifTrue:[
  1344         sel := selection.
  1390         sel := self selection.
  1345         super unselect.
  1391         self setSelection:nil withRedraw:true.
  1346         aBlock value.
  1392         aBlock value.
  1347         super select:sel
  1393         self setSelection:sel withRedraw:true.
  1348     ]
  1394     ]
  1349 
  1395 
  1350 
  1396 
  1351 ! !
  1397 ! !
  1352 
  1398 
  1413     ^ false
  1459     ^ false
  1414 
  1460 
  1415     "Modified: 8.4.1997 / 01:19:14 / cg"
  1461     "Modified: 8.4.1997 / 01:19:14 / cg"
  1416 !
  1462 !
  1417 
  1463 
  1418 canSelect:something
  1464 hasSelection
  1419     "returns true if something can be selected and enabled is true
  1465     "returns true if any selected object exists
  1420     "
  1466     "
  1421     ^ (self enabled and:[something ~~ selection])
  1467     ^ self numberOfSelections ~~ 0
  1422 
  1468 
  1423 !
  1469 !
  1424 
  1470 
  1425 hasUndos
  1471 hasUndos
  1426     "returns true if undoHistory not empty
  1472     "returns true if undoHistory not empty
  1431 isHorizontalResizable:aComponent
  1477 isHorizontalResizable:aComponent
  1432     "returns true if instance is horizontal resizeable
  1478     "returns true if instance is horizontal resizeable
  1433     "
  1479     "
  1434     ^ self subclassResponsibility
  1480     ^ self subclassResponsibility
  1435 
  1481 
       
  1482 
       
  1483 !
       
  1484 
       
  1485 isSelected:anObject
       
  1486     "return true, if the argument, anObject is selected
       
  1487     "
       
  1488     anObject notNil ifTrue:[
       
  1489         self selectionDo:[:el| el == anObject ifTrue:[^ true]]
       
  1490     ].
       
  1491   ^ false
  1436 
  1492 
  1437 !
  1493 !
  1438 
  1494 
  1439 isVerticalResizable:aComponent
  1495 isVerticalResizable:aComponent
  1440     "returns true if instance is vertical resizeable
  1496     "returns true if instance is vertical resizeable
  1465 
  1521 
  1466 transaction:aType selectionDo:aOneArgBlock
  1522 transaction:aType selectionDo:aOneArgBlock
  1467     "opens a transaction and evaluates a block within the transaction; the
  1523     "opens a transaction and evaluates a block within the transaction; the
  1468      argument to the block is a view from the selection
  1524      argument to the block is a view from the selection
  1469     "
  1525     "
  1470     self transaction:aType objects:selection do:aOneArgBlock
  1526     self transaction:aType objects:(self selection) do:aOneArgBlock
  1471 
  1527 
  1472 
  1528 
  1473 !
  1529 !
  1474 
  1530 
  1475 undoLayoutView:aView
  1531 undoLayoutView:aView
  1643 !UIObjectView methodsFor:'user actions - move'!
  1699 !UIObjectView methodsFor:'user actions - move'!
  1644 
  1700 
  1645 moveSelectionDown
  1701 moveSelectionDown
  1646     "move selection down
  1702     "move selection down
  1647     "
  1703     "
  1648     |gridY n|
  1704     |gridY n sel|
  1649 
  1705 
  1650     (self canMove:selection) ifTrue:[
  1706     self moveableSelection notNil ifTrue:[
  1651         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1707         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1652 
  1708 
  1653         self withSelectionHiddenDo:[
  1709         self withSelectionHiddenDo:[
  1654             self selectionDo:[:aView|
  1710             self selectionDo:[:aView|
  1655                 aligning ifTrue:[
  1711                 aligning ifTrue:[
  1674 moveSelectionLeft
  1730 moveSelectionLeft
  1675     "move selection left
  1731     "move selection left
  1676     "
  1732     "
  1677     |gridX n|
  1733     |gridX n|
  1678 
  1734 
  1679     (self canMove:selection) ifTrue:[
  1735     self moveableSelection notNil ifTrue:[
  1680         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1736         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1681 
  1737 
  1682         self withSelectionHiddenDo:[
  1738         self withSelectionHiddenDo:[
  1683             self selectionDo:[:aView|
  1739             self selectionDo:[:aView|
  1684                 aligning ifTrue:[
  1740                 aligning ifTrue:[
  1698 moveSelectionRight
  1754 moveSelectionRight
  1699     "move selection right
  1755     "move selection right
  1700     "
  1756     "
  1701     |gridX n|
  1757     |gridX n|
  1702 
  1758 
  1703     (self canMove:selection) ifTrue:[
  1759     self moveableSelection notNil ifTrue:[
  1704         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1760         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1705 
  1761 
  1706         self withSelectionHiddenDo:[
  1762         self withSelectionHiddenDo:[
  1707             self selectionDo:[:aView|
  1763             self selectionDo:[:aView|
  1708                 aligning ifTrue:[
  1764                 aligning ifTrue:[
  1723 moveSelectionUp
  1779 moveSelectionUp
  1724     "move selection up
  1780     "move selection up
  1725     "
  1781     "
  1726     |gridY n|
  1782     |gridY n|
  1727 
  1783 
  1728     (self canMove:selection) ifTrue:[
  1784     self moveableSelection notNil ifTrue:[
  1729         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1785         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1730 
  1786 
  1731         self withSelectionHiddenDo:[
  1787         self withSelectionHiddenDo:[
  1732             self selectionDo:[:aView|
  1788             self selectionDo:[:aView|
  1733                 aligning ifTrue:[
  1789                 aligning ifTrue:[
  1749 
  1805 
  1750 alignSelectionBottom
  1806 alignSelectionBottom
  1751     "align selection to the bottom of the first object in the selection; in case
  1807     "align selection to the bottom of the first object in the selection; in case
  1752      of one selection the object is aligned to the bottom of its superview
  1808      of one selection the object is aligned to the bottom of its superview
  1753     "
  1809     "
  1754     |bmost delta|
  1810     |bmost delta sel|
  1755 
  1811 
  1756     (self canMove:selection) ifTrue:[
  1812     (sel := self moveableSelection) notNil ifTrue:[
  1757         self withSelectionHiddenDo:[
  1813         self withSelectionHiddenDo:[
  1758             self numberOfSelections > 1 ifTrue:[
  1814             self numberOfSelections > 1 ifTrue:[
  1759                 bmost := (selection at:1) computeCorner y.
  1815                 bmost := (sel first) computeCorner y.
  1760 
  1816 
  1761                 self transaction:#alignBottom selectionDo:[:v|
  1817                 self transaction:#alignBottom selectionDo:[:v|
  1762                     (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
  1818                     (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
  1763                         self shiftLayout:v top:delta bottom:delta.
  1819                         self shiftLayout:v top:delta bottom:delta.
  1764                     ]
  1820                     ]
  1779 
  1835 
  1780 alignSelectionCenterHor
  1836 alignSelectionCenterHor
  1781     "align selection to the center/horizontal of the first object in the selection; in case
  1837     "align selection to the center/horizontal of the first object in the selection; in case
  1782      of one selection the object is aligned to the center/horizontal of its superview
  1838      of one selection the object is aligned to the center/horizontal of its superview
  1783     "
  1839     "
  1784     |view center|
  1840     |view center sel|
  1785 
  1841 
  1786     (self canMove:selection) ifTrue:[
  1842     (sel := self moveableSelection) notNil ifTrue:[
  1787         self withSelectionHiddenDo:[
  1843         self withSelectionHiddenDo:[
  1788             view := self singleSelection.
  1844             view := self singleSelection.
  1789 
  1845 
  1790             view notNil ifTrue:[
  1846             view notNil ifTrue:[
  1791                 view   := view superView.
  1847                 view   := view superView.
  1792                 center := view computeExtent
  1848                 center := view computeExtent
  1793             ] ifFalse:[
  1849             ] ifFalse:[
  1794                 view   := selection at:1.
  1850                 view   := sel first.
  1795                 center := view computeCorner + view computeOrigin.
  1851                 center := view computeCorner + view computeOrigin.
  1796             ].
  1852             ].
  1797             center := center x // 2.
  1853             center := center x // 2.
  1798 
  1854 
  1799             self transaction:#alignCenterHorizontal selectionDo:[:v|
  1855             self transaction:#alignCenterHorizontal selectionDo:[:v|
  1815 
  1871 
  1816 alignSelectionCenterVer
  1872 alignSelectionCenterVer
  1817     "align selection to the center/vertical of the first object in the selection; in case
  1873     "align selection to the center/vertical of the first object in the selection; in case
  1818      of one selection the object is aligned to the center/vertical of its superview
  1874      of one selection the object is aligned to the center/vertical of its superview
  1819     "
  1875     "
  1820     |view center|
  1876     |view center sel|
  1821 
  1877 
  1822     (self canMove:selection) ifTrue:[
  1878     (sel := self moveableSelection) notNil ifTrue:[
  1823         self withSelectionHiddenDo:[
  1879         self withSelectionHiddenDo:[
  1824             view := self singleSelection.
  1880             view := self singleSelection.
  1825 
  1881 
  1826             view notNil ifTrue:[
  1882             view notNil ifTrue:[
  1827                 view   := view superView.
  1883                 view   := view superView.
  1828                 center := view computeExtent
  1884                 center := view computeExtent
  1829             ] ifFalse:[
  1885             ] ifFalse:[
  1830                 view   := selection at:1.
  1886                 view   := sel first.
  1831                 center := view computeCorner + view computeOrigin.
  1887                 center := view computeCorner + view computeOrigin.
  1832             ].
  1888             ].
  1833             center := center y // 2.
  1889             center := center y // 2.
  1834 
  1890 
  1835             self transaction:#alignCenterVertical selectionDo:[:v|
  1891             self transaction:#alignCenterVertical selectionDo:[:v|
  1848 
  1904 
  1849 alignSelectionLeft
  1905 alignSelectionLeft
  1850     "align selection to the left of the first object in the selection; in case
  1906     "align selection to the left of the first object in the selection; in case
  1851      of one selection the object is aligned to the left of its superview
  1907      of one selection the object is aligned to the left of its superview
  1852     "
  1908     "
  1853     |lmost delta|
  1909     |lmost delta sel|
  1854 
  1910 
  1855     (self canMove:selection) ifTrue:[
  1911     (sel := self moveableSelection) notNil ifTrue:[
  1856         self withSelectionHiddenDo:[
  1912         self withSelectionHiddenDo:[
  1857             self numberOfSelections > 1 ifTrue:[
  1913             self numberOfSelections > 1 ifTrue:[
  1858                 lmost := (selection at:1) computeOrigin x.
  1914                 lmost := (sel first) computeOrigin x.
  1859 
  1915 
  1860                 self transaction:#alignLeft selectionDo:[:v|
  1916                 self transaction:#alignLeft selectionDo:[:v|
  1861                     (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1917                     (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1862                         self shiftLayout:v left:delta right:delta
  1918                         self shiftLayout:v left:delta right:delta
  1863                     ]
  1919                     ]
  1875 
  1931 
  1876 alignSelectionLeftAndRight
  1932 alignSelectionLeftAndRight
  1877     "align selection to the left/right of the first object in the selection; in case
  1933     "align selection to the left/right of the first object in the selection; in case
  1878      of one selection the object is aligned to the left/right of its superview
  1934      of one selection the object is aligned to the left/right of its superview
  1879     "
  1935     "
  1880     |lmost rmost|
  1936     |lmost rmost sel|
  1881 
  1937 
  1882     (self canMove:selection) ifTrue:[
  1938     (sel := self moveableSelection) notNil ifTrue:[
  1883         self withSelectionHiddenDo:[
  1939         self withSelectionHiddenDo:[
  1884             self numberOfSelections > 1 ifTrue:[
  1940             self numberOfSelections > 1 ifTrue:[
  1885                 lmost := (selection at:1) computeOrigin x.
  1941                 lmost := (sel first) computeOrigin x.
  1886                 rmost := (selection at:1) computeCorner x.
  1942                 rmost := (sel first) computeCorner x.
  1887 
  1943 
  1888                 self transaction:#alignLeftRight selectionDo:[:aView|
  1944                 self transaction:#alignLeftRight selectionDo:[:aView|
  1889                     |layout|
  1945                     |layout|
  1890                     layout := self class asLayoutFrameFromView:aView.
  1946                     layout := self class asLayoutFrameFromView:aView.
  1891 
  1947 
  1916 
  1972 
  1917 alignSelectionRight
  1973 alignSelectionRight
  1918     "align selection to the right of the first object in the selection; in case
  1974     "align selection to the right of the first object in the selection; in case
  1919      of one selection the object is aligned to the right of its superview
  1975      of one selection the object is aligned to the right of its superview
  1920     "
  1976     "
  1921     |rmost delta|
  1977     |rmost delta sel|
  1922 
  1978 
  1923     (self canMove:selection) ifTrue:[
  1979     (sel := self moveableSelection) notNil ifTrue:[
  1924         self withSelectionHiddenDo:[
  1980         self withSelectionHiddenDo:[
  1925             self numberOfSelections > 1 ifTrue:[
  1981             self numberOfSelections > 1 ifTrue:[
  1926                 rmost := (selection at:1) computeCorner x.
  1982                 rmost := (sel first) computeCorner x.
  1927 
  1983 
  1928                 self transaction:#alignRight selectionDo:[:v|
  1984                 self transaction:#alignRight selectionDo:[:v|
  1929                     (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
  1985                     (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
  1930                         self shiftLayout:v left:delta right:delta
  1986                         self shiftLayout:v left:delta right:delta
  1931                     ]
  1987                     ]
  1943 
  1999 
  1944 alignSelectionTop
  2000 alignSelectionTop
  1945     "align selection to the top of the first object in the selection; in case
  2001     "align selection to the top of the first object in the selection; in case
  1946      of one selection the object is aligned to the top of its superview
  2002      of one selection the object is aligned to the top of its superview
  1947     "
  2003     "
  1948     |tmost delta|
  2004     |tmost delta sel|
  1949 
  2005 
  1950     (self canMove:selection) ifTrue:[
  2006     (sel := self moveableSelection) notNil ifTrue:[
  1951         self withSelectionHiddenDo:[
  2007         self withSelectionHiddenDo:[
  1952             self numberOfSelections > 1 ifTrue:[
  2008             self numberOfSelections > 1 ifTrue:[
  1953                 tmost := (selection at:1) computeOrigin y.
  2009                 tmost := (sel first) computeOrigin y.
  1954 
  2010 
  1955                 self transaction:#alignTop selectionDo:[:v|
  2011                 self transaction:#alignTop selectionDo:[:v|
  1956                     (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
  2012                     (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
  1957                         self shiftLayout:v top:delta bottom:delta
  2013                         self shiftLayout:v top:delta bottom:delta
  1958                     ]
  2014                     ]
  1971 
  2027 
  1972 alignSelectionTopAndBottom
  2028 alignSelectionTopAndBottom
  1973     "align selection to the top/bottom of the first object in the selection; in case
  2029     "align selection to the top/bottom of the first object in the selection; in case
  1974      of one selection the object is aligned to the top/bottom of its superview
  2030      of one selection the object is aligned to the top/bottom of its superview
  1975     "
  2031     "
  1976     |tmost bmost|
  2032     |tmost bmost sel|
  1977 
  2033 
  1978     (self canMove:selection) ifTrue:[
  2034     (sel := self moveableSelection) notNil ifTrue:[
  1979         self withSelectionHiddenDo:[
  2035         self withSelectionHiddenDo:[
  1980             self numberOfSelections > 1 ifTrue:[
  2036             self numberOfSelections > 1 ifTrue:[
  1981                 tmost := (selection at:1) computeOrigin y.
  2037                 tmost := (sel first) computeOrigin y.
  1982                 bmost := (selection at:1) computeCorner y.
  2038                 bmost := (sel first) computeCorner y.
  1983 
  2039 
  1984                 self transaction:#alignTopBottom selectionDo:[:aView|
  2040                 self transaction:#alignTopBottom selectionDo:[:aView|
  1985                     |layout|
  2041                     |layout|
  1986                     layout := self class asLayoutFrameFromView:aView.
  2042                     layout := self class asLayoutFrameFromView:aView.
  1987 
  2043 
  2013     "center selection horizontal or vertical dependant on the block result( x or y).
  2069     "center selection horizontal or vertical dependant on the block result( x or y).
  2014      The argument to the block is the point.
  2070      The argument to the block is the point.
  2015     "
  2071     "
  2016     |superview min max delta val|
  2072     |superview min max delta val|
  2017 
  2073 
  2018     (self canMove:selection) ifFalse:[
  2074     (self moveableSelection) isNil ifTrue:[
  2019         ^ self
  2075         ^ self
  2020     ].
  2076     ].
  2021 
  2077 
  2022     self withSelectionHiddenDo:[
  2078     self withSelectionHiddenDo:[
  2023         max := 0.
  2079         max := 0.
  2096 !
  2152 !
  2097 
  2153 
  2098 spreadSelectionHor
  2154 spreadSelectionHor
  2099     "spread multiple selection horizontal
  2155     "spread multiple selection horizontal
  2100     "
  2156     "
  2101     |sumWidths min max viewsInOrder topsInOrder count space|
  2157     |sumWidths min max viewsInOrder topsInOrder count space sel|
  2102 
  2158 
  2103     (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
  2159     sel := self moveableSelection.
       
  2160 
       
  2161     (sel notNil and:[self numberOfSelections > 1]) ifFalse:[
  2104         ^ self
  2162         ^ self
  2105     ].
  2163     ].
  2106 
  2164 
  2107     self withSelectionHiddenDo:[
  2165     self withSelectionHiddenDo:[
  2108         count := 0.
  2166         count := 0.
  2116                      ifFalse:[min := min min:(aView left)].
  2174                      ifFalse:[min := min min:(aView left)].
  2117 
  2175 
  2118             max := max max:(aView right).
  2176             max := max max:(aView right).
  2119             count := count + 1
  2177             count := count + 1
  2120         ].
  2178         ].
  2121         viewsInOrder := Array withAll:selection.
  2179         viewsInOrder := Array withAll:sel.
  2122         topsInOrder  := viewsInOrder collect:[:aView | aView left].
  2180         topsInOrder  := viewsInOrder collect:[:aView | aView left].
  2123         topsInOrder sortWith:viewsInOrder.
  2181         topsInOrder sortWith:viewsInOrder.
  2124 
  2182 
  2125         space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
  2183         space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
  2126 
  2184 
  2137 !
  2195 !
  2138 
  2196 
  2139 spreadSelectionVer
  2197 spreadSelectionVer
  2140     "spread multiple selection vertical
  2198     "spread multiple selection vertical
  2141     "
  2199     "
  2142     |sumHeights min max viewsInOrder topsInOrder count space|
  2200     |sumHeights min max viewsInOrder topsInOrder count space sel|
  2143 
  2201 
  2144     (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
  2202     sel := self moveableSelection.
       
  2203 
       
  2204     (sel notNil and:[self numberOfSelections > 1]) ifFalse:[
  2145         ^ self
  2205         ^ self
  2146     ].
  2206     ].
  2147 
  2207 
  2148     self withSelectionHiddenDo:[
  2208     self withSelectionHiddenDo:[
  2149         count := 0.
  2209         count := 0.
  2157                      ifFalse:[min := min min:(aView top)].
  2217                      ifFalse:[min := min min:(aView top)].
  2158 
  2218 
  2159             max   := max max:(aView bottom).
  2219             max   := max max:(aView bottom).
  2160             count := count + 1
  2220             count := count + 1
  2161         ].
  2221         ].
  2162         viewsInOrder := Array withAll:selection.
  2222         viewsInOrder := Array withAll:sel.
  2163         topsInOrder  := viewsInOrder collect:[:aView|aView top].
  2223         topsInOrder  := viewsInOrder collect:[:aView|aView top].
  2164         topsInOrder sortWith:viewsInOrder.
  2224         topsInOrder sortWith:viewsInOrder.
  2165 
  2225 
  2166         space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
  2226         space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
  2167 
  2227