MenuEditor.st
changeset 2850 3a5c3b8eedff
parent 2843 066a69e88211
child 2856 8f5778095338
equal deleted inserted replaced
2849:e061cea3416f 2850:3a5c3b8eedff
    25 	classVariableNames:''
    25 	classVariableNames:''
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	privateIn:MenuEditor
    27 	privateIn:MenuEditor
    28 !
    28 !
    29 
    29 
       
    30 ApplicationModel subclass:#ImageResourceEditor
       
    31 	instanceVariableNames:'selectorHolder iconAndLabelHolder retrieverHolder imageHolder
       
    32 		imageList selectorFilterHolder imageListView'
       
    33 	classVariableNames:''
       
    34 	poolDictionaries:''
       
    35 	privateIn:MenuEditor
       
    36 !
       
    37 
       
    38 HierarchicalItem subclass:#ImageResourceEditorItem
       
    39 	instanceVariableNames:'selector icon'
       
    40 	classVariableNames:''
       
    41 	poolDictionaries:''
       
    42 	privateIn:MenuEditor::ImageResourceEditor
       
    43 !
       
    44 
    30 MenuEditor::Item subclass:#ActionItem
    45 MenuEditor::Item subclass:#ActionItem
    31 	instanceVariableNames:''
    46 	instanceVariableNames:''
    32 	classVariableNames:''
    47 	classVariableNames:''
    33 	poolDictionaries:''
    48 	poolDictionaries:''
    34 	privateIn:MenuEditor
    49 	privateIn:MenuEditor
    48 	privateIn:MenuEditor
    63 	privateIn:MenuEditor
    49 !
    64 !
    50 
    65 
    51 MenuEditor::Item subclass:#RegularMenuItem
    66 MenuEditor::Item subclass:#RegularMenuItem
    52 	instanceVariableNames:''
    67 	instanceVariableNames:''
    53 	classVariableNames:''
       
    54 	poolDictionaries:''
       
    55 	privateIn:MenuEditor
       
    56 !
       
    57 
       
    58 ApplicationModel subclass:#ResourceEditor
       
    59 	instanceVariableNames:'selectorHolder iconAndLabelHolder retrieverHolder imageHolder
       
    60 		imageList imageViewer'
       
    61 	classVariableNames:''
       
    62 	poolDictionaries:''
       
    63 	privateIn:MenuEditor
       
    64 !
       
    65 
       
    66 HierarchicalItem subclass:#ResourceEditorItem
       
    67 	instanceVariableNames:'selector icon'
       
    68 	classVariableNames:''
    68 	classVariableNames:''
    69 	poolDictionaries:''
    69 	poolDictionaries:''
    70 	privateIn:MenuEditor
    70 	privateIn:MenuEditor
    71 !
    71 !
    72 
    72 
   240 flyByHelpSpec
   240 flyByHelpSpec
   241     ^super flyByHelpSpec addPairsFrom:(self localFlyHelpSpecStrings)
   241     ^super flyByHelpSpec addPairsFrom:(self localFlyHelpSpecStrings)
   242 !
   242 !
   243 
   243 
   244 helpSpec
   244 helpSpec
   245     "This resource specification was automatically generated
   245     ^super helpSpec addPairsFrom:(self localFlyHelpSpecStrings)
   246      by the UIHelpTool of ST/X."
   246 
   247 
   247     "Modified: / 03-08-2011 / 10:13:37 / cg"
   248     "Do not manually edit this!! If it is corrupted,
       
   249      the UIHelpTool may not be able to read the specification."
       
   250 
       
   251     "
       
   252      UIHelpTool openOnClass:MenuEditor
       
   253     "
       
   254 
       
   255     <resource: #help>
       
   256 
       
   257     ^ super helpSpec addPairsFrom:#(
       
   258 
       
   259 #addDelayedMenu
       
   260 'Add a new delayed menu to item.'
       
   261 
       
   262 #addDelayedSubMenuLink
       
   263 'Add a new linked delayed menu to item.'
       
   264 
       
   265 #addMenuItem
       
   266 'Add a new menu item.'
       
   267 
       
   268 #addMenuSeparator
       
   269 'Add a new menu separator.'
       
   270 
       
   271 #addMenuSliceItem
       
   272 'Add a new menu slice.'
       
   273 
       
   274 #addSubMenu
       
   275 'Add a new sub menu.'
       
   276 
       
   277 #addSubMenuLink
       
   278 'Add a new linked sub menu.'
       
   279 
       
   280 #basicsAction
       
   281 'An action selector with 0, 1 (the argument field), or 2 (the selected item) arguments.'
       
   282 
       
   283 #browseMethod
       
   284 'Open a browser on this method in the application. Create the method, if it does not exist.'
       
   285 
       
   286 #basicsArgument
       
   287 'An optional arg passed with above selector, if it is a 1 or 2 arg selector (enter a Smalltalk literal).'
       
   288 
       
   289 #basicsChoice
       
   290 'Aspect for a boolean holder, block or method, specifying the choices state (RadioButton behavior).'
       
   291 
       
   292 #basicsChoiceValue
       
   293 'That choices value (typically number or symbol).'
       
   294 
       
   295 #basicsIndication
       
   296 'Aspect for boolean holder, block, or method, specifying the indication state (CheckToggle behavior).'
       
   297 
       
   298 #basicsIsButton
       
   299 'Button-like look and behavior.'
       
   300 
       
   301 #basicsKey
       
   302 'Internal key of the item (optional, for programmed accesses).'
       
   303 
       
   304 #basicsLabel
       
   305 'Label of the item.'
       
   306 
       
   307 #basicsMenu
       
   308 'Aspect providing the sub menu to be opened if item is selected (provide spec or valueHolder).'
       
   309 
       
   310 #basicsMenuArgument
       
   311 'An argument passed with the menu selector.'
       
   312 
       
   313 #basicsNameKey
       
   314 'Unique identifier of the item (optional).'
       
   315 
       
   316 #basicsSelector
       
   317 'Selector under which the generated menu spec is saved.'
       
   318 
       
   319 #basicsSeparatorType
       
   320 'List of valid separators.'
       
   321 
       
   322 #basicsTranslateLabel
       
   323 'Translate the label via the classes resource file (internationalization).'
       
   324 
       
   325 #browseResource
       
   326 'Search for methods with image resource.'
       
   327 
       
   328 #detailsAccelerator
       
   329 'Accelerator key to select the menu item from the keyboard (Cmdx or Ctrlx).'
       
   330 
       
   331 #detailsAccessCharaterPosition
       
   332 'Index of the access character position of the textual label (obsolete, VW compatibility).'
       
   333 
       
   334 #detailsAuxValue
       
   335 'Some additional value - for arbitrary use by the program.'
       
   336 
       
   337 #detailsEnabled
       
   338 'Aspect or binding providing a boolean value holder to enable/disable the menu item.'
       
   339 
       
   340 #detailsIgnoreAcceleratorKeys
       
   341 'Ignore accelerator keys in submenu(s).'
       
   342 
       
   343 #detailsIgnoreMnemonicKeys
       
   344 'Ignore mnemonic keys (access characters) in submenu(s).'
       
   345 
       
   346 #detailsStartGroup
       
   347 'Specify start of a specially aligned group.'
       
   348 
       
   349 #detailsVisibility
       
   350 'Boolean, or aspect or binding for a boolean holder controlling the visibility of the menu item.'
       
   351 
       
   352 #fileLoad
       
   353 'Load a menu spec from a class.'
       
   354 
       
   355 #fileNew
       
   356 'Create a new menu spec.'
       
   357 
       
   358 #filePickAMenu
       
   359 'Select a menu from an open view and read its specification'
       
   360 
       
   361 #fileChooseAMenu
       
   362 'Select a menu from an open view and edit its spec-method'
       
   363 
       
   364 #fileSave
       
   365 'Save the menu spec (and the help spec, if modified).'
       
   366 
       
   367 #fileSaveAs
       
   368 'Open a dialog to save the menu spec (and the help spec, if modified).'
       
   369 
       
   370 #fileShowMenuSpec
       
   371 'Opens a Workspace showing the current menu spec.'
       
   372 
       
   373 #generateAspectMethods
       
   374 'Generates aspect methods for defined aspect selectors of the menu.'
       
   375 
       
   376 #hideMenuOnActivated
       
   377 'If on, the menu hides itself after the item was activated (PopUp/PullDown-Menus only).'
       
   378 
       
   379 #horizontalLayout
       
   380 'If on, the submenu organizes its items horizontal insteat of vertical (default).'
       
   381 
       
   382 #imageImageAndLabel
       
   383 'Toggle display of both image and textual label.'
       
   384 
       
   385 #imageImageEditor
       
   386 'Open an Image Editor on the resource method defined by retriever and selector.'
       
   387 
       
   388 #imageBrowseImageClass
       
   389 'Open a Browser on the resource retriever class.'
       
   390 
       
   391 #imageImageList
       
   392 'Currently existing image resources.'
       
   393 
       
   394 #imageRetriever
       
   395 'Class implementing the image resource method. If unspecified, the application class is taken.'
       
   396 
       
   397 #imageSelector
       
   398 'Selector returning an image (sent to above or the application).'
       
   399 
       
   400 #keepLinkedMenu
       
   401 'Keep the linked menu after activation (do not destroy; if off, menu is rebuild for every activation).'
       
   402 
       
   403 #sendToOriginator
       
   404 'Send action-Message to widget (instead of application); only valid for PopUpMenus.'
       
   405 
       
   406 #settingsRedefineAspectMethods
       
   407 'Toggles the permission to overwrite existing aspect methods.'
       
   408 
       
   409 #showBusyCursorWhilePerforming
       
   410 'If on, a busy cursor is shown while the items action is performing.'
       
   411 
       
   412 #triggerOnDown
       
   413 'If on, the items action is performed on mouse-button press (default is: on button-release).'
       
   414 
       
   415 )
       
   416 
       
   417     "Modified: / 21-10-2010 / 14:18:03 / cg"
       
   418 !
   248 !
   419 
   249 
   420 localFlyHelpSpecStrings
   250 localFlyHelpSpecStrings
   421     "This resource specification was automatically generated
   251     "This resource specification was automatically generated
   422      by the UIHelpTool of ST/X."
   252      by the UIHelpTool of ST/X."
   439 'Copy Item'
   269 'Copy Item'
   440 
   270 
   441 #editPaste
   271 #editPaste
   442 'Paste Item'
   272 'Paste Item'
   443 
   273 
   444 #fileLoad
       
   445 'Load Menuspec from Method'
       
   446 
       
   447 #fileSave
       
   448 'Save Menuspec as Method'
       
   449 
       
   450 #fileSaveSpec
   274 #fileSaveSpec
   451 'Save Menuspec'
   275 'Save Menuspec'
   452 
   276 
   453 #fileSaveAs
       
   454 'Save Menuspec as Method...'
       
   455 
       
   456 #addMenuSeparator
       
   457 'Add Separator'
       
   458 
       
   459 #addMenuItem
       
   460 'Add Item'
       
   461 
       
   462 #addMenuSlice
   277 #addMenuSlice
   463 'Add Menuslice'
   278 'Add Menuslice'
   464 
   279 
       
   280 #addDelayedMenu
       
   281 'Add a new delayed menu to item.'
       
   282 
       
   283 #addDelayedSubMenuLink
       
   284 'Add a new linked delayed menu to item.'
       
   285 
       
   286 #addMenuItem
       
   287 'Add a new menu item.'
       
   288 
       
   289 #addMenuSeparator
       
   290 'Add a new menu separator.'
       
   291 
       
   292 #addMenuSliceItem
       
   293 'Add a new menu slice.'
       
   294 
   465 #addSubMenu
   295 #addSubMenu
   466 'Add Submenu'
   296 'Add a new sub menu.'
   467 
       
   468 #addDelayedMenu
       
   469 'Add Delayed Menu'
       
   470 
       
   471 #addDelayedSubMenuLink
       
   472 'Add Delayed Linked Menu'
       
   473 
   297 
   474 #addSubMenuLink
   298 #addSubMenuLink
   475 'Add Linked Submenu'
   299 'Add a new linked sub menu.'
       
   300 
       
   301 #basicsAction
       
   302 'An action selector with 0, 1 (the argument field), or 2 (the selected item) arguments.'
       
   303 
       
   304 #browseMethod
       
   305 'Open a browser on this method in the application. Create the method, if it does not exist.'
       
   306 
       
   307 #basicsArgument
       
   308 'An optional arg passed with above selector, if it is a 1 or 2 arg selector (enter a Smalltalk literal).'
       
   309 
       
   310 #basicsChoice
       
   311 'Aspect for a boolean holder, block or method, specifying the choices state (RadioButton behavior).'
       
   312 
       
   313 #basicsChoiceValue
       
   314 'That choices value (typically number or symbol).'
       
   315 
       
   316 #basicsIndication
       
   317 'Aspect for boolean holder, block, or method, specifying the indication state (CheckToggle behavior).'
       
   318 
       
   319 #basicsIsButton
       
   320 'Button-like look and behavior.'
       
   321 
       
   322 #basicsKey
       
   323 'Internal key of the item (optional, for programmed accesses).'
       
   324 
       
   325 #basicsLabel
       
   326 'Label of the item.'
       
   327 
       
   328 #basicsMenu
       
   329 'Aspect providing the sub menu to be opened if item is selected (provide spec or valueHolder).'
       
   330 
       
   331 #basicsMenuArgument
       
   332 'An argument passed with the menu selector.'
       
   333 
       
   334 #basicsNameKey
       
   335 'Unique identifier of the item (optional).'
       
   336 
       
   337 #basicsSelector
       
   338 'Selector under which the generated menu spec is saved.'
       
   339 
       
   340 #basicsSeparatorType
       
   341 'List of valid separators.'
       
   342 
       
   343 #basicsTranslateLabel
       
   344 'Translate the label via the classes resource file (internationalization).'
       
   345 
       
   346 #browseResource
       
   347 'Search for methods with image resource.'
       
   348 
       
   349 #detailsAccelerator
       
   350 'Accelerator key to select the menu item from the keyboard (Cmdx or Ctrlx).'
       
   351 
       
   352 #detailsAccessCharaterPosition
       
   353 'Index of the access character position of the textual label (obsolete, VW compatibility).'
       
   354 
       
   355 #detailsAuxValue
       
   356 'Some additional value - for arbitrary use by the program.'
       
   357 
       
   358 #detailsEnabled
       
   359 'Aspect or binding providing a boolean value holder to enable/disable the menu item.'
       
   360 
       
   361 #detailsIgnoreAcceleratorKeys
       
   362 'Ignore accelerator keys in submenu(s).'
       
   363 
       
   364 #detailsIgnoreMnemonicKeys
       
   365 'Ignore mnemonic keys (access characters) in submenu(s).'
       
   366 
       
   367 #detailsStartGroup
       
   368 'Specify start of a specially aligned group.'
       
   369 
       
   370 #detailsVisibility
       
   371 'Boolean, or aspect or binding for a boolean holder controlling the visibility of the menu item.'
       
   372 
       
   373 #fileLoad
       
   374 'Load a menu spec from a class.'
   476 
   375 
   477 #fileNew
   376 #fileNew
   478 'New Menuspec'
   377 'Create a new menu spec.'
       
   378 
       
   379 #filePickAMenu
       
   380 'Select a menu from an open view and read its specification'
       
   381 
       
   382 #fileChooseAMenu
       
   383 'Select a menu from an open view and edit its spec-method'
       
   384 
       
   385 #fileSave
       
   386 'Save the menu spec (and the help spec, if modified).'
       
   387 
       
   388 #fileSaveAs
       
   389 'Open a dialog to save the menu spec (and the help spec, if modified).'
       
   390 
       
   391 #fileShowMenuSpec
       
   392 'Opens a Workspace showing the current menu spec.'
       
   393 
       
   394 #generateAspectMethods
       
   395 'Generates aspect methods for defined aspect selectors of the menu.'
       
   396 
       
   397 #hideMenuOnActivated
       
   398 'If on, the menu hides itself after the item was activated (PopUp/PullDown-Menus only).'
       
   399 
       
   400 #horizontalLayout
       
   401 'If on, the submenu organizes its items horizontal insteat of vertical (default).'
       
   402 
       
   403 #imageImageAndLabel
       
   404 'Toggle display of both image and textual label.'
       
   405 
       
   406 #imageImageEditor
       
   407 'Open an Image Editor on the resource method defined by retriever and selector.'
       
   408 
       
   409 #imageBrowseImageClass
       
   410 'Open a Browser on the resource retriever class.'
       
   411 
       
   412 #imageImageList
       
   413 'Currently existing image resources.'
       
   414 
       
   415 #imageRetriever
       
   416 'Class implementing the image resource method. If unspecified, the application class is taken.'
       
   417 
       
   418 #imageSelector
       
   419 'Selector returning an image (sent to above or the application).'
       
   420 
       
   421 #keepLinkedMenu
       
   422 'Keep the linked menu after activation (do not destroy; if off, menu is rebuild for every activation).'
       
   423 
       
   424 #sendToOriginator
       
   425 'Send action-Message to widget (instead of application); only valid for PopUpMenus.'
       
   426 
       
   427 #settingsRedefineAspectMethods
       
   428 'Toggles the permission to overwrite existing aspect methods.'
       
   429 
       
   430 #showBusyCursorWhilePerforming
       
   431 'If on, a busy cursor is shown while the items action is performing.'
       
   432 
       
   433 #triggerOnDown
       
   434 'If on, the items action is performed on mouse-button press (default is: on button-release).'
       
   435 
       
   436 #selectorFilter
       
   437 'In the list below, only matching selectors are shown'
   479 )
   438 )
       
   439 
       
   440     "Modified: / 03-08-2011 / 10:17:05 / cg"
   480 ! !
   441 ! !
   481 
   442 
   482 !MenuEditor class methodsFor:'image specs'!
   443 !MenuEditor class methodsFor:'image specs'!
   483 
   444 
   484 browseActionImage
   445 browseActionImage
  1666 	tool
  1627 	tool
  1667     ]
  1628     ]
  1668 !
  1629 !
  1669 
  1630 
  1670 imageTool
  1631 imageTool
  1671     "get the image tool application
  1632     "get the image tool application"
  1672     "
  1633 
  1673     ^ wizards at:#image ifAbsentPut:[ |tool|
  1634     ^ wizards 
  1674         tool := ResourceEditor new createBuilder.
  1635         at:#image 
  1675         tool masterApplication:self.
  1636         ifAbsentPut:[ 
  1676         tool modifiedChannel: self enablingCommitButtonsHolder.
  1637             |tool|
  1677         tool builder window:(ApplicationSubView new client:tool).
  1638 
  1678         tool
  1639             tool := ImageResourceEditor new createBuilder.
  1679     ]
  1640             tool masterApplication:self.
       
  1641             tool modifiedChannel: self enablingCommitButtonsHolder.
       
  1642             tool builder window:(ApplicationSubView new client:tool).
       
  1643             tool
       
  1644         ]
       
  1645 
       
  1646     "Modified: / 03-08-2011 / 10:03:08 / cg"
  1680 !
  1647 !
  1681 
  1648 
  1682 savedSpec
  1649 savedSpec
  1683     ^ savedSpec
  1650     ^ savedSpec
  1684 !
  1651 !
  3884 
  3851 
  3885 canMoveUpOrDown
  3852 canMoveUpOrDown
  3886     "returns true if the item can change its vertical order in its sibling
  3853     "returns true if the item can change its vertical order in its sibling
  3887     "
  3854     "
  3888     ^ parent children size > 1
  3855     ^ parent children size > 1
       
  3856 ! !
       
  3857 
       
  3858 !MenuEditor::ImageResourceEditor class methodsFor:'interface specs'!
       
  3859 
       
  3860 windowSpec
       
  3861     "This resource specification was automatically generated
       
  3862      by the UIPainter of ST/X."
       
  3863 
       
  3864     "Do not manually edit this!! If it is corrupted,
       
  3865      the UIPainter may not be able to read the specification."
       
  3866 
       
  3867     "
       
  3868      UIPainter new openOnClass:MenuEditor::ImageResourceEditor andSelector:#windowSpec
       
  3869      MenuEditor::ImageResourceEditor new openInterface:#windowSpec
       
  3870      MenuEditor::ImageResourceEditor open
       
  3871     "
       
  3872 
       
  3873     <resource: #canvas>
       
  3874 
       
  3875     ^ 
       
  3876      #(FullSpec
       
  3877         name: windowSpec
       
  3878         window: 
       
  3879        (WindowSpec
       
  3880           label: 'Image Item'
       
  3881           name: 'Image Item'
       
  3882           min: (Point 10 10)
       
  3883           bounds: (Rectangle 0 0 303 304)
       
  3884         )
       
  3885         component: 
       
  3886        (SpecCollection
       
  3887           collection: (
       
  3888            (LabelSpec
       
  3889               label: 'Retriever:'
       
  3890               name: 'retrieverLabel'
       
  3891               layout: (AlignmentOrigin 107 0 26 0 1 0.5)
       
  3892               activeHelpKey: imageRetriever
       
  3893               translateLabel: true
       
  3894               resizeForLabel: true
       
  3895               adjust: right
       
  3896             )
       
  3897            (ComboBoxSpec
       
  3898               name: 'retrieverHolder'
       
  3899               layout: (LayoutFrame 110 0 15 0 -2 1.0 37 0)
       
  3900               activeHelpKey: imageRetriever
       
  3901               tabable: true
       
  3902               model: retrieverHolder
       
  3903               type: symbolOrNil
       
  3904               immediateAccept: true
       
  3905               acceptOnReturn: false
       
  3906               acceptOnTab: false
       
  3907               acceptOnPointerLeave: false
       
  3908               entryCompletionBlock: entryCompletionForRetriever
       
  3909               comboList: retrieverList
       
  3910               isFilenameBox: false
       
  3911             )
       
  3912            (LabelSpec
       
  3913               label: 'Selector:'
       
  3914               name: 'iconLabel'
       
  3915               layout: (AlignmentOrigin 107 0 51 0 1 0.5)
       
  3916               activeHelpKey: imageSelector
       
  3917               translateLabel: true
       
  3918               resizeForLabel: true
       
  3919               adjust: right
       
  3920             )
       
  3921            (InputFieldSpec
       
  3922               name: 'selectorHolder'
       
  3923               layout: (LayoutFrame 110 0 40 0 -24 1.0 62 0)
       
  3924               activeHelpKey: imageSelector
       
  3925               tabable: true
       
  3926               model: selectorHolder
       
  3927               group: inputGroup
       
  3928               type: symbolOrNil
       
  3929               immediateAccept: true
       
  3930               acceptOnReturn: false
       
  3931               acceptOnTab: false
       
  3932               modifiedChannel: modifiedChannel
       
  3933               acceptOnPointerLeave: false
       
  3934             )
       
  3935            (ActionButtonSpec
       
  3936               label: '...'
       
  3937               name: 'browseButton'
       
  3938               layout: (LayoutFrame -22 1 40 0 -2 1 62 0)
       
  3939               activeHelpKey: browseResource
       
  3940               tabable: true
       
  3941               model: doBrowseForImageResource
       
  3942             )
       
  3943            (DividerSpec
       
  3944               name: 'Separator1'
       
  3945               layout: (LayoutFrame 0 0.0 66 0 0 1.0 70 0)
       
  3946             )
       
  3947            (ViewSpec
       
  3948               name: 'SelectorFilterBox2'
       
  3949               layout: (LayoutFrame 0 0.0 74 0 0 1.0 96 0)
       
  3950               activeHelpKey: selectorFilter
       
  3951               component: 
       
  3952              (SpecCollection
       
  3953                 collection: (
       
  3954                  (LabelSpec
       
  3955                     label: 'Filter:'
       
  3956                     name: 'Label1'
       
  3957                     layout: (AlignmentOrigin 107 0 11 0 1 0.5)
       
  3958                     activeHelpKey: selectorFilter
       
  3959                     translateLabel: true
       
  3960                     resizeForLabel: true
       
  3961                     adjust: right
       
  3962                   )
       
  3963                  (InputFieldSpec
       
  3964                     name: 'EntryField1'
       
  3965                     layout: (LayoutFrame 110 0 0 0 -2 1 22 0)
       
  3966                     model: selectorFilterHolder
       
  3967                     immediateAccept: true
       
  3968                     acceptOnLeave: true
       
  3969                     acceptOnReturn: false
       
  3970                     acceptOnTab: false
       
  3971                     acceptOnPointerLeave: false
       
  3972                     activeHelpKey: selectorFilter
       
  3973                   )
       
  3974                  )
       
  3975                
       
  3976               )
       
  3977             )
       
  3978            (HierarchicalListViewSpec
       
  3979               name: 'imageList'
       
  3980               layout: (LayoutFrame 2 0.0 100 0 -2 1.0 -60 1.0)
       
  3981               activeHelpKey: imageImageList
       
  3982               model: imageHolder
       
  3983               menu: menuEditImage
       
  3984               hasHorizontalScrollBar: true
       
  3985               hasVerticalScrollBar: true
       
  3986               miniScrollerHorizontal: true
       
  3987               listModel: imageList
       
  3988               useIndex: false
       
  3989               highlightMode: label
       
  3990               postBuildCallback: postBuildImageViewer:
       
  3991             )
       
  3992            (ViewSpec
       
  3993               name: 'Box1'
       
  3994               layout: (LayoutFrame 20 0.0 -60 1.0 -20 1.0 0 1.0)
       
  3995               level: 0
       
  3996               component: 
       
  3997              (SpecCollection
       
  3998                 collection: (
       
  3999                  (CheckBoxSpec
       
  4000                     label: 'Image & Label'
       
  4001                     name: 'iconAndLabelCheckBox'
       
  4002                     layout: (AlignmentOrigin 0 0 17 0 0 0.5)
       
  4003                     activeHelpKey: imageImageAndLabel
       
  4004                     tabable: true
       
  4005                     model: iconAndLabelHolder
       
  4006                     translateLabel: true
       
  4007                   )
       
  4008                  (ActionButtonSpec
       
  4009                     label: 'Image Editor'
       
  4010                     name: 'imageEditorButton'
       
  4011                     layout: (AlignmentOrigin -69 1.0 17 0 0 0.5)
       
  4012                     activeHelpKey: imageImageEditor
       
  4013                     hasCharacterOrientedLabel: false
       
  4014                     foregroundColor: (Color 0.0 0.0 66.9993133440146)
       
  4015                     tabable: true
       
  4016                     model: doEditImage
       
  4017                   )
       
  4018                  (ActionButtonSpec
       
  4019                     label: 'Browse'
       
  4020                     name: 'Button1'
       
  4021                     layout: (AlignmentOrigin -69 1.0 41 0 0 0.5)
       
  4022                     activeHelpKey: imageBrowseImageClass
       
  4023                     hasCharacterOrientedLabel: false
       
  4024                     foregroundColor: (Color 0.0 0.0 66.9993133440146)
       
  4025                     tabable: true
       
  4026                     model: doBrowseImageClass
       
  4027                   )
       
  4028                  )
       
  4029                
       
  4030               )
       
  4031             )
       
  4032            )
       
  4033          
       
  4034         )
       
  4035       )
       
  4036 
       
  4037     "Modified: / 03-08-2011 / 10:16:13 / cg"
       
  4038 ! !
       
  4039 
       
  4040 !MenuEditor::ImageResourceEditor methodsFor:'accessing'!
       
  4041 
       
  4042 resourceRetriever
       
  4043     |rcv sel cls clsName|
       
  4044 
       
  4045     sel := selectorHolder value.
       
  4046     sel size == 0 ifTrue:[ ^ nil ].
       
  4047     cls := self retrieverClass.
       
  4048     cls notNil ifTrue:[ 
       
  4049         clsName := retrieverHolder value.
       
  4050         clsName isEmptyOrNil ifTrue:[
       
  4051             clsName := cls name.
       
  4052         ].
       
  4053         clsName := clsName asSymbol.
       
  4054     ].
       
  4055 
       
  4056     rcv := ResourceRetriever new.
       
  4057     rcv className:clsName.
       
  4058     rcv selector:sel.
       
  4059 
       
  4060     iconAndLabelHolder value ifTrue:[ rcv labelText:'' ].
       
  4061     ^ rcv
       
  4062 !
       
  4063 
       
  4064 resourceRetriever:aResourceRetriever
       
  4065     |className sel isOn|
       
  4066 
       
  4067     aResourceRetriever notNil ifTrue:[
       
  4068         className := aResourceRetriever className.
       
  4069         className isBehavior ifTrue:[
       
  4070             className := className name asSymbol
       
  4071         ].
       
  4072         sel  := aResourceRetriever selector.
       
  4073         isOn := aResourceRetriever labelText notNil.
       
  4074     ] ifFalse:[
       
  4075         className := sel := nil.
       
  4076         isOn := false.
       
  4077     ].
       
  4078 
       
  4079     retrieverHolder value:className.
       
  4080     selectorHolder  value:sel.
       
  4081     iconAndLabelHolder value:isOn.
       
  4082 !
       
  4083 
       
  4084 retrieverClass
       
  4085     |clsName cls|
       
  4086 
       
  4087     clsName  := retrieverHolder value.
       
  4088     clsName notEmptyOrNil ifTrue:[
       
  4089         cls := Smalltalk at:clsName ifAbsent:nil.
       
  4090         (cls isBehavior) ifTrue:[
       
  4091             ^ cls
       
  4092         ].
       
  4093     ].
       
  4094     ^ nil
       
  4095 ! !
       
  4096 
       
  4097 !MenuEditor::ImageResourceEditor methodsFor:'actions'!
       
  4098 
       
  4099 doBrowseForImageResource
       
  4100     "opens a browser on image-resource methods"
       
  4101 
       
  4102     |classAndSelector|
       
  4103 
       
  4104     classAndSelector := ResourceSelectionBrowser
       
  4105 		request:'Use Image From Class'
       
  4106 		onSuperclass:nil
       
  4107 		andClass:(self retrieverClass)
       
  4108 		andSelector:(selectorHolder value)
       
  4109 		withResourceTypes:#(image fileImage programImage).
       
  4110 
       
  4111     classAndSelector isNil ifTrue:[ ^ self ].
       
  4112 
       
  4113     retrieverHolder value:(classAndSelector methodClass) name.
       
  4114     selectorHolder  value:(classAndSelector methodSelector).
       
  4115 !
       
  4116 
       
  4117 doBrowseImageClass
       
  4118     |cls sel image|
       
  4119 
       
  4120     (cls := retrieverHolder value) isNil ifTrue:[
       
  4121         Dialog warn:'No resource retriever is defined.'.
       
  4122     ] ifFalse:[
       
  4123         sel := selectorHolder value.
       
  4124 
       
  4125         cls := Smalltalk classNamed:cls.
       
  4126         cls isNil ifTrue:[
       
  4127             Dialog warn:'No such resource retriever class.'.
       
  4128         ] ifFalse:[
       
  4129             (cls respondsTo:#visualFor:) ifTrue:[
       
  4130                 image := cls visualFor:sel.
       
  4131                 image ~~ (cls perform:sel) ifTrue:[
       
  4132                     self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  4133                     sel := #visualFor:.
       
  4134                 ].
       
  4135             ].
       
  4136             UserPreferences current systemBrowserClass openInClass:cls class selector:sel
       
  4137         ]
       
  4138     ]
       
  4139 
       
  4140     "Created: / 20-09-2010 / 13:27:34 / cg"
       
  4141 !
       
  4142 
       
  4143 doEditImage
       
  4144     |sel cls item image|
       
  4145 
       
  4146     item := imageHolder value.
       
  4147     item notNil ifTrue:[
       
  4148         item doEdit.
       
  4149         ^ self.
       
  4150     ].
       
  4151 
       
  4152     sel := selectorHolder value. 
       
  4153     sel isNil ifTrue:[
       
  4154         Dialog warn:'No selector is defined.'.
       
  4155         ^ self.
       
  4156     ].
       
  4157     cls := retrieverHolder value.
       
  4158     cls isNil ifTrue:[
       
  4159         Dialog warn:'No resource retriever is defined.'.
       
  4160         ^ self.
       
  4161     ].
       
  4162     cls := Smalltalk classNamed:cls.
       
  4163     cls isNil ifTrue:[
       
  4164         Dialog warn:'No such resource retriever class.'.
       
  4165         ^ self.
       
  4166     ].
       
  4167     (cls respondsTo:#visualFor:) ifTrue:[
       
  4168         image := cls visualFor:sel.
       
  4169         image ~~ (cls perform:sel ifNotUnderstood:nil) ifTrue:[
       
  4170             self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  4171             image notNil ifTrue:[
       
  4172                 ImageEditor openOnImage:image.
       
  4173             ].
       
  4174             ^ self.
       
  4175         ].
       
  4176     ].
       
  4177 
       
  4178     ImageEditor openOnClass:cls andSelector:sel
       
  4179 ! !
       
  4180 
       
  4181 !MenuEditor::ImageResourceEditor methodsFor:'aspects'!
       
  4182 
       
  4183 entryCompletionForRetriever
       
  4184     ^ DoWhatIMeanSupport classNameEntryCompletionBlock.
       
  4185 
       
  4186     "Modified: / 10-08-2006 / 12:55:22 / cg"
       
  4187 !
       
  4188 
       
  4189 iconAndLabelHolder
       
  4190     ^ iconAndLabelHolder
       
  4191 !
       
  4192 
       
  4193 imageHolder
       
  4194     ^ imageHolder.
       
  4195 !
       
  4196 
       
  4197 imageList
       
  4198     ^ imageList
       
  4199 !
       
  4200 
       
  4201 modifiedChannel
       
  4202     ^ builder booleanValueAspectFor: #modifiedChannel
       
  4203 !
       
  4204 
       
  4205 modifiedChannel:aChannel
       
  4206     builder aspectAt:#modifiedChannel put:aChannel.
       
  4207 !
       
  4208 
       
  4209 retrieverHolder
       
  4210     ^ retrieverHolder
       
  4211 !
       
  4212 
       
  4213 retrieverList
       
  4214     |list cls|
       
  4215 
       
  4216     list := builder bindingAt:#retrieverList.
       
  4217     list isNil ifTrue:[
       
  4218         list := MenuEditor imageRetrieverClasses asList.
       
  4219         builder aspectAt:#retrieverList put:list.
       
  4220     ].
       
  4221     (masterApplication notNil 
       
  4222      and:[(cls := masterApplication specClass) notNil]) ifTrue:[
       
  4223         list := list copyWithFirst:cls.
       
  4224     ].
       
  4225     ^ list
       
  4226 !
       
  4227 
       
  4228 selectorFilterHolder
       
  4229     ^ selectorFilterHolder
       
  4230 
       
  4231     "Created: / 03-08-2011 / 10:01:05 / cg"
       
  4232 !
       
  4233 
       
  4234 selectorHolder
       
  4235     ^ selectorHolder.
       
  4236 ! !
       
  4237 
       
  4238 !MenuEditor::ImageResourceEditor methodsFor:'change & update'!
       
  4239 
       
  4240 retrieverChanged
       
  4241     |retriever list name|
       
  4242 
       
  4243     retriever := self retrieverClass.
       
  4244     imageHolder setValue:nil.
       
  4245 
       
  4246     self updateImageList.
       
  4247     self updateSelectedImage.
       
  4248 
       
  4249     (retriever notNil and:[imageList size ~~ 0]) ifTrue:[
       
  4250         list := self retrieverList.
       
  4251         name := retriever name.
       
  4252 
       
  4253         (list includes:name) ifFalse:[
       
  4254             list add:(name asSymbol).
       
  4255         ]
       
  4256     ].
       
  4257 
       
  4258     "Modified: / 03-08-2011 / 10:56:58 / cg"
       
  4259 !
       
  4260 
       
  4261 selectorChanged
       
  4262     self updateSelectedImage.
       
  4263 
       
  4264     "Modified: / 03-08-2011 / 10:56:04 / cg"
       
  4265 !
       
  4266 
       
  4267 selectorFilterChanged
       
  4268     self updateImageList.
       
  4269     self updateSelectedImage.
       
  4270 
       
  4271     "Created: / 03-08-2011 / 10:58:47 / cg"
       
  4272 !
       
  4273 
       
  4274 update:what with:aPara from:aModel
       
  4275     |item|
       
  4276 
       
  4277     self modifiedChannel value:true.
       
  4278 
       
  4279     aModel == retrieverHolder ifTrue:[ self retrieverChanged. ^ self ].
       
  4280     aModel == selectorHolder ifTrue:[ self selectorChanged. ^ self  ].
       
  4281     aModel == selectorFilterHolder ifTrue:[ self selectorFilterChanged. ^ self  ].
       
  4282 
       
  4283     aModel == imageHolder ifTrue:[
       
  4284         item := imageHolder value.
       
  4285         item ifNotNil:[ 
       
  4286             selectorHolder value:(item label) 
       
  4287         ].
       
  4288         ^ self
       
  4289     ].
       
  4290     super update:what with:aPara from:aModel
       
  4291 
       
  4292     "Modified: / 03-08-2011 / 10:58:37 / cg"
       
  4293 !
       
  4294 
       
  4295 updateImageList
       
  4296     |retriever selectorFilterString filter|
       
  4297 
       
  4298     retriever := self retrieverClass.
       
  4299 
       
  4300     filter := [:sel | true].
       
  4301     (selectorFilterString := selectorFilterHolder value) notEmptyOrNil ifTrue:[
       
  4302         selectorFilterString includesMatchCharacters ifTrue:[
       
  4303             filter := [:sel | selectorFilterString match:sel ignoreCase:true].
       
  4304         ] ifFalse:[
       
  4305             filter := [:sel | sel includesString:selectorFilterString].
       
  4306         ].
       
  4307     ].
       
  4308 
       
  4309     imageList root updateFromClass:retriever selectorFilter:filter.
       
  4310 
       
  4311     "Created: / 03-08-2011 / 10:56:41 / cg"
       
  4312 !
       
  4313 
       
  4314 updateSelectedImage
       
  4315     "provider or selector has changed; select it in the list"
       
  4316 
       
  4317     |item selector line|
       
  4318 
       
  4319     imageList isEmpty ifTrue:[^ self].
       
  4320 
       
  4321     selector := selectorHolder value.
       
  4322     selector isEmptyOrNil ifTrue:[ 
       
  4323         imageHolder value:nil. 
       
  4324         ^ self 
       
  4325     ].
       
  4326 
       
  4327     item     := nil.
       
  4328     selector := selector asSymbol.
       
  4329 
       
  4330     imageList do:[:anItem| 
       
  4331         |sel|
       
  4332 
       
  4333         sel := anItem selector.
       
  4334         selector == sel ifTrue:[
       
  4335             imageHolder value:anItem.
       
  4336             ^ self
       
  4337         ].
       
  4338         item isNil ifTrue:[
       
  4339             (sel startsWith:selector) ifTrue:[ item := anItem ]
       
  4340         ]
       
  4341     ].
       
  4342     imageHolder value:nil.
       
  4343 
       
  4344     item ifNotNil:[
       
  4345         line := imageList identityIndexOf:item.
       
  4346         line ~~ 0 ifTrue:[
       
  4347             "/ imageListView scrollToLine:line
       
  4348             imageListView makeLineVisible:line
       
  4349         ]
       
  4350     ].
       
  4351 
       
  4352     "Created: / 03-08-2011 / 10:55:45 / cg"
       
  4353 ! !
       
  4354 
       
  4355 !MenuEditor::ImageResourceEditor methodsFor:'initialization'!
       
  4356 
       
  4357 initialize
       
  4358     super initialize.
       
  4359 
       
  4360     iconAndLabelHolder := true asValue.
       
  4361     iconAndLabelHolder addDependent:self.
       
  4362 
       
  4363     imageHolder := nil asValue.
       
  4364 
       
  4365     selectorHolder := nil asValue.
       
  4366     selectorHolder addDependent:self.
       
  4367 
       
  4368     imageList := HierarchicalList new.
       
  4369     imageList application:self.
       
  4370     imageList root:(ImageResourceEditorItem new).
       
  4371     imageList showRoot:false.
       
  4372 
       
  4373     imageHolder := nil asValue.
       
  4374     imageHolder addDependent:self.
       
  4375 
       
  4376     retrieverHolder := nil asValue.
       
  4377     retrieverHolder addDependent:self.
       
  4378 
       
  4379     selectorFilterHolder := '' asValue.
       
  4380     selectorFilterHolder addDependent:self.
       
  4381 
       
  4382     "Modified: / 03-08-2011 / 10:18:46 / cg"
       
  4383 !
       
  4384 
       
  4385 postBuildImageViewer:aWidget
       
  4386     imageListView := aWidget.
       
  4387 ! !
       
  4388 
       
  4389 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'accessing'!
       
  4390 
       
  4391 icon
       
  4392     ^ icon
       
  4393 !
       
  4394 
       
  4395 label
       
  4396     ^ selector
       
  4397 !
       
  4398 
       
  4399 selector
       
  4400     ^ selector
       
  4401 ! !
       
  4402 
       
  4403 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'instance creation'!
       
  4404 
       
  4405 forClass:aClass selector:aSelector
       
  4406     |w h magnify iconOrSymbol|
       
  4407 
       
  4408     selector := aSelector asSymbol.
       
  4409     selector numArgs == 0 ifFalse:[^ self].
       
  4410 
       
  4411     "do what the ResourceRetriever will do"
       
  4412     (aClass respondsTo:#visualFor:) ifTrue:[
       
  4413         iconOrSymbol := aClass visualFor:selector.
       
  4414     ].
       
  4415     iconOrSymbol isNil ifTrue:[
       
  4416         iconOrSymbol := aClass perform:selector.
       
  4417     ].
       
  4418     iconOrSymbol isSymbol ifTrue:[
       
  4419         icon := ToolbarIconLibrary perform:iconOrSymbol.
       
  4420     ] ifFalse:[
       
  4421         icon := iconOrSymbol.
       
  4422     ].
       
  4423 
       
  4424     w := icon width.
       
  4425     h := icon height.
       
  4426 
       
  4427     w > 32 ifTrue:[
       
  4428         magnify := 32 / w.
       
  4429         h > 32 ifTrue:[ magnify := (32 / h) max:magnify ].
       
  4430     ] ifFalse:[
       
  4431         h > 32 ifFalse:[^ self].
       
  4432         magnify := 32 / h.
       
  4433     ].
       
  4434     icon := icon magnifiedBy: magnify.
       
  4435 
       
  4436     "Modified: / 13-04-2011 / 18:56:45 / cg"
       
  4437     "Created: / 03-08-2011 / 10:47:16 / cg"
       
  4438 !
       
  4439 
       
  4440 initialize
       
  4441     super initialize.
       
  4442     children := #().
       
  4443 !
       
  4444 
       
  4445 updateFromClass:aClass selectorFilter:aFilterBlock
       
  4446     |r item|
       
  4447 
       
  4448     (aClass notNil and:[aClass isBehavior]) ifFalse:[
       
  4449         ^ self collapse.
       
  4450     ].
       
  4451 "/    aClass == selector ifTrue:[
       
  4452 "/        ^ self expand
       
  4453 "/    ].
       
  4454     self collapse.
       
  4455 
       
  4456     selector := aClass.
       
  4457     children := OrderedCollection new.
       
  4458 
       
  4459     self application withWaitCursorDo:[
       
  4460         aClass withAllSuperclassesDo:[:aClass|
       
  4461             aClass class selectorsAndMethodsDo:[:sel :m|
       
  4462                 (aFilterBlock value:sel) ifTrue:[
       
  4463                     m hasResource ifTrue:[
       
  4464                         r := m resources.
       
  4465                         r notEmptyOrNil ifTrue:[
       
  4466                             ((r includesKey:#image) or:[r includesKey:#programImage]) ifTrue:[
       
  4467                                 item := self class new forClass:aClass selector:sel.
       
  4468                                 item parent:self.
       
  4469                                 children add:item
       
  4470                             ]
       
  4471                         ]
       
  4472                     ]
       
  4473                 ]
       
  4474             ]
       
  4475         ].
       
  4476         children sort:[:a :b | a label < b label ].
       
  4477         self expand
       
  4478     ].
       
  4479 
       
  4480     "Created: / 03-08-2011 / 10:48:10 / cg"
       
  4481 ! !
       
  4482 
       
  4483 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'user operations'!
       
  4484 
       
  4485 doEdit
       
  4486     "open image browser on self"
       
  4487 
       
  4488     |parent aClass image|
       
  4489 
       
  4490     parent := self parent.
       
  4491     parent notNil ifTrue:[
       
  4492         aClass := parent selector.
       
  4493         (aClass respondsTo:#visualFor:) ifTrue:[
       
  4494             image := aClass visualFor:selector.
       
  4495             image ~~ (aClass perform:selector) ifTrue:[
       
  4496                 self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  4497                 ImageEditor openOnImage:image.
       
  4498                 ^ self.
       
  4499             ].
       
  4500         ].
       
  4501         ImageEditor openOnClass:aClass andSelector:selector.
       
  4502     ].
  3889 ! !
  4503 ! !
  3890 
  4504 
  3891 !MenuEditor::ActionItem class methodsFor:'defaults'!
  4505 !MenuEditor::ActionItem class methodsFor:'defaults'!
  3892 
  4506 
  3893 defaultLabel
  4507 defaultLabel
  5110 
  5724 
  5111 isKindOfMenu
  5725 isKindOfMenu
  5112     ^ true
  5726     ^ true
  5113 ! !
  5727 ! !
  5114 
  5728 
  5115 !MenuEditor::ResourceEditor class methodsFor:'interface specs'!
       
  5116 
       
  5117 windowSpec
       
  5118     "This resource specification was automatically generated
       
  5119      by the UIPainter of ST/X."
       
  5120 
       
  5121     "Do not manually edit this!! If it is corrupted,
       
  5122      the UIPainter may not be able to read the specification."
       
  5123 
       
  5124     "
       
  5125      UIPainter new openOnClass:MenuEditor::ResourceEditor andSelector:#windowSpec
       
  5126      MenuEditor::ResourceEditor new openInterface:#windowSpec
       
  5127      MenuEditor::ResourceEditor open
       
  5128     "
       
  5129 
       
  5130     <resource: #canvas>
       
  5131 
       
  5132     ^ 
       
  5133      #(FullSpec
       
  5134         name: windowSpec
       
  5135         window: 
       
  5136        (WindowSpec
       
  5137           label: 'Image Item'
       
  5138           name: 'Image Item'
       
  5139           min: (Point 10 10)
       
  5140           bounds: (Rectangle 0 0 303 304)
       
  5141         )
       
  5142         component: 
       
  5143        (SpecCollection
       
  5144           collection: (
       
  5145            (LabelSpec
       
  5146               label: 'Retriever:'
       
  5147               name: 'retrieverLabel'
       
  5148               layout: (AlignmentOrigin 107 0 26 0 1 0.5)
       
  5149               activeHelpKey: imageRetriever
       
  5150               translateLabel: true
       
  5151               resizeForLabel: true
       
  5152               adjust: right
       
  5153             )
       
  5154            (ComboBoxSpec
       
  5155               name: 'retrieverHolder'
       
  5156               layout: (LayoutFrame 110 0 15 0 -20 1.0 37 0)
       
  5157               activeHelpKey: imageRetriever
       
  5158               tabable: true
       
  5159               model: retrieverHolder
       
  5160               type: symbolOrNil
       
  5161               immediateAccept: true
       
  5162               acceptOnReturn: false
       
  5163               acceptOnTab: false
       
  5164               acceptOnPointerLeave: false
       
  5165               entryCompletionBlock: entryCompletionForRetriever
       
  5166               comboList: retrieverList
       
  5167               isFilenameBox: false
       
  5168             )
       
  5169            (LabelSpec
       
  5170               label: 'Selector:'
       
  5171               name: 'iconLabel'
       
  5172               layout: (AlignmentOrigin 107 0 51 0 1 0.5)
       
  5173               activeHelpKey: imageSelector
       
  5174               translateLabel: true
       
  5175               resizeForLabel: true
       
  5176               adjust: right
       
  5177             )
       
  5178            (InputFieldSpec
       
  5179               name: 'selectorHolder'
       
  5180               layout: (LayoutFrame 110 0 40 0 -42 1.0 62 0)
       
  5181               activeHelpKey: imageSelector
       
  5182               tabable: true
       
  5183               model: selectorHolder
       
  5184               group: inputGroup
       
  5185               type: symbolOrNil
       
  5186               immediateAccept: true
       
  5187               acceptOnReturn: false
       
  5188               acceptOnTab: false
       
  5189               modifiedChannel: modifiedChannel
       
  5190               acceptOnPointerLeave: false
       
  5191             )
       
  5192            (ActionButtonSpec
       
  5193               label: '...'
       
  5194               name: 'browseButton'
       
  5195               layout: (LayoutFrame -40 1 40 0 -20 1 62 0)
       
  5196               activeHelpKey: browseResource
       
  5197               tabable: true
       
  5198               model: doBrowseForImageResource
       
  5199             )
       
  5200            (HierarchicalListViewSpec
       
  5201               name: 'imageList'
       
  5202               layout: (LayoutFrame 20 0.0 67 0 -20 1.0 -60 1.0)
       
  5203               activeHelpKey: imageImageList
       
  5204               model: imageHolder
       
  5205               menu: menuEditImage
       
  5206               hasHorizontalScrollBar: true
       
  5207               hasVerticalScrollBar: true
       
  5208               miniScrollerHorizontal: true
       
  5209               listModel: imageList
       
  5210               useIndex: false
       
  5211               highlightMode: label
       
  5212               postBuildCallback: postBuildImageViewer:
       
  5213             )
       
  5214            (ViewSpec
       
  5215               name: 'Box1'
       
  5216               layout: (LayoutFrame 20 0.0 -60 1.0 -20 1.0 0 1.0)
       
  5217               level: 0
       
  5218               component: 
       
  5219              (SpecCollection
       
  5220                 collection: (
       
  5221                  (CheckBoxSpec
       
  5222                     label: 'Image & Label'
       
  5223                     name: 'iconAndLabelCheckBox'
       
  5224                     layout: (AlignmentOrigin 0 0 17 0 0 0.5)
       
  5225                     activeHelpKey: imageImageAndLabel
       
  5226                     tabable: true
       
  5227                     model: iconAndLabelHolder
       
  5228                     translateLabel: true
       
  5229                   )
       
  5230                  (ActionButtonSpec
       
  5231                     label: 'Image Editor'
       
  5232                     name: 'imageEditorButton'
       
  5233                     layout: (AlignmentOrigin -69 1.0 17 0 0 0.5)
       
  5234                     activeHelpKey: imageImageEditor
       
  5235                     hasCharacterOrientedLabel: false
       
  5236                     foregroundColor: (Color 0.0 0.0 66.9993133440146)
       
  5237                     tabable: true
       
  5238                     model: doEditImage
       
  5239                   )
       
  5240                  (ActionButtonSpec
       
  5241                     label: 'Browse'
       
  5242                     name: 'Button1'
       
  5243                     layout: (AlignmentOrigin -69 1.0 45 0 0 0.5)
       
  5244                     activeHelpKey: imageBrowseImageClass
       
  5245                     hasCharacterOrientedLabel: false
       
  5246                     foregroundColor: (Color 0.0 0.0 66.9993133440146)
       
  5247                     tabable: true
       
  5248                     model: doBrowseImageClass
       
  5249                   )
       
  5250                  )
       
  5251                
       
  5252               )
       
  5253             )
       
  5254            )
       
  5255          
       
  5256         )
       
  5257       )
       
  5258 ! !
       
  5259 
       
  5260 !MenuEditor::ResourceEditor methodsFor:'accessing'!
       
  5261 
       
  5262 resourceRetriever
       
  5263     |rcv sel cls clsName|
       
  5264 
       
  5265     sel := selectorHolder value.
       
  5266     sel size == 0 ifTrue:[ ^ nil ].
       
  5267     cls := self retrieverClass.
       
  5268     cls notNil ifTrue:[ 
       
  5269         clsName := retrieverHolder value.
       
  5270         clsName isEmptyOrNil ifTrue:[
       
  5271             clsName := cls name.
       
  5272         ].
       
  5273         clsName := clsName asSymbol.
       
  5274     ].
       
  5275 
       
  5276     rcv := ResourceRetriever new.
       
  5277     rcv className:clsName.
       
  5278     rcv selector:sel.
       
  5279 
       
  5280     iconAndLabelHolder value ifTrue:[ rcv labelText:'' ].
       
  5281     ^ rcv
       
  5282 !
       
  5283 
       
  5284 resourceRetriever:aResourceRetriever
       
  5285     |className sel isOn|
       
  5286 
       
  5287     aResourceRetriever notNil ifTrue:[
       
  5288         className := aResourceRetriever className.
       
  5289         className isBehavior ifTrue:[
       
  5290             className := className name asSymbol
       
  5291         ].
       
  5292         sel  := aResourceRetriever selector.
       
  5293         isOn := aResourceRetriever labelText notNil.
       
  5294     ] ifFalse:[
       
  5295         className := sel := nil.
       
  5296         isOn := false.
       
  5297     ].
       
  5298 
       
  5299     retrieverHolder value:className.
       
  5300     selectorHolder  value:sel.
       
  5301     iconAndLabelHolder value:isOn.
       
  5302 !
       
  5303 
       
  5304 retrieverClass
       
  5305     |clsName cls|
       
  5306 
       
  5307     clsName  := retrieverHolder value.
       
  5308     clsName notEmptyOrNil ifTrue:[
       
  5309         cls := Smalltalk at:clsName ifAbsent:nil.
       
  5310         (cls isBehavior) ifTrue:[
       
  5311             ^ cls
       
  5312         ].
       
  5313     ].
       
  5314     ^ nil
       
  5315 ! !
       
  5316 
       
  5317 !MenuEditor::ResourceEditor methodsFor:'actions'!
       
  5318 
       
  5319 doBrowseForImageResource
       
  5320     "opens a browser on image-resource methods"
       
  5321 
       
  5322     |classAndSelector|
       
  5323 
       
  5324     classAndSelector := ResourceSelectionBrowser
       
  5325 		request:'Use Image From Class'
       
  5326 		onSuperclass:nil
       
  5327 		andClass:(self retrieverClass)
       
  5328 		andSelector:(selectorHolder value)
       
  5329 		withResourceTypes:#(image fileImage programImage).
       
  5330 
       
  5331     classAndSelector isNil ifTrue:[ ^ self ].
       
  5332 
       
  5333     retrieverHolder value:(classAndSelector methodClass) name.
       
  5334     selectorHolder  value:(classAndSelector methodSelector).
       
  5335 !
       
  5336 
       
  5337 doBrowseImageClass
       
  5338     |cls sel image|
       
  5339 
       
  5340     (cls := retrieverHolder value) isNil ifTrue:[
       
  5341         Dialog warn:'No resource retriever is defined.'.
       
  5342     ] ifFalse:[
       
  5343         sel := selectorHolder value.
       
  5344 
       
  5345         cls := Smalltalk classNamed:cls.
       
  5346         cls isNil ifTrue:[
       
  5347             Dialog warn:'No such resource retriever class.'.
       
  5348         ] ifFalse:[
       
  5349             (cls respondsTo:#visualFor:) ifTrue:[
       
  5350                 image := cls visualFor:sel.
       
  5351                 image ~~ (cls perform:sel) ifTrue:[
       
  5352                     self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5353                     sel := #visualFor:.
       
  5354                 ].
       
  5355             ].
       
  5356             UserPreferences current systemBrowserClass openInClass:cls class selector:sel
       
  5357         ]
       
  5358     ]
       
  5359 
       
  5360     "Created: / 20-09-2010 / 13:27:34 / cg"
       
  5361 !
       
  5362 
       
  5363 doEditImage
       
  5364     |sel cls item image|
       
  5365 
       
  5366     item := imageHolder value.
       
  5367     item notNil ifTrue:[
       
  5368         item doEdit.
       
  5369         ^ self.
       
  5370     ].
       
  5371 
       
  5372     sel := selectorHolder value. 
       
  5373     sel isNil ifTrue:[
       
  5374         Dialog warn:'No selector is defined.'.
       
  5375         ^ self.
       
  5376     ].
       
  5377     cls := retrieverHolder value.
       
  5378     cls isNil ifTrue:[
       
  5379         Dialog warn:'No resource retriever is defined.'.
       
  5380         ^ self.
       
  5381     ].
       
  5382     cls := Smalltalk classNamed:cls.
       
  5383     cls isNil ifTrue:[
       
  5384         Dialog warn:'No such resource retriever class.'.
       
  5385         ^ self.
       
  5386     ].
       
  5387     (cls respondsTo:#visualFor:) ifTrue:[
       
  5388         image := cls visualFor:sel.
       
  5389         image ~~ (cls perform:sel ifNotUnderstood:nil) ifTrue:[
       
  5390             self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5391             image notNil ifTrue:[
       
  5392                 ImageEditor openOnImage:image.
       
  5393             ].
       
  5394             ^ self.
       
  5395         ].
       
  5396     ].
       
  5397 
       
  5398     ImageEditor openOnClass:cls andSelector:sel
       
  5399 ! !
       
  5400 
       
  5401 !MenuEditor::ResourceEditor methodsFor:'aspects'!
       
  5402 
       
  5403 entryCompletionForRetriever
       
  5404     ^ DoWhatIMeanSupport classNameEntryCompletionBlock.
       
  5405 
       
  5406     "Modified: / 10-08-2006 / 12:55:22 / cg"
       
  5407 !
       
  5408 
       
  5409 iconAndLabelHolder
       
  5410     ^ iconAndLabelHolder
       
  5411 !
       
  5412 
       
  5413 imageHolder
       
  5414     ^ imageHolder.
       
  5415 !
       
  5416 
       
  5417 imageList
       
  5418     ^ imageList
       
  5419 !
       
  5420 
       
  5421 modifiedChannel
       
  5422     ^ builder booleanValueAspectFor: #modifiedChannel
       
  5423 !
       
  5424 
       
  5425 modifiedChannel:aChannel
       
  5426     builder aspectAt:#modifiedChannel put:aChannel.
       
  5427 !
       
  5428 
       
  5429 retrieverHolder
       
  5430     ^ retrieverHolder
       
  5431 !
       
  5432 
       
  5433 retrieverList
       
  5434     |list cls|
       
  5435 
       
  5436     list := builder bindingAt:#retrieverList.
       
  5437     list isNil ifTrue:[
       
  5438         list := MenuEditor imageRetrieverClasses asList.
       
  5439         builder aspectAt:#retrieverList put:list.
       
  5440     ].
       
  5441     (masterApplication notNil 
       
  5442      and:[(cls := masterApplication specClass) notNil]) ifTrue:[
       
  5443         list := list copyWithFirst:cls.
       
  5444     ].
       
  5445     ^ list
       
  5446 !
       
  5447 
       
  5448 selectorHolder
       
  5449     ^ selectorHolder.
       
  5450 ! !
       
  5451 
       
  5452 !MenuEditor::ResourceEditor methodsFor:'change & update'!
       
  5453 
       
  5454 retrieverChanged
       
  5455     |retriever list name|
       
  5456 
       
  5457     retriever := self retrieverClass.
       
  5458     imageHolder setValue:nil.
       
  5459 
       
  5460     imageList root fromClass:retriever.
       
  5461     self updateImageHolder.
       
  5462 
       
  5463     (retriever notNil and:[imageList size ~~ 0]) ifTrue:[
       
  5464         list := self retrieverList.
       
  5465         name := retriever name.
       
  5466 
       
  5467         (list includes:name) ifFalse:[
       
  5468             list add:(name asSymbol).
       
  5469         ]
       
  5470     ].
       
  5471 !
       
  5472 
       
  5473 selectorChanged
       
  5474     self updateImageHolder.
       
  5475 !
       
  5476 
       
  5477 update:what with:aPara from:aModel
       
  5478     |item|
       
  5479 
       
  5480     self modifiedChannel value:true.
       
  5481 
       
  5482     aModel == retrieverHolder ifTrue:[ ^ self retrieverChanged ].
       
  5483     aModel == selectorHolder  ifTrue:[ ^ self selectorChanged  ].
       
  5484 
       
  5485     aModel == imageHolder ifTrue:[
       
  5486         item := imageHolder value.
       
  5487         item ifNotNil:[ 
       
  5488             selectorHolder value:(item label) 
       
  5489         ].
       
  5490         ^ self
       
  5491     ].
       
  5492     super update:what with:aPara from:aModel
       
  5493 !
       
  5494 
       
  5495 updateImageHolder
       
  5496     |item selector line|
       
  5497 
       
  5498     imageList isEmpty ifTrue:[^ self].
       
  5499 
       
  5500     selector := selectorHolder value.
       
  5501     selector isEmptyOrNil ifTrue:[ 
       
  5502         imageHolder value:nil. 
       
  5503         ^ self 
       
  5504     ].
       
  5505 
       
  5506     item     := nil.
       
  5507     selector := selector asSymbol.
       
  5508 
       
  5509     imageList do:[:anItem| 
       
  5510         |sel|
       
  5511 
       
  5512         sel := anItem selector.
       
  5513         selector == sel ifTrue:[
       
  5514             imageHolder value:anItem.
       
  5515             ^ self
       
  5516         ].
       
  5517         item isNil ifTrue:[
       
  5518             (sel startsWith:selector) ifTrue:[ item := anItem ]
       
  5519         ]
       
  5520     ].
       
  5521     imageHolder value:nil.
       
  5522 
       
  5523     item ifNotNil:[
       
  5524         line := imageList identityIndexOf:item.
       
  5525         imageViewer scrollToLine:line
       
  5526     ].
       
  5527 ! !
       
  5528 
       
  5529 !MenuEditor::ResourceEditor methodsFor:'initialization'!
       
  5530 
       
  5531 initialize
       
  5532     super initialize.
       
  5533 
       
  5534     iconAndLabelHolder := true asValue.
       
  5535     iconAndLabelHolder addDependent:self.
       
  5536 
       
  5537     imageHolder := nil asValue.
       
  5538 
       
  5539     selectorHolder := nil asValue.
       
  5540     selectorHolder addDependent:self.
       
  5541 
       
  5542     imageList := HierarchicalList new.
       
  5543     imageList application:self.
       
  5544     imageList root:(MenuEditor::ResourceEditorItem new).
       
  5545     imageList showRoot:false.
       
  5546 
       
  5547     imageHolder := nil asValue.
       
  5548     imageHolder addDependent:self.
       
  5549 
       
  5550     retrieverHolder := nil asValue.
       
  5551     retrieverHolder addDependent:self.
       
  5552 !
       
  5553 
       
  5554 postBuildImageViewer:aWidget
       
  5555     imageViewer := aWidget.
       
  5556 ! !
       
  5557 
       
  5558 !MenuEditor::ResourceEditorItem class methodsFor:'instance creation'!
       
  5559 
       
  5560 fromClass:aClass selector:aSelector
       
  5561     |item|
       
  5562 
       
  5563     item := self new.
       
  5564     item fromClass:aClass selector:aSelector.
       
  5565     ^ item
       
  5566 ! !
       
  5567 
       
  5568 !MenuEditor::ResourceEditorItem methodsFor:'accessing'!
       
  5569 
       
  5570 icon
       
  5571     ^ icon
       
  5572 !
       
  5573 
       
  5574 label
       
  5575     ^ selector
       
  5576 !
       
  5577 
       
  5578 selector
       
  5579     ^ selector
       
  5580 ! !
       
  5581 
       
  5582 !MenuEditor::ResourceEditorItem methodsFor:'instance creation'!
       
  5583 
       
  5584 fromClass:aClass
       
  5585     |r item|
       
  5586 
       
  5587     (aClass notNil and:[aClass isBehavior]) ifFalse:[
       
  5588         ^ self collapse.
       
  5589     ].
       
  5590     aClass == selector ifTrue:[
       
  5591         ^ self expand
       
  5592     ].
       
  5593     self collapse.
       
  5594 
       
  5595     selector := aClass.
       
  5596     children := SortedCollection sortBlock:[:a :b| a label < b label ].
       
  5597 
       
  5598     self application withWaitCursorDo:[
       
  5599         aClass withAllSuperclassesDo:[:aClass|
       
  5600             aClass class selectorsAndMethodsDo:[:sel :m|
       
  5601                 r := m resourceType.
       
  5602                 ( #(#image #programImage) includes:r) ifTrue:[
       
  5603                     item := self class fromClass:aClass selector:sel.
       
  5604                     item parent:self.
       
  5605                     children add:item
       
  5606                 ]
       
  5607             ]
       
  5608         ].
       
  5609         self expand
       
  5610     ].
       
  5611 !
       
  5612 
       
  5613 fromClass:aClass selector:aSelector
       
  5614     |w h magnify iconOrSymbol|
       
  5615 
       
  5616     selector := aSelector asSymbol.
       
  5617     selector numArgs == 0 ifFalse:[^ self].
       
  5618 
       
  5619     "do what the ResourceRetriever will do"
       
  5620     (aClass respondsTo:#visualFor:) ifTrue:[
       
  5621         iconOrSymbol := aClass visualFor:selector.
       
  5622     ].
       
  5623     iconOrSymbol isNil ifTrue:[
       
  5624         iconOrSymbol := aClass perform:selector.
       
  5625     ].
       
  5626     iconOrSymbol isSymbol ifTrue:[
       
  5627         icon := ToolbarIconLibrary perform:iconOrSymbol.
       
  5628     ] ifFalse:[
       
  5629         icon := iconOrSymbol.
       
  5630     ].
       
  5631 
       
  5632     w := icon width.
       
  5633     h := icon height.
       
  5634 
       
  5635     w > 32 ifTrue:[
       
  5636         magnify := 32 / w.
       
  5637         h > 32 ifTrue:[ magnify := (32 / h) max:magnify ].
       
  5638     ] ifFalse:[
       
  5639         h > 32 ifFalse:[^ self].
       
  5640         magnify := 32 / h.
       
  5641     ].
       
  5642     icon := icon magnifiedBy: magnify.
       
  5643 
       
  5644     "Modified: / 13-04-2011 / 18:56:45 / cg"
       
  5645 !
       
  5646 
       
  5647 initialize
       
  5648     super initialize.
       
  5649     children := #().
       
  5650 ! !
       
  5651 
       
  5652 !MenuEditor::ResourceEditorItem methodsFor:'user operations'!
       
  5653 
       
  5654 doEdit
       
  5655     "open image browser on self"
       
  5656 
       
  5657     |parent aClass image|
       
  5658 
       
  5659     parent := self parent.
       
  5660     parent notNil ifTrue:[
       
  5661         aClass := parent selector.
       
  5662         (aClass respondsTo:#visualFor:) ifTrue:[
       
  5663             image := aClass visualFor:selector.
       
  5664             image ~~ (aClass perform:selector) ifTrue:[
       
  5665                 self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5666                 ImageEditor openOnImage:image.
       
  5667                 ^ self.
       
  5668             ].
       
  5669         ].
       
  5670         ImageEditor openOnClass:aClass andSelector:selector.
       
  5671     ].
       
  5672 ! !
       
  5673 
       
  5674 !MenuEditor::RootItem class methodsFor:'defaults'!
  5729 !MenuEditor::RootItem class methodsFor:'defaults'!
  5675 
  5730 
  5676 defaultLabel
  5731 defaultLabel
  5677     ^ MenuEditor resourceType
  5732     ^ MenuEditor resourceType
  5678 ! !
  5733 ! !