UIPainterView.st
changeset 119 39acd704ad51
parent 115 e4200c506aad
child 121 96d6feeeb049
equal deleted inserted replaced
118:bc196200ea8b 119:39acd704ad51
    15 	classVariableNames:'HandCursor'
    15 	classVariableNames:'HandCursor'
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Interface-UIPainter'
    17 	category:'Interface-UIPainter'
    18 !
    18 !
    19 
    19 
       
    20 MultiSelectionInList subclass:#ListHolder
       
    21 	instanceVariableNames:'painter propertyList masterElement disabledChanged'
       
    22 	classVariableNames:''
       
    23 	poolDictionaries:''
       
    24 	privateIn:UIPainterView
       
    25 !
       
    26 
    20 Object subclass:#ViewProperty
    27 Object subclass:#ViewProperty
    21 	instanceVariableNames:'view spec identifier'
    28 	instanceVariableNames:'view spec identifier'
    22 	classVariableNames:'Identifier'
    29 	classVariableNames:'Identifier'
    23 	poolDictionaries:''
    30 	poolDictionaries:''
    24 	privateIn:UIPainterView
    31 	privateIn:UIPainterView
    25 !
    32 !
    26 
    33 
    27 UIPainterView::ViewProperty subclass:#GroupProperties
    34 UIPainterView::ViewProperty subclass:#GroupProperties
    28 	instanceVariableNames:'controlledObjects group name'
    35 	instanceVariableNames:'controlledObjects group name'
    29 	classVariableNames:''
       
    30 	poolDictionaries:''
       
    31 	privateIn:UIPainterView
       
    32 !
       
    33 
       
    34 MultiSelectionInList subclass:#ListHolder
       
    35 	instanceVariableNames:'painter propertyList masterElement disabledChanged'
       
    36 	classVariableNames:''
    36 	classVariableNames:''
    37 	poolDictionaries:''
    37 	poolDictionaries:''
    38 	privateIn:UIPainterView
    38 	privateIn:UIPainterView
    39 !
    39 !
    40 
    40 
   177                 #'label:' 'align'
   177                 #'label:' 'align'
   178                 #'value:' #align
   178                 #'value:' #align
   179                 #'submenu:'
   179                 #'submenu:'
   180                         #(#Menu #(
   180                         #(#Menu #(
   181                                 #(#MenuItem
   181                                 #(#MenuItem
   182                                         #'label:' 'align left'
       
   183                                         #'value:' #alignSelectionLeft
   182                                         #'value:' #alignSelectionLeft
   184                                  )
   183                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignL 'align left' )
   185                                 #(#MenuItem
   184                                  )
   186                                         #'label:' 'align right'
   185                                 #(#MenuItem
   187                                         #'value:' #alignSelectionRight
   186                                         #'value:' #alignSelectionRight
   188                                  )
   187                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignR 'align right' )
   189                                 #(#MenuItem
   188                                  )
   190                                         #'label:' 'align left & right'
   189                                 #(#MenuItem
   191                                         #'value:' #alignSelectionLeftAndRight
   190                                         #'value:' #alignSelectionLeftAndRight
   192                                  )
   191                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignLR 'align left & right' )
   193                                 #(#MenuItem
   192                                  )
   194                                         #'label:' 'align top'
   193                                 #(#MenuItem
   195                                         #'value:' #alignSelectionTop
   194                                         #'value:' #alignSelectionTop
   196                                  )
   195                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignT 'align top' )
   197                                 #(#MenuItem
   196                                  )
   198                                         #'label:' 'align bottom' #'value:'
   197                                 #(#MenuItem
   199                                         #alignSelectionBottom
   198                                         #'value:' #alignSelectionBottom
   200                                  )
   199                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignB 'align bottom' )
   201                                 #(#MenuItem
   200                                  )
   202                                         #'label:' 'align centered vertical'
   201                                 #(#MenuItem
       
   202                                         #'value:' #alignSelectionTopAndBottom
       
   203                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignTB 'align top & bottom' )
       
   204                                  )
       
   205                                 #(#MenuItem
   203                                         #'value:' #alignSelectionCenterHor
   206                                         #'value:' #alignSelectionCenterHor
   204                                  )
   207                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterH 'align centered horizontal' )
   205                                 #(#MenuItem
   208                                  )
   206                                         #'label:' 'align centered horizontal'
   209                                 #(#MenuItem
   207                                         #'value:' #alignSelectionCenterVer
   210                                         #'value:' #alignSelectionCenterVer
       
   211                                         #'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterV 'align centered vertical' )
   208                                  )
   212                                  )
   209                                 #(#MenuItem
   213                                 #(#MenuItem
   210                                         #'label:' 'spread horizontal'
   214                                         #'label:' 'spread horizontal'
   211                                         #'value:' #spreadSelectionHor
   215                                         #'value:' #spreadSelectionHor
   212                                  )
   216                                  )
   221                                 #(#MenuItem
   225                                 #(#MenuItem
   222                                         #'label:' 'center vertical in frame'
   226                                         #'label:' 'center vertical in frame'
   223                                         #'value:' #centerSelectionVer
   227                                         #'value:' #centerSelectionVer
   224                                  )
   228                                  )
   225                                 )
   229                                 )
   226                                #(7 2)
   230                                #(8 2)
   227                                nil
   231                                nil
   228                         )
   232                         )
   229          )
   233          )
   230         )
   234         )
   231         #(4) 
   235         #(4) 
   480 !UIPainterView methodsFor:'drag & drop'!
   484 !UIPainterView methodsFor:'drag & drop'!
   481 
   485 
   482 canDrop:anObjectOrCollection
   486 canDrop:anObjectOrCollection
   483     |spec|
   487     |spec|
   484 
   488 
   485     testMode ifFalse:[
   489     self enabled ifTrue:[
   486         anObjectOrCollection size == 1 ifTrue:[
   490         anObjectOrCollection size == 1 ifTrue:[
   487             spec := (anObjectOrCollection at:1) theObject.
   491             spec := (anObjectOrCollection at:1) theObject.
   488             ^ (spec isKindOf:UISpecification)
   492             ^ (spec isKindOf:UISpecification)
   489         ]
   493         ]
   490     ].
   494     ].
   991 menu
   995 menu
   992     "returns middle-button menu dependent on the selection
   996     "returns middle-button menu dependent on the selection
   993     "
   997     "
   994     |menu canPaste|
   998     |menu canPaste|
   995 
   999 
   996     testMode ifTrue:[^ nil ].
  1000     self enabled ifFalse:[^ nil ].
   997     menu := MenuPanel fromSpec:(self class menu) receiver:self.
  1001     menu := MenuPanel fromSpec:(self class menu) receiver:self.
   998 
  1002 
   999     canPaste := self canPaste:(self getSelection).
  1003     canPaste := self canPaste:(self getSelection).
  1000 
  1004 
  1001     selection isNil ifTrue:[
  1005     selection isNil ifTrue:[
  1593 
  1597 
  1594 
  1598 
  1595 
  1599 
  1596 ! !
  1600 ! !
  1597 
  1601 
  1598 !UIPainterView::ViewProperty class methodsFor:'documentation'!
       
  1599 
       
  1600 version
       
  1601     ^ '$Header$'
       
  1602 ! !
       
  1603 
       
  1604 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
       
  1605 
       
  1606 new
       
  1607     Identifier notNil ifTrue:[Identifier := Identifier + 1]
       
  1608                      ifFalse:[Identifier := 1].
       
  1609 
       
  1610   ^ self basicNew initialize
       
  1611 ! !
       
  1612 
       
  1613 !UIPainterView::ViewProperty methodsFor:'accessing'!
       
  1614 
       
  1615 group
       
  1616     ^ nil
       
  1617 !
       
  1618 
       
  1619 identifier
       
  1620     "return the unique identifier assigned to property
       
  1621     "
       
  1622     ^ identifier
       
  1623 !
       
  1624 
       
  1625 spec
       
  1626     "return the value of the instance variable 'spec' (automatically generated)"
       
  1627 
       
  1628     ^ spec!
       
  1629 
       
  1630 spec:something
       
  1631     "set the value of the instance variable 'spec' (automatically generated)"
       
  1632 
       
  1633     spec := something.!
       
  1634 
       
  1635 view
       
  1636     "return the value of the instance variable 'view' (automatically generated)"
       
  1637 
       
  1638     ^ view!
       
  1639 
       
  1640 view:something
       
  1641     "set the value of the instance variable 'view' (automatically generated)"
       
  1642 
       
  1643     view := something.! !
       
  1644 
       
  1645 !UIPainterView::ViewProperty methodsFor:'initialization'!
       
  1646 
       
  1647 initialize
       
  1648     super initialize.
       
  1649     identifier := Identifier
       
  1650 ! !
       
  1651 
       
  1652 !UIPainterView::ViewProperty methodsFor:'misc'!
       
  1653 
       
  1654 extractNumberStartingAt:anIndex
       
  1655     "return the number from the name starting at anIndex or 0.
       
  1656     "
       
  1657     |val|
       
  1658 
       
  1659     val := 0.
       
  1660 
       
  1661     self name from:anIndex do:[:c|
       
  1662         c isDigit ifTrue:[val := val * 10 + c digitValue]
       
  1663                  ifFalse:[^ 0]
       
  1664     ].
       
  1665     ^ val
       
  1666         
       
  1667 ! !
       
  1668 
       
  1669 !UIPainterView::ViewProperty methodsFor:'spec messages'!
       
  1670 
       
  1671 doesNotUnderstand:aMessage
       
  1672     spec notNil ifTrue:[
       
  1673         (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
       
  1674     ].
       
  1675     ^ nil
       
  1676 !
       
  1677 
       
  1678 layout
       
  1679     spec layout
       
  1680 !
       
  1681 
       
  1682 layout:aLayout
       
  1683     spec layout:aLayout
       
  1684 !
       
  1685 
       
  1686 name
       
  1687     ^ spec name
       
  1688 !
       
  1689 
       
  1690 name:aName
       
  1691     spec name:aName
       
  1692 ! !
       
  1693 
       
  1694 !UIPainterView::GroupProperties methodsFor:'accessing'!
       
  1695 
       
  1696 controlledObjects
       
  1697     "return the value of the instance variable 'controlledObjects' (automatically generated)"
       
  1698 
       
  1699     ^ controlledObjects!
       
  1700 
       
  1701 controlledObjects:something
       
  1702     "set the value of the instance variable 'controlledObjects' (automatically generated)"
       
  1703 
       
  1704     controlledObjects := something.!
       
  1705 
       
  1706 group
       
  1707     "return the value of the instance variable 'group'
       
  1708     "
       
  1709     ^ group
       
  1710 !
       
  1711 
       
  1712 group:something
       
  1713     "set the value of the instance variable 'group'
       
  1714     "
       
  1715     group := something.
       
  1716 !
       
  1717 
       
  1718 name
       
  1719     "return the value of the group name
       
  1720     "
       
  1721     ^ name
       
  1722 !
       
  1723 
       
  1724 name:aName
       
  1725     "set the value of the group name
       
  1726     "
       
  1727     name := aName
       
  1728 ! !
       
  1729 
       
  1730 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1602 !UIPainterView::ListHolder class methodsFor:'instance creation'!
  1731 
  1603 
  1732 for:aPainter
  1604 for:aPainter
  1733     ^ self new for:aPainter
  1605     ^ self new for:aPainter
  1734 ! !
  1606 ! !
  1735 
  1607 
  1736 !UIPainterView::ListHolder methodsFor:'accessing'!
  1608 !UIPainterView::ListHolder methodsFor:'accessing'!
  1737 
       
  1738 canModify
       
  1739     ^ (painter notNil and:[painter testMode not])
       
  1740 !
       
  1741 
  1609 
  1742 painter
  1610 painter
  1743     "returns painter
  1611     "returns painter
  1744     "
  1612     "
  1745     ^ painter
  1613     ^ painter
  1867 !UIPainterView::ListHolder methodsFor:'initialization'!
  1735 !UIPainterView::ListHolder methodsFor:'initialization'!
  1868 
  1736 
  1869 for:aPainter
  1737 for:aPainter
  1870     "initialize for a painter
  1738     "initialize for a painter
  1871     "
  1739     "
       
  1740     painter := aPainter.
  1872     self list:(OrderedCollection new).
  1741     self list:(OrderedCollection new).
  1873     propertyList := OrderedCollection new.
  1742     propertyList := OrderedCollection new.
  1874     self selection:#().
  1743     self selection:#().
  1875     disabledChanged := false.
  1744     disabledChanged := false.
  1876     painter := aPainter.
  1745     painter := aPainter.
  2015 selectGroup
  1884 selectGroup
  2016     "select all elements assigned to master
  1885     "select all elements assigned to master
  2017     "
  1886     "
  2018     |start end sel size|
  1887     |start end sel size|
  2019 
  1888 
  2020     self canModify ifTrue:[
  1889     painter enabled ifTrue:[
  2021         (start := self masterElement) ~~ 0 ifTrue:[
  1890         (start := self masterElement) ~~ 0 ifTrue:[
  2022             end  := self lastInGroupStartingAt:start.
  1891             end  := self lastInGroupStartingAt:start.
  2023             size := end - start + 1.
  1892             size := end - start + 1.
  2024             sel  := Array new:size.
  1893             sel  := Array new:size.
  2025 
  1894 
  2050 !
  1919 !
  2051 
  1920 
  2052 selectionIndex:aList
  1921 selectionIndex:aList
  2053     |masterIndex aSel|
  1922     |masterIndex aSel|
  2054 
  1923 
  2055     self canModify ifTrue:[aSel := aList]
  1924     painter enabled ifTrue:[aSel := aList]
  2056                   ifFalse:[aSel := nil].
  1925                    ifFalse:[aSel := nil].
  2057 
  1926 
  2058     aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1]
  1927     aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1]
  2059                   ifFalse:[masterIndex := 0].
  1928                   ifFalse:[masterIndex := 0].
  2060 
  1929 
  2061     self masterElement:masterIndex.
  1930     self masterElement:masterIndex.
  2062     super selectionIndex:aSel
  1931     super selectionIndex:aSel
  2063 ! !
  1932 ! !
  2064 
  1933 
  2065 !UIPainterView class methodsFor:'documentation'!
  1934 !UIPainterView::ViewProperty class methodsFor:'documentation'!
  2066 
  1935 
  2067 version
  1936 version
  2068     ^ '$Header$'
  1937     ^ '$Header$'
  2069 ! !
  1938 ! !
       
  1939 
       
  1940 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
       
  1941 
       
  1942 new
       
  1943     Identifier notNil ifTrue:[Identifier := Identifier + 1]
       
  1944                      ifFalse:[Identifier := 1].
       
  1945 
       
  1946   ^ self basicNew initialize
       
  1947 ! !
       
  1948 
       
  1949 !UIPainterView::ViewProperty methodsFor:'accessing'!
       
  1950 
       
  1951 group
       
  1952     ^ nil
       
  1953 !
       
  1954 
       
  1955 identifier
       
  1956     "return the unique identifier assigned to property
       
  1957     "
       
  1958     ^ identifier
       
  1959 !
       
  1960 
       
  1961 spec
       
  1962     "return the value of the instance variable 'spec' (automatically generated)"
       
  1963 
       
  1964     ^ spec!
       
  1965 
       
  1966 spec:something
       
  1967     "set the value of the instance variable 'spec' (automatically generated)"
       
  1968 
       
  1969     spec := something.!
       
  1970 
       
  1971 view
       
  1972     "return the value of the instance variable 'view' (automatically generated)"
       
  1973 
       
  1974     ^ view!
       
  1975 
       
  1976 view:something
       
  1977     "set the value of the instance variable 'view' (automatically generated)"
       
  1978 
       
  1979     view := something.! !
       
  1980 
       
  1981 !UIPainterView::ViewProperty methodsFor:'initialization'!
       
  1982 
       
  1983 initialize
       
  1984     super initialize.
       
  1985     identifier := Identifier
       
  1986 ! !
       
  1987 
       
  1988 !UIPainterView::ViewProperty methodsFor:'misc'!
       
  1989 
       
  1990 extractNumberStartingAt:anIndex
       
  1991     "return the number from the name starting at anIndex or 0.
       
  1992     "
       
  1993     |val|
       
  1994 
       
  1995     val := 0.
       
  1996 
       
  1997     self name from:anIndex do:[:c|
       
  1998         c isDigit ifTrue:[val := val * 10 + c digitValue]
       
  1999                  ifFalse:[^ 0]
       
  2000     ].
       
  2001     ^ val
       
  2002         
       
  2003 ! !
       
  2004 
       
  2005 !UIPainterView::ViewProperty methodsFor:'spec messages'!
       
  2006 
       
  2007 doesNotUnderstand:aMessage
       
  2008     spec notNil ifTrue:[
       
  2009         (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
       
  2010     ].
       
  2011     ^ nil
       
  2012 !
       
  2013 
       
  2014 layout
       
  2015     spec layout
       
  2016 !
       
  2017 
       
  2018 layout:aLayout
       
  2019     spec layout:aLayout
       
  2020 !
       
  2021 
       
  2022 name
       
  2023     ^ spec name
       
  2024 !
       
  2025 
       
  2026 name:aName
       
  2027     spec name:aName
       
  2028 ! !
       
  2029 
       
  2030 !UIPainterView::GroupProperties methodsFor:'accessing'!
       
  2031 
       
  2032 controlledObjects
       
  2033     "return the value of the instance variable 'controlledObjects' (automatically generated)"
       
  2034 
       
  2035     ^ controlledObjects!
       
  2036 
       
  2037 controlledObjects:something
       
  2038     "set the value of the instance variable 'controlledObjects' (automatically generated)"
       
  2039 
       
  2040     controlledObjects := something.!
       
  2041 
       
  2042 group
       
  2043     "return the value of the instance variable 'group'
       
  2044     "
       
  2045     ^ group
       
  2046 !
       
  2047 
       
  2048 group:something
       
  2049     "set the value of the instance variable 'group'
       
  2050     "
       
  2051     group := something.
       
  2052 !
       
  2053 
       
  2054 name
       
  2055     "return the value of the group name
       
  2056     "
       
  2057     ^ name
       
  2058 !
       
  2059 
       
  2060 name:aName
       
  2061     "set the value of the group name
       
  2062     "
       
  2063     name := aName
       
  2064 ! !
       
  2065 
       
  2066 !UIPainterView class methodsFor:'documentation'!
       
  2067 
       
  2068 version
       
  2069     ^ '$Header$'
       
  2070 ! !