996 #name: 'isVisibleInputField' |
984 #name: 'isVisibleInputField' |
997 #layout: #(#LayoutFrame 110 0 65 0 -5 1.0 87 0) |
985 #layout: #(#LayoutFrame 110 0 65 0 -5 1.0 87 0) |
998 #activeHelpKey: #detailsVisibility |
986 #activeHelpKey: #detailsVisibility |
999 #tabable: true |
987 #tabable: true |
1000 #model: #isVisible |
988 #model: #isVisible |
1001 #group: #inputGroup |
989 #group: #inputGroup4 |
1002 #type: #symbolOrNil |
990 #type: #symbolOrNil |
1003 #acceptOnReturn: true |
991 #acceptOnReturn: true |
1004 #acceptOnTab: true |
992 #acceptOnTab: true |
1005 #acceptChannel: #acceptChannel |
993 #acceptChannel: #acceptChannel |
1006 #modifiedChannel: #modifiedChannel |
994 #modifiedChannel: #modifiedChannel |
|
995 #acceptOnPointerLeave: false |
|
996 ) |
|
997 #(#LabelSpec |
|
998 #label: 'Aux Value' |
|
999 #name: 'auxLabel' |
|
1000 #layout: #(#AlignmentOrigin 107 0 101 0 1 0.5) |
|
1001 #activeHelpKey: #detailsAuxValue |
|
1002 #translateLabel: true |
|
1003 #resizeForLabel: true |
|
1004 #adjust: #right |
|
1005 ) |
|
1006 #(#InputFieldSpec |
|
1007 #name: 'auxInputField' |
|
1008 #layout: #(#LayoutFrame 110 0 90 0 -5 1.0 112 0) |
|
1009 #activeHelpKey: #detailsAuxValue |
|
1010 #tabable: true |
|
1011 #model: #auxValue |
|
1012 #group: #inputGroup4 |
|
1013 #type: #smalltalkObject |
|
1014 #acceptOnReturn: true |
|
1015 #acceptOnTab: true |
|
1016 #acceptChannel: #acceptChannel |
|
1017 #modifiedChannel: #modifiedChannel |
|
1018 #acceptOnPointerLeave: false |
1007 ) |
1019 ) |
1008 #(#LabelSpec |
1020 #(#LabelSpec |
1009 #label: 'Start Group:' |
1021 #label: 'Start Group:' |
1010 #name: 'StartGroupLabel' |
1022 #name: 'StartGroupLabel' |
1011 #layout: #(#AlignmentOrigin 107 0 139 0 1 0.5) |
1023 #layout: #(#AlignmentOrigin 107 0 139 0 1 0.5) |
1038 #name: 'accessCharField' |
1051 #name: 'accessCharField' |
1039 #layout: #(#LayoutFrame 220 0 159 0 -5 1.0 181 0) |
1052 #layout: #(#LayoutFrame 220 0 159 0 -5 1.0 181 0) |
1040 #activeHelpKey: #detailsAccessCharaterPosition |
1053 #activeHelpKey: #detailsAccessCharaterPosition |
1041 #tabable: true |
1054 #tabable: true |
1042 #model: #accessCharacterPos |
1055 #model: #accessCharacterPos |
1043 #group: #inputGroup |
1056 #group: #inputGroup4 |
1044 #type: #numberOrNil |
1057 #type: #numberOrNil |
1045 #immediateAccept: false |
1058 #immediateAccept: false |
1046 #acceptOnReturn: true |
1059 #acceptOnReturn: true |
1047 #acceptOnTab: true |
1060 #acceptOnTab: true |
1048 #acceptChannel: #acceptChannel |
1061 #acceptChannel: #acceptChannel |
1049 #modifiedChannel: #modifiedChannel |
1062 #modifiedChannel: #modifiedChannel |
1050 ) |
1063 #acceptOnPointerLeave: false |
1051 #(#LabelSpec |
|
1052 #label: 'Aux Value' |
|
1053 #name: 'auxLabel' |
|
1054 #layout: #(#AlignmentOrigin 107 0 101 0 1 0.5) |
|
1055 #activeHelpKey: #detailsAuxValue |
|
1056 #translateLabel: true |
|
1057 #resizeForLabel: true |
|
1058 #adjust: #right |
|
1059 ) |
|
1060 #(#InputFieldSpec |
|
1061 #name: 'auxInputField' |
|
1062 #layout: #(#LayoutFrame 110 0 90 0 -5 1.0 112 0) |
|
1063 #activeHelpKey: #detailsAuxValue |
|
1064 #tabable: true |
|
1065 #model: #auxValue |
|
1066 #group: #inputGroup |
|
1067 #type: #smalltalkObject |
|
1068 #acceptOnReturn: true |
|
1069 #acceptOnTab: true |
|
1070 #acceptChannel: #acceptChannel |
|
1071 #modifiedChannel: #modifiedChannel |
|
1072 ) |
1064 ) |
1073 ) |
1065 ) |
1074 |
1066 |
1075 ) |
1067 ) |
1076 ) |
1068 ) |
1208 MenuEditor open |
1195 MenuEditor open |
1209 " |
1196 " |
1210 |
1197 |
1211 <resource: #canvas> |
1198 <resource: #canvas> |
1212 |
1199 |
1213 ^ |
1200 ^ |
1214 |
1201 #(#FullSpec |
1215 #(#FullSpec |
1202 #name: #windowSpec |
1216 #window: |
1203 #window: |
1217 #(#WindowSpec |
1204 #(#WindowSpec |
1218 #name: 'Menu Editor' |
1205 #label: 'Menu Editor' |
1219 #layout: #(#LayoutFrame 53 0 403 0 609 0 810 0) |
1206 #name: 'Menu Editor' |
1220 #label: 'Menu Editor' |
1207 #min: #(#Point 550 440) |
1221 #min: #(#Point 510 390) |
1208 #max: #(#Point 1152 900) |
1222 #max: #(#Point 1152 900) |
1209 #bounds: #(#Rectangle 162 299 719 739) |
1223 #bounds: #(#Rectangle 53 403 610 811) |
1210 #menu: #menu |
1224 #menu: #menu |
1211 ) |
1225 #usePreferredExtent: false |
1212 #component: |
1226 ) |
1213 #(#SpecCollection |
1227 #component: |
1214 #collection: #( |
1228 #(#SpecCollection |
1215 #(#MenuPanelSpec |
1229 #collection: |
1216 #name: 'menuToolbarView' |
1230 #( |
1217 #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
1231 #(#MenuPanelSpec |
1218 #menu: #menuToolbar |
1232 #name: 'menuToolbarView' |
1219 #showSeparatingLines: true |
1233 #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0) |
1220 ) |
1234 #menu: #menuToolbar |
1221 #(#VariableHorizontalPanelSpec |
1235 #showSeparatingLines: true |
1222 #name: 'VariableHorizontalPanel' |
1236 ) |
1223 #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
1237 #(#VariableHorizontalPanelSpec |
1224 #component: |
1238 #name: 'VariableHorizontalPanel' |
1225 #(#SpecCollection |
1239 #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0) |
1226 #collection: #( |
|
1227 #(#ArbitraryComponentSpec |
|
1228 #name: 'TreeView' |
|
1229 #menu: #menuEdit |
|
1230 #hasHorizontalScrollBar: true |
|
1231 #hasVerticalScrollBar: true |
|
1232 #hasBorder: false |
|
1233 #component: #treeView |
|
1234 ) |
|
1235 #(#ViewSpec |
|
1236 #name: 'Box' |
|
1237 #level: -1 |
1240 #component: |
1238 #component: |
1241 #(#SpecCollection |
1239 #(#SpecCollection |
1242 #collection: |
1240 #collection: #( |
1243 #( |
1241 #(#NoteBookViewSpec |
1244 #(#ArbitraryComponentSpec |
1242 #name: 'NoteBook' |
1245 #name: 'TreeView' |
1243 #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -30 1.0) |
1246 #menu: #menuEdit |
1244 #enableChannel: #hasAnySingleSelection |
1247 #hasHorizontalScrollBar: true |
1245 #tabable: true |
1248 #hasVerticalScrollBar: true |
1246 #model: #tabModel |
1249 #component: #treeView |
1247 #menu: #tabList |
1250 #hasBorder: false |
1248 #useIndex: true |
1251 ) |
1249 #canvas: #tabCanvasHolder |
1252 #(#ViewSpec |
1250 #keepCanvasAlive: true |
1253 #name: 'Box' |
|
1254 #component: |
|
1255 #(#SpecCollection |
|
1256 #collection: |
|
1257 #( |
|
1258 #(#NoteBookViewSpec |
|
1259 #name: 'NoteBook' |
|
1260 #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -30 1.0) |
|
1261 #tabable: true |
|
1262 #model: #tabModel |
|
1263 #menu: #tabList |
|
1264 #useIndex: true |
|
1265 #canvas: #noteBookView |
|
1266 ) |
|
1267 #(#UISubSpecification |
|
1268 #name: 'SubSpecification' |
|
1269 #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0) |
|
1270 #majorKey: #ToolApplicationModel |
|
1271 #minorKey: #windowSpecForCommit |
|
1272 ) |
|
1273 ) |
|
1274 ) |
|
1275 #level: -1 |
|
1276 ) |
|
1277 ) |
1251 ) |
|
1252 #(#UISubSpecification |
|
1253 #name: 'SubSpecification' |
|
1254 #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0) |
|
1255 #majorKey: #ToolApplicationModel |
|
1256 #minorKey: #windowSpecForCommit |
|
1257 ) |
|
1258 ) |
|
1259 |
1278 ) |
1260 ) |
1279 #handles: #(#Any 0.30117 1.0) |
1261 ) |
1280 ) |
1262 ) |
1281 #(#UISubSpecification |
1263 |
1282 #name: 'InfoBarSubSpec' |
|
1283 #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
1284 #majorKey: #ToolApplicationModel |
|
1285 #minorKey: #windowSpecForInfoBar |
|
1286 ) |
|
1287 ) |
1264 ) |
1288 ) |
1265 #handles: #(#Any 0.346499 1.0) |
|
1266 ) |
|
1267 #(#UISubSpecification |
|
1268 #name: 'InfoBarSubSpec' |
|
1269 #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0) |
|
1270 #majorKey: #ToolApplicationModel |
|
1271 #minorKey: #windowSpecForInfoBar |
|
1272 ) |
|
1273 ) |
|
1274 |
|
1275 ) |
1289 ) |
1276 ) |
1290 ! ! |
1277 ! ! |
1291 |
1278 |
1292 !MenuEditor class methodsFor:'menu specs'! |
1279 !MenuEditor class methodsFor:'menu specs'! |
1293 |
1280 |
2034 ^ holder |
1993 ^ holder |
2035 |
1994 |
2036 |
1995 |
2037 ! |
1996 ! |
2038 |
1997 |
|
1998 tabCanvasHolder |
|
1999 "keep the canvas for the current selected item or nil |
|
2000 " |
|
2001 |holder| |
|
2002 |
|
2003 (holder := builder bindingAt:#tabCanvasHolder) isNil ifTrue:[ |
|
2004 builder aspectAt:#tabCanvasHolder put: (holder := nil asValue). |
|
2005 ]. |
|
2006 ^ holder |
|
2007 |
|
2008 |
|
2009 ! |
|
2010 |
2039 tabList |
2011 tabList |
2040 "get a value holder with the list of the attribute sections (slices)" |
2012 "get a value holder with the list of the attribute sections (slices)" |
2041 |
2013 |
2042 |holder| |
2014 |holder| |
|
2015 |
2043 (holder := builder bindingAt:#tabList) isNil ifTrue:[ |
2016 (holder := builder bindingAt:#tabList) isNil ifTrue:[ |
2044 builder aspectAt:#tabList put:(holder := #(Basics Details Image Help) asValue). |
2017 builder aspectAt:#tabList put:(holder := nil asValue). |
2045 ]. |
2018 ]. |
2046 ^ holder |
2019 ^ holder |
2047 |
2020 |
2048 |
2021 |
2049 ! |
2022 ! |
2050 |
2023 |
2051 treeView |
2024 treeView |
2052 "get a tree view representing hierarchically the menu items" |
2025 "get a tree view representing hierarchically the menu items" |
2053 |
2026 |
2054 |treeView| |
2027 ^ treeView |
2055 (treeView := builder bindingAt:#treeView) isNil ifTrue:[ |
|
2056 treeView := TreeView new. |
|
2057 treeView action:[:dummy|self menuChanged]. |
|
2058 builder aspectAt: #treeView put: treeView |
|
2059 ]. |
|
2060 ^treeView |
|
2061 ! ! |
2028 ! ! |
2062 |
2029 |
2063 !MenuEditor methodsFor:'building'! |
2030 !MenuEditor methodsFor:'building'! |
2064 |
2031 |
2065 buildFromClass:aClass andSelector:aSelector |
2032 buildFromClass:aClass andSelector:aSelector |
2066 |
2033 |
2067 self isStandAlone ifTrue:[ |
2034 self isStandAlone ifTrue:[ |
2068 self helpTool buildFromClass:specClass |
2035 self helpTool buildFromClass:specClass |
2069 ]. |
2036 ]. |
2070 self treeView buildFromClass: aClass andSelector: aSelector. |
2037 treeView buildFromClass: aClass andSelector: aSelector. |
2071 |
2038 |
2072 self updateHistory. |
2039 self updateHistory. |
2073 self updateInfoLabel. |
2040 self updateInfoLabel. |
2074 self treeView selection: 2. |
2041 |
2075 self menuChanged |
2042 ! |
2076 |
2043 |
2077 ! |
2044 buildFromResourceSpec:aResourceSpec |
2078 |
2045 |spec| |
2079 buildFromResourceSpec: aResourceSpec |
2046 |
2080 |
2047 spec := aResourceSpec isCollection ifTrue:[aResourceSpec decodeAsLiteralArray] |
2081 self buildFromMenu: |
2048 ifFalse:[aResourceSpec]. |
2082 (aResourceSpec class == Menu ifTrue: [aResourceSpec] ifFalse: [aResourceSpec decodeAsLiteralArray]) |
2049 |
|
2050 self buildFromMenu:spec |
2083 ! ! |
2051 ! ! |
2084 |
2052 |
2085 !MenuEditor methodsFor:'change & update'! |
2053 !MenuEditor methodsFor:'change & update'! |
2086 |
2054 |
2087 update:something with:aParameter from:changedObject |
2055 update:something with:aParameter from:changedObject |
2088 super update:something with:aParameter from:changedObject. |
2056 super update:something with:aParameter from:changedObject. |
2089 |
2057 |
2090 changedObject == (aspects at:#retriever) ifTrue:[ |
2058 changedObject == (aspects at:#retriever) ifTrue:[ |
2091 "/ self updateListOfImages. |
2059 self updateImageView. |
2092 self updateSelectionOfImage |
|
2093 ]. |
2060 ]. |
2094 |
2061 |
2095 "Modified: / 24.8.1998 / 21:47:48 / cg" |
2062 "Modified: / 24.8.1998 / 21:47:48 / cg" |
2096 ! |
2063 ! |
2097 |
2064 |
2098 updateChannels |
2065 updateChannels |
2099 "update channels" |
2066 "update channels" |
2100 |
2067 |
2101 |node parent next state| |
2068 |node parent next state canPaste| |
2102 |
2069 |
2103 self clearModifiedFlag. |
|
2104 state := false. |
2070 state := false. |
2105 self updateSelectionOfImage. |
2071 node := treeView selectedNode. |
2106 |
2072 |
2107 (node := self treeView selectedNode) notNil |
2073 node notNil ifTrue:[ |
2108 ifTrue: |
|
2109 [ |
|
2110 self hasAnySingleSelection value:true. |
2074 self hasAnySingleSelection value:true. |
2111 (parent := node parent) notNil |
2075 canPaste := self valueOfCanPaste value. |
2112 ifTrue: |
2076 |
2113 [ |
2077 (parent := node parent) notNil ifTrue:[ |
2114 next := parent childAt:((parent indexOfChild:node) + 1). |
2078 next := parent childAt:((parent indexOfChild:node) + 1). |
2115 self valueOfEnableMovingIn value:(next notNil and:[next hasChildren]). |
2079 self valueOfEnableMovingIn value:(next notNil and:[next hasChildren]). |
2116 self valueOfEnableMovingUpOrDown value:(parent children size > 1). |
2080 self valueOfEnableMovingUpOrDown value:(parent children size > 1). |
2117 self valueOfEnableMovingOut value:parent parent notNil. |
2081 self valueOfEnableMovingOut value:parent parent notNil. |
2118 self hasValidSingleSelection value:true. |
|
2119 self hasValidSelection value:true. |
2082 self hasValidSelection value:true. |
2120 self valueOfCanPaste value:true & self valueOfCanPaste value. |
2083 self valueOfCanPaste value:canPaste. |
2121 ^self |
2084 ^ self |
2122 ] |
2085 ]. |
2123 ] |
2086 ] ifFalse:[ |
2124 ifFalse: |
2087 canPaste := false. |
2125 [ |
2088 |
2126 self hasAnySingleSelection value:false. |
2089 self hasAnySingleSelection value:false. |
2127 self treeView numberOfSelections ~~ 0 ifTrue:[ |
2090 |
2128 state := (self treeView isInSelection:1) not |
2091 treeView numberOfSelections ~~ 0 ifTrue:[ |
|
2092 canPaste := false. |
|
2093 state := (treeView isInSelection:1) not |
2129 ] |
2094 ] |
2130 ]. |
2095 ]. |
2131 self valueOfEnableMovingUpOrDown value:false. |
2096 self valueOfEnableMovingUpOrDown value:false. |
2132 self valueOfEnableMovingIn value:false. |
2097 self valueOfEnableMovingIn value:false. |
2133 self valueOfEnableMovingOut value:false. |
2098 self valueOfEnableMovingOut value:false. |
2134 self hasValidSingleSelection value:false. |
|
2135 self hasValidSelection value:state. |
2099 self hasValidSelection value:state. |
2136 self valueOfCanPaste value:(self hasValidSingleSelection value or: [node == self treeView root]) & self valueOfCanPaste value. |
2100 self valueOfCanPaste value:canPaste. |
2137 |
2101 |
2138 ! |
2102 ! |
2139 |
2103 |
2140 updateListAndSelectionOfImage |
2104 updateImageView |
2141 "updates the list and selection of image" |
2105 "update the image view |
2142 |
2106 " |
2143 self updateListOfImages. |
2107 |cls newList icon| |
2144 self updateSelectionOfImage |
2108 |
2145 ! |
2109 self isImageViewSelected ifFalse:[ |
2146 |
2110 ^ self |
2147 updateListOfImages |
2111 ]. |
2148 "updates the list of images" |
2112 cls := self currentImageRetrieverClass. |
2149 |
2113 |
2150 |iconClass| |
2114 lastImageRetriever == cls ifTrue:[ |
2151 |
2115 newList := self listOfImages |
2152 (iconClass := (aspects at: #retriever) value ? specClass) notNil ifTrue: |
2116 ] ifFalse:[ |
2153 [ |
2117 cls notNil ifTrue:[ |
2154 iconClass := Smalltalk at: iconClass |
2118 lastImageRetriever := cls. |
2155 ]. |
2119 |
2156 |
2120 newList := self class getAllImageSelectorsFrom:cls. |
2157 self listOfImages contents: |
2121 newList := newList collect: [:sel| |img| |
2158 ((self class getAllImageSelectorsFrom: iconClass) |
2122 img := cls perform: sel. |
2159 collect: [:sel| |image| |
2123 img height > 22 ifTrue:[ |
2160 image := iconClass perform: sel. |
2124 img := img magnifiedBy: 22 / img extent y |
2161 image height > 22 ifTrue:[ |
2125 ]. |
2162 image := image magnifiedBy: 22/image extent y |
2126 LabelAndIcon icon:img string:sel |
2163 ]. |
2127 ]. |
2164 LabelAndIcon |
2128 ] ifFalse:[ |
2165 icon:image |
2129 newList := #() |
2166 string:sel |
2130 ]. |
2167 ]). |
2131 self listOfImages contents:newList. |
2168 |
2132 ]. |
2169 ! |
2133 |
2170 |
2134 icon := (aspects at:#icon) value. |
2171 updateSelectionOfImage |
2135 |
2172 "updates the selection of image" |
2136 icon notNil ifTrue:[ |
2173 |
2137 icon := newList detect:[:el| el string == icon] ifNone:nil. |
2174 self selectionOfImage value: nil. |
2138 ]. |
2175 self updateListOfImages. |
2139 self selectionOfImage value:icon. |
2176 self selectionOfImage value: (self listOfImages detect: [:im| im string == (aspects at: #icon) value] ifNone: nil). |
2140 |
2177 |
2141 |
2178 ! ! |
2142 ! ! |
2179 |
2143 |
2180 !MenuEditor methodsFor:'defaults'! |
2144 !MenuEditor methodsFor:'defaults'! |
2181 |
2145 |
2192 !MenuEditor methodsFor:'event handling'! |
2156 !MenuEditor methodsFor:'event handling'! |
2193 |
2157 |
2194 doesNotUnderstand: aMessage |
2158 doesNotUnderstand: aMessage |
2195 "detour incoming messages to the tree view" |
2159 "detour incoming messages to the tree view" |
2196 |
2160 |
2197 (self treeView respondsTo: aMessage selector) |
2161 ^ aMessage sendTo:treeView |
2198 ifTrue: |
|
2199 [ |
|
2200 ^aMessage sendTo: self treeView |
|
2201 ]. |
|
2202 super doesNotUnderstand:aMessage |
|
2203 |
|
2204 |
|
2205 ! ! |
2162 ! ! |
2206 |
2163 |
2207 !MenuEditor methodsFor:'private'! |
2164 !MenuEditor methodsFor:'private'! |
|
2165 |
|
2166 currentImageRetrieverClass |
|
2167 "returns the current class which provides the images dependent on |
|
2168 the retriver or the current spec. |
|
2169 " |
|
2170 |clsName| |
|
2171 |
|
2172 clsName := (aspects at: #retriever) value. |
|
2173 |
|
2174 clsName size == 0 ifTrue:[ |
|
2175 clsName := specClass |
|
2176 ]. |
|
2177 ^ Smalltalk at:clsName ifAbsent:nil |
|
2178 ! |
2208 |
2179 |
2209 helpKey |
2180 helpKey |
2210 "get the help key of the selected menu item" |
2181 "get the help key of the selected menu item" |
2211 |
2182 |
2212 |node| |
2183 |node| |
2213 (node := self treeView selectedNode) notNil ifTrue:[ |
2184 |
|
2185 (node := treeView selectedNode) notNil ifTrue:[ |
2214 ^ node contents activeHelpKey |
2186 ^ node contents activeHelpKey |
2215 ]. |
2187 ]. |
2216 ^ nil |
2188 ^ nil |
2217 ! |
2189 ! |
2218 |
2190 |
2219 helpTool |
2191 helpTool |
2220 "get the help tool" |
2192 "get the help tool application |
2221 |
2193 " |
2222 ^helpCanvas application |
2194 |helpView helpTool| |
|
2195 |
|
2196 helpTool := listOfCanvas at:#help ifAbsent:nil. |
|
2197 |
|
2198 helpTool isNil ifTrue:[ |
|
2199 helpTool := UIHelpTool new createBuilder. |
|
2200 helpTool masterApplication:self. |
|
2201 helpTool modifiedHolder: self valueOfEnablingCommitButtons. |
|
2202 helpView := View new client:helpTool. |
|
2203 helpTool builder window:helpView. |
|
2204 listOfCanvas at:#help put:helpTool. |
|
2205 ]. |
|
2206 ^ helpTool |
|
2207 |
|
2208 |
2223 ! ! |
2209 ! ! |
2224 |
2210 |
2225 !MenuEditor methodsFor:'queries'! |
2211 !MenuEditor methodsFor:'queries'! |
2226 |
2212 |
2227 isHelpToolSelected |
2213 isHelpToolSelected |
2228 "return true if current selection is help tool" |
2214 "return true if current selection is help tool |
2229 |
2215 " |
2230 (tabSelection ~~ 0 and:[slices notNil]) ifTrue:[ |
2216 ^ typeOfCanvas == #help |
2231 ^(slices at:tabSelection) first = UIHelpTool label |
2217 |
2232 ]. |
2218 ! |
2233 ^false |
2219 |
|
2220 isImageViewSelected |
|
2221 "return true if current selection is help tool |
|
2222 " |
|
2223 ^ typeOfCanvas == #imageEditSpec |
|
2224 |
2234 ! |
2225 ! |
2235 |
2226 |
2236 preferredExtent |
2227 preferredExtent |
2237 |
2228 |
2238 ^super preferredExtent max: (Screen current width//3)@(Screen current height//2.5) |
2229 ^super preferredExtent max: (Screen current width//3)@(Screen current height//2.5) |
2239 |
2230 |
2240 |
2231 |
2241 ! ! |
2232 ! ! |
2242 |
2233 |
2243 !MenuEditor methodsFor:'selection'! |
2234 !MenuEditor methodsFor:'selection'! |
|
2235 |
|
2236 clearSelection |
|
2237 tabSelection := 0. |
|
2238 typeOfCanvas := nil. |
|
2239 ! |
2244 |
2240 |
2245 imageSelected |
2241 imageSelected |
2246 |imgSel| |
2242 |imgSel| |
2247 |
2243 |
2248 imgSel := self selectionOfImage value. |
2244 imgSel := self selectionOfImage value. |
2251 ] |
2247 ] |
2252 ! |
2248 ! |
2253 |
2249 |
2254 menuChanged |
2250 menuChanged |
2255 |
2251 |
2256 |node item slc sel old myClass| |
2252 |node item myClass oldLabel oldSlices newList index| |
2257 |
2253 |
2258 aspects do: [:holder| holder removeDependent:self]. |
2254 node := treeView selectedNode. |
2259 (node := self treeView selectedNode) notNil ifTrue:[ |
2255 |
2260 "/ cg: this is rubbish - should only clear |
2256 node isNil ifTrue:[ |
2261 "/ item-specific aspects (if at all) |
2257 slices := nil. |
2262 "/ (added a q&d kludge for #retrieverClassList - no time to investigate) |
2258 index := 0. |
2263 |
2259 ] ifFalse:[ |
2264 aspects do:[:anAspect| |
2260 oldSlices := slices. |
2265 anAspect isBlock ifFalse:[ |
2261 myClass := self class. |
2266 anAspect == (aspects at:#retrieverClassList) ifFalse:[ |
2262 item := node contents. |
2267 anAspect value:nil |
2263 |
2268 ] |
|
2269 ] |
|
2270 ]. |
|
2271 item := node contents. |
|
2272 item toAspects:aspects. |
|
2273 |
|
2274 myClass := self class. |
|
2275 item isSeparator ifFalse:[ |
2264 item isSeparator ifFalse:[ |
2276 node parent isNil ifFalse:[ |
2265 node parent isNil ifFalse:[ |
2277 node hasChildren ifTrue:[ |
2266 node hasChildren ifTrue:[ |
2278 slc := #slicesMenu |
2267 slices := #slicesMenu |
2279 ] ifFalse:[ |
2268 ] ifFalse:[ |
2280 item submenuChannel isNil ifTrue:[slc := #slicesItem] |
2269 item submenuChannel isNil ifTrue:[slices := #slicesItem] |
2281 ifFalse:[slc := #slicesLink] |
2270 ifFalse:[slices := #slicesLink] |
2282 ]. |
2271 ]. |
2283 slc := (myClass perform:slc) copyWith:#( 'Help' #dummy ). |
2272 slices := listOfSlices at:slices |
|
2273 ifAbsentPut:[(myClass perform:slices) copyWith:#('Help' #help)]. |
2284 ] ifTrue:[ |
2274 ] ifTrue:[ |
2285 slc := myClass perform:#slicesRootMenu |
2275 slices := listOfSlices at:#slicesRootMenu |
|
2276 ifAbsentPut:[myClass perform:#slicesRootMenu]. |
2286 ]. |
2277 ]. |
2287 ] ifTrue:[ |
2278 ] ifTrue:[ |
2288 slc := myClass perform:#slicesSeparatorMenu. |
2279 slices := myClass perform:#slicesSeparatorMenu. |
2289 ] |
|
2290 ]. |
|
2291 |
|
2292 self helpTool helpKey: self helpKey. |
|
2293 "Next line helps me to preserve myself against unnecessary settings of |
|
2294 valueOfEnablingCommitButtons to true in the help tool." |
|
2295 |
|
2296 self valueOfEnablingCommitButtons value: false. |
|
2297 self modifiedChannel value: false. |
|
2298 |
|
2299 slc ~= slices ifTrue:[ |
|
2300 tabSelection ~~ 0 ifTrue:[ |
|
2301 old := (slices at:tabSelection) first |
|
2302 ]. |
2280 ]. |
2303 |
2281 index := tabSelection ? 0. |
2304 (slices := slc) notNil ifTrue:[ |
2282 self clearSelection. |
2305 sel := slices collect:[:s| s first]. |
2283 |
2306 tabSelection := 0. |
2284 slices ~~ oldSlices ifTrue:[ |
2307 self tabList value:sel. |
2285 newList := slices collect:[:el| el first]. |
2308 |
2286 |
2309 (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[ |
2287 index ~~ 0 ifTrue:[ |
2310 sel := 1 |
2288 oldLabel := self tabList value at:index ifAbsent:nil. |
|
2289 |
|
2290 oldLabel notNil ifTrue:[ |
|
2291 index := newList indexOf:oldLabel. |
|
2292 ] |
2311 ]. |
2293 ]. |
2312 self tabModel value:sel |
2294 self tabList value:newList. |
2313 ] ifFalse:[ |
2295 ]. |
2314 self tabList value:nil. |
2296 index := index max:1. |
2315 self tabSelection:0. |
2297 ]. |
2316 ] |
2298 self tabModel value:index. |
2317 ]. |
|
2318 self updateChannels. |
2299 self updateChannels. |
2319 aspects do: [:holder| holder addDependent:self]. |
2300 self cancel. |
2320 |
2301 |
2321 "Modified: / 4.2.1999 / 17:37:54 / cg" |
|
2322 ! |
2302 ! |
2323 |
2303 |
2324 tabSelection: aSelection |
2304 tabSelection: aSelection |
2325 "put the section aSelection into the note book" |
2305 "put the section aSelection into the note book |
|
2306 " |
|
2307 |view| |
2326 |
2308 |
2327 tabSelection = aSelection ifTrue:[ |
2309 tabSelection = aSelection ifTrue:[ |
2328 ^ self |
2310 ^ self |
2329 ]. |
2311 ]. |
2330 (aSelection ~~ 0 and:[slices isNil]) ifTrue:[ |
2312 typeOfCanvas := nil. |
2331 ^ self |
2313 |
2332 ]. |
2314 (tabSelection := aSelection) ~~ 0 ifTrue:[ |
2333 (tabSelection := aSelection) == 0 ifTrue:[ |
2315 typeOfCanvas := (slices at:tabSelection) last. |
2334 slices isNil ifTrue:[ |
2316 |
2335 specCanvas client:nil. |
2317 self isHelpToolSelected ifTrue:[ |
2336 ^ specCanvas raise. |
2318 view := self helpTool window. |
2337 ]. |
2319 ] ifFalse:[ |
2338 tabSelection == 1 ifTrue:[^ self]. |
2320 self updateImageView. |
2339 tabSelection := 1 |
2321 view := listOfCanvas at:typeOfCanvas ifAbsentPut:[View new client:self spec:typeOfCanvas]. |
2340 ]. |
2322 ] |
2341 |
2323 ]. |
2342 self isHelpToolSelected ifTrue:[ |
2324 self tabCanvasHolder value:view |
2343 self helpTool helpKey:(self helpKey). |
2325 |
2344 helpCanvas raise. |
|
2345 ] ifFalse:[ |
|
2346 aspects do: [:holder| holder removeDependent:self]. |
|
2347 specCanvas client:self spec:(self class perform:(slices at:tabSelection) last) builder:builder. |
|
2348 aspects do: [:holder| holder addDependent:self]. |
|
2349 specCanvas raise. |
|
2350 ] |
|
2351 |
|
2352 "Modified: / 14.8.1998 / 15:07:06 / cg" |
|
2353 ! ! |
2326 ! ! |
2354 |
2327 |
2355 !MenuEditor methodsFor:'startup / release'! |
2328 !MenuEditor methodsFor:'startup / release'! |
2356 |
2329 |
2357 initialize |
2330 initialize |
2375 with:[:a | a size > 0] |
2354 with:[:a | a size > 0] |
2376 argument:(aspects at:#choice)). |
2355 argument:(aspects at:#choice)). |
2377 |
2356 |
2378 aspects at:#retrieverClassList put:self class defaultRetrieverClassList asValue. |
2357 aspects at:#retrieverClassList put:self class defaultRetrieverClassList asValue. |
2379 |
2358 |
2380 "Modified: / 14.8.1998 / 15:07:58 / cg" |
2359 aspects do: [:holder| holder addDependent:self]. |
|
2360 |
2381 ! |
2361 ! |
2382 |
2362 |
2383 openModalOnMenu: aMenu |
2363 openModalOnMenu: aMenu |
2384 "build a tree from aMenu and open it modal" |
2364 "build a tree from aMenu and open it modal" |
2385 |
2365 |
2386 super openModalOnResourceSpec: aMenu |
2366 super openModalOnResourceSpec: aMenu |
2387 ! |
|
2388 |
|
2389 postOpenWith:aBuilder |
|
2390 |
|
2391 super postOpenWith:aBuilder. |
|
2392 |
|
2393 self isHelpToolSelected |
|
2394 ifTrue: [helpCanvas raise] |
|
2395 ifFalse: [specCanvas raise] |
|
2396 |
|
2397 ! ! |
2367 ! ! |
2398 |
2368 |
2399 !MenuEditor methodsFor:'user actions'! |
2369 !MenuEditor methodsFor:'user actions'! |
2400 |
2370 |
2401 accept |
2371 accept |
2402 "invoked by button 'OK' and by save requests of menu item changes" |
2372 "invoked by button 'OK' and by save requests of menu item changes" |
2403 |
2373 |
2404 |node| |
2374 |node item| |
2405 |
2375 |
2406 super accept. |
2376 super accept. |
2407 |
2377 |
2408 (node := self treeView selectedNode) notNil ifTrue:[ |
2378 (node := treeView selectedNode) notNil ifTrue:[ |
|
2379 item := node contents. |
|
2380 |
2409 self isHelpToolSelected ifTrue:[ |
2381 self isHelpToolSelected ifTrue:[ |
2410 self helpTool accept. |
2382 self helpTool accept. |
2411 node contents activeHelpKey: self helpTool helpKey. |
2383 item activeHelpKey: self helpTool helpKey. |
2412 self valueOfEnablingCommitButtons value: false. |
2384 self valueOfEnablingCommitButtons value: false. |
2413 self clearModifiedFlag. |
2385 self clearModifiedFlag. |
2414 ] ifFalse:[ |
2386 ] ifFalse:[ |
2415 node contents buildFromAspects: aspects. |
2387 item buildFromAspects:aspects. |
2416 node changed. |
2388 node changed. |
2417 specSelector := self treeView selectorName. |
2389 specSelector := treeView selectorName. |
2418 ] |
2390 ] |
2419 ]. |
2391 ]. |
2420 self updateInfoLabel. |
2392 self updateInfoLabel. |
2421 self updateListAndSelectionOfImage. |
|
2422 |
2393 |
2423 ! |
2394 ! |
2424 |
2395 |
2425 cancel |
2396 cancel |
2426 "invoked by button 'Cancel'" |
2397 "invoked by button 'Cancel'" |
2427 |
2398 |node item| |
2428 |node| |
2399 |
2429 |
2400 node := treeView selectedNode. |
2430 (node := self treeView selectedNode) notNil ifTrue:[ |
2401 |
2431 self helpTool helpKey:(self helpKey). |
2402 aspects keysAndValuesDo:[:aKey :anAspect| |
2432 aspects do:[:anAspect| anAspect value:'' ]. |
2403 aKey ~~ #retrieverClassList ifTrue:[ |
2433 node contents toAspects:aspects |
2404 anAspect setValue:''. "/ to clear the field. |
2434 ]. |
2405 anAspect value:'' |
2435 self valueOfEnablingCommitButtons value: false. |
2406 ] |
|
2407 ]. |
|
2408 |
|
2409 node notNil ifTrue:[ |
|
2410 item := node contents. |
|
2411 item toAspects:aspects. |
|
2412 self helpTool helpKey:(item activeHelpKey). |
|
2413 ]. |
|
2414 self updateImageView. |
|
2415 self valueOfEnablingCommitButtons value:false. |
2436 self clearModifiedFlag. |
2416 self clearModifiedFlag. |
2437 modified := false |
|
2438 ! |
2417 ! |
2439 |
2418 |
2440 doBrowseForImageResource |
2419 doBrowseForImageResource |
2441 "opens a browser on image-resource methods" |
2420 "opens a browser on image-resource methods" |
2442 |
2421 |
2443 |msg currClass w cls sel| |
2422 |msg currClass w cls sel| |
2444 |
2423 |
2445 currClass := (Smalltalk at: (aspects at: #retriever) value ? specClass). |
2424 currClass := self currentImageRetrieverClass. |
2446 msg := |
2425 msg := |
2447 (ResourceSelectionBrowser |
2426 (ResourceSelectionBrowser |
2448 request: 'Use Image From Class' |
2427 request: 'Use Image From Class' |
2449 onSuperclass: nil |
2428 onSuperclass: nil |
2450 andClass: currClass |
2429 andClass: currClass |
2484 |
2463 |
2485 doPickAMenu |
2464 doPickAMenu |
2486 |
2465 |
2487 |view| |
2466 |view| |
2488 |
2467 |
2489 ((view := Screen current viewFromUser) isNil or: |
2468 self askForModification ifTrue:[ |
2490 [view == Screen current rootView]) ifTrue:[ |
2469 ((view := Screen current viewFromUser) isNil or: |
2491 ^ self |
2470 [view == Screen current rootView]) ifTrue:[ |
2492 ]. |
2471 ^ self |
2493 view specClass == MenuPanelSpec ifTrue:[ |
2472 ]. |
2494 ^ self treeView buildFromMenu: view asMenu |
2473 view specClass == MenuPanelSpec ifTrue:[ |
|
2474 ^ treeView buildFromMenu: view asMenu |
|
2475 ]. |
2495 ]. |
2476 ]. |
2496 ^ nil |
2477 ^ nil |
2497 ! |
2478 ! |
2498 |
2479 |
2499 doRemoveImage |
2480 doRemoveImage |
2500 "removes the image of the selected line" |
2481 "removes the image of the selected line" |
2501 |
2482 |cls sel| |
2502 self selectionOfImage value notNil |
2483 |
2503 ifTrue: |
2484 sel := self selectionOfImage value. |
2504 [ |
2485 |
2505 (Smalltalk at: (aspects at: #retriever) value ? specClass) class removeSelector: |
2486 sel size ~~ 0 ifTrue:[ |
2506 self selectionOfImage value string. |
2487 cls := self currentImageRetrieverClass. |
2507 |
2488 cls notNil ifTrue:[ |
2508 self updateListAndSelectionOfImage. |
2489 cls class removeSelector:(sel string) |
2509 (aspects at:#icon) value: nil |
2490 ]. |
|
2491 (aspects at:#icon) value:nil. |
|
2492 lastImageRetriever := nil. |
|
2493 self updateImageView. |
2510 ] |
2494 ] |
2511 ! |
2495 ! |
2512 |
2496 |
2513 doSave |
2497 doSave |
2514 |cls treeView menu spec mthd category code excla| |
2498 |cls menu spec mthd category code excla| |
2515 |
2499 |
2516 super doSave ifFalse: [^nil]. |
2500 super doSave ifFalse: [^nil]. |
2517 |
2501 |
2518 cls := self resolveName: specClass. |
2502 cls := self resolveName: specClass. |
2519 treeView := self treeView. |
2503 menu := treeView asMenu literalArrayEncoding. |
2520 menu := treeView asMenu. |
|
2521 menu := menu literalArrayEncoding. |
|
2522 spec := WriteStream on:String new. |
2504 spec := WriteStream on:String new. |
2523 UISpecification prettyPrintSpecArray:menu on:spec indent:5. |
2505 UISpecification prettyPrintSpecArray:menu on:spec indent:5. |
2524 spec := spec contents. |
2506 spec := spec contents. |
2525 |
2507 |
2526 "/ if that method already exists, do not overwrite the category |
2508 "/ if that method already exists, do not overwrite the category |