--- a/MenuEditor.st Sun Dec 27 10:18:46 1998 +0100
+++ b/MenuEditor.st Wed Jan 20 20:25:32 1999 +0100
@@ -135,6 +135,14 @@
"Modified: / 14.8.1998 / 14:46:36 / cg"
! !
+!MenuEditor class methodsFor:'defaults'!
+
+defaultRetrieverClassList
+ ^ #(Icon NewLauncher BrowserView)
+
+
+! !
+
!MenuEditor class methodsFor:'help specs'!
helpSpec
@@ -170,24 +178,24 @@
#basicsArgument
'An argument passed to above selector, if it is a 1 or a 2 argument selector.'
-#basicsIndication
-'A boolean holder, a boolean block, or a boolean method, specifying the indication state.'
-
#basicsChoice
'A boolean holder, a boolean block, or a boolean method, specifying the choices state.'
#basicsChoiceValue
'That choices value (typically number or symbol).'
+#basicsIndication
+'A boolean holder, a boolean block, or a boolean method, specifying the indication state.'
+
#basicsIsButton
'Turns on/off a button behavior.'
+#basicsKey
+'Internal key of the item (optional, for programmed accesses).'
+
#basicsLabel
'Label of the item.'
-#basicsKey
-'Internal key of the item (optional, for programmed accesses).'
-
#basicsMenu
'A value holder providing the sub menu to be opened if item is selected.'
@@ -206,6 +214,9 @@
#basicsTranslateLabel
'Translate the label via the classes resource file (internationalization).'
+#browseResource
+'Search for methods with image resource.'
+
#detailsAccelerator
'Key to be pressed to select the menu item from the keyboard (accelerator key).'
@@ -236,29 +247,22 @@
#fileSaveAs
'Opens a dialog to save the menu spec (and the help spec, if modified).'
-#historyMenuItem
-'Edit this menu specification.'
-
#imageImageAndLabel
'Toggles display of both image and textual label.'
#imageImageEditor
'Opens an Image Editor on the resource method defined by retriever and selector.'
+#imageImageList
+'Currently existing image resources.'
+
#imageRetriever
'Class implementing the image resource method. If no class is given, the current application class will be taken.'
#imageSelector
'Selector returning an image (sent to above or the application).'
-#imageImageList
-'Currently existing image resources.'
-
-#test
-'Displays the current menu (layout test).'
)
-
- "Modified: / 18.8.1998 / 16:19:13 / cg"
! !
!MenuEditor class methodsFor:'image specs'!
@@ -1001,11 +1005,11 @@
#window:
#(#WindowSpec
#name: 'Image Item'
- #layout: #(#LayoutFrame 182 0 348 0 577 0 624 0)
+ #layout: #(#LayoutFrame 25 0 119 0 420 0 395 0)
#label: 'Image Item'
#min: #(#Point 10 10)
#max: #(#Point 1280 1024)
- #bounds: #(#Rectangle 182 348 578 625)
+ #bounds: #(#Rectangle 25 119 421 396)
#usePreferredExtent: false
)
#component:
@@ -1025,42 +1029,42 @@
#layout: #(#AlignmentOrigin 107 0 26 0 1 0.5)
#activeHelpKey: #imageRetriever
#label: 'Retriever:'
+ #resizeForLabel: true
#adjust: #right
- #resizeForLabel: true
)
- #(#InputFieldSpec
+ #(#ComboBoxSpec
#name: 'retrieverField'
- #layout: #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
+ #layout: #(#LayoutFrame 110 0 15 0 0 1.0 37 0)
#activeHelpKey: #imageRetriever
#tabable: true
#model: #retriever
#type: #symbolOrNil
#acceptOnReturn: false
#acceptOnTab: false
- #group: #inputGroup
+ #comboList: #retrieverClassList
)
#(#LabelSpec
#name: 'iconLabel'
#layout: #(#AlignmentOrigin 107 0 51 0 1 0.5)
#activeHelpKey: #imageSelector
#label: 'Selector:'
+ #resizeForLabel: true
#adjust: #right
- #resizeForLabel: true
)
#(#InputFieldSpec
#name: 'iconField'
- #layout: #(#LayoutFrame 110 0 40 0 -5 1.0 62 0)
+ #layout: #(#LayoutFrame 110 0 40 0 -31 1.0 62 0)
#activeHelpKey: #imageSelector
#tabable: true
#model: #icon
+ #group: #inputGroup
#type: #symbolOrNil
#acceptOnReturn: false
#acceptOnTab: false
- #group: #inputGroup
)
#(#ActionButtonSpec
#name: 'imageEditorButton'
- #layout: #(#LayoutFrame 5 0.6 67 0 -5 1 91 0)
+ #layout: #(#LayoutFrame 19 0.6 128 0 -5 1 152 0)
#activeHelpKey: #imageImageEditor
#label: 'Image Editor'
#tabable: true
@@ -1068,8 +1072,8 @@
)
#(#SequenceViewSpec
#name: 'systemOrUserImagesList'
+ #layout: #(#LayoutFrame 22 0 67 0 11 0.6 200 0)
#activeHelpKey: #imageImageList
- #layout: #(#LayoutFrame 110 0 67 0 0 0.6 200 0)
#model: #selectionOfImage
#menu: #menuEditImage
#hasHorizontalScrollBar: true
@@ -1080,11 +1084,16 @@
#useIndex: false
#sequenceList: #listOfImages
)
+ #(#ActionButtonSpec
+ #name: 'browseButton'
+ #layout: #(#LayoutFrame -26 1 41 0 -2 1 63 0)
+ #activeHelpKey: #browseResource
+ #label: '...'
+ #model: #doBrowseForImageResource
+ )
)
)
)
-
- "Modified: / 18.8.1998 / 16:17:59 / cg"
!
windowSpec
@@ -1770,12 +1779,15 @@
aClass isSymbol
ifTrue: [iconClass := Smalltalk at: aClass]
ifFalse: [iconClass := aClass].
+ aClass isBehavior ifFalse:[
+ ^ #()
+ ].
imageMethodSelectors := OrderedCollection new.
iconClass withAllSuperclasses do:[:cls |
cls class methodDictionary keysAndValuesDo: [:sel :m |
- (r := m resourceType == #image
+ ((r := m resourceType) == #image
or:[r == #programImage]) ifTrue:[
imageMethodSelectors add:sel
]
@@ -1977,7 +1989,8 @@
super update:something with:aParameter from:changedObject.
changedObject == (aspects at:#retriever) ifTrue:[
- self updateListOfImages
+ "/ self updateListOfImages.
+ self updateSelectionOfImage
].
"Modified: / 24.8.1998 / 21:47:48 / cg"
@@ -2022,6 +2035,7 @@
self hasValidSelection value:state.
self valueOfCanPaste value:(self hasValidSingleSelection value or: [node == self treeView root]) & self valueOfCanPaste value.
+
!
updateListAndSelectionOfImage
@@ -2043,9 +2057,16 @@
self listOfImages contents:
((self class getAllImageSelectorsFrom: iconClass)
- collect: [:sel| |image| image := iconClass perform: sel. LabelAndIcon icon:(image magnifiedBy: 22/image extent y ) string: sel]).
-
- "Modified: / 24.8.1998 / 21:29:24 / cg"
+ collect: [:sel| |image|
+ image := iconClass perform: sel.
+ image height > 22 ifTrue:[
+ image := image magnifiedBy: 22/image extent y
+ ].
+ LabelAndIcon
+ icon:image
+ string:sel
+ ]).
+
!
updateSelectionOfImage
@@ -2130,17 +2151,26 @@
menuChanged
- |node item slc sel old|
+ |node item slc sel old myClass|
aspects do: [:holder| holder removeDependent:self].
(node := self treeView selectedNode) notNil ifTrue:[
+ "/ cg: this is rubbish - should only clear
+ "/ item-specific aspects (if at all)
+ "/ (added a q&d kludge for #retrieverClassList - no time to investigate)
+
aspects do:[:anAspect|
- anAspect isBlock ifFalse:[anAspect value:nil]
+ anAspect isBlock ifFalse:[
+ anAspect == (aspects at:#retrieverClassList) ifFalse:[
+ anAspect value:nil
+ ]
+ ]
].
item := node contents.
item toAspects:aspects.
item isSeparator ifFalse:[
+ myClass := self class.
node parent isNil ifFalse:[
node hasChildren ifTrue:[
slc := #slicesMenu
@@ -2148,12 +2178,12 @@
item submenuChannel isNil ifTrue:[slc := #slicesItem]
ifFalse:[slc := #slicesLink]
].
- slc := (self class perform:slc) copyWith:#( 'Help' #dummy ).
+ slc := (myClass perform:slc) copyWith:#( 'Help' #dummy ).
] ifTrue:[
- slc := self class perform:#slicesRootMenu
+ slc := myClass perform:#slicesRootMenu
].
] ifTrue:[
- slc := self class perform:#slicesSeparatorMenu.
+ slc := myClass perform:#slicesSeparatorMenu.
]
].
@@ -2242,6 +2272,8 @@
with:[:a | a size > 0]
argument:(aspects at:#choice)).
+ aspects at:#retrieverClassList put:self class defaultRetrieverClassList asValue.
+
"Modified: / 14.8.1998 / 15:07:58 / cg"
!
@@ -2306,6 +2338,37 @@
modified := false
!
+doBrowseForImageResource
+ "opens a browser on image-resource methods"
+
+ |msg currClass w cls sel|
+
+ currClass := (Smalltalk at: (aspects at: #retriever) value ? specClass).
+ msg :=
+ (ResourceSelectionBrowser
+ request: 'Use Image From Class'
+ onSuperclass: nil
+ andClass: currClass
+ andSelector: (aspects at: #icon)
+ withResourceTypes: #(image fileImage programImage)).
+
+ msg notNil ifTrue:[
+ (w := msg asCollectionOfWords) size == 2 ifTrue:[
+ cls := w at:1.
+ sel := w at:2.
+ cls ~= currClass ifTrue:[
+ (aspects at: #retriever) value:cls asSymbol.
+ ].
+ sel ~= (aspects at:#icon) ifTrue:[
+ (aspects at: #icon) value:sel asSymbol.
+ ].
+ self updateSelectionOfImage
+ ].
+ ].
+
+
+!
+
doEditImage
"opens a Image Editor on the resource retriever and the icon selector;
then updates the list of images and select the line of the image"