UIPropertyView.st
changeset 70 4e667db10910
parent 68 889c3877baf0
child 72 a5a7054e2b7d
equal deleted inserted replaced
69:e533f77871dd 70:4e667db10910
  1467     layoutType ~~ something ifTrue:[
  1467     layoutType ~~ something ifTrue:[
  1468         layoutType := something.
  1468         layoutType := something.
  1469 
  1469 
  1470         layoutType notNil ifTrue:[
  1470         layoutType notNil ifTrue:[
  1471             self modified:true.
  1471             self modified:true.
       
  1472             self perform:(('fetch',  layoutType asString) asSymbol).
  1472             spec := ('specification', layoutType asString) asSymbol.
  1473             spec := ('specification', layoutType asString) asSymbol.
  1473             spec := self class perform:spec.
  1474             spec := self class perform:spec.
  1474         ].
  1475         ].
  1475         self showSpec:spec.
  1476         self showSpec:spec.
  1476         self changed:#layoutType.
  1477         self changed:#layoutType.
  1477     ].
  1478     ].
  1478 
       
  1479     "Modified: 28.2.1997 / 13:07:10 / cg"
       
  1480 !
  1479 !
  1481 
  1480 
  1482 layoutTypeList
  1481 layoutTypeList
  1483     ^ #( #LayoutFrame #AlignmentOrigin #LayoutOrigin #Point #Rectangle )
  1482     ^ #( #LayoutFrame #AlignmentOrigin #LayoutOrigin #Point #Rectangle )
  1484 
  1483 
  1489 !
  1488 !
  1490 
  1489 
  1491 showAndFetchLayout
  1490 showAndFetchLayout
  1492     "fetch and show layout specification assigned to current view
  1491     "fetch and show layout specification assigned to current view
  1493     "
  1492     "
  1494     |type|
  1493     |type spec|
  1495 
  1494 
  1496     self modified:false.
  1495     self modified:false.
  1497     modified := true.
  1496     modified := true.
  1498 
  1497 
  1499     currentView notNil ifTrue:[
  1498     currentView notNil ifTrue:[
  1500         type := builderView class layoutType:currentView.
  1499         type := builderView class layoutType:currentView.
  1501 
  1500 
  1502         type notNil ifTrue:[
  1501         type notNil ifTrue:[
  1503             layoutAspects do:[:aValue| aValue value:nil ].
  1502             self perform:(('fetch', type asString) asSymbol).
  1504             self perform:(('fetch', type asString) asSymbol)
  1503 
       
  1504             type notNil ifTrue:[
       
  1505                 spec := ('specification', type asString) asSymbol.
       
  1506                 spec := self class perform:spec.
       
  1507             ]
  1505         ]
  1508         ]
  1506     ].
  1509     ].
  1507     self layoutType:type.
  1510 
       
  1511     type ~~ layoutType ifTrue:[
       
  1512         layoutType := type.
       
  1513         self changed:#layoutType
       
  1514     ].
       
  1515     self showSpec:spec.
       
  1516 
       
  1517     type ~~ layoutType ifTrue:[
       
  1518         layoutType := type.
       
  1519         self changed:#layoutType
       
  1520     ].
  1508     modified := false.
  1521     modified := false.
  1509 
  1522 
  1510 !
  1523 !
  1511 
  1524 
  1512 updateLayout
  1525 updateLayout
  1526 !UIPropertyView methodsFor:'private layout fetch'!
  1539 !UIPropertyView methodsFor:'private layout fetch'!
  1527 
  1540 
  1528 fetchAlignmentOrigin
  1541 fetchAlignmentOrigin
  1529     "fetch alignmentOrigin
  1542     "fetch alignmentOrigin
  1530     "
  1543     "
  1531     |aLayout|
  1544     |layout type extent|
  1532 
  1545 
  1533     aLayout := currentView geometryLayout.
  1546     type   := builderView class layoutType:currentView.
  1534 
  1547     layout := currentView geometryLayout.
  1535     (layoutAspects at:#leftAlignmentFraction) value:(aLayout leftAlignmentFraction).
  1548 
  1536     (layoutAspects at:#topAlignmentFraction)  value:(aLayout topAlignmentFraction).
  1549     layout isLayout ifTrue:[
  1537 
  1550         (layoutAspects at:#leftOffset)   value:(layout leftOffset).
  1538     self fetchLayoutOrigin
  1551         (layoutAspects at:#leftFraction) value:(layout leftFraction).
       
  1552         (layoutAspects at:#topOffset)    value:(layout topOffset).
       
  1553         (layoutAspects at:#topFraction)  value:(layout topFraction).
       
  1554 
       
  1555         type == #AlignmentOrigin ifTrue:[
       
  1556             (layoutAspects at:#leftAlignmentFraction) value:(layout leftAlignmentFraction).
       
  1557             (layoutAspects at:#topAlignmentFraction)  value:(layout topAlignmentFraction).
       
  1558           ^ self
       
  1559         ]
       
  1560     ] ifFalse:[
       
  1561         layout := currentView computeOrigin.
       
  1562 
       
  1563         (layoutAspects at:#leftOffset)   value:(layout x).
       
  1564         (layoutAspects at:#leftFraction) value:0.
       
  1565         (layoutAspects at:#topOffset)    value:(layout y).
       
  1566         (layoutAspects at:#topFraction)  value:0.
       
  1567     ].
       
  1568     (layoutAspects at:#leftAlignmentFraction) value:0.
       
  1569     (layoutAspects at:#topAlignmentFraction)  value:0.
       
  1570 
       
  1571 
  1539 !
  1572 !
  1540 
  1573 
  1541 fetchExtent
  1574 fetchExtent
  1542     |extent|
  1575     |extent|
  1543 
  1576 
  1544     extent := currentView extent.
  1577     extent := currentView computeExtent.
  1545     (layoutAspects at:#leftOffset)  value:(extent x).
  1578     (layoutAspects at:#leftOffset)  value:(extent x).
  1546     (layoutAspects at:#rightOffset) value:(extent y).
  1579     (layoutAspects at:#rightOffset) value:(extent y).
  1547 !
  1580 !
  1548 
  1581 
  1549 fetchLayoutFrame
  1582 fetchLayoutFrame
  1550     "fetch layoutFrame
  1583     "fetch layoutFrame
  1551     "
  1584     "
  1552     |aLayout org|
  1585     |layout|
  1553 
  1586 
  1554     aLayout := currentView geometryLayout.
  1587     layout := builderView class asLayoutFrameFromView:currentView.
  1555     org := currentView computeOrigin.
  1588 
  1556 
  1589     (layoutAspects at:#leftOffset)     value:(layout leftOffset).
  1557     (layoutAspects at:#absLeft) value:(org x).
  1590     (layoutAspects at:#leftFraction)   value:(layout leftFraction).
  1558     (layoutAspects at:#absTop)  value:(org y).
  1591     (layoutAspects at:#topOffset)      value:(layout topOffset).
  1559 
  1592     (layoutAspects at:#topFraction)    value:(layout topFraction).
  1560     (layoutAspects at:#leftOffset)     value:(aLayout leftOffset).
  1593     (layoutAspects at:#rightOffset)    value:(layout rightOffset).
  1561     (layoutAspects at:#leftFraction)   value:(aLayout leftFraction).
  1594     (layoutAspects at:#bottomOffset)   value:(layout bottomOffset).
  1562     (layoutAspects at:#topOffset)      value:(aLayout topOffset).
  1595     (layoutAspects at:#rightFraction)  value:(layout rightFraction).
  1563     (layoutAspects at:#topFraction)    value:(aLayout topFraction).
  1596     (layoutAspects at:#bottomFraction) value:(layout bottomFraction).
  1564     (layoutAspects at:#rightOffset)    value:(aLayout rightOffset).
       
  1565     (layoutAspects at:#bottomOffset)   value:(aLayout bottomOffset).
       
  1566     (layoutAspects at:#rightFraction)  value:(aLayout rightFraction).
       
  1567     (layoutAspects at:#bottomFraction) value:(aLayout bottomFraction).
       
  1568 
       
  1569     "Modified: 28.2.1997 / 12:58:37 / cg"
       
  1570 !
  1597 !
  1571 
  1598 
  1572 fetchLayoutOrigin
  1599 fetchLayoutOrigin
  1573     "fetch layoutOrigin
  1600     "fetch layoutOrigin
  1574     "
  1601     "
  1575     |extent aLayout leftFraction topFraction leftOffset topOffset org|
  1602     |layout|
  1576 
  1603 
  1577     extent  := currentView extent.
  1604     layout := builderView class asLayoutFrameFromView:currentView.
  1578     aLayout := currentView geometryLayout.
  1605 
  1579     org := currentView computeOrigin.
  1606     (layoutAspects at:#leftOffset)   value:(layout leftOffset).
  1580 
  1607     (layoutAspects at:#leftFraction) value:(layout leftFraction).
  1581     (layoutAspects at:#absLeft) value:(org x).
  1608     (layoutAspects at:#topOffset)    value:(layout topOffset).
  1582     (layoutAspects at:#absTop)  value:(org y).
  1609     (layoutAspects at:#topFraction)  value:(layout topFraction).
  1583 
  1610 
  1584     leftFraction := aLayout leftFraction.
       
  1585     topFraction  := aLayout topFraction.
       
  1586     leftOffset   := aLayout leftOffset.
       
  1587     topOffset    := aLayout topOffset.
       
  1588 
       
  1589     (layoutAspects at:#leftOffset)   value:leftOffset.
       
  1590     (layoutAspects at:#leftFraction) value:leftFraction.
       
  1591     (layoutAspects at:#topOffset)    value:topOffset.
       
  1592     (layoutAspects at:#topFraction)  value:topFraction.
       
  1593 
       
  1594     (layoutAspects at:#rightFraction)  value:leftFraction.
       
  1595     (layoutAspects at:#rightOffset)    value:(leftOffset + extent x).
       
  1596     (layoutAspects at:#bottomFraction) value:topFraction.
       
  1597     (layoutAspects at:#bottomOffset)   value:(topOffset  + extent y).
       
  1598 
       
  1599     "Modified: 28.2.1997 / 12:58:49 / cg"
       
  1600 !
  1611 !
  1601 
  1612 
  1602 fetchPoint
  1613 fetchPoint
  1603     "fetch point
  1614     "fetch point
  1604     "
  1615     "
  1605     |e x y p|
  1616     |origin|
  1606 
  1617 
  1607     p := currentView geometryLayout.
  1618     origin := currentView computeOrigin.
  1608     x := p x.
  1619     (layoutAspects at:#absLeft) value:(origin x).
  1609     y := p y.
  1620     (layoutAspects at:#absTop)  value:(origin y).
  1610     e := currentView computeExtent.
       
  1611 
       
  1612     (layoutAspects at:#absLeft) value:x.
       
  1613     (layoutAspects at:#absTop)  value:y.
       
  1614 
       
  1615     (layoutAspects at:#leftOffset)   value:x.
       
  1616     (layoutAspects at:#topOffset)    value:y.
       
  1617     (layoutAspects at:#rightOffset)  value:(x + e x).
       
  1618     (layoutAspects at:#bottomOffset) value:(y + e y).
       
  1619 
       
  1620     "Modified: 28.2.1997 / 12:59:26 / cg"
       
  1621 !
  1621 !
  1622 
  1622 
  1623 fetchRectangle
  1623 fetchRectangle
  1624     "fetch rectangle
  1624     "fetch rectangle
  1625     "
  1625     "
  1626     |aRectangle|
  1626     |origin corner|
  1627 
  1627 
  1628     aRectangle := currentView geometryLayout.
  1628     origin := currentView computeOrigin.
  1629 
  1629     corner := currentView computeCorner.
  1630     (layoutAspects at:#absLeft) value:(aRectangle left).
  1630 
  1631     (layoutAspects at:#absTop)  value:(aRectangle top).
  1631     (layoutAspects at:#leftOffset)   value:(origin x).
  1632 
  1632     (layoutAspects at:#rightOffset)  value:(corner x).
  1633     (layoutAspects at:#leftOffset)   value:(aRectangle left).
  1633     (layoutAspects at:#topOffset)    value:(origin y).
  1634     (layoutAspects at:#rightOffset)  value:(aRectangle right).
  1634     (layoutAspects at:#bottomOffset) value:(corner y).
  1635     (layoutAspects at:#topOffset)    value:(aRectangle top).
       
  1636     (layoutAspects at:#bottomOffset) value:(aRectangle bottom).
       
  1637 
       
  1638     "Modified: 28.2.1997 / 12:59:09 / cg"
       
  1639 ! !
  1635 ! !
  1640 
  1636 
  1641 !UIPropertyView methodsFor:'private layout write'!
  1637 !UIPropertyView methodsFor:'private layout write'!
  1642 
  1638 
  1643 writeAlignmentOrigin
  1639 writeAlignmentOrigin
  1751 makeAlignCenter
  1747 makeAlignCenter
  1752     self makeAlignLeft:0.5 top:0.5
  1748     self makeAlignLeft:0.5 top:0.5
  1753 
  1749 
  1754 !
  1750 !
  1755 
  1751 
  1756 makeAlignLeft:leftFraction top:topFraction
  1752 makeAlignLeft:leftAlignmentFraction top:topAlignmentFraction
  1757     |lA tA lO tO|
  1753     |lAF tAF lO tO ext|
  1758 
  1754 
  1759     lA := (layoutAspects at:#leftAlignmentFraction) value ? 0.
  1755     lAF := (layoutAspects at:#leftAlignmentFraction) value ? 0.
  1760     tA := (layoutAspects at:#topAlignmentFraction) value ? 0.
  1756     tAF := (layoutAspects at:#topAlignmentFraction)  value ? 0.
  1761 
  1757     ext := currentView computeExtent.
  1762     (layoutAspects at:#leftAlignmentFraction) value:leftFraction.
  1758 
  1763     (layoutAspects at:#topAlignmentFraction)  value:topFraction.
  1759     (layoutAspects at:#leftAlignmentFraction) value:leftAlignmentFraction.
  1764 
  1760     (layoutAspects at:#topAlignmentFraction)  value:topAlignmentFraction.
  1765     lO := (layoutAspects at:#leftOffset) value.
  1761 
  1766     tO := (layoutAspects at:#topOffset) value.
  1762     lO := (layoutAspects at:#leftOffset) value ? 0.
  1767 
  1763     tO := (layoutAspects at:#topOffset)  value ? 0.
  1768     lO := lO + (currentView computeExtent x * (leftFraction - lA)).
  1764 
  1769     tO := tO + (currentView computeExtent y * (topFraction - tA)).
  1765     lO := lO + (ext x * (leftAlignmentFraction - lAF)).
  1770 
  1766     tO := tO + (ext y * (topAlignmentFraction  - tAF)).
  1771     (layoutAspects at:#leftOffset) value:lO.
  1767 
  1772     (layoutAspects at:#topOffset) value:tO.
  1768     (layoutAspects at:#leftOffset) value:(lO rounded).
       
  1769     (layoutAspects at:#topOffset)  value:(tO rounded).
  1773 !
  1770 !
  1774 
  1771 
  1775 makeAlignLeftCenter
  1772 makeAlignLeftCenter
  1776     self makeAlignLeft:0 top:0.5
  1773     self makeAlignLeft:0 top:0.5
  1777 
  1774 
  1796     self makeAlignLeft:1 top:0
  1793     self makeAlignLeft:1 top:0
  1797 
  1794 
  1798 !
  1795 !
  1799 
  1796 
  1800 makeLayout:what xOrY:xOrY offset:aBool
  1797 makeLayout:what xOrY:xOrY offset:aBool
  1801     |layout extent fraction offset fractSymb offsetSymb|
  1798     |extent fraction offset fractSymb offsetSymb|
  1802 
  1799 
  1803     currentView isNil ifTrue:[
  1800     extent     := (currentView superView computeExtent) perform:xOrY.
  1804         ^ self
       
  1805     ].
       
  1806     layout := currentView geometryLayout.
       
  1807 
       
  1808     layout isLayout ifFalse:[
       
  1809         ^ self
       
  1810     ].
       
  1811     fractSymb  := (what, 'Fraction') asSymbol.
  1801     fractSymb  := (what, 'Fraction') asSymbol.
  1812     offsetSymb := (what,   'Offset') asSymbol.
  1802     offsetSymb := (what,   'Offset') asSymbol.
  1813 
  1803 
  1814     (    (layout respondsTo:fractSymb)
  1804     fraction := (layoutAspects at:fractSymb)  value.
  1815      and:[layout respondsTo:offsetSymb]
  1805     offset   := (layoutAspects at:offsetSymb) value.
  1816     ) ifTrue:[
  1806 
  1817 
  1807     aBool ifTrue:[
  1818         fraction := layout perform:fractSymb.
  1808         offset   := offset + ((fraction * extent) asInteger).
  1819         offset   := layout perform:offsetSymb.
  1809         fraction := 0.
  1820         extent   := (currentView superView computeExtent) perform:xOrY.
  1810     ] ifFalse:[
  1821 
  1811         fraction   := (fraction + (offset / extent)) asFloat.
  1822         aBool ifTrue:[
  1812 
  1823             offset := offset + ((fraction * extent) asInteger).
  1813         (fraction > 1.0) ifTrue:[ fraction := 1.0 ].
  1824             (layoutAspects at:offsetSymb) value:offset.
  1814         (fraction < 0.0) ifTrue:[ fraction := 0 ].
  1825             (layoutAspects at:fractSymb)  value:0.
  1815         offset := 0.
  1826         ] ifFalse:[
  1816     ].
  1827             fraction   := (fraction + (offset / extent)) asFloat.
  1817     (layoutAspects at:offsetSymb) value:offset.
  1828 
  1818     (layoutAspects at:fractSymb)  value:fraction.
  1829             (fraction > 1.0) ifTrue:[ fraction := 1.0 ].
       
  1830             (fraction < 0.0) ifTrue:[ fraction := 0.0 ].
       
  1831 
       
  1832             (layoutAspects at:offsetSymb) value:0.
       
  1833             (layoutAspects at:fractSymb)  value:fraction.
       
  1834         ]
       
  1835     ]
       
  1836 
  1819 
  1837 
  1820 
  1838 !
  1821 !
  1839 
  1822 
  1840 makeOffsetAll
  1823 makeOffsetAll