UIPainter.st
changeset 892 b200d2d9bf5e
parent 890 dac91d5af289
child 913 12e73e6c57b4
equal deleted inserted replaced
891:bafed0c2436d 892:b200d2d9bf5e
  1968 !
  1968 !
  1969 
  1969 
  1970 openEditMenu
  1970 openEditMenu
  1971     "opens a Menu Editor on current widget"
  1971     "opens a Menu Editor on current widget"
  1972 
  1972 
  1973     |cls selectorOrMenu editor selectedSpec|
  1973     |cls selectorOrMenu editor selectedSpec spec|
  1974 
  1974 
  1975     (cls := self resolveName:specClass) isNil ifTrue:[
  1975     (cls := self resolveName:specClass) isNil ifTrue:[
  1976         self askForSaving ifFalse: [^self]
  1976         self askForSaving ifFalse: [^self]
  1977     ].
  1977     ].
  1978 
  1978 
  1979     cls notNil ifTrue:[
  1979     cls notNil ifTrue:[
  1980         (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[
  1980         spec := self specTool specification.
       
  1981         (selectorOrMenu := spec menuSelector) notNil ifTrue:[
  1981             selectorOrMenu := selectorOrMenu asSymbol
  1982             selectorOrMenu := selectorOrMenu asSymbol
  1982         ] ifFalse:[
  1983         ] ifFalse:[
  1983             "/ cg: q&d hack ...
  1984             "/ cg: q&d hack ...
  1984 
  1985 
  1985             (selectedSpec := treeView propertySelected) notNil ifTrue:[
  1986             (selectedSpec := treeView propertySelected) notNil ifTrue:[
  2000             ifFalse: [editor openModalOnMenu:selectorOrMenu].
  2001             ifFalse: [editor openModalOnMenu:selectorOrMenu].
  2001         self helpTool updateList.
  2002         self helpTool updateList.
  2002 
  2003 
  2003         editor specSelector ~= selectorOrMenu ifTrue:[
  2004         editor specSelector ~= selectorOrMenu ifTrue:[
  2004             editor hasSaved ifTrue:[
  2005             editor hasSaved ifTrue:[
  2005                 self specTool specification menuSelector:editor specSelector.
  2006                 spec menuSelector:editor specSelector.
  2006                 self modifiedChannel value:true.
  2007                 self modifiedChannel value:true.
  2007                 self accept
  2008                 self accept
  2008             ]
  2009             ]
  2009         ].
  2010         ].
  2010     ]
  2011     ]
  2011 
  2012 
  2012     "Modified: 31.7.1997 / 14:26:13 / cg"
  2013     "Modified: / 16.7.1998 / 18:16:42 / cg"
  2013 !
  2014 !
  2014 
  2015 
  2015 openHierarchicalListEditor
  2016 openHierarchicalListEditor
  2016     "opens a Hierarchical List Editor on current widget"
  2017     "opens a Hierarchical List Editor on current widget"
  2017 
  2018 
  2018     |selector editor|
  2019     |selector editor spec|
  2019 
  2020 
  2020     (self resolveName:specClass) isNil ifTrue:[
  2021     (self resolveName:specClass) isNil ifTrue:[
  2021         self askForSaving ifFalse: [^self]
  2022         self askForSaving ifFalse: [^self]
  2022     ].
  2023     ].
  2023 
  2024 
  2024     (selector := self specTool specification hierarchicalList) notNil ifTrue:[
  2025     spec := self specTool specification.
       
  2026     (selector := spec hierarchicalList) notNil ifTrue:[
  2025         selector := selector asSymbol
  2027         selector := selector asSymbol
  2026     ].
  2028     ].
  2027 
  2029 
  2028     editor := HierarchicalListEditor new.
  2030     editor := HierarchicalListEditor new.
  2029     editor masterApplication:self.
  2031     editor masterApplication:self.
  2030     editor openModalOnClass:specClass andSelector:selector.
  2032     editor openModalOnClass:specClass andSelector:selector.
  2031 
  2033 
  2032     editor specSelector ~= selector ifTrue:[
  2034     editor specSelector ~= selector ifTrue:[
  2033         editor hasSaved ifTrue:[
  2035         editor hasSaved ifTrue:[
  2034             self specTool specification hierarchicalList:editor specSelector.
  2036             spec hierarchicalList:editor specSelector.
  2035             self modifiedChannel value:true.
  2037             self modifiedChannel value:true.
  2036             self accept
  2038             self accept
  2037         ]
  2039         ]
  2038     ]
  2040     ]
       
  2041 
       
  2042     "Modified: / 16.7.1998 / 18:15:46 / cg"
  2039 !
  2043 !
  2040 
  2044 
  2041 openSubSpecGUIPainter
  2045 openSubSpecGUIPainter
  2042     "opens a GUI Painter on the current subspecification"
  2046     "opens a GUI Painter on the current subspecification"
  2043 
  2047 
  2065 !
  2069 !
  2066 
  2070 
  2067 openTabListEditor
  2071 openTabListEditor
  2068     "opens a Tab List Editor on current widget"
  2072     "opens a Tab List Editor on current widget"
  2069 
  2073 
  2070     |selector editor|
  2074     |selector editor spec|
  2071 
  2075 
  2072     (self resolveName:specClass) isNil ifTrue:[
  2076     (self resolveName:specClass) isNil ifTrue:[
  2073         self askForSaving ifFalse: [^self]
  2077         self askForSaving ifFalse: [^self]
  2074     ].
  2078     ].
  2075 
  2079 
  2076     (selector := self specTool specification listSelector) isArray 
  2080     spec := self specTool specification.
       
  2081     (selector := spec listSelector) isArray 
  2077         ifTrue: [^self warn: 'Cannot open the Tab List Editor on an array!!'].
  2082         ifTrue: [^self warn: 'Cannot open the Tab List Editor on an array!!'].
  2078 
  2083 
  2079     editor := TabListEditor new.
  2084     editor := TabListEditor new.
  2080     editor masterApplication:self.
  2085     editor masterApplication:self.
  2081     editor openModalOnClass:specClass andSelector:selector.
  2086     editor openModalOnClass:specClass andSelector:selector.
  2082 
  2087 
  2083     editor specSelector ~= selector ifTrue:[
  2088     editor specSelector ~= selector ifTrue:[
  2084         editor hasSaved ifTrue:[
  2089         editor hasSaved ifTrue:[
  2085             self specTool specification listSelector:editor specSelector.
  2090             spec listSelector:editor specSelector.
  2086             self modifiedChannel value:true.
  2091             self modifiedChannel value:true.
  2087             self accept.
  2092             self accept.
  2088         ]
  2093         ]
  2089     ]
  2094     ]
       
  2095 
       
  2096     "Modified: / 16.7.1998 / 18:15:14 / cg"
  2090 ! !
  2097 ! !
  2091 
  2098 
  2092 !UIPainter methodsFor:'change & update'!
  2099 !UIPainter methodsFor:'change & update'!
  2093 
  2100 
  2094 layoutChanged
  2101 layoutChanged
  2120 !
  2127 !
  2121 
  2128 
  2122 update:something with:aParameter from:someObject
  2129 update:something with:aParameter from:someObject
  2123     "catches change notifications"
  2130     "catches change notifications"
  2124 
  2131 
       
  2132     |window|
       
  2133 
  2125     someObject == treeView model ifTrue:[
  2134     someObject == treeView model ifTrue:[
  2126         (something == #selection
  2135         (something == #selection
  2127         or:[something == #selectionIndex]) ifTrue:[self treeSelection].
  2136         or:[something == #selectionIndex]) ifTrue:[self treeSelection].
  2128       ^ self
  2137       ^ self
  2129     ].
  2138     ].
  2130 
  2139 
  2131     self galleryShown == someObject ifTrue:[
  2140     someObject == self galleryShown ifTrue:[
  2132         (self galleryShown value) ifTrue:[
  2141         "/ galleryShown toggle changed
  2133             self raiseUIView:(selectionPanel window)
  2142         window := selectionPanel window.
       
  2143         (someObject value) ifTrue:[
       
  2144             self raiseUIView:window
  2134         ] ifFalse:[
  2145         ] ifFalse:[
  2135             self hideUIView:(selectionPanel window)
  2146             self hideUIView:window
  2136         ].
  2147         ].
  2137       ^ self
  2148       ^ self
  2138     ].
  2149     ].
  2139 
  2150 
  2140     self painterShown == someObject ifTrue:[
  2151     someObject == self painterShown ifTrue:[
  2141         (self painterShown value) ifTrue:[
  2152         "/ canvasShown toggle changed
  2142             self raiseUIView:(self painter topView)
  2153         window := self painter topView.
       
  2154         (someObject value) ifTrue:[
       
  2155             self raiseUIView:window
  2143         ] ifFalse:[
  2156         ] ifFalse:[
  2144             self hideUIView:(self painter topView)
  2157             self hideUIView:window
  2145         ].
  2158         ].
  2146       ^ self
  2159       ^ self
  2147     ].
  2160     ].
  2148 
  2161 
  2149     "Modified: / 29.10.1997 / 17:48:19 / cg"
  2162     "Modified: / 16.7.1998 / 19:09:57 / cg"
  2150 !
  2163 !
  2151 
  2164 
  2152 updateChannels
  2165 updateChannels
  2153     "updates the channels"
  2166     "updates the channels"
  2154 
  2167 
  2155     |canCutOrCopy canPaste clipboard sel|
  2168     |canCutOrCopy canPaste clipboard sel treeSelection|
  2156 
  2169 
  2157     self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
  2170     self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
  2158     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
  2171     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
  2159     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
  2172     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
  2160     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
  2173     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
  2161     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
  2174     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
  2162 
  2175 
  2163     treeView notNil
  2176     treeView notNil
  2164     ifTrue:
  2177     ifTrue:
  2165     [
  2178     [
  2166         canCutOrCopy := treeView selection size >= 1 and:[treeView selection first ~~ 1].
  2179         treeSelection := treeView selection.
       
  2180         "/ the top-node cannot be cut, copied or pasted.
       
  2181         canCutOrCopy := treeSelection size >= 1 and:[treeSelection first ~~ 1].
  2167         clipboard := self getSelection.
  2182         clipboard := self getSelection.
  2168 
  2183 
  2169         clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
  2184         clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
  2170                               ifFalse:[sel := clipboard].
  2185                               ifFalse:[sel := clipboard].
  2171 
  2186 
  2172         canPaste := (sel isKindOf:UISpecification) and: 
  2187         canPaste := (sel isKindOf:UISpecification) and: 
  2173                     [treeView selection size  = 1 
  2188                     [treeSelection size  = 1 
  2174                     and:[treeView selection first == 1 
  2189                     and:[treeSelection first == 1 
  2175                     or: [self canPasteInto: treeView selectedNode contents view]]]
  2190                     or: [self canPasteInto: treeView selectedNode contents view]]]
  2176     ].
  2191     ].
  2177 
  2192 
  2178     self valueOfCanCut value: canCutOrCopy.
  2193     self valueOfCanCut value: canCutOrCopy.
  2179     self valueOfCanCopy value: canCutOrCopy.
  2194     self valueOfCanCopy value: canCutOrCopy.
  2180     self valueOfCanPaste value: canPaste.            
  2195     self valueOfCanPaste value: canPaste.            
  2181     self valueOfCanPasteWithKeepingLayout value: (canPaste "&  self canKeepLayoutInSelection").
  2196     self valueOfCanPasteWithKeepingLayout value: (canPaste "&  self canKeepLayoutInSelection").
       
  2197 
       
  2198     "Modified: / 16.7.1998 / 19:13:30 / cg"
  2182 ! !
  2199 ! !
  2183 
  2200 
  2184 !UIPainter methodsFor:'event handling'!
  2201 !UIPainter methodsFor:'event handling'!
  2185 
  2202 
  2186 doesNotUnderstand:aMessage
  2203 doesNotUnderstand:aMessage
  2953 !
  2970 !
  2954 
  2971 
  2955 doDefineClassAndSelector
  2972 doDefineClassAndSelector
  2956     "launches a dialog for defining class, superclass, and selector of the application"
  2973     "launches a dialog for defining class, superclass, and selector of the application"
  2957 
  2974 
  2958     |again tmp helpDict helpKey|
  2975     |again tmp helpDict helpKey helpTool|
  2959 
  2976 
  2960     [
  2977     [
  2961         again := false.
  2978         again := false.
  2962 
  2979 
  2963         (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication'].
  2980         (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication'].
  2990     ] doWhile:[again].
  3007     ] doWhile:[again].
  2991 
  3008 
  2992     specClass := specClass isBehavior ifTrue:[specClass name]
  3009     specClass := specClass isBehavior ifTrue:[specClass name]
  2993                                       ifFalse:[specClass].
  3010                                       ifFalse:[specClass].
  2994 
  3011 
  2995     helpDict := self helpTool dictionary.
  3012     helpTool := self helpTool.
  2996     helpKey  := self helpTool helpKey.
  3013     helpDict := helpTool dictionary.
  2997     self helpTool buildFromClass:specClass.    
  3014     helpKey  := helpTool helpKey.
  2998     self helpTool dictionary declareAllFrom: helpDict.
  3015     helpTool buildFromClass:specClass.    
  2999     self helpTool updateList.
  3016     helpTool dictionary declareAllFrom: helpDict.
  3000     self helpTool helpKey: helpKey.
  3017     helpTool updateList.
       
  3018     helpTool helpKey: helpKey.
  3001     self modifiedChannel value: false.
  3019     self modifiedChannel value: false.
  3002     self helpTool modified: true.
  3020     helpTool modified: true.
  3003 
  3021 
  3004     self updateInfoLabel
  3022     self updateInfoLabel
       
  3023 
       
  3024     "Modified: / 16.7.1998 / 18:26:33 / cg"
  3005 !
  3025 !
  3006 
  3026 
  3007 doDefineGrid
  3027 doDefineGrid
  3008     "opens a dialog for the grid parameters"
  3028     "opens a dialog for the grid parameters"
  3009 
  3029