13 |
13 |
14 ObjectView subclass:#UIObjectView |
14 ObjectView subclass:#UIObjectView |
15 instanceVariableNames:'saveSelection undoHistory copiedExtent copiedLayout resizeData |
15 instanceVariableNames:'saveSelection undoHistory copiedExtent copiedLayout resizeData |
16 clipChildren selectionHiddenLevel gridParameters |
16 clipChildren selectionHiddenLevel gridParameters |
17 setOfSuperViewsSizeChanged hasUndoHistoryHolder' |
17 setOfSuperViewsSizeChanged hasUndoHistoryHolder' |
18 classVariableNames:'' |
18 classVariableNames:'CopiedLayout CopiedExtent' |
19 poolDictionaries:'' |
19 poolDictionaries:'' |
20 category:'Interface-UIPainter' |
20 category:'Interface-UIPainter' |
21 ! |
21 ! |
22 |
22 |
23 Object subclass:#PostEventHandler |
23 Object subclass:#PostEventHandler |
254 ! |
254 ! |
255 |
255 |
256 isVerticalResizable:aComponent |
256 isVerticalResizable:aComponent |
257 "returns true if instance is vertical resizeable |
257 "returns true if instance is vertical resizeable |
258 " |
258 " |
259 (aComponent isKindOf:EditField) ifTrue:[ |
259 "/ (aComponent isKindOf:EditField) ifTrue:[ |
260 ^ false |
260 "/ ^ false |
261 ]. |
261 "/ ]. |
262 (aComponent isKindOf:ComboBoxView) ifTrue:[ |
262 "/ (aComponent isKindOf:ComboBoxView) ifTrue:[ |
263 ^ false |
263 "/ ^ false |
264 ]. |
264 "/ ]. |
265 (aComponent isKindOf:CheckBox) ifTrue:[ |
265 "/ (aComponent isKindOf:CheckBox) ifTrue:[ |
266 ^ false |
266 "/ ^ false |
267 ]. |
267 "/ ]. |
268 (aComponent isKindOf:ScrollBar) ifTrue:[ |
268 "/ (aComponent isKindOf:ScrollBar) ifTrue:[ |
269 ^ aComponent orientation == #vertical |
269 "/ ^ aComponent orientation == #vertical |
270 ]. |
270 "/ ]. |
271 (aComponent isKindOf:Scroller) ifTrue:[ |
271 "/ (aComponent isKindOf:Scroller) ifTrue:[ |
272 ^ aComponent orientation == #vertical |
272 "/ ^ aComponent orientation == #vertical |
273 ]. |
273 "/ ]. |
274 (aComponent isKindOf:Slider) ifTrue:[ |
274 "/ (aComponent isKindOf:Slider) ifTrue:[ |
275 ^ aComponent orientation == #vertical |
275 "/ ^ aComponent orientation == #vertical |
276 ]. |
276 "/ ]. |
277 ^ true |
277 ^ true |
278 |
|
279 ! |
278 ! |
280 |
279 |
281 layoutType:aView |
280 layoutType:aView |
282 "returns layout type of aView or nil |
281 "returns layout type of aView or nil |
283 " |
282 " |
865 clickedView viewOperatedUpon b pView| |
864 clickedView viewOperatedUpon b pView| |
866 |
865 |
867 self enabled ifFalse:[^ self]. |
866 self enabled ifFalse:[^ self]. |
868 |
867 |
869 selectedView := self singleSelection. |
868 selectedView := self singleSelection. |
870 clickedView := self findObjectAt:aPoint. |
869 |
871 |
870 "/ clickedView := self findObjectAt:aPoint. |
872 (clickedView isComponentOf:selectedView) ifTrue:[ |
871 "/ (clickedView notNil |
873 self unselect. |
872 "/ and:[clickedView isComponentOf:selectedView]) ifTrue:[ |
874 selectedView := nil. |
873 "/ self unselect. |
875 ]. |
874 "/ selectedView := nil. |
|
875 "/ ]. |
876 |
876 |
877 selectedView notNil ifTrue:[ |
877 selectedView notNil ifTrue:[ |
878 containerOfSelectedView := self findContainerOfView:selectedView. |
878 containerOfSelectedView := self findContainerOfView:selectedView. |
879 |
879 |
880 containerOfSelectedView specClass canResizeSubComponents ifTrue:[ |
880 containerOfSelectedView specClass canResizeSubComponents ifTrue:[ |
990 [self sensor hasExposeEventFor:nil] whileTrue:[ |
998 [self sensor hasExposeEventFor:nil] whileTrue:[ |
991 self windowGroup processExposeEvents |
999 self windowGroup processExposeEvents |
992 ]. |
1000 ]. |
993 |
1001 |
994 self setSelection:object withRedraw:true. |
1002 self setSelection:object withRedraw:true. |
995 self forEach:selection do:[:aView | |
1003 self forEach:self selection do:[:aView | |
996 self recomputeShapeIfTransparentBox:aView. |
1004 self recomputeShapeIfTransparentBox:aView. |
997 ]. |
1005 ]. |
998 self layoutChanged. |
1006 self layoutChanged. |
999 ! |
1007 ! |
1000 |
1008 |
1607 ! ! |
1614 ! ! |
1608 |
1615 |
1609 !UIObjectView methodsFor:'user actions-dimension'! |
1616 !UIObjectView methodsFor:'user actions-dimension'! |
1610 |
1617 |
1611 copyExtent |
1618 copyExtent |
1612 "copy the extent from the selected object |
1619 "copy the extent from the selected object" |
1613 " |
1620 |
1614 |object| |
1621 |object| |
1615 |
1622 |
1616 object := self singleSelection. |
1623 object := self singleSelection. |
1617 |
|
1618 object notNil ifTrue:[ |
1624 object notNil ifTrue:[ |
1619 copiedExtent := object computeExtent |
1625 CopiedExtent := object computeExtent |
1620 ] ifFalse:[ |
1626 ] ifFalse:[ |
1621 self warn:'exactly one element must be selected'. |
1627 self warn:'Exactly one element must be selected!!'. |
1622 ] |
1628 ] |
1623 |
|
1624 |
|
1625 |
|
1626 ! |
1629 ! |
1627 |
1630 |
1628 copyLayout |
1631 copyLayout |
1629 "copy the layout from the selected object |
1632 "copy the layout from the selected object" |
1630 " |
1633 |
1631 |object| |
1634 |object| |
1632 |
1635 |
1633 object := self singleSelection. |
1636 object := self singleSelection. |
1634 |
|
1635 object notNil ifTrue:[ |
1637 object notNil ifTrue:[ |
1636 copiedLayout := object geometryLayout copy |
1638 CopiedLayout := object geometryLayout copy |
1637 ] ifFalse:[ |
1639 ] ifFalse:[ |
1638 self warn:'exactly one element must be selected'. |
1640 self warn:'Exactly one element must be selected!!'. |
1639 ] |
1641 ] |
1640 |
|
1641 |
|
1642 |
|
1643 ! |
1642 ! |
1644 |
1643 |
1645 exchangeLayouts |
1644 exchangeLayouts |
1646 "exchange the layout of two elements |
1645 "exchange the layout of two elements |
1647 (useful to change the order of radiobuttons or checkBoxes) |
1646 (useful to change the order of radiobuttons or checkBoxes) |
1667 |
1666 |
1668 |
1667 |
1669 ! |
1668 ! |
1670 |
1669 |
1671 pasteExtent |
1670 pasteExtent |
1672 "paste the copied extent to all objects in the selection |
1671 "paste the copied extent to all objects in the selection" |
1673 " |
1672 |
1674 copiedExtent notNil ifTrue:[ |
1673 CopiedExtent notNil ifTrue:[ |
1675 self transaction:#pasteExtent dimensionDo:[:v| |
1674 self transaction:#pasteExtent dimensionDo:[:v| |
1676 self resize:v corner:(v computeOrigin + copiedExtent) |
1675 self resize:v corner:(v computeOrigin + CopiedExtent) |
1677 ] |
1676 ] |
1678 ] |
1677 ] |
1679 ! |
1678 ! |
1680 |
1679 |
1681 pasteHeight |
1680 pasteHeight |
1682 "paste the copied extent height to all objects in the selection |
1681 "paste the copied extent's height to all objects in the selection" |
1683 " |
1682 |
1684 copiedExtent notNil ifTrue:[ |
1683 CopiedExtent notNil ifTrue:[ |
1685 self transaction:#pasteHeight dimensionDo:[:v| |
1684 self transaction:#pasteHeight dimensionDo:[:v| |
1686 self resize:v bottom:(v computeOrigin + copiedExtent) |
1685 self resize:v bottom:(v computeOrigin + CopiedExtent y) |
1687 ] |
1686 ] |
1688 ] |
1687 ] |
1689 |
|
1690 ! |
1688 ! |
1691 |
1689 |
1692 pasteLayout |
1690 pasteLayout |
1693 "paste layout to all objects in the selection |
1691 "paste the layout to all objects in the selection" |
1694 " |
1692 |
1695 copiedLayout notNil ifTrue:[ |
1693 CopiedLayout notNil ifTrue:[ |
1696 self transaction:#pasteLayout dimensionDo:[:v| |
1694 self transaction:#pasteLayout dimensionDo:[:v| |
1697 v geometryLayout:(copiedLayout copy) |
1695 v geometryLayout:(CopiedLayout copy) |
1698 ] |
1696 ] |
1699 ] |
1697 ] |
1700 ! |
1698 ! |
1701 |
1699 |
1702 pasteWidth |
1700 pasteWidth |
1703 "paste the copied extent width to all objects in the selection |
1701 "paste the copied extent's width to all objects in the selection" |
1704 " |
1702 |
1705 copiedExtent notNil ifTrue:[ |
1703 CopiedExtent notNil ifTrue:[ |
1706 self transaction:#pasteWidth dimensionDo:[:v| |
1704 self transaction:#pasteWidth dimensionDo:[:v| |
1707 self resize:v right:(v computeOrigin + copiedExtent) |
1705 self resize:v right:(v computeOrigin + CopiedExtent x) |
1708 ] |
1706 ] |
1709 ] |
1707 ] |
1710 |
|
1711 ! |
1708 ! |
1712 |
1709 |
1713 setExtent:anExtent |
1710 setExtent:anExtent |
1714 "change extent for all selected objects |
1711 "change extent for all selected objects |
1715 " |
1712 " |
1923 ] |
1920 ] |
1924 |
1921 |
1925 ! ! |
1922 ! ! |
1926 |
1923 |
1927 !UIObjectView methodsFor:'user actions-position'! |
1924 !UIObjectView methodsFor:'user actions-position'! |
|
1925 |
|
1926 alignResizeSelectionLeft |
|
1927 "resize the selection on the left to align their left edge with the |
|
1928 of the first object in the selection; |
|
1929 in case of a single object selection, the objects left edge is aligned with the left of its superview" |
|
1930 |
|
1931 |lmost delta sel| |
|
1932 |
|
1933 (sel := self moveableSelection) notNil ifTrue:[ |
|
1934 self withSelectionHiddenDo:[ |
|
1935 self numberOfSelections > 1 ifTrue:[ |
|
1936 lmost := (sel first) computeOrigin x. |
|
1937 |
|
1938 self transaction:#alignResizeLeft selectionDo:[:v| |
|
1939 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
|
1940 self shiftLayout:v left:delta right:0 |
|
1941 ] |
|
1942 ] |
|
1943 ] ifFalse:[ |
|
1944 self extentToFrame:#Left do:[:aLayout| |
|
1945 aLayout leftFraction:0.0 offset:0. |
|
1946 ] |
|
1947 ] |
|
1948 ]. |
|
1949 self layoutChanged |
|
1950 ] |
|
1951 ! |
|
1952 |
|
1953 alignResizeSelectionRight |
|
1954 "align selection to the right of the first object in the selection; |
|
1955 in case of one selection the object is aligned to the right of its superview" |
|
1956 |
|
1957 |rmost delta sel| |
|
1958 |
|
1959 (sel := self moveableSelection) notNil ifTrue:[ |
|
1960 self withSelectionHiddenDo:[ |
|
1961 self numberOfSelections > 1 ifTrue:[ |
|
1962 rmost := (sel first) computeCorner x. |
|
1963 |
|
1964 self transaction:#alignRight selectionDo:[:v| |
|
1965 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
|
1966 self shiftLayout:v left:0 right:delta |
|
1967 ] |
|
1968 ] |
|
1969 ] ifFalse:[ |
|
1970 self extentToFrame:#Right do:[:aLayout| |
|
1971 aLayout rightOffset:0. |
|
1972 aLayout rightFraction:1.0. |
|
1973 ] |
|
1974 ] |
|
1975 ]. |
|
1976 self layoutChanged |
|
1977 ] |
|
1978 ! |
1928 |
1979 |
1929 alignSelectionBottom |
1980 alignSelectionBottom |
1930 "align selection to the bottom of the first object in the selection; in case |
1981 "align selection to the bottom of the first object in the selection; in case |
1931 of one selection the object is aligned to the bottom of its superview |
1982 of one selection the object is aligned to the bottom of its superview |
1932 " |
1983 " |
2025 self layoutChanged |
2076 self layoutChanged |
2026 ] |
2077 ] |
2027 ! |
2078 ! |
2028 |
2079 |
2029 alignSelectionLeft |
2080 alignSelectionLeft |
2030 "align selection to the left of the first object in the selection; in case |
2081 "align the selection with the left edge of the first object in the selection. |
2031 of one selection the object is aligned to the left of its superview |
2082 in case of a single object selection, the object is moved to the left of its superview" |
2032 " |
2083 |
2033 |lmost delta sel| |
2084 |dominantLeft delta sel| |
2034 |
2085 |
2035 (sel := self moveableSelection) notNil ifTrue:[ |
2086 (sel := self moveableSelection) notNil ifTrue:[ |
2036 self withSelectionHiddenDo:[ |
2087 self withSelectionHiddenDo:[ |
|
2088 dominantLeft := (sel first) computeOrigin x. |
2037 self numberOfSelections > 1 ifTrue:[ |
2089 self numberOfSelections > 1 ifTrue:[ |
2038 lmost := (sel first) computeOrigin x. |
|
2039 |
|
2040 self transaction:#alignLeft selectionDo:[:v| |
2090 self transaction:#alignLeft selectionDo:[:v| |
2041 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
2091 (delta := dominantLeft - (v computeOrigin x)) ~~ 0 ifTrue:[ |
2042 self shiftLayout:v left:delta right:delta |
2092 self shiftLayout:v left:delta right:delta |
2043 ] |
2093 ] |
2044 ] |
2094 ] |
2045 ] ifFalse:[ |
2095 ] ifFalse:[ |
2046 self extentToFrame:#Left do:[:aLayout| |
2096 self transaction:#alignLeft selectionDo:[:v| |
2047 aLayout leftFraction:0.0 offset:0. |
2097 self shiftLayout:v left:dominantLeft negated right:dominantLeft negated |
2048 ] |
2098 ]. |
2049 ] |
2099 ] |
2050 ]. |
2100 ]. |
2051 self layoutChanged |
2101 self layoutChanged |
2052 ] |
2102 ] |
2053 ! |
2103 ! |
2092 |
2142 |
2093 alignSelectionRight |
2143 alignSelectionRight |
2094 "align selection to the right of the first object in the selection; in case |
2144 "align selection to the right of the first object in the selection; in case |
2095 of one selection the object is aligned to the right of its superview |
2145 of one selection the object is aligned to the right of its superview |
2096 " |
2146 " |
2097 |rmost delta sel| |
2147 |dominantRight delta sel| |
2098 |
2148 |
2099 (sel := self moveableSelection) notNil ifTrue:[ |
2149 (sel := self moveableSelection) notNil ifTrue:[ |
2100 self withSelectionHiddenDo:[ |
2150 self withSelectionHiddenDo:[ |
2101 self numberOfSelections > 1 ifTrue:[ |
2151 dominantRight := (sel first) computeCorner x. |
2102 rmost := (sel first) computeCorner x. |
2152 self numberOfSelections > 1 ifTrue:[ |
2103 |
2153 self transaction:#alignRight selectionDo:[:v| |
2104 self transaction:#alignRight selectionDo:[:v| |
2154 (delta := dominantRight - (v computeCorner x)) ~~ 0 ifTrue:[ |
2105 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
2155 self shiftLayout:v left:delta right:delta |
2106 self shiftLayout:v left:delta right:delta |
2156 ] |
2107 ] |
2157 ] |
2108 ] |
2158 ] ifFalse:[ |
2109 ] ifFalse:[ |
2159 self transaction:#alignRight selectionDo:[:v| |
2110 self extentToFrame:#Right do:[:aLayout| |
2160 delta := v superView width - dominantRight. |
2111 aLayout rightOffset:0. |
2161 self shiftLayout:v left:delta right:delta |
2112 aLayout rightFraction:1.0. |
2162 ] |
2113 ] |
2163 "/ self extentToFrame:#Right do:[:aLayout| |
2114 ] |
2164 "/ aLayout rightOffset:0. |
2115 ]. |
2165 "/ aLayout rightFraction:1.0. |
2116 self layoutChanged |
2166 "/ ] |
|
2167 ] |
|
2168 ]. |
|
2169 self layoutChanged |
2117 ] |
2170 ] |
2118 ! |
2171 ! |
2119 |
2172 |
2120 alignSelectionTop |
2173 alignSelectionTop |
2121 "align selection to the top of the first object in the selection; in case |
2174 "align selection to the top of the first object in the selection; in case |