UIObjectView.st
changeset 72 a5a7054e2b7d
parent 68 889c3877baf0
child 76 c9c4254a9ee5
equal deleted inserted replaced
71:407d25aca670 72:a5a7054e2b7d
   390     "Modified: 5.9.1995 / 12:25:25 / claus"
   390     "Modified: 5.9.1995 / 12:25:25 / claus"
   391 
   391 
   392 
   392 
   393 !
   393 !
   394 
   394 
       
   395 minSetOfSuperViews:aCollectionOfViews
       
   396     |setOfViews setOfSuperViews|
       
   397 
       
   398     aCollectionOfViews isCollection ifFalse:[
       
   399         ^ aCollectionOfViews
       
   400     ].
       
   401 
       
   402     setOfViews := aCollectionOfViews asIdentitySet.
       
   403 
       
   404     setOfSuperViews := setOfViews select:[:aView|
       
   405                             (setOfViews detect:[:v|aView isComponentOf:v]
       
   406                                      ifNone:nil
       
   407                             ) isNil
       
   408                         ].
       
   409 
       
   410     setOfSuperViews size == 1 ifTrue:[
       
   411         ^ setOfSuperViews first
       
   412     ].
       
   413     ^ setOfSuperViews asOrderedCollection
       
   414 !
       
   415 
   395 setDefaultActions
   416 setDefaultActions
   396     "set default actions
   417     "set default actions
   397     "
   418     "
   398     pressAction      := [:pressPoint | self startSelectOrMove:pressPoint].
   419     pressAction      := [:pressPoint | self startSelectOrMove:pressPoint].
   399     shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
   420     shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
   692 
   713 
   693     "prepare move operation for an object
   714     "prepare move operation for an object
   694     "
   715     "
   695 
   716 
   696     motionAction := [:movePoint|
   717     motionAction := [:movePoint|
   697         (aPoint dist:movePoint) > 4.0 ifTrue:[
   718         (aPoint dist:movePoint) > 8.0 ifTrue:[
   698             self startObjectMoveAt:aPoint
   719             self startObjectMoveAt:aPoint
   699         ]
   720         ]
   700     ].
   721     ].
   701 ! !
   722 ! !
   702 
   723 
   759     |object|
   780     |object|
   760 
   781 
   761     object := self singleSelection.
   782     object := self singleSelection.
   762     self actionResize:object selector:b.
   783     self actionResize:object selector:b.
   763 
   784 
   764     self transaction:#extent selectionDo:[:aView|
   785     self transaction:#resize selectionDo:[:aView|
   765         self undoLayoutView:aView
   786         self undoLayoutView:aView
   766     ].
   787     ].
   767     super unselect.
   788     super unselect.
   768 
   789 
   769     motionAction  := [:movePoint | self doDragResize:movePoint].
   790     motionAction  := [:movePoint | self doDragResize:movePoint].
  1233     ].
  1254     ].
  1234 
  1255 
  1235     aBlock valueNowOrOnUnwindDo:[
  1256     aBlock valueNowOrOnUnwindDo:[
  1236         selectionHiddenLevel == 1 ifTrue:[
  1257         selectionHiddenLevel == 1 ifTrue:[
  1237             setOfSuperViewsSizeChanged notEmpty ifTrue:[
  1258             setOfSuperViewsSizeChanged notEmpty ifTrue:[
  1238                 setOfSuperViewsSizeChanged do:[:aSuperView|
  1259                 |s|
  1239                     aSuperView sizeChanged:nil
  1260                 s := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
       
  1261 
       
  1262                 s isCollection ifTrue:[
       
  1263                     s do:[:aSuperView|aSuperView sizeChanged:nil]
       
  1264                 ] ifFalse:[
       
  1265                     s sizeChanged:nil
  1240                 ].
  1266                 ].
  1241                 setOfSuperViewsSizeChanged := IdentitySet new
  1267                 setOfSuperViewsSizeChanged := IdentitySet new
  1242             ].
  1268             ].
  1243             self selectionDo:[:aView| self showSelected:aView].
  1269             self selectionDo:[:aView| self showSelected:aView].
  1244         ].
  1270         ].
  1412 
  1438 
  1413 pasteExtent
  1439 pasteExtent
  1414     "paste the copied extent to all objects in the selection
  1440     "paste the copied extent to all objects in the selection
  1415     "
  1441     "
  1416     copiedExtent notNil ifTrue:[
  1442     copiedExtent notNil ifTrue:[
  1417         self transition:#extent dimensionDo:[:v|
  1443         self transition:#pasteExtent dimensionDo:[:v|
  1418             self resize:v corner:(v computeOrigin + copiedExtent)
  1444             self resize:v corner:(v computeOrigin + copiedExtent)
  1419         ]    
  1445         ]    
  1420     ]    
  1446     ]    
  1421 !
  1447 !
  1422 
  1448 
  1423 pasteHeight
  1449 pasteHeight
  1424     "paste the copied extent height to all objects in the selection
  1450     "paste the copied extent height to all objects in the selection
  1425     "
  1451     "
  1426     copiedExtent notNil ifTrue:[
  1452     copiedExtent notNil ifTrue:[
  1427         self transition:'paste height' dimensionDo:[:v|
  1453         self transition:#pasteHeight dimensionDo:[:v|
  1428             self resize:v bottom:(v computeOrigin + copiedExtent)
  1454             self resize:v bottom:(v computeOrigin + copiedExtent)
  1429         ]    
  1455         ]    
  1430     ]    
  1456     ]    
  1431 
  1457 
  1432 !
  1458 !
  1433 
  1459 
  1434 pasteWidth
  1460 pasteWidth
  1435     "paste the copied extent width to all objects in the selection
  1461     "paste the copied extent width to all objects in the selection
  1436     "
  1462     "
  1437     copiedExtent notNil ifTrue:[
  1463     copiedExtent notNil ifTrue:[
  1438         self transition:'paste width' dimensionDo:[:v|
  1464         self transition:#pasteWidth dimensionDo:[:v|
  1439             self resize:v right:(v computeOrigin + copiedExtent)
  1465             self resize:v right:(v computeOrigin + copiedExtent)
  1440         ]    
  1466         ]    
  1441     ]    
  1467     ]    
  1442 
  1468 
  1443 !
  1469 !
  1452 !
  1478 !
  1453 
  1479 
  1454 setExtent:anExtent
  1480 setExtent:anExtent
  1455     "change extent for all selected objects
  1481     "change extent for all selected objects
  1456     "
  1482     "
  1457     self transition:#layout dimensionDo:[:v|
  1483     self transition:#extent dimensionDo:[:v|
  1458         v geometryLayout:nil.
  1484         v geometryLayout:nil.
  1459         v extent:anExtent.
  1485         v extent:anExtent.
  1460     ].
  1486     ].
  1461 
  1487 
  1462     "Modified: 28.2.1997 / 12:49:00 / cg"
  1488     "Modified: 28.2.1997 / 12:49:00 / cg"
  1463 !
  1489 !
  1464 
  1490 
  1465 setToDefaultExtent
  1491 setToDefaultExtent
  1466     "change extent of all selected views to their default extent
  1492     "change extent of all selected views to their default extent
  1467     "
  1493     "
  1468     self transition:#extent dimensionDo:[:v|
  1494     self transition:#defaultExtent dimensionDo:[:v|
  1469         self resize:v corner:(v computeOrigin + (v preferredExtent))
  1495         self resize:v corner:(v computeOrigin + (v preferredExtent))
  1470     ]    
  1496     ]    
  1471 
  1497 
  1472 !
  1498 !
  1473 
  1499 
  1474 setToDefaultHeight
  1500 setToDefaultHeight
  1475     "change height of all selected views to their default height
  1501     "change height of all selected views to their default height
  1476     "
  1502     "
  1477     self transition:'default height' dimensionDo:[:v|
  1503     self transition:#defaultHeight dimensionDo:[:v|
  1478         self resize:v bottom:(v computeOrigin + (v preferredExtent))
  1504         self resize:v bottom:(v computeOrigin + (v preferredExtent))
  1479     ]    
  1505     ]    
  1480 
  1506 
  1481 !
  1507 !
  1482 
  1508 
  1483 setToDefaultWidth
  1509 setToDefaultWidth
  1484     "change width of all selected views to their default width
  1510     "change width of all selected views to their default width
  1485     "
  1511     "
  1486     self transition:'default width' dimensionDo:[:v|
  1512     self transition:#defaultWidth dimensionDo:[:v|
  1487         self resize:v right:(v computeOrigin + (v preferredExtent))
  1513         self resize:v right:(v computeOrigin + (v preferredExtent))
  1488     ]    
  1514     ]    
  1489 
  1515 
  1490 !
  1516 !
  1491 
  1517 
  1515 
  1541 
  1516     (self canMove:selection) ifTrue:[
  1542     (self canMove:selection) ifTrue:[
  1517         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1543         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1518 
  1544 
  1519         self withSelectionHiddenDo:[
  1545         self withSelectionHiddenDo:[
  1520             self transaction:#move selectionDo:[:aView|
  1546             self transaction:#moveDown selectionDo:[:aView|
  1521                 |n d|
  1547                 |n d|
  1522 
  1548 
  1523                 n := aNumber.
  1549                 n := aNumber.
  1524 
  1550 
  1525                 aligning ifTrue:[
  1551                 aligning ifTrue:[
  1545 
  1571 
  1546     (self canMove:selection) ifTrue:[
  1572     (self canMove:selection) ifTrue:[
  1547         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1573         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1548 
  1574 
  1549         self withSelectionHiddenDo:[
  1575         self withSelectionHiddenDo:[
  1550             self transaction:#move selectionDo:[:aView|
  1576             self transaction:#moveLeft selectionDo:[:aView|
  1551                 |n d|
  1577                 |n d|
  1552 
  1578 
  1553                 n := aNumber.
  1579                 n := aNumber.
  1554 
  1580 
  1555                 aligning ifTrue:[
  1581                 aligning ifTrue:[
  1574 
  1600 
  1575     (self canMove:selection) ifTrue:[
  1601     (self canMove:selection) ifTrue:[
  1576         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1602         gridAlign notNil ifTrue:[gridX := gridAlign x].
  1577 
  1603 
  1578         self withSelectionHiddenDo:[
  1604         self withSelectionHiddenDo:[
  1579             self transaction:#move selectionDo:[:aView|
  1605             self transaction:#moveRight selectionDo:[:aView|
  1580                 |n d|
  1606                 |n d|
  1581 
  1607 
  1582                 n := aNumber.
  1608                 n := aNumber.
  1583 
  1609 
  1584                 aligning ifTrue:[
  1610                 aligning ifTrue:[
  1603 
  1629 
  1604     (self canMove:selection) ifTrue:[
  1630     (self canMove:selection) ifTrue:[
  1605         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1631         gridAlign notNil ifTrue:[gridY := gridAlign y].
  1606 
  1632 
  1607         self withSelectionHiddenDo:[
  1633         self withSelectionHiddenDo:[
  1608             self transaction:#move selectionDo:[:aView|
  1634             self transaction:#moveUp selectionDo:[:aView|
  1609                 |n d|
  1635                 |n d|
  1610 
  1636 
  1611                 n := aNumber.
  1637                 n := aNumber.
  1612 
  1638 
  1613                 aligning ifTrue:[
  1639                 aligning ifTrue:[
  1626 
  1652 
  1627 ! !
  1653 ! !
  1628 
  1654 
  1629 !UIObjectView methodsFor:'user actions - position'!
  1655 !UIObjectView methodsFor:'user actions - position'!
  1630 
  1656 
  1631 alignFrameLayout:aBlock
       
  1632     "perform block on a frameLayout assigned to the current single selection
       
  1633     "
       
  1634     |layout|
       
  1635 
       
  1636     self transaction:#align selectionDo:[:aView|
       
  1637         layout := self class asLayoutFrameFromView:aView.
       
  1638 
       
  1639         layout notNil ifTrue:[
       
  1640             self undoLayoutView:aView.
       
  1641             aBlock value:layout.
       
  1642             aView geometryLayout:layout.
       
  1643             self elementChangedSize:aView.
       
  1644         ]
       
  1645     ]
       
  1646 !
       
  1647 
       
  1648 alignSelectionBottom
  1657 alignSelectionBottom
  1649     "align selection to the bottom of the first object in the selection; in case
  1658     "align selection to the bottom of the first object in the selection; in case
  1650      of one selection the object is aligned to the bottom of its superview
  1659      of one selection the object is aligned to the bottom of its superview
  1651     "
  1660     "
  1652     |bmost delta|
  1661     |bmost delta|
  1654     (self canMove:selection) ifTrue:[
  1663     (self canMove:selection) ifTrue:[
  1655         self withSelectionHiddenDo:[
  1664         self withSelectionHiddenDo:[
  1656             self numberOfSelections > 1 ifTrue:[
  1665             self numberOfSelections > 1 ifTrue:[
  1657                 bmost := (selection at:1) computeCorner y.
  1666                 bmost := (selection at:1) computeCorner y.
  1658 
  1667 
  1659                 self transaction:#align selectionDo:[:v|
  1668                 self transaction:#alignBottom selectionDo:[:v|
  1660                     (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
  1669                     (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
  1661                         self shiftLayout:v top:delta bottom:delta.
  1670                         self shiftLayout:v top:delta bottom:delta.
  1662                     ]
  1671                     ]
  1663                 ]
  1672                 ]
  1664             ] ifFalse:[
  1673             ] ifFalse:[
  1665                 self alignFrameLayout:[:aLayout|
  1674                 self extentToFrame:#Bottom do:[:aLayout|
  1666                     aLayout bottomOffset:0.
  1675                     aLayout bottomOffset:0.
  1667                     aLayout bottomFraction:1.0
  1676                     aLayout bottomFraction:1.0
  1668                 ]
  1677                 ]
  1669             ]
  1678             ]
  1670         ].
  1679         ].
  1692                 view   := selection at:1.
  1701                 view   := selection at:1.
  1693                 center := view computeCorner + view computeOrigin.
  1702                 center := view computeCorner + view computeOrigin.
  1694             ].
  1703             ].
  1695             center := center x // 2.
  1704             center := center x // 2.
  1696 
  1705 
  1697             self transaction:#align selectionDo:[:v|
  1706             self transaction:#alignCenterHorizontal selectionDo:[:v|
  1698                 |newX oldX delta|
  1707                 |newX oldX delta|
  1699 
  1708 
  1700                 oldX  := v computeOrigin x.
  1709                 oldX  := v computeOrigin x.
  1701                 newX  := center - ((v computeCorner x - oldX) // 2).
  1710                 newX  := center - ((v computeCorner x - oldX) // 2).
  1702                 delta := newX - oldX.
  1711                 delta := newX - oldX.
  1728                 view   := selection at:1.
  1737                 view   := selection at:1.
  1729                 center := view computeCorner + view computeOrigin.
  1738                 center := view computeCorner + view computeOrigin.
  1730             ].
  1739             ].
  1731             center := center y // 2.
  1740             center := center y // 2.
  1732 
  1741 
  1733             self transaction:#align selectionDo:[:v|
  1742             self transaction:#alignCenterVertical selectionDo:[:v|
  1734                 |newY oldY delta|
  1743                 |newY oldY delta|
  1735 
  1744 
  1736                 oldY  := v computeOrigin y.
  1745                 oldY  := v computeOrigin y.
  1737                 newY  := center - ((v computeCorner y - oldY) // 2).
  1746                 newY  := center - ((v computeCorner y - oldY) // 2).
  1738                 delta := newY - oldY.
  1747                 delta := newY - oldY.
  1753     (self canMove:selection) ifTrue:[
  1762     (self canMove:selection) ifTrue:[
  1754         self withSelectionHiddenDo:[
  1763         self withSelectionHiddenDo:[
  1755             self numberOfSelections > 1 ifTrue:[
  1764             self numberOfSelections > 1 ifTrue:[
  1756                 lmost := (selection at:1) computeOrigin x.
  1765                 lmost := (selection at:1) computeOrigin x.
  1757 
  1766 
  1758                 self transaction:#align selectionDo:[:v|
  1767                 self transaction:#alignLeft selectionDo:[:v|
  1759                     (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1768                     (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
  1760                         self shiftLayout:v left:delta right:delta
  1769                         self shiftLayout:v left:delta right:delta
  1761                     ]
  1770                     ]
  1762                 ]
  1771                 ]
  1763             ] ifFalse:[
  1772             ] ifFalse:[
  1764                 self alignFrameLayout:[:aLayout|
  1773                 self extentToFrame:#Left do:[:aLayout|
  1765                     aLayout leftOffset:0.
  1774                     aLayout leftOffset:0.
  1766                     aLayout leftFraction:0.0.
  1775                     aLayout leftFraction:0.0.
  1767                 ]
  1776                 ]
  1768             ]
  1777             ]
  1769         ].
  1778         ].
  1781         self withSelectionHiddenDo:[
  1790         self withSelectionHiddenDo:[
  1782             self numberOfSelections > 1 ifTrue:[
  1791             self numberOfSelections > 1 ifTrue:[
  1783                 lmost := (selection at:1) computeOrigin x.
  1792                 lmost := (selection at:1) computeOrigin x.
  1784                 rmost := (selection at:1) computeCorner x.
  1793                 rmost := (selection at:1) computeCorner x.
  1785 
  1794 
  1786                 self transaction:#align selectionDo:[:v|
  1795                 self transaction:#alignLeftRight selectionDo:[:aView|
  1787                     self shiftLayout:v left:(lmost - (v computeOrigin x))
  1796                     |layout|
  1788                                      right:(rmost - (v computeCorner x)).
  1797                     layout := self class asLayoutFrameFromView:aView.
  1789 
  1798 
  1790                     self elementChangedSize:v.
  1799                     layout notNil ifTrue:[
       
  1800                         self undoLayoutView:aView.
       
  1801                         aView geometryLayout:layout.
       
  1802 
       
  1803                         undoHistory disabledTransitionDo:[    
       
  1804                             self shiftLayout:aView left:(lmost - (aView computeOrigin x))
       
  1805                                                   right:(rmost - (aView computeCorner x)).
       
  1806                         ].
       
  1807                         self elementChangedSize:aView
       
  1808                     ]
  1791                 ]
  1809                 ]
  1792             ] ifFalse:[
  1810             ] ifFalse:[
  1793                 self alignFrameLayout:[:aLayout|
  1811                 self extentToFrame:#LeftRight do:[:aLayout|
  1794                     aLayout leftOffset:0.
  1812                     aLayout leftOffset:0.
  1795                     aLayout leftFraction:0.0.
  1813                     aLayout leftFraction:0.0.
  1796                     aLayout rightOffset:0.
  1814                     aLayout rightOffset:0.
  1797                     aLayout rightFraction:1.0.
  1815                     aLayout rightFraction:1.0.
  1798                 ]
  1816                 ]
  1812     (self canMove:selection) ifTrue:[
  1830     (self canMove:selection) ifTrue:[
  1813         self withSelectionHiddenDo:[
  1831         self withSelectionHiddenDo:[
  1814             self numberOfSelections > 1 ifTrue:[
  1832             self numberOfSelections > 1 ifTrue:[
  1815                 rmost := (selection at:1) computeCorner x.
  1833                 rmost := (selection at:1) computeCorner x.
  1816 
  1834 
  1817                 self transaction:#align selectionDo:[:v|
  1835                 self transaction:#alignRight selectionDo:[:v|
  1818                     (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
  1836                     (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
  1819                         self shiftLayout:v left:delta right:delta
  1837                         self shiftLayout:v left:delta right:delta
  1820                     ]
  1838                     ]
  1821                 ]
  1839                 ]
  1822             ] ifFalse:[
  1840             ] ifFalse:[
  1823                 self alignFrameLayout:[:aLayout|
  1841                 self extentToFrame:#Right do:[:aLayout|
  1824                     aLayout rightOffset:0.
  1842                     aLayout rightOffset:0.
  1825                     aLayout rightFraction:1.0.
  1843                     aLayout rightFraction:1.0.
  1826                 ]
  1844                 ]
  1827             ]
  1845             ]
  1828         ].
  1846         ].
  1839     (self canMove:selection) ifTrue:[
  1857     (self canMove:selection) ifTrue:[
  1840         self withSelectionHiddenDo:[
  1858         self withSelectionHiddenDo:[
  1841             self numberOfSelections > 1 ifTrue:[
  1859             self numberOfSelections > 1 ifTrue:[
  1842                 tmost := (selection at:1) computeOrigin y.
  1860                 tmost := (selection at:1) computeOrigin y.
  1843 
  1861 
  1844                 self transaction:#align selectionDo:[:v|
  1862                 self transaction:#alignTop selectionDo:[:v|
  1845                     (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
  1863                     (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
  1846                         self shiftLayout:v top:delta bottom:delta
  1864                         self shiftLayout:v top:delta bottom:delta
  1847                     ]
  1865                     ]
  1848                 ]
  1866                 ]
  1849             ] ifFalse:[
  1867             ] ifFalse:[
  1850                 self alignFrameLayout:[:aLayout|
  1868                 self extentToFrame:#Top do:[:aLayout|
  1851                     aLayout topOffset:0.
  1869                     aLayout topOffset:0.
  1852                     aLayout topFraction:0.0.
  1870                     aLayout topFraction:0.0.
  1853                 ]
  1871                 ]
  1854             ]
  1872             ]
  1855         ].
  1873         ].
  1868         self withSelectionHiddenDo:[
  1886         self withSelectionHiddenDo:[
  1869             self numberOfSelections > 1 ifTrue:[
  1887             self numberOfSelections > 1 ifTrue:[
  1870                 tmost := (selection at:1) computeOrigin y.
  1888                 tmost := (selection at:1) computeOrigin y.
  1871                 bmost := (selection at:1) computeCorner y.
  1889                 bmost := (selection at:1) computeCorner y.
  1872 
  1890 
  1873                 self transaction:#align selectionDo:[:v|
  1891                 self transaction:#alignTopBottom selectionDo:[:aView|
  1874                     self shiftLayout:v top:(tmost - (v computeOrigin y))
  1892                     |layout|
  1875                                     bottom:(bmost - (v computeCorner y)).
  1893                     layout := self class asLayoutFrameFromView:aView.
  1876                     self elementChangedSize:v.
  1894 
       
  1895                     layout notNil ifTrue:[
       
  1896                         self undoLayoutView:aView.
       
  1897                         aView geometryLayout:layout.
       
  1898 
       
  1899                         undoHistory disabledTransitionDo:[    
       
  1900                             self shiftLayout:aView top:(tmost - (aView computeOrigin y))
       
  1901                                                 bottom:(bmost - (aView computeCorner y)).
       
  1902                         ].
       
  1903                         self elementChangedSize:aView
       
  1904                     ]
  1877                 ]
  1905                 ]
  1878             ] ifFalse:[
  1906             ] ifFalse:[
  1879                 self alignFrameLayout:[:aLayout|
  1907                 self extentToFrame:#TopBottom do:[:aLayout|
  1880                     aLayout topOffset:0.
  1908                     aLayout topOffset:0.
  1881                     aLayout topFraction:0.0.
  1909                     aLayout topFraction:0.0.
  1882                     aLayout bottomOffset:0.
  1910                     aLayout bottomOffset:0.
  1883                     aLayout bottomFraction:1.0.
  1911                     aLayout bottomFraction:1.0.
  1884                 ]
  1912                 ]
  1885             ]
  1913             ]
  1886         ].
  1914         ].
  1887         self changed:#layout
  1915         self changed:#layout
  1888     ]
  1916     ]
  1889 !
       
  1890 
       
  1891 alignSingleSelection:aBlock
       
  1892 
       
  1893     |type layout|
       
  1894 
       
  1895     self withSelectionHiddenDo:[
       
  1896         self transaction:#align selectionDo:[:aView|
       
  1897             type := self class layoutType:aView.
       
  1898 
       
  1899             type notNil ifTrue:[
       
  1900                 self undoLayoutView:aView.
       
  1901 
       
  1902                 layout := aView layout.
       
  1903 
       
  1904                 type == #LayoutFrame ifFalse:[
       
  1905                     layout := aView bounds asLayout
       
  1906                 ].
       
  1907                 aBlock value:layout.
       
  1908                 aView geometryLayout:layout.
       
  1909             ]
       
  1910         ]
       
  1911     ].
       
  1912     self changed:#layout
       
  1913 
       
  1914 
       
  1915 
       
  1916 !
  1917 !
  1917 
  1918 
  1918 centerSelection:aOneArgBlockXorY orientation:orientation
  1919 centerSelection:aOneArgBlockXorY orientation:orientation
  1919     "center selection horizontal or vertical dependant on the block result( x or y).
  1920     "center selection horizontal or vertical dependant on the block result( x or y).
  1920      The argument to the block is the point.
  1921      The argument to the block is the point.
  1947 
  1948 
  1948         val := aOneArgBlockXorY value:(superview computeExtent).
  1949         val := aOneArgBlockXorY value:(superview computeExtent).
  1949         max := (min + val - max) // 2.
  1950         max := (min + val - max) // 2.
  1950 
  1951 
  1951         max == min ifFalse:[
  1952         max == min ifFalse:[
       
  1953             |type|
       
  1954             (orientation == #y) ifTrue:[type := #centerVertical]
       
  1955                                ifFalse:[type := #centerHorizontal].
  1952             delta := max - min.
  1956             delta := max - min.
  1953 
  1957 
  1954             self transaction:#center selectionDo:[:v|
  1958             self transaction:type selectionDo:[:v|
  1955                 orientation == #y ifTrue:[
  1959                 orientation == #y ifTrue:[
  1956                     self shiftLayout:v top:delta bottom:delta
  1960                     self shiftLayout:v top:delta bottom:delta
  1957                 ] ifFalse:[
  1961                 ] ifFalse:[
  1958                     self shiftLayout:v left:delta right:delta
  1962                     self shiftLayout:v left:delta right:delta
  1959                 ]
  1963                 ]
  1977     "center selection vertical
  1981     "center selection vertical
  1978     "
  1982     "
  1979     self centerSelection:[:aPoint| aPoint y] orientation:#y
  1983     self centerSelection:[:aPoint| aPoint y] orientation:#y
  1980 !
  1984 !
  1981 
  1985 
       
  1986 extentToFrame:toWhat do:aBlock
       
  1987     "align to frame (Left Right ...) and perform the block on a frameLayout
       
  1988     "
       
  1989     |layout type|
       
  1990 
       
  1991     type := ('extent', toWhat asString) asSymbol.
       
  1992 
       
  1993     self transaction:type selectionDo:[:aView|
       
  1994         layout := self class asLayoutFrameFromView:aView.
       
  1995 
       
  1996         layout notNil ifTrue:[
       
  1997             self undoLayoutView:aView.
       
  1998             aBlock value:layout.
       
  1999             aView geometryLayout:layout.
       
  2000             self elementChangedSize:aView.
       
  2001         ]
       
  2002     ]
       
  2003 !
       
  2004 
  1982 spreadSelectionHor
  2005 spreadSelectionHor
  1983     "spread multiple selection horizontal
  2006     "spread multiple selection horizontal
  1984     "
  2007     "
  1985     |sumWidths min max viewsInOrder topsInOrder count space|
  2008     |sumWidths min max viewsInOrder topsInOrder count space|
  1986 
  2009 
  2006         topsInOrder  := viewsInOrder collect:[:aView | aView left].
  2029         topsInOrder  := viewsInOrder collect:[:aView | aView left].
  2007         topsInOrder sortWith:viewsInOrder.
  2030         topsInOrder sortWith:viewsInOrder.
  2008 
  2031 
  2009         space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
  2032         space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
  2010 
  2033 
  2011         self transaction:#spread objects:viewsInOrder do:[:aView|
  2034         self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView|
  2012             |delta|
  2035             |delta|
  2013 
  2036 
  2014             delta := min - aView computeOrigin x.
  2037             delta := min - aView computeOrigin x.
  2015             self shiftLayout:aView left:delta right:delta.
  2038             self shiftLayout:aView left:delta right:delta.
  2016             min := min + aView computeExtent x + space
  2039             min := min + aView computeExtent x + space
  2047         topsInOrder  := viewsInOrder collect:[:aView|aView top].
  2070         topsInOrder  := viewsInOrder collect:[:aView|aView top].
  2048         topsInOrder sortWith:viewsInOrder.
  2071         topsInOrder sortWith:viewsInOrder.
  2049 
  2072 
  2050         space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
  2073         space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
  2051 
  2074 
  2052         self transaction:#spread objects:viewsInOrder do:[:aView|
  2075         self transaction:#spreadVertical objects:viewsInOrder do:[:aView|
  2053             |delta|
  2076             |delta|
  2054 
  2077 
  2055             delta := min - aView computeOrigin y.
  2078             delta := min - aView computeOrigin y.
  2056             self shiftLayout:aView top:delta bottom:delta.
  2079             self shiftLayout:aView top:delta bottom:delta.
  2057             min := min + aView height + space
  2080             min := min + aView height + space
  2060     self changed:#layout
  2083     self changed:#layout
  2061 ! !
  2084 ! !
  2062 
  2085 
  2063 !UIObjectView methodsFor:'user actions - undo history'!
  2086 !UIObjectView methodsFor:'user actions - undo history'!
  2064 
  2087 
       
  2088 enableUndoHistory:aState
       
  2089     "enable or disable undo history
       
  2090     "
       
  2091     undoHistory enabled:aState
       
  2092 !
       
  2093 
  2065 openUndoMenu
  2094 openUndoMenu
  2066     "open undo menu
  2095     "open undo menu
  2067     "
  2096     "
  2068     self unselect.
  2097     self unselect.
  2069 
  2098 
  2110 
  2139 
  2111 ! !
  2140 ! !
  2112 
  2141 
  2113 !UIObjectView::UndoHistory methodsFor:'accessing'!
  2142 !UIObjectView::UndoHistory methodsFor:'accessing'!
  2114 
  2143 
       
  2144 enabled
       
  2145     ^ enabled
       
  2146 !
       
  2147 
       
  2148 enabled:aState
       
  2149     enabled := aState
       
  2150 !
       
  2151 
  2115 historySize
  2152 historySize
  2116     ^ history size
  2153     ^ history size
       
  2154 !
       
  2155 
       
  2156 lastTypeAsString
       
  2157     "returns type of last undo asString or nil
       
  2158     "
       
  2159     history notEmpty ifTrue:[
       
  2160         ^ history last typeAsString
       
  2161     ].
       
  2162     ^ nil
       
  2163 
       
  2164 
  2117 ! !
  2165 ! !
  2118 
  2166 
  2119 !UIObjectView::UndoHistory methodsFor:'initialization'!
  2167 !UIObjectView::UndoHistory methodsFor:'initialization'!
  2120 
  2168 
  2121 initialize
  2169 initialize
  2136 ! !
  2184 ! !
  2137 
  2185 
  2138 !UIObjectView::UndoHistory methodsFor:'menu'!
  2186 !UIObjectView::UndoHistory methodsFor:'menu'!
  2139 
  2187 
  2140 openUndoMenu
  2188 openUndoMenu
  2141     |list top slv hzp inset selection okButton|
  2189     |list tabs top slv hzp inset selection okButton|
  2142 
  2190 
  2143     history isEmpty ifTrue:[
  2191     history isEmpty ifTrue:[
  2144         ^ self
  2192         ^ self
  2145     ].
  2193     ].
  2146 
  2194 
  2157     inset := hzp preferredExtent y.
  2205     inset := hzp preferredExtent y.
  2158     hzp topInset:(inset negated).
  2206     hzp topInset:(inset negated).
  2159     slv   bottomInset:inset.
  2207     slv   bottomInset:inset.
  2160     slv := slv scrolledView.
  2208     slv := slv scrolledView.
  2161 
  2209 
       
  2210     tabs := TabulatorSpecification new.
       
  2211     tabs unit:#cm.
       
  2212     tabs positions:#(0 5).
       
  2213     tabs align:#(#left ##left).
       
  2214 
  2162     list := history collect:[:aTrans||e|
  2215     list := history collect:[:aTrans||e|
  2163         e := MultiColListEntry new.
  2216         e := MultiColListEntry new.
  2164         e colAt:1 put:(aTrans type asString).
  2217         e colAt:1 put:(aTrans typeAsString).
  2165         e colAt:2 put:(aTrans text ? '').
  2218         e colAt:2 put:(aTrans text ? '').
       
  2219         e tabulatorSpecification:tabs.
  2166         e
  2220         e
  2167     ].
  2221     ].
  2168 
  2222 
  2169     slv list:list.
  2223     slv list:list.
  2170     slv action:[:index | selection := index ].
  2224     slv action:[:index | selection := index ].
  2277 
  2331 
  2278 ! !
  2332 ! !
  2279 
  2333 
  2280 !UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
  2334 !UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
  2281 
  2335 
  2282 asString
       
  2283     "returns printable string
       
  2284     "
       
  2285     |string|
       
  2286 
       
  2287     string := type asString.
       
  2288 
       
  2289     text notNil ifTrue:[^ string, '    ', text ]
       
  2290                ifFalse:[^ string ]
       
  2291 !
       
  2292 
       
  2293 text
  2336 text
  2294     "returns text or nil assigned to transition
  2337     "returns text or nil assigned to transition
  2295     "
  2338     "
  2296     ^ text
  2339     ^ text
  2297 !
  2340 !
  2304 
  2347 
  2305 type:aType
  2348 type:aType
  2306     "change type assigned to transition
  2349     "change type assigned to transition
  2307     "
  2350     "
  2308     type := aType
  2351     type := aType
       
  2352 !
       
  2353 
       
  2354 typeAsString
       
  2355     "returns type as printable string
       
  2356     "
       
  2357     |line name size sep|
       
  2358 
       
  2359     line := type asString.
       
  2360     size := 0.
       
  2361     line do:[:c| (c isUppercase) ifTrue:[size := size+1] ].
       
  2362     name := String new:(line size + size).
       
  2363     size := 1.
       
  2364     sep  := Character space.
       
  2365 
       
  2366     line do:[:c|
       
  2367         (c isUppercase) ifFalse:[
       
  2368             name at:size put:c
       
  2369         ] ifTrue:[
       
  2370             name at:size put:sep.
       
  2371             sep  := $&.
       
  2372             size := size + 1.
       
  2373             name at:size put:(c asLowercase)
       
  2374         ].
       
  2375         size := size + 1
       
  2376     ].
       
  2377     ^ name
  2309 ! !
  2378 ! !
  2310 
  2379 
  2311 !UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!
  2380 !UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!
  2312 
  2381 
  2313 add:anUndoBlock
  2382 add:anUndoBlock