MenuEditor.st
author Claus Gittinger <cg@exept.de>
Tue, 14 May 2019 09:46:21 +0200
changeset 3663 9d49ecf8661a
parent 3636 197a2fbb8c5d
child 3664 0d01da886d5a
permissions -rw-r--r--
#UI_ENHANCEMENT by cg
class: TabListEditor class
changed:
#canvasSpec
#menu
#windowSpec
     1 "{ Encoding: utf8 }"
     2 
     3 "
     4  COPYRIGHT (c) 1997 by eXept Software AG
     5 	      All Rights Reserved
     6 
     7  This software is furnished under a license and may be used
     8  only in accordance with the terms of that license and with the
     9  inclusion of the above copyright notice. This software may not
    10  be provided or otherwise made available to, or used by, any
    11  other person.  No title to or ownership of the software is
    12  hereby transferred.
    13 "
    14 "{ Package: 'stx:libtool2' }"
    15 
    16 "{ NameSpace: Smalltalk }"
    17 
    18 ResourceSpecEditor subclass:#MenuEditor
    19 	instanceVariableNames:'selectionHolder tabHolder listOfItems listOfTabs
    20 		selectedSuperItems notifyDisabledCounter wizards listOfItemsView
    21 		dropOverLine savedSpec'
    22 	classVariableNames:'ImageRetrieverClasses'
    23 	poolDictionaries:''
    24 	category:'Interface-UIPainter'
    25 !
    26 
    27 HierarchicalItem subclass:#Item
    28 	instanceVariableNames:'menuItem'
    29 	classVariableNames:''
    30 	poolDictionaries:''
    31 	privateIn:MenuEditor
    32 !
    33 
    34 ApplicationModel subclass:#ImageResourceEditor
    35 	instanceVariableNames:'selectorHolder iconAndLabelHolder retrieverHolder imageHolder
    36 		imageList selectorFilterHolder imageListView'
    37 	classVariableNames:''
    38 	poolDictionaries:''
    39 	privateIn:MenuEditor
    40 !
    41 
    42 HierarchicalItem subclass:#ImageResourceEditorItem
    43 	instanceVariableNames:'selector icon'
    44 	classVariableNames:''
    45 	poolDictionaries:''
    46 	privateIn:MenuEditor::ImageResourceEditor
    47 !
    48 
    49 MenuEditor::Item subclass:#ActionItem
    50 	instanceVariableNames:''
    51 	classVariableNames:''
    52 	poolDictionaries:''
    53 	privateIn:MenuEditor
    54 !
    55 
    56 MenuEditor::Item subclass:#LinkedMenuItem
    57 	instanceVariableNames:''
    58 	classVariableNames:''
    59 	poolDictionaries:''
    60 	privateIn:MenuEditor
    61 !
    62 
    63 MenuEditor::Item subclass:#MenuSliceItem
    64 	instanceVariableNames:''
    65 	classVariableNames:''
    66 	poolDictionaries:''
    67 	privateIn:MenuEditor
    68 !
    69 
    70 MenuEditor::Item subclass:#RegularMenuItem
    71 	instanceVariableNames:''
    72 	classVariableNames:''
    73 	poolDictionaries:''
    74 	privateIn:MenuEditor
    75 !
    76 
    77 MenuEditor::RegularMenuItem subclass:#RootItem
    78 	instanceVariableNames:''
    79 	classVariableNames:''
    80 	poolDictionaries:''
    81 	privateIn:MenuEditor
    82 !
    83 
    84 MenuEditor::Item subclass:#SeparatorItem
    85 	instanceVariableNames:''
    86 	classVariableNames:''
    87 	poolDictionaries:''
    88 	privateIn:MenuEditor
    89 !
    90 
    91 !MenuEditor class methodsFor:'documentation'!
    92 
    93 copyright
    94 "
    95  COPYRIGHT (c) 1997 by eXept Software AG
    96 	      All Rights Reserved
    97 
    98  This software is furnished under a license and may be used
    99  only in accordance with the terms of that license and with the
   100  inclusion of the above copyright notice. This software may not
   101  be provided or otherwise made available to, or used by, any
   102  other person.  No title to or ownership of the software is
   103  hereby transferred.
   104 "
   105 !
   106 
   107 documentation
   108 "
   109     The MenuEditor allows you to create, modify or just inspect
   110     menu specifications. Such specifications are returned by menu-spec methods
   111     of the application class. These methods are typically tagged with a menu-resource.
   112     The menu editor is able to retrieve such specifications and generate new menu-spec
   113     methods.
   114 
   115     The editor is typically opened by double-clicking on a menu-spec method in the browser.
   116 
   117     [Instance variables:]
   118 
   119 	listOfItemsView         <HierarcicalListView>  the view which shows the list of items
   120 	listOfItems             <HierarchicalList>     hierarchical list of menu items
   121 	listOfTabs              <List>                 list of current shown tab-labels
   122 
   123 	selectionHolder         <ValueHolder>          collection of current selected items
   124 	selectedSuperItems      <Collection>           collection of superItems derived from selection
   125 
   126 	tabHolder               <ValueHolder>          selected tab label holder
   127 	notifyDisabledCounter   <SmallInteger>         ~~ 0 than change notifications are discard
   128 	wizards                 <IdentityDictionary>   keeps all created wizard dialogs
   129 
   130 	dropOverLine            <nil or SmallInteger>  nil: drop context not dropabel.
   131 						       = 0: drop context dropable but no item specified
   132 						       ~ 0: drop context dropable for item at lineNumber
   133 						       used t6o restore drop indication drawings
   134 
   135     [Class variables:]
   136 	ImageRetrieverClasses   <Collection>        sorted collection of image receivers
   137 
   138     [start with:]
   139 	MenuEditor open
   140 	MenuEditor openOnClass:MenuEditor andSelector:#menu
   141 
   142     [author:]
   143 	Claus Atzkern, eXept Software AG
   144 	Thomas Zwick, eXept Software AG
   145 "
   146 ! !
   147 
   148 !MenuEditor class methodsFor:'initialization'!
   149 
   150 initialize
   151     ImageRetrieverClasses := #(
   152 				Icon
   153 				SystemBrowser
   154 				ToolbarIconLibrary
   155 			      ).
   156 
   157     "
   158      self initialize
   159     "
   160 ! !
   161 
   162 !MenuEditor class methodsFor:'instance creation'!
   163 
   164 openModalOnMenu: aMenu
   165     "Open a MenuEditor modal on aMenu
   166      self openModalOnMenu: (self perform: #menu) decodeAsLiteralArray
   167     "
   168     ^self new openModalOnMenu:aMenu
   169 ! !
   170 
   171 !MenuEditor class methodsFor:'accessing image retriever'!
   172 
   173 addNewImageRetriever:aSymbolOrClass
   174     "add a class to the imageRetriever list"
   175 
   176     |key|
   177 
   178     aSymbolOrClass isBehavior ifTrue:[
   179 	key := aSymbolOrClass nameWithNameSpacePrefix
   180     ] ifFalse:[
   181 	key := aSymbolOrClass
   182     ].
   183 
   184     key size ~~ 0 ifTrue:[
   185 	key := key asSymbol.
   186 
   187 	(ImageRetrieverClasses includes:key) ifFalse:[
   188 	    ImageRetrieverClasses := ImageRetrieverClasses asOrderedCollection.
   189 	    ImageRetrieverClasses add:key.
   190 	    ImageRetrieverClasses sort.
   191 	]
   192     ].
   193 !
   194 
   195 imageRetrieverClasses
   196     "returns a collection of image retrievers
   197     "
   198     ^ ImageRetrieverClasses
   199 ! !
   200 
   201 !MenuEditor class methodsFor:'aspects'!
   202 
   203 aspects
   204     "get the aspects for the attributes of the menu components"
   205 
   206     ^#(
   207         rawLabel
   208         accessCharacterPosition
   209         showBusyCursorWhilePerforming
   210         horizontalLayout
   211         triggerOnDown
   212         font
   213         argument
   214         submenuChannel
   215         keepLinkedMenu
   216         enabled
   217         itemValue
   218         nameKey
   219         indication
   220         choice
   221         choiceValue
   222         translateLabel
   223         isButton
   224         shortcutKeyCharacter
   225         startGroup
   226         isVisible
   227         hideMenuOnActivated
   228         auxValue
   229         activeHelpKey
   230         resourceRetriever
   231         sendToOriginator
   232         ignoreMnemonicKeys
   233         ignoreShortcutKeys
   234         isMenuSlice
   235         hasMenuIndicator
   236      )
   237 
   238     "Modified: / 09-08-2018 / 17:03:56 / Claus Gittinger"
   239 ! !
   240 
   241 !MenuEditor class methodsFor:'defaults'!
   242 
   243 resourceType
   244     "get the type of the resource of the method generated by the MenuEditor
   245     "
   246     ^ #menu
   247 ! !
   248 
   249 !MenuEditor class methodsFor:'help specs'!
   250 
   251 helpSpec
   252     ^super helpSpec addPairsFrom: #(
   253 
   254 #editCut
   255 'Cut Item'
   256 
   257 #editCopy
   258 'Copy Item'
   259 
   260 #editPaste
   261 'Paste Item'
   262 
   263 #fileSaveSpec
   264 'Save Menuspec'
   265 
   266 #addMenuSlice
   267 'Add Menuslice'
   268 
   269 #addDelayedMenu
   270 'Add a new delayed menu to item.'
   271 
   272 #addDelayedSubMenuLink
   273 'Add a new linked delayed menu to item.'
   274 
   275 #addMenuItem
   276 'Add a new menu item.'
   277 
   278 #addMenuSeparator
   279 'Add a new menu separator.'
   280 
   281 #addMenuSliceItem
   282 'Add a new menu slice.'
   283 
   284 #addSubMenu
   285 'Add a new sub menu.'
   286 
   287 #addSubMenuLink
   288 'Add a new linked sub menu.'
   289 
   290 #basicsAction
   291 'An action selector with 0, 1 (the argument field), or 2 (the selected item) arguments.'
   292 
   293 #browseMethod
   294 'Open a browser on this method in the application. Create the method, if it does not exist.'
   295 
   296 #basicsArgument
   297 'An optional arg passed with above selector, if it is a 1 or 2 arg selector (enter a Smalltalk literal).'
   298 
   299 #basicsChoice
   300 'Aspect for a boolean holder, block or method, specifying the choices state (RadioButton behavior).'
   301 
   302 #basicsChoiceValue
   303 'That choices value (typically number or symbol).'
   304 
   305 #basicsIndication
   306 'Aspect for boolean holder, block, or method, specifying the indication state (CheckToggle behavior).'
   307 
   308 #basicsIsButton
   309 'Button-like look and behavior.'
   310 
   311 #basicsKey
   312 'Internal key of the item (optional, for programmed accesses).'
   313 
   314 #basicsLabel
   315 'Label of the item.'
   316 
   317 #basicsMenu
   318 'Aspect providing the sub menu to be opened if item is selected (provide spec or valueHolder).'
   319 
   320 #basicsMenuArgument
   321 'An argument passed with the menu selector.'
   322 
   323 #basicsNameKey
   324 'Unique identifier of the item (optional).'
   325 
   326 #basicsSelector
   327 'Selector under which the generated menu spec is saved.'
   328 
   329 #basicsSeparatorType
   330 'List of valid separators.'
   331 
   332 #basicsTranslateLabel
   333 'Translate the label via the classes resource file (internationalization).'
   334 
   335 #browseResource
   336 'Search for methods with image resource.'
   337 
   338 #detailsAccelerator
   339 'Accelerator key to select the menu item from the keyboard (Cmdx or Ctrlx).'
   340 
   341 #detailsAccessCharaterPosition
   342 'Index of the access character position of the textual label (obsolete, VW compatibility).'
   343 
   344 #detailsAuxValue
   345 'Some additional value - for arbitrary use by the program.'
   346 
   347 #detailsEnabled
   348 'Aspect or binding providing a boolean value holder to enable/disable the menu item.'
   349 
   350 #detailsIgnoreAcceleratorKeys
   351 'Ignore accelerator keys in submenu(s).'
   352 
   353 #detailsIgnoreMnemonicKeys
   354 'Ignore mnemonic keys (access characters) in submenu(s).'
   355 
   356 #detailsStartGroup
   357 'Specify start of a specially aligned group.'
   358 
   359 #detailsVisibility
   360 'Boolean, or aspect or binding for a boolean holder controlling the visibility of the menu item.'
   361 
   362 #fileLoad
   363 'Load a menu spec from a class.'
   364 
   365 #fileNew
   366 'Create a new menu spec.'
   367 
   368 #filePickAMenu
   369 'Select a menu from an open view and read its specification'
   370 
   371 #fileChooseAMenu
   372 'Select a menu from an open view and edit its spec-method'
   373 
   374 #fileSave
   375 'Save the menu spec (and the help spec, if modified).'
   376 
   377 #fileSaveAs
   378 'Open a dialog to save the menu spec (and the help spec, if modified).'
   379 
   380 #fileShowMenuSpec
   381 'Opens a Workspace showing the current menu spec.'
   382 
   383 #forceMenuIndicator
   384 'Always show a menu indicator in horizontal menu (little down-arrow).'
   385 
   386 #generateAspectMethods
   387 'Generates aspect methods for defined aspect selectors of the menu.'
   388 
   389 #hideMenuOnActivated
   390 'If on, the menu hides itself after the item was activated (PopUp/PullDown-Menus only).'
   391 
   392 #horizontalLayout
   393 'If on, the submenu organizes its items horizontal instead of vertical (default).'
   394 
   395 #imageImageAndLabel
   396 'Toggle display of both image and textual label.'
   397 
   398 #imageImageEditor
   399 'Open an Image Editor on the resource method defined by retriever and selector.'
   400 
   401 #imageBrowseImageClass
   402 'Open a Browser on the resource retriever class.'
   403 
   404 #imageImageList
   405 'Currently existing image resources.'
   406 
   407 #imageRetriever
   408 'Class implementing the image resource method. If unspecified, the application instance / class are asked.'
   409 
   410 #imageSelector
   411 'Selector returning an image (sent to above or the application).'
   412 
   413 #keepLinkedMenu
   414 'Keep the linked menu after activation (do not destroy; if off, menu is rebuild for every activation).'
   415 
   416 #sendToOriginator
   417 'Send action-Message to widget (instead of application); only valid for PopUpMenus.'
   418 
   419 #settingsRedefineAspectMethods
   420 'Toggles the permission to overwrite existing aspect methods.'
   421 
   422 #showBusyCursorWhilePerforming
   423 'If on, a busy cursor is shown while the items action is performing.'
   424 
   425 #triggerOnDown
   426 'If on, the items action is performed on mouse-button press (default is: on button-release).'
   427 
   428 #selectorFilter
   429 'In the list below, only matching selectors are shown'
   430 )
   431 
   432     "Modified: / 09-08-2018 / 17:09:02 / Claus Gittinger"
   433 ! !
   434 
   435 !MenuEditor class methodsFor:'image specs'!
   436 
   437 browseActionImage
   438     <resource: #programImage>
   439 
   440     ^ UIPainter browseActionImage
   441 !
   442 
   443 defaultIcon
   444     <resource: #programImage>
   445 
   446     ^ ToolbarIconLibrary startMenuEditorIcon
   447 !
   448 
   449 iconUnknown
   450     "returns an image used for picked items containing an image
   451     "
   452     <resource: #programImage>
   453 
   454     ^ MenuPanelSpec icon
   455 ! !
   456 
   457 !MenuEditor class methodsFor:'interface specs'!
   458 
   459 windowSpec
   460     "This resource specification was automatically generated
   461      by the UIPainter of ST/X."
   462 
   463     "Do not manually edit this!! If it is corrupted,
   464      the UIPainter may not be able to read the specification."
   465 
   466     "
   467      UIPainter new openOnClass:MenuEditor andSelector:#windowSpec
   468      MenuEditor new openInterface:#windowSpec
   469      MenuEditor open
   470     "
   471 
   472     <resource: #canvas>
   473 
   474     ^ 
   475     #(FullSpec
   476        name: windowSpec
   477        uuid: '7d4bc1c6-2067-11b2-b33d-3065ec8abe8a'
   478        window: 
   479       (WindowSpec
   480          label: 'Menu Editor'
   481          name: 'Menu Editor'
   482          uuid: '7d4bc6f8-2067-11b2-b33d-3065ec8abe8a'
   483          min: (Point 550 385)
   484          bounds: (Rectangle 0 0 574 473)
   485          menu: menu
   486          icon: defaultIcon
   487          returnIsOKInDialog: false
   488          escapeIsCancelInDialog: false
   489        )
   490        component: 
   491       (SpecCollection
   492          collection: (
   493           (MenuPanelSpec
   494              name: 'toolbar'
   495              layout: (LayoutFrame 0 0.0 0 0 0 1.0 32 0)
   496              uuid: '7d4bcc98-2067-11b2-b33d-3065ec8abe8a'
   497              tabable: true
   498              menu: toolbar
   499              showSeparatingLines: true
   500            )
   501           (VariableHorizontalPanelSpec
   502              name: 'mainPanel'
   503              layout: (LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
   504              uuid: '7d4bd2ba-2067-11b2-b33d-3065ec8abe8a'
   505              component: 
   506             (SpecCollection
   507                collection: (
   508                 (HierarchicalListViewSpec
   509                    name: 'ListOfItemsView'
   510                    uuid: '7d4bd7ba-2067-11b2-b33d-3065ec8abe8a'
   511                    model: selectionHolder
   512                    menu: editMenu
   513                    hasHorizontalScrollBar: true
   514                    hasVerticalScrollBar: true
   515                    miniScrollerHorizontal: true
   516                    miniScrollerVertical: true
   517                    listModel: listOfItems
   518                    multipleSelectOk: true
   519                    useIndex: false
   520                    highlightMode: label
   521                    doubleClickSelector: indicatorClickedAt:
   522                    selectConditionSelector: canSelect:
   523                    showLeftIndicators: false
   524                    indicatorSelector: indicatorClickedAt:
   525                    postBuildCallback: postBuildListOfItemsView:
   526                    properties: 
   527                   (PropertyListDictionary
   528                      dropSelector: doDrop:
   529                      dragArgument: nil
   530                      overSelector: dropOver:
   531                      canDropSelector: canDrop:
   532                      dropObjectSelector: dropObjects
   533                      enterSelector: dropEnter:
   534                      dropArgument: nil
   535                      leaveSelector: dropLeave:
   536                    )
   537                  )
   538                 (ViewSpec
   539                    name: 'Box'
   540                    uuid: '7d4be156-2067-11b2-b33d-3065ec8abe8a'
   541                    level: -1
   542                    component: 
   543                   (SpecCollection
   544                      collection: (
   545                       (NoteBookViewSpec
   546                          name: 'NoteBook'
   547                          layout: (LayoutFrame 1 0.0 0 0.0 1 1.0 -39 1.0)
   548                          uuid: '7d4be430-2067-11b2-b33d-3065ec8abe8a'
   549                          enableChannel: hasSingleSelectionChannel
   550                          tabable: true
   551                          model: tabHolder
   552                          menu: listOfTabs
   553                          fitLastRow: false
   554                          translateLabel: true
   555                          canvas: wizardHolder
   556                          keepCanvasAlive: true
   557                          postBuildCallback: postBuildNoteBook:
   558                        )
   559                       (UISubSpecification
   560                          name: 'SubSpecification'
   561                          layout: (LayoutFrame 2 0.0 -35 1.0 -2 1.0 -2 1.0)
   562                          uuid: '7d4beab6-2067-11b2-b33d-3065ec8abe8a'
   563                          majorKey: ToolApplicationModel
   564                          minorKey: windowSpecForCommit
   565                        )
   566                       )
   567                     
   568                    )
   569                  )
   570                 )
   571               
   572              )
   573              handles: (Any 0.29999999999999999 1.0)
   574            )
   575           (UISubSpecification
   576              name: 'infoBarSubSpec'
   577              layout: (LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
   578              uuid: '7d4bee30-2067-11b2-b33d-3065ec8abe8a'
   579              majorKey: ToolApplicationModel
   580              minorKey: windowSpecForInfoBar
   581            )
   582           )
   583         
   584        )
   585      )
   586 ! !
   587 
   588 !MenuEditor class methodsFor:'menu specs'!
   589 
   590 addMenu
   591     "This resource specification was automatically generated
   592      by the MenuEditor of ST/X."
   593 
   594     "Do not manually edit this!! If it is corrupted,
   595      the MenuEditor may not be able to read the specification."
   596 
   597     "
   598      MenuEditor new openOnClass:MenuEditor andSelector:#addMenu
   599      (Menu new fromLiteralArrayEncoding:(MenuEditor addMenu)) startUp
   600     "
   601 
   602     <resource: #menu>
   603 
   604     ^
   605      #(Menu
   606 	(
   607 	 (MenuItem
   608 	    activeHelpKey: addMenuSeparator
   609 	    label: 'Separator'
   610 	    itemValue: doCreateSep
   611 	    translateLabel: true
   612 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconSeparator '')
   613 	  )
   614 	 (MenuItem
   615 	    activeHelpKey: addMenuItem
   616 	    label: 'Item'
   617 	    itemValue: doCreateItem
   618 	    translateLabel: true
   619 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconItem '')
   620 	  )
   621 	 (MenuItem
   622 	    activeHelpKey: addMenuSliceItem
   623 	    label: 'Menu Slice'
   624 	    itemValue: doCreateMenuSliceItem
   625 	    translateLabel: true
   626 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconSliceMenu '')
   627 	  )
   628 	 (MenuItem
   629 	    activeHelpKey: addMenuItem
   630 	    label: 'Menu'
   631 	    itemValue: doCreateMenu
   632 	    translateLabel: true
   633 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconMenu '')
   634 	  )
   635 	 (MenuItem
   636 	    activeHelpKey: addSubMenuLink
   637 	    label: 'Linked Menu'
   638 	    itemValue: doCreateLinkedMenu
   639 	    translateLabel: true
   640 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconLinkedMenu '')
   641 	  )
   642 	 (MenuItem
   643 	    label: '-'
   644 	  )
   645 	 (MenuItem
   646 	    activeHelpKey: addDelayedMenu
   647 	    enabled: canCreateDelayedMenuChannel
   648 	    label: 'Delayed Menu'
   649 	    itemValue: doCreateDelayedMenu:
   650 	    translateLabel: true
   651 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconDelayedMenu '')
   652 	    argument: menu
   653 	  )
   654 	 (MenuItem
   655 	    activeHelpKey: addDelayedSubMenuLink
   656 	    enabled: canCreateDelayedMenuChannel
   657 	    label: 'Delayed Linked Menu'
   658 	    itemValue: doCreateDelayedMenu:
   659 	    translateLabel: true
   660 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconDelayedLinkedMenu '')
   661 	    argument: linkedMenu
   662 	  )
   663 	 (MenuItem
   664 	    label: '-'
   665 	  )
   666 	 (MenuItem
   667 	    label: 'Standard Menus'
   668 	    translateLabel: true
   669 	    submenuChannel: standardMenus
   670 	    keepLinkedMenu: true
   671 	  )
   672 	 )
   673 "/        nil
   674 "/        nil
   675       )
   676 !
   677 
   678 editMenu
   679     "This resource specification was automatically generated
   680      by the MenuEditor of ST/X."
   681 
   682     "Do not manually edit this!! If it is corrupted,
   683      the MenuEditor may not be able to read the specification."
   684 
   685     "
   686      MenuEditor new openOnClass:MenuEditor andSelector:#editMenu
   687      (Menu new fromLiteralArrayEncoding:(MenuEditor editMenu)) startUp
   688     "
   689 
   690     <resource: #menu>
   691 
   692     ^
   693      #(Menu
   694         (
   695          (MenuItem
   696             activeHelpKey: editCut
   697             enabled: hasSelectionChannel
   698             label: 'Cut'
   699             itemValue: doCut
   700             translateLabel: true
   701             shortcutKey: Cut
   702           )
   703          (MenuItem
   704             activeHelpKey: editCopy
   705             enabled: hasSelectionChannel
   706             label: 'Copy'
   707             itemValue: doCopy
   708             translateLabel: true
   709             shortcutKey: Copy
   710           )
   711          (MenuItem
   712             activeHelpKey: editPaste
   713             enabled: canPasteHolder
   714             label: 'Paste'
   715             itemValue: doPaste
   716             translateLabel: true
   717             shortcutKey: Paste
   718           )
   719          (MenuItem
   720             activeHelpKey: editDelete
   721             enabled: hasSelectionChannel
   722             label: 'Delete'
   723             itemValue: doDelete
   724             translateLabel: true
   725             isVisible: false
   726           )
   727          (MenuItem
   728             label: '-'
   729           )
   730          (MenuItem
   731             activeHelpKey: makeLinkedMenu
   732             enabled: hasNonLinkedMenuSelectedHolder
   733             label: 'Make Linked Menu...'
   734             itemValue: doMakeLinkedMenu
   735             translateLabel: true
   736           )
   737          (MenuItem
   738             label: '-'
   739           )
   740          (MenuItem
   741             activeHelpKey: editMoveUp
   742             enabled: enableMovingUpOrDownHolder
   743             label: 'Move Up'
   744             itemValue: doMoveUpOrDown:
   745             translateLabel: true
   746             startGroup: right
   747             shortcutKey: CtrlCursorUp
   748             labelImage: (ResourceRetriever Icon upIcon 'Move Up')
   749             argument: up
   750           )
   751          (MenuItem
   752             activeHelpKey: editMoveDown
   753             enabled: enableMovingUpOrDownHolder
   754             label: 'Move Down'
   755             itemValue: doMoveUpOrDown:
   756             translateLabel: true
   757             shortcutKey: CtrlCursorDown
   758             labelImage: (ResourceRetriever Icon downIcon 'Move Down')
   759             argument: down
   760           )
   761          (MenuItem
   762             activeHelpKey: editMoveIn
   763             enabled: enableMovingInHolder
   764             label: 'Move Into Next'
   765             itemValue: doMoveIn:
   766             translateLabel: true
   767             shortcutKey: CtrlCursorRight
   768             labelImage: (ResourceRetriever Icon downRightIcon 'Move Into Next')
   769             argument: inNext
   770           )
   771          (MenuItem
   772             activeHelpKey: editMoveInAbove
   773             enabled: enableMovingInAboveHolder
   774             label: 'Move Into Previous'
   775             itemValue: doMoveIn:
   776             translateLabel: true
   777             labelImage: (ResourceRetriever Icon upRightIcon 'Move Into Previous' )
   778             argument: inPrev
   779           )
   780          (MenuItem
   781             activeHelpKey: editMoveOut
   782             enabled: enableMovingOutHolder
   783             label: 'Move Out'
   784             itemValue: doMoveOut
   785             translateLabel: true
   786             shortcutKey: CtrlCursorLeft
   787             labelImage: (ResourceRetriever Icon leftDownIcon 'Move Out' )
   788           )
   789          )
   790         nil
   791         nil
   792       )
   793 !
   794 
   795 editMenuForMainMenuWithoutAccelerators
   796     "This resource specification was automatically generated
   797      by the MenuEditor of ST/X."
   798 
   799     "Do not manually edit this!! If it is corrupted,
   800      the MenuEditor may not be able to read the specification."
   801 
   802     "
   803      MenuEditor new openOnClass:MenuEditor andSelector:#editMenuForMainMenuWithoutAccelerators
   804      (Menu new fromLiteralArrayEncoding:(MenuEditor editMenuForMainMenuWithoutAccelerators)) startUp
   805     "
   806 
   807     <resource: #menu>
   808 
   809     ^
   810      #(Menu
   811 	(
   812 	 (MenuItem
   813 	    activeHelpKey: editCut
   814 	    enabled: hasSelectionChannel
   815 	    label: 'Cut'
   816 	    itemValue: doCut
   817 	    translateLabel: true
   818 	  )
   819 	 (MenuItem
   820 	    activeHelpKey: editCopy
   821 	    enabled: hasSelectionChannel
   822 	    label: 'Copy'
   823 	    itemValue: doCopy
   824 	    translateLabel: true
   825 	  )
   826 	 (MenuItem
   827 	    activeHelpKey: editPaste
   828 	    enabled: canPasteHolder
   829 	    label: 'Paste'
   830 	    itemValue: doPaste
   831 	    translateLabel: true
   832 	  )
   833 	 (MenuItem
   834 	    activeHelpKey: editDelete
   835 	    enabled: hasSelectionChannel
   836 	    label: 'Delete'
   837 	    itemValue: doDelete
   838 	    translateLabel: true
   839 	    isVisible: false
   840 	  )
   841 	 (MenuItem
   842 	    label: '-'
   843 	  )
   844 	 (MenuItem
   845 	    activeHelpKey: editMoveUp
   846 	    enabled: enableMovingUpOrDownHolder
   847 	    label: 'Move Up'
   848 	    itemValue: doMoveUpOrDown:
   849 	    translateLabel: true
   850 	    startGroup: right
   851 	    labelImage: (ResourceRetriever Icon upIcon 'Move Up')
   852 	    argument: up
   853 	  )
   854 	 (MenuItem
   855 	    activeHelpKey: editMoveDown
   856 	    enabled: enableMovingUpOrDownHolder
   857 	    label: 'Move Down'
   858 	    itemValue: doMoveUpOrDown:
   859 	    translateLabel: true
   860 	    labelImage: (ResourceRetriever Icon downIcon 'Move Down')
   861 	    argument: down
   862 	  )
   863 	 (MenuItem
   864 	    activeHelpKey: editMoveIn
   865 	    enabled: enableMovingInHolder
   866 	    label: 'Move Into Next'
   867 	    itemValue: doMoveIn:
   868 	    translateLabel: true
   869 	    labelImage: (ResourceRetriever Icon downRightIcon 'Move Into Next')
   870 	    argument: inNext
   871 	  )
   872 	 (MenuItem
   873 	    activeHelpKey: editMoveInAbove
   874 	    enabled: enableMovingInAboveHolder
   875 	    label: 'Move Into Previous'
   876 	    itemValue: doMoveIn:
   877 	    translateLabel: true
   878 	    labelImage: (ResourceRetriever Icon upRightIcon 'Move Into Previous')
   879 	    argument: inPrev
   880 	  )
   881 	 (MenuItem
   882 	    activeHelpKey: editMoveOut
   883 	    enabled: enableMovingOutHolder
   884 	    label: 'Move Out'
   885 	    itemValue: doMoveOut
   886 	    translateLabel: true
   887 	    labelImage: (ResourceRetriever Icon leftDownIcon 'Move Out')
   888 	  )
   889 	 )
   890 	nil
   891 	nil
   892       )
   893 !
   894 
   895 fileMenu
   896     "This resource specification was automatically generated
   897      by the MenuEditor of ST/X."
   898 
   899     "Do not manually edit this!! If it is corrupted,
   900      the MenuEditor may not be able to read the specification."
   901 
   902     "
   903      MenuEditor new openOnClass:MenuEditor andSelector:#fileMenu
   904      (Menu new fromLiteralArrayEncoding:(MenuEditor fileMenu)) startUp
   905     "
   906 
   907     <resource: #menu>
   908 
   909     ^
   910      #(Menu
   911 	(
   912 	 (MenuItem
   913 	    isVisible: isNotEditingSpecOnlyAndNotEmbeddedInBrowser
   914 	    activeHelpKey: fileNew
   915 	    label: 'New'
   916 	    itemValue: doNew
   917 	    translateLabel: true
   918 	  )
   919 	 (MenuItem
   920 	    isVisible: isNotEditingSpecOnlyAndNotEmbeddedInBrowser
   921 	    label: '-'
   922 	  )
   923 	 (MenuItem
   924 	    isVisible: isNotEditingSpecOnlyAndNotEmbeddedInBrowser
   925 	    activeHelpKey: fileLoad
   926 	    label: 'Load...'
   927 	    itemValue: doLoad
   928 	    translateLabel: true
   929 	  )
   930 	 (MenuItem
   931 	    isVisible: isNotEditingSpecOnlyAndNotEmbeddedInBrowser
   932 	    label: '-'
   933 	  )
   934 	 (MenuItem
   935 	    isVisible: isEditingSpecOnly
   936 	    activeHelpKey: fileSaveSpec
   937 	    label: 'Save'
   938 	    itemValue: doSave
   939 	    translateLabel: true
   940 	  )
   941 	 (MenuItem
   942 	    isVisible: isNotEditingSpecOnly
   943 	    activeHelpKey: fileSave
   944 	    label: 'Save'
   945 	    itemValue: doSave
   946 	    translateLabel: true
   947 	  )
   948 	 (MenuItem
   949 	    isVisible: isNotEditingSpecOnlyAndNotEmbeddedInBrowser
   950 	    activeHelpKey: fileSaveAs
   951 	    label: 'Save As...'
   952 	    itemValue: doSaveAs
   953 	    translateLabel: true
   954 	  )
   955 	 (MenuItem
   956 	    label: '-'
   957 	  )
   958 	 (MenuItem
   959 	    activeHelpKey: filePickAMenu
   960 	    label: 'Pick a Menu...'
   961 	    itemValue: doPickAMenu
   962 	    translateLabel: true
   963 	  )
   964 	 (MenuItem
   965 	    activeHelpKey: fileChooseAMenu
   966 	    label: 'Choose a Menu...'
   967 	    itemValue: doChooseAMenu
   968 	    translateLabel: true
   969 	  )
   970 	 (MenuItem
   971 	    label: '-'
   972 	    isVisible: isStandAlone
   973 	  )
   974 	 (MenuItem
   975 	    activeHelpKey: fileBrowseClass
   976 	    enabled: hasValidSpecClass
   977 	    label: 'Browse Class'
   978 	    itemValue: doBrowseClass
   979 	    translateLabel: true
   980 	    isVisible: isStandAlone
   981 	  )
   982 	 (MenuItem
   983 	    activeHelpKey: fileShowMenuSpec
   984 	    label: 'Show Menu Spec'
   985 	    itemValue: doShowMenuSpec
   986 	    translateLabel: true
   987 	    isVisible: isStandAlone
   988 	  )
   989 	 (MenuItem
   990 	    label: '-'
   991 	    isVisible: isStandAlone
   992 	  )
   993 	 (MenuItem
   994 	    activeHelpKey: fileExit
   995 	    label: 'Exit'
   996 	    itemValue: closeRequest
   997 	    translateLabel: true
   998 	    isVisible: isStandAlone
   999 	  )
  1000 	 )
  1001 	nil
  1002 	nil
  1003       )
  1004 !
  1005 
  1006 generateMenu
  1007     "This resource specification was automatically generated
  1008      by the MenuEditor of ST/X."
  1009 
  1010     "Do not manually edit this!! If it is corrupted,
  1011      the MenuEditor may not be able to read the specification."
  1012 
  1013     "
  1014      MenuEditor new openOnClass:MenuEditor andSelector:#generateMenu
  1015      (Menu new fromLiteralArrayEncoding:(MenuEditor generateMenu)) startUp
  1016     "
  1017 
  1018     <resource: #menu>
  1019 
  1020     ^
  1021      #(#Menu
  1022 	#(
  1023 	 #(#MenuItem
  1024 	    #activeHelpKey: #generateAspectMethods
  1025 	    #enabled: #hasValidSpecClass
  1026 	    #label: 'Aspect Methods'
  1027 	    #itemValue: #doGenerateAspectMethods
  1028 	    #translateLabel: true
  1029 	  )
  1030 	 )
  1031 	nil
  1032 	nil
  1033       )
  1034 !
  1035 
  1036 helpMenu
  1037     "This resource specification was automatically generated
  1038      by the MenuEditor of ST/X."
  1039 
  1040     "Do not manually edit this!! If it is corrupted,
  1041      the MenuEditor may not be able to read the specification."
  1042 
  1043     "
  1044      MenuEditor new openOnClass:MenuEditor andSelector:#helpMenu
  1045      (Menu new fromLiteralArrayEncoding:(MenuEditor helpMenu)) startUp
  1046     "
  1047 
  1048     <resource: #menu>
  1049 
  1050     ^
  1051      #(#Menu
  1052 	#(
  1053 	 #(#MenuItem
  1054 	    #activeHelpKey: #helpTutorial
  1055 	    #label: 'Documentation'
  1056 	    #itemValue: #openHTMLDocument:
  1057 	    #translateLabel: true
  1058 	    #argument: 'tools/uipainter/MenuEditor.html'
  1059 	  )
  1060 	 #(#MenuItem
  1061 	    #label: '-'
  1062 	  )
  1063 	 #(#MenuItem
  1064 	    #activeHelpKey: #helpHelpTool
  1065 	    #label: 'Help Tool'
  1066 	    #itemValue: #openHTMLDocument:
  1067 	    #translateLabel: true
  1068 	    #argument: 'tools/uipainter/HelpTool.html'
  1069 	  )
  1070 	 #(#MenuItem
  1071 	    #label: '-'
  1072 	  )
  1073 	 #(#MenuItem
  1074 	    #activeHelpKey: #helpShowHelp
  1075 	    #label: 'Show Help Texts'
  1076 	    #translateLabel: true
  1077 	    #indication: #showingHelp:
  1078 	  )
  1079 	 #(#MenuItem
  1080 	    #label: '-'
  1081 	  )
  1082 	 #(#MenuItem
  1083 	    #activeHelpKey: #aboutThisAppliaction
  1084 	    #label: 'About MenuEditor...'
  1085 	    #itemValue: #openAboutThisApplication
  1086 	    #translateLabel: true
  1087 	  )
  1088 	 )
  1089 	nil
  1090 	nil
  1091       )
  1092 !
  1093 
  1094 menu
  1095     "This resource specification was automatically generated
  1096      by the MenuEditor of ST/X."
  1097 
  1098     "Do not manually edit this!! If it is corrupted,
  1099      the MenuEditor may not be able to read the specification."
  1100 
  1101     "
  1102      MenuEditor new openOnClass:MenuEditor andSelector:#menu
  1103      (Menu new fromLiteralArrayEncoding:(MenuEditor menu)) startUp
  1104     "
  1105 
  1106     <resource: #menu>
  1107 
  1108     ^
  1109      #(Menu
  1110 	(
  1111 	 (MenuItem
  1112 	    label: '&File'
  1113 	    translateLabel: true
  1114 	    submenuChannel: fileMenu
  1115 	    keepLinkedMenu: true
  1116 	    ignoreMnemonicKeys: true
  1117 	    ignoreShortcutKeys: true
  1118 	  )
  1119 	 (MenuItem
  1120 	    label: '&Edit'
  1121 	    translateLabel: true
  1122 	    submenuChannel: editMenuForMainMenuWithoutAccelerators
  1123 	    keepLinkedMenu: true
  1124 	  )
  1125 	 (MenuItem
  1126 	    enabled: hasSingleSelectionChannel
  1127 	    label: 'Item'
  1128 	    translateLabel: true
  1129 	    submenuChannel: addMenu
  1130 	    keepLinkedMenu: true
  1131 	    ignoreMnemonicKeys: true
  1132 	    ignoreShortcutKeys: true
  1133 	  )
  1134 	 (MenuItem
  1135 	    isVisible: isNotEditingSpecOnly
  1136 	    label: 'Generate'
  1137 	    translateLabel: true
  1138 	    submenuChannel: generateMenu
  1139 	    keepLinkedMenu: true
  1140 	    ignoreMnemonicKeys: true
  1141 	    ignoreShortcutKeys: true
  1142 	  )
  1143 	 (MenuItem
  1144 	    label: 'Test'
  1145 	    translateLabel: true
  1146 	    submenuChannel: submenuTest
  1147 	    ignoreMnemonicKeys: true
  1148 	    ignoreShortcutKeys: true
  1149 	  )
  1150 	 (MenuItem
  1151 	    label: 'Settings'
  1152 	    translateLabel: true
  1153 	    submenuChannel: settingsMenu
  1154 	    keepLinkedMenu: true
  1155 	    ignoreMnemonicKeys: true
  1156 	    ignoreShortcutKeys: true
  1157 	  )
  1158 	 (MenuItem
  1159 	    label: 'History'
  1160 	    translateLabel: true
  1161 	    isVisible: isStandAlone
  1162 	    submenuChannel: menuHistory
  1163 	    ignoreMnemonicKeys: true
  1164 	    ignoreShortcutKeys: true
  1165 	  )
  1166 	 (MenuItem
  1167 	    label: 'MENU_Help'
  1168 	    translateLabel: true
  1169 	    startGroup: conditionalRight
  1170 	    submenuChannel: helpMenu
  1171 	    keepLinkedMenu: true
  1172 	    ignoreMnemonicKeys: true
  1173 	    ignoreShortcutKeys: true
  1174 	  )
  1175 	 )
  1176 	nil
  1177 	nil
  1178       )
  1179 !
  1180 
  1181 settingsMenu
  1182     "This resource specification was automatically generated
  1183      by the MenuEditor of ST/X."
  1184 
  1185     "Do not manually edit this!! If it is corrupted,
  1186      the MenuEditor may not be able to read the specification."
  1187 
  1188     "
  1189      MenuEditor new openOnClass:MenuEditor andSelector:#settingsMenu
  1190      (Menu new fromLiteralArrayEncoding:(MenuEditor settingsMenu)) startUp
  1191     "
  1192 
  1193     <resource: #menu>
  1194 
  1195     ^
  1196      #(#Menu
  1197 	#(
  1198 	 #(#MenuItem
  1199 	    isVisible: isNotEditingSpecOnly
  1200 	    #activeHelpKey: #settingsRedefineAspectMethods
  1201 	    #enabled: #hasValidSpecClass
  1202 	    #label: 'Redefine Aspect Methods'
  1203 	    #translateLabel: true
  1204 	    #hideMenuOnActivated: false
  1205 	    #indication: #redefineAspectMethodsChannel
  1206 	  )
  1207 	 #(#MenuItem
  1208 	    #activeHelpKey: #settingsRedefineAspectMethods
  1209 	    #label: 'AutoAccept on Selection-Change'
  1210 	    #translateLabel: true
  1211 	    #hideMenuOnActivated: false
  1212 	    #indication: #autoAcceptOnSelectionChange
  1213 	  )
  1214 	 )
  1215 	nil
  1216 	nil
  1217       )
  1218 !
  1219 
  1220 standardMenus
  1221     "This resource specification was automatically generated
  1222      by the MenuEditor of ST/X."
  1223 
  1224     "Do not manually edit this!! If it is corrupted,
  1225      the MenuEditor may not be able to read the specification."
  1226 
  1227     "
  1228      MenuEditor new openOnClass:MenuEditor andSelector:#standardMenus
  1229      (Menu new fromLiteralArrayEncoding:(MenuEditor standardMenus)) startUp
  1230     "
  1231 
  1232     <resource: #menu>
  1233 
  1234     ^
  1235      #(#Menu
  1236 	#(
  1237 	 #(#MenuItem
  1238 	    #label: 'Standard Menu: File'
  1239 	    #itemValue: #doCreateStandardFileMenu
  1240 	    #translateLabel: true
  1241 	  )
  1242 	 #(#MenuItem
  1243 	    #label: 'Standard Menu: Edit'
  1244 	    #itemValue: #doCreateStandardEditMenu
  1245 	    #translateLabel: true
  1246 	  )
  1247 	 #(#MenuItem
  1248 	    #label: 'Standard Menu: Help'
  1249 	    #itemValue: #doCreateStandardHelpMenu
  1250 	    #translateLabel: true
  1251 	  )
  1252 	 )
  1253 	nil
  1254 	nil
  1255       )
  1256 !
  1257 
  1258 toolbar
  1259     "This resource specification was automatically generated
  1260      by the MenuEditor of ST/X."
  1261 
  1262     "Do not manually edit this!! If it is corrupted,
  1263      the MenuEditor may not be able to read the specification."
  1264 
  1265     "
  1266      MenuEditor new openOnClass:MenuEditor andSelector:#toolbar
  1267      (Menu new fromLiteralArrayEncoding:(MenuEditor toolbar)) startUp
  1268     "
  1269 
  1270     <resource: #menu>
  1271 
  1272     ^
  1273      #(Menu
  1274 	(
  1275 	 (MenuItem
  1276 	    activeHelpKey: fileNew
  1277 	    label: 'New'
  1278 	    itemValue: doNew
  1279 	    translateLabel: true
  1280 	    isButton: true
  1281 	    labelImage: (ResourceRetriever ToolbarIconLibrary newMenuIcon)
  1282 	  )
  1283 	 (MenuItem
  1284 	    label: '-'
  1285 	  )
  1286 	 (MenuItem
  1287 	    activeHelpKey: fileLoad
  1288 	    label: 'Load'
  1289 	    itemValue: doLoad
  1290 	    translateLabel: true
  1291 	    isButton: true
  1292 	    isVisible: isNotEditingSpecOnly
  1293 	    submenuChannel: menuHistory
  1294 	    labelImage: (ResourceRetriever ToolbarIconLibrary loadFromMethodIcon)
  1295 	    keepLinkedMenu: true
  1296 	  )
  1297 	 (MenuItem
  1298 	    activeHelpKey: fileSave
  1299 	    label: 'Save'
  1300 	    itemValue: doSave
  1301 	    translateLabel: true
  1302 	    isButton: true
  1303 	    isVisible: isNotEditingSpecOnly
  1304 	    labelImage: (ResourceRetriever ToolbarIconLibrary saveAsMethodIcon)
  1305 	  )
  1306 	 (MenuItem
  1307 	    activeHelpKey: fileSaveSpec
  1308 	    label: 'Save'
  1309 	    itemValue: doSave
  1310 	    translateLabel: true
  1311 	    isButton: true
  1312 	    isVisible: isEditingSpecOnly
  1313 	    labelImage: (ResourceRetriever XPToolbarIconLibrary saveImageIcon)
  1314 	  )
  1315 	 (MenuItem
  1316 	    label: '-'
  1317 	  )
  1318 	 (MenuItem
  1319 	    activeHelpKey: editCut
  1320 	    enabled: hasSelectionChannel
  1321 	    label: 'Cut'
  1322 	    itemValue: doCut
  1323 	    translateLabel: true
  1324 	    isButton: true
  1325 	    labelImage: (ResourceRetriever ToolbarIconLibrary cutMenuItemIcon)
  1326 	  )
  1327 	 (MenuItem
  1328 	    activeHelpKey: editCopy
  1329 	    enabled: hasSelectionChannel
  1330 	    label: 'Copy'
  1331 	    itemValue: doCopy
  1332 	    translateLabel: true
  1333 	    isButton: true
  1334 	    labelImage: (ResourceRetriever ToolbarIconLibrary copyMenuItemIcon)
  1335 	  )
  1336 	 (MenuItem
  1337 	    activeHelpKey: editPaste
  1338 	    enabled: canPasteHolder
  1339 	    label: 'Paste'
  1340 	    itemValue: doPaste
  1341 	    translateLabel: true
  1342 	    isButton: true
  1343 	    labelImage: (ResourceRetriever ToolbarIconLibrary pasteMenuItemIcon)
  1344 	  )
  1345 	 (MenuItem
  1346 	    label: '-'
  1347 	  )
  1348 	 (MenuItem
  1349 	    activeHelpKey: addMenuItem
  1350 	    enabled: hasSingleSelectionChannel
  1351 	    label: 'Add Item'
  1352 	    itemValue: doCreateItem
  1353 	    translateLabel: true
  1354 	    isButton: true
  1355 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconItem)
  1356 	  )
  1357 	 (MenuItem
  1358 	    activeHelpKey: addMenuSeparator
  1359 	    enabled: hasSingleSelectionChannel
  1360 	    label: 'Add Separator'
  1361 	    itemValue: doCreateSep
  1362 	    translateLabel: true
  1363 	    isButton: true
  1364 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconSeparator)
  1365 	  )
  1366 	 (MenuItem
  1367 	    activeHelpKey: addMenuSlice
  1368 	    enabled: hasSingleSelectionChannel
  1369 	    label: 'Menu Slice'
  1370 	    itemValue: doCreateMenuSliceItem
  1371 	    translateLabel: true
  1372 	    isButton: true
  1373 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconSliceMenu)
  1374 	  )
  1375 	 (MenuItem
  1376 	    activeHelpKey: addSubMenu
  1377 	    enabled: hasSingleSelectionChannel
  1378 	    label: 'Add Menu'
  1379 	    itemValue: doCreateMenu
  1380 	    translateLabel: true
  1381 	    isButton: true
  1382 	    submenuChannel: standardMenus
  1383 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconMenu)
  1384 	    keepLinkedMenu: true
  1385 	  )
  1386 	 (MenuItem
  1387 	    activeHelpKey: addSubMenuLink
  1388 	    enabled: hasSingleSelectionChannel
  1389 	    label: 'Add Linked Menu'
  1390 	    itemValue: doCreateLinkedMenu
  1391 	    translateLabel: true
  1392 	    isButton: true
  1393 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconLinkedMenu)
  1394 	  )
  1395 	 (MenuItem
  1396 	    activeHelpKey: addDelayedMenu
  1397 	    enabled: canCreateDelayedMenuChannel
  1398 	    label: 'Add Delayed Menu'
  1399 	    itemValue: doCreateDelayedMenu:
  1400 	    translateLabel: true
  1401 	    isButton: true
  1402 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconDelayedMenu)
  1403 	    argument: menu
  1404 	  )
  1405 	 (MenuItem
  1406 	    activeHelpKey: addDelayedSubMenuLink
  1407 	    enabled: canCreateDelayedMenuChannel
  1408 	    label: 'Add Delayed Linked Menu'
  1409 	    itemValue: doCreateDelayedMenu:
  1410 	    translateLabel: true
  1411 	    isButton: true
  1412 	    labelImage: (ResourceRetriever #'MenuEditor::Item' iconDelayedLinkedMenu)
  1413 	    argument: linkedMenu
  1414 	  )
  1415 	 (MenuItem
  1416 	    label: ''
  1417 	  )
  1418 	 (MenuItem
  1419 	    activeHelpKey: editMoveUp
  1420 	    enabled: enableMovingUpOrDownHolder
  1421 	    label: 'Move Up'
  1422 	    itemValue: doMoveUp
  1423 	    translateLabel: true
  1424 	    isButton: true
  1425 	    startGroup: right
  1426 	    labelImage: (ResourceRetriever Icon upIcon)
  1427 	  )
  1428 	 (MenuItem
  1429 	    activeHelpKey: editMoveDown
  1430 	    enabled: enableMovingUpOrDownHolder
  1431 	    label: 'Move Down'
  1432 	    itemValue: doMoveDown
  1433 	    translateLabel: true
  1434 	    isButton: true
  1435 	    labelImage: (ResourceRetriever Icon downIcon)
  1436 	  )
  1437 	 (MenuItem
  1438 	    activeHelpKey: editMoveIn
  1439 	    enabled: enableMovingInHolder
  1440 	    label: 'Move Into Next'
  1441 	    itemValue: doMoveInNext
  1442 	    translateLabel: true
  1443 	    isButton: true
  1444 	    labelImage: (ResourceRetriever Icon downRightIcon)
  1445 	  )
  1446 	 (MenuItem
  1447 	    activeHelpKey: editMoveInAbove
  1448 	    enabled: enableMovingInAboveHolder
  1449 	    label: 'Move Into Previous'
  1450 	    itemValue: doMoveInPrevious
  1451 	    translateLabel: true
  1452 	    isButton: true
  1453 	    labelImage: (ResourceRetriever Icon upRightIcon)
  1454 	  )
  1455 	 (MenuItem
  1456 	    activeHelpKey: editMoveOut
  1457 	    enabled: enableMovingOutHolder
  1458 	    label: 'Move Out'
  1459 	    itemValue: doMoveOut
  1460 	    translateLabel: true
  1461 	    isButton: true
  1462 	    labelImage: (ResourceRetriever Icon leftDownIcon)
  1463 	  )
  1464 	 )
  1465 	nil
  1466 	nil
  1467       )
  1468 ! !
  1469 
  1470 !MenuEditor class methodsFor:'menu specs-standard'!
  1471 
  1472 standardEditMenu
  1473     "This resource specification was automatically generated
  1474      by the MenuEditor of ST/X."
  1475 
  1476     "Do not manually edit this!! If it is corrupted,
  1477      the MenuEditor may not be able to read the specification."
  1478 
  1479     "
  1480      MenuEditor new openOnClass:MenuEditor andSelector:#standardEditMenu
  1481      (Menu new fromLiteralArrayEncoding:(MenuEditor standardEditMenu)) startUp
  1482     "
  1483 
  1484     <resource: #menu>
  1485 
  1486     ^
  1487      #(#Menu
  1488 	#(
  1489 	 #(#MenuItem
  1490 	    #label: 'Cut'
  1491 	    #translateLabel: true
  1492 	    #value: #cutSelection
  1493 	  )
  1494 	 #(#MenuItem
  1495 	    #label: 'Copy'
  1496 	    #translateLabel: true
  1497 	    #value: #copySelection
  1498 	  )
  1499 	 #(#MenuItem
  1500 	    #label: 'Paste'
  1501 	    #translateLabel: true
  1502 	    #value: #paste
  1503 	  )
  1504 	 )
  1505 	nil
  1506 	nil
  1507       )
  1508 !
  1509 
  1510 standardFileMenu
  1511     "This resource specification was automatically generated
  1512      by the MenuEditor of ST/X."
  1513 
  1514     "Do not manually edit this!! If it is corrupted,
  1515      the MenuEditor may not be able to read the specification."
  1516 
  1517     "
  1518      MenuEditor new openOnClass:MenuEditor andSelector:#standardFileMenu
  1519      (Menu new fromLiteralArrayEncoding:(MenuEditor standardFileMenu)) startUp
  1520     "
  1521 
  1522     <resource: #menu>
  1523 
  1524     ^
  1525      #(#Menu
  1526 	#(
  1527 	 #(#MenuItem
  1528 	    #label: 'New'
  1529 	    #translateLabel: true
  1530 	    #value: #menuNew
  1531 	  )
  1532 	 #(#MenuItem
  1533 	    #label: '-'
  1534 	  )
  1535 	 #(#MenuItem
  1536 	    #label: 'Open...'
  1537 	    #translateLabel: true
  1538 	    #value: #menuOpen
  1539 	  )
  1540 	 #(#MenuItem
  1541 	    #label: '-'
  1542 	  )
  1543 	 #(#MenuItem
  1544 	    #label: 'Save'
  1545 	    #translateLabel: true
  1546 	    #value: #menuSave
  1547 	  )
  1548 	 #(#MenuItem
  1549 	    #label: 'Save As...'
  1550 	    #translateLabel: true
  1551 	    #value: #menuSaveAs
  1552 	  )
  1553 	 #(#MenuItem
  1554 	    #label: '-'
  1555 	  )
  1556 	 #(#MenuItem
  1557 	    #label: 'Exit'
  1558 	    #translateLabel: true
  1559 	    #value: #closeRequest
  1560 	  )
  1561 	 )
  1562 	nil
  1563 	nil
  1564       )
  1565 !
  1566 
  1567 standardHelpMenu
  1568     "This resource specification was automatically generated
  1569      by the MenuEditor of ST/X."
  1570 
  1571     "Do not manually edit this!! If it is corrupted,
  1572      the MenuEditor may not be able to read the specification."
  1573 
  1574     "
  1575      MenuEditor new openOnClass:MenuEditor andSelector:#standardHelpMenu
  1576      (Menu new fromLiteralArrayEncoding:(MenuEditor standardHelpMenu)) startUp
  1577     "
  1578 
  1579     <resource: #menu>
  1580 
  1581     ^
  1582      #(#Menu
  1583 	#(
  1584 	 #(#MenuItem
  1585 	    #label: 'Documentation'
  1586 	    #translateLabel: true
  1587 	    #value: #openDocumentation
  1588 	  )
  1589 	 #(#MenuItem
  1590 	    #label: '-'
  1591 	  )
  1592 	 #(#MenuItem
  1593 	    #label: 'About this Application...'
  1594 	    #translateLabel: true
  1595 	    #value: #openAboutThisApplication
  1596 	  )
  1597 	 )
  1598 	nil
  1599 	nil
  1600       )
  1601 ! !
  1602 
  1603 !MenuEditor methodsFor:'accessing'!
  1604 
  1605 helpSpec
  1606     |spec t g|
  1607 
  1608     spec := super helpSpec.
  1609     t := spec at:#detailsStartGroup.
  1610     g := (aspects at:#startGroup ifAbsent:nil) value.
  1611     g == #conditionalRight ifTrue:[
  1612         t := t , ' #conditionalRight means: "right on non-win32 systems"'
  1613     ].
  1614     g == #right ifTrue:[
  1615         t := t , ' #right means: "right align from here"'
  1616     ].
  1617     g == #left ifTrue:[
  1618         t := t , ' #left means: "left align group"'
  1619     ].
  1620     spec at:#detailsStartGroup put:t.
  1621 
  1622     ^ spec.
  1623 "/ #detailsStartGroup
  1624 "/ 'Specify start of a right-aligned item group.'
  1625 
  1626     "Created: / 16-10-2006 / 13:19:14 / cg"
  1627 !
  1628 
  1629 helpTool
  1630     "get the help tool application
  1631     "
  1632     ^ wizards at:#help ifAbsentPut:[ |tool|
  1633 	tool := UIHelpTool new.
  1634 	tool masterApplication:self.
  1635 	tool modifiedHolder: self enablingCommitButtonsHolder.
  1636 	tool builder window:(ApplicationSubView new client:tool spec:#innerSpec).
  1637 	tool masterApplication:self.
  1638 	tool
  1639     ]
  1640 !
  1641 
  1642 imageTool
  1643     "get the image tool application"
  1644 
  1645     ^ wizards
  1646 	at:#image
  1647 	ifAbsentPut:[
  1648 	    |tool|
  1649 
  1650 	    tool := ImageResourceEditor new createBuilder.
  1651 	    tool masterApplication:self.
  1652 	    tool modifiedChannel: self enablingCommitButtonsHolder.
  1653 	    tool builder window:(ApplicationSubView new client:tool).
  1654 	    tool
  1655 	]
  1656 
  1657     "Modified: / 03-08-2011 / 10:03:08 / cg"
  1658 !
  1659 
  1660 savedSpec
  1661     ^ savedSpec
  1662 !
  1663 
  1664 useHelpTool:aHelpTool
  1665     "take the help dictionaries from aHelpTool into my helpTool
  1666     "
  1667     self helpTool loadFromHelpTool:aHelpTool.
  1668 ! !
  1669 
  1670 !MenuEditor methodsFor:'actions'!
  1671 
  1672 accept
  1673     "accept modifications
  1674     "
  1675     self accept:true.
  1676 !
  1677 
  1678 accept:ok
  1679     "if ok is true, the modifications are accepted.
  1680      then reload from item
  1681     "
  1682     |selectedItem rscRetrHolder helpKeyHolder helpTool imageTool acceptChannel|
  1683 
  1684     selectedItem := self selectedItem.
  1685 
  1686     selectedItem notNil ifTrue:[
  1687 	self withoutNotifyDo:[
  1688 	    rscRetrHolder := aspects at:#resourceRetriever.
  1689 	    helpKeyHolder := aspects at:#activeHelpKey.
  1690 	    imageTool     := self imageTool.
  1691 	    helpTool      := self helpTool.
  1692 	    acceptChannel := self acceptChannel.
  1693 
  1694 	    acceptChannel triggerValue:true.
  1695 	    acceptChannel setValue:false.
  1696 
  1697 	    ok ifTrue:[
  1698 		helpTool accept.
  1699 		rscRetrHolder value:(imageTool resourceRetriever).
  1700 		helpKeyHolder value:(helpTool helpKey).
  1701 		selectedItem  fromAspects:aspects.
  1702 		self setModified.
  1703 
  1704 		selectedItem isRootItem ifTrue:[
  1705 		    "/ update specSelector
  1706 		    specSelector := selectedItem rawLabel.
  1707 		].
  1708 	    ].
  1709 	    selectedItem toAspects:aspects.
  1710 	    helpTool     helpKey:(helpKeyHolder value).
  1711 	    imageTool    resourceRetriever:(rscRetrHolder value).
  1712 	]
  1713     ].
  1714     self updateChannels.
  1715 "/    self clearModified.
  1716     self clearModifiedFlag.
  1717 
  1718     self enablingCommitButtonsHolder value:false.
  1719 
  1720     "Modified: / 29-11-2011 / 11:28:02 / cg"
  1721 !
  1722 
  1723 cancel
  1724     "reload aspects from current selected item; reset modification flag"
  1725 
  1726     self accept:false.
  1727 
  1728     "Modified: / 29-08-2006 / 10:20:46 / cg"
  1729 !
  1730 
  1731 indicatorClickedAt:atLine
  1732     "indicator clicked at line number; toggle expand of item at line
  1733     "
  1734     |item|
  1735 
  1736     item := listOfItems at:atLine ifAbsent:nil.
  1737     item notNil ifTrue:[
  1738 	item toggleExpand.
  1739 	self hasSelection ifFalse:[
  1740 	    self selectedItem:item
  1741 	]
  1742     ].
  1743 
  1744     "Modified: / 29-11-2011 / 11:28:20 / cg"
  1745 ! !
  1746 
  1747 !MenuEditor methodsFor:'aspects'!
  1748 
  1749 canCreateDelayedMenuChannel
  1750     "boolean holder, true if the current selected item accepts a delayed menu
  1751     "
  1752     ^ builder booleanValueAspectFor:#canCreateDelayedMenuChannel
  1753 !
  1754 
  1755 hasItemValue
  1756     "boolean holder, true if any item is selected
  1757     "
  1758     ^ BlockValue
  1759 	with:[:holder | holder size > 0]
  1760 	argument:(self aspectFor:#itemValue)
  1761 
  1762     "Modified: / 08-03-2007 / 22:59:42 / cg"
  1763 !
  1764 
  1765 hasNonLinkedMenuSelectedHolder
  1766     "boolean holder, true if a single non linked menu item is selected
  1767     "
  1768     ^ BlockValue
  1769         with:[:m | 
  1770                 |items| 
  1771 
  1772                 items := self selectionHolder value.
  1773                 (items size == 1) 
  1774                 and:[items first isKindOfNonLinkedMenu
  1775                 and:[items first isRootItem not]]
  1776              ]
  1777         argument:(self selectionHolder)
  1778 !
  1779 
  1780 hasSelectionChannel
  1781     "boolean holder, true if any item is selected
  1782     "
  1783     ^ builder booleanValueAspectFor:#hasSelectionChannel
  1784 !
  1785 
  1786 hasSingleSelectionChannel
  1787     "boolean holder, true if one item is selected
  1788     "
  1789     ^ builder booleanValueAspectFor:#hasSingleSelectionChannel
  1790 !
  1791 
  1792 listOfItems
  1793     "returns the hierarchical list of menuItems
  1794     "
  1795     ^ listOfItems
  1796 !
  1797 
  1798 listOfTabs
  1799     "returns the list of current shown tab-labels retrieved
  1800      from the current selected item.
  1801     "
  1802     ^ listOfTabs
  1803 !
  1804 
  1805 redefineAspectMethodsChannel
  1806     "boolean holder, true if aspects should be generated in only implemented
  1807      in superClass by calling #super ...
  1808     "
  1809     ^ builder booleanValueAspectFor:#redefineAspectMethodsChannel
  1810 !
  1811 
  1812 selectionHolder
  1813     "value holder, which keeps the current selected items
  1814     "
  1815     ^ selectionHolder
  1816 !
  1817 
  1818 tabHolder
  1819     "value holder, which keeps the current selected tab label or nil
  1820     "
  1821     ^ tabHolder
  1822 !
  1823 
  1824 wizardHolder
  1825     "holder, which keeps the current wizard window
  1826     "
  1827     |holder|
  1828 
  1829     holder := builder bindingAt:#wizardHolder.
  1830 
  1831     holder isNil ifTrue:[
  1832 	holder := nil asValue.
  1833 	builder aspectAt:#wizardHolder put:holder.
  1834     ].
  1835     ^ holder
  1836 ! !
  1837 
  1838 !MenuEditor methodsFor:'building'!
  1839 
  1840 buildFromMenu:aMenu selector:aSelector
  1841     "rebuild menu from a Menu
  1842     "
  1843     |root menu|
  1844 
  1845     aMenu isCollection ifTrue:[menu := aMenu decodeAsLiteralArray]
  1846 		      ifFalse:[menu := aMenu].
  1847 
  1848     self enablingCommitButtonsHolder value:false.
  1849     root := listOfItems root.
  1850 
  1851     self withoutNotifyDo:[
  1852 	selectionHolder setValue:#().
  1853 	root menu:aMenu labeled:(aSelector ? specSelector).
  1854     ].
  1855     self selectedItem:root.
  1856     self updateHistory.
  1857 !
  1858 
  1859 buildFromResourceSpec:aResourceSpec
  1860     "rebuild the menu from a resource spec"
  1861 
  1862     self buildFromMenu:aResourceSpec selector:nil
  1863 !
  1864 
  1865 loadFromClass:aClass andSelector:aSelector
  1866     "rebuild menu from a class and selector"
  1867 
  1868     |cls menu|
  1869 
  1870     self assert:(aClass isNil or:[aClass isClass]).
  1871 
  1872     menu := nil.
  1873 
  1874     self isStandAlone ifTrue:[ self helpTool loadFromClass:aClass ].
  1875 
  1876     specClass := aClass.
  1877     specSelector := aSelector.
  1878 
  1879     aSelector notNil ifTrue:[
  1880 	aClass notNil ifTrue:[
  1881 	    cls := aClass isBehavior ifTrue:[ aClass ] ifFalse:[ self resolveName:aClass].
  1882 
  1883 	    (cls respondsTo:aSelector) ifTrue:[
  1884 		menu := cls perform: aSelector.
  1885 	    ].
  1886 	].
  1887     ].
  1888     self loadFromMenu:menu selector:aSelector.
  1889 !
  1890 
  1891 loadFromMenu:menuArg selector:selectorOrNil
  1892     "rebuild menu"
  1893 
  1894     |menu|
  1895 
  1896     menu := menuArg.
  1897     menu notNil ifTrue:[
  1898 	(menu isCollection) ifTrue:[
  1899 	    menu := Menu decodeFromLiteralArray:menu
  1900 	].
  1901     ].
  1902     self buildFromMenu:menu selector:selectorOrNil.
  1903     self clearModified.
  1904 
  1905     "Modified: / 27-03-2007 / 11:16:47 / cg"
  1906 ! !
  1907 
  1908 !MenuEditor methodsFor:'change & update'!
  1909 
  1910 selectedSuperItems
  1911     "returns collection of superItems derived from selection
  1912     "
  1913     |selection size root|
  1914 
  1915     selectedSuperItems notNil ifTrue:[ ^ selectedSuperItems ].
  1916 
  1917     selection := selectionHolder value.
  1918     size      := selection size.
  1919 
  1920     size <= 1 ifTrue:[
  1921 	selectedSuperItems := selection ? #().
  1922       ^ selectedSuperItems
  1923     ].
  1924 
  1925     root := listOfItems root.
  1926 
  1927     (selection includesIdentical:root) ifTrue:[
  1928 	selectedSuperItems := Array with:root.
  1929       ^ selectedSuperItems
  1930     ].
  1931     selectedSuperItems := OrderedCollection new.
  1932 
  1933     selection do:[:anItem|
  1934 	anItem parentsDetect:[:el| selection includesIdentical:el ]
  1935 		      ifNone:[ selectedSuperItems add:anItem ].
  1936     ].
  1937     ^ selectedSuperItems
  1938 
  1939     "Modified: / 29-11-2011 / 11:28:23 / cg"
  1940 !
  1941 
  1942 selectionChanged
  1943     "called if the selection has changed
  1944     "
  1945     |newTabList selection|
  1946 
  1947     selection := selectionHolder value.
  1948 
  1949     selection size == 1 ifTrue:[
  1950 	selectedSuperItems := selection.
  1951 
  1952 	newTabList := selection first slices collect:[:el| el first ].
  1953 	newTabList = listOfTabs ifFalse:[
  1954 	    listOfTabs contents:newTabList.
  1955 	].
  1956     ] ifFalse:[
  1957 	"must compute selected super items on request
  1958 	"
  1959 	selectedSuperItems := nil.
  1960     ].
  1961     self cancel.
  1962     self tabChanged.
  1963     self updateChannels.
  1964 !
  1965 
  1966 tabChanged
  1967     "called if the tab changed"
  1968 
  1969     |tab selector item canvas wizardHolder|
  1970 
  1971     wizardHolder := self wizardHolder.
  1972     item := self selectedItem.
  1973     item isNil ifTrue:[
  1974 	wizardHolder value:nil.
  1975 	^ self
  1976     ].
  1977 
  1978     tab := tabHolder value.
  1979 
  1980     tab notNil ifTrue:[
  1981 	tab := item slices detect:[:el| el first = tab ] ifNone:nil.
  1982     ].
  1983     tab isNil ifTrue:[
  1984 	tabHolder value:( listOfTabs at:1 ifAbsent:nil ).
  1985 	^ self.
  1986     ].
  1987     selector := tab last.
  1988 
  1989     selector == #help  ifTrue:[
  1990 	wizardHolder value:(self helpTool  window).
  1991 	^ self
  1992     ].
  1993     selector == #image ifTrue:[
  1994 	wizardHolder value:(self imageTool window).
  1995 	^ self
  1996     ].
  1997 
  1998     canvas := wizards
  1999 		at:(item class name, selector) asSymbol
  2000 		ifAbsentPut:[
  2001 		    SimpleView new
  2002 			client:self
  2003 			spec:(item class perform:selector)
  2004 			builder:(self builder)
  2005 		].
  2006 
  2007     wizardHolder value:canvas.
  2008 !
  2009 
  2010 update:something with:aParameter from:changedObject
  2011     |lbl|
  2012 
  2013     notifyDisabledCounter ~~ 0 ifTrue:[ ^ self ].
  2014 
  2015     changedObject == selectionHolder ifTrue:[ ^ self selectionChanged ].
  2016     changedObject == tabHolder       ifTrue:[ ^ self tabChanged ].
  2017 
  2018     changedObject == self autoAcceptOnSelectionChange ifTrue:[
  2019 	lbl := changedObject value ifTrue:['Apply'] ifFalse:['OK'].
  2020 	(builder componentAt:'okButton') label:(resources string:lbl).
  2021 	^ self
  2022     ].
  2023 
  2024     super update:something with:aParameter from:changedObject
  2025 !
  2026 
  2027 updateChannels
  2028     "update all channels"
  2029 
  2030     |selection sizeOfSel selectedItem hasSelection|
  2031 
  2032     super updateChannels.
  2033 
  2034     selection := selectionHolder value.
  2035     sizeOfSel := selection size.
  2036 
  2037     hasSelection := sizeOfSel ~~ 0.
  2038     sizeOfSel == 1 ifTrue:[selectedItem := selection at:1]
  2039 		  ifFalse:[selectedItem := nil].
  2040 
  2041     self hasSelectionChannel       value:hasSelection.
  2042     self hasSingleSelectionChannel value:(selectedItem notNil).
  2043 
  2044     selectedItem isNil ifTrue:[
  2045 "/        self enableMovingUpOrDownHolder  value:false.
  2046 	self enableMovingInHolder        value:false.
  2047 	self enableMovingOutHolder       value:false.
  2048 	self enableMovingInAboveHolder   value:false.
  2049 	self canCreateDelayedMenuChannel value:false.
  2050     ] ifFalse:[
  2051 "/        self enableMovingUpOrDownHolder  value:(selectedItem canMoveUpOrDown).
  2052 	self enableMovingInHolder        value:(selectedItem canMoveInNext).
  2053 	self enableMovingOutHolder       value:(selectedItem canMoveOut).
  2054 	self enableMovingInAboveHolder   value:(selectedItem canMoveInAbove).
  2055 	self canCreateDelayedMenuChannel value:(selectedItem canAddDelayedMenu).
  2056     ].
  2057     self enableMovingUpOrDownHolder value:(selection conform:[:i | i canMoveUpOrDown]).
  2058 
  2059     "Modified (comment): / 18-01-2012 / 11:24:07 / cg"
  2060 ! !
  2061 
  2062 !MenuEditor methodsFor:'drag & drop'!
  2063 
  2064 canDrop:aDropContext
  2065     "return true, if the DropContext can be dropped into the list of items.
  2066      The dropable objects are already validated by: #dropEnter:"
  2067 
  2068     ^ (dropOverLine notNil and:[dropOverLine ~~ 0])
  2069 
  2070     "Modified: / 13-10-2006 / 16:03:47 / cg"
  2071 !
  2072 
  2073 changeDropLineTo:aLineOrNil in:aContext
  2074     "the over dropLine changed; redraw drop indication stuff
  2075     "
  2076     |x0 x1 y0|
  2077 
  2078     aLineOrNil == dropOverLine ifTrue:[
  2079 	^ self. "/ nothing changed
  2080     ].
  2081     x0 := listOfItemsView margin + 2.
  2082     x1 := listOfItemsView width - x0.
  2083 
  2084     "/ inform the DragAndDrop handler that the draw contents will change
  2085     aContext contentsWillChange.
  2086 
  2087     (dropOverLine notNil and:[dropOverLine ~~ 0]) ifTrue:[
  2088 	"/ restore old draw
  2089 	y0 := listOfItemsView yVisibleOfLine:(dropOverLine + 1).
  2090 	y0 := y0 - 3.
  2091 
  2092 	listOfItemsView invalidate:(Rectangle left:x0 top:y0 width:(x1-x0+1) height:2)
  2093 			 repairNow:true.
  2094     ].
  2095 
  2096     dropOverLine := aLineOrNil.
  2097 
  2098     (dropOverLine notNil and:[dropOverLine ~~ 0]) ifTrue:[
  2099 	"/ highlight new drop target
  2100 	y0 := listOfItemsView yVisibleOfLine:(dropOverLine + 1).
  2101 	y0 := y0 - 3.
  2102 
  2103 	listOfItemsView paint:(Color white).
  2104 	listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  2105 	y0 := y0 + 1.
  2106 	listOfItemsView paint:(Color black).
  2107 	listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  2108     ].
  2109 !
  2110 
  2111 doDrop:aDropContext
  2112     "drop the dropContext into the hierachical list of items
  2113     "
  2114     |done item|
  2115 
  2116     dropOverLine isNil ifTrue:[^ false ].      "/ context not valid to me ...
  2117 
  2118     item := listOfItems at:dropOverLine ifAbsent:nil.
  2119     self dropLeave:aDropContext.
  2120     item isNil ifTrue:[^ false].
  2121 
  2122     selectionHolder setValue:(Array with:item).
  2123 
  2124     done := false.
  2125 
  2126     self addAndSelectValueOf:[
  2127 	done := true.
  2128 	aDropContext dropObjects collect:[:el| Item menuItem:(el theObject) ]
  2129     ].
  2130     ^ done
  2131 
  2132     "Modified: / 13-10-2006 / 16:03:54 / cg"
  2133 !
  2134 
  2135 dropEnter:aDropContext
  2136     "a drop operation enters my widget; validate dropable objects.
  2137      If the objects are not dropable, dropOverLine is set to nil,
  2138      otherwise to 0 (can drop the contents but not).
  2139     "
  2140     |objects|
  2141 
  2142     dropOverLine := nil.
  2143 
  2144     self enablingCommitButtonsHolder value ifTrue:[
  2145 	"/ current editing spec is modified (couldn't accept operation)
  2146 	^ self
  2147     ].
  2148     objects := aDropContext dropObjects.
  2149     objects isEmpty ifTrue:[ ^ self ].  "/ nothing to drop ???
  2150 
  2151     "/ test whether all objects are dropable (kind of MenuItem)
  2152     (objects conform:[:el | (el theObject askFor:#isMenuItem)]) ifTrue:[
  2153 	"/ ok, the contents is dropable
  2154 	dropOverLine := 0.
  2155     ]
  2156 
  2157     "Modified: / 13-10-2006 / 16:04:14 / cg"
  2158 !
  2159 
  2160 dropLeave:aDropContext
  2161     "restore drop indications drawn..."
  2162 
  2163     self changeDropLineTo:nil in:aDropContext.
  2164 
  2165     "Modified: / 13-10-2006 / 16:03:59 / cg"
  2166 !
  2167 
  2168 dropObjects
  2169     "returns list of DropObjects
  2170     "
  2171     |obj items|
  2172 
  2173     items := self selectedSuperItems.
  2174     items isEmpty ifTrue:[ ^ nil ].
  2175 
  2176   ^ items collect:[:el|
  2177 	obj := DropObject new:(el menuItem).
  2178 	obj displayObject:(el rawLabel).
  2179 	obj
  2180     ].
  2181 !
  2182 
  2183 dropOver:aDropContext
  2184     "called during drag & drop while moving over the widget."
  2185 
  2186     |lnNr item|
  2187 
  2188     dropOverLine isNil ifTrue:[^ self ].       "/ context not valid to me ...
  2189 
  2190     lnNr := listOfItemsView yVisibleToLineNr:(aDropContext targetPointInDeviceCoordinates y).
  2191     item := nil.
  2192 
  2193     lnNr notNil ifTrue:[
  2194         item := listOfItems at:lnNr ifAbsent:nil.
  2195         item notNil ifTrue:[
  2196             (item isAction and:[item hasDelayedMenu]) ifTrue:[
  2197                 item := nil
  2198             ]
  2199         ]
  2200     ].
  2201     item isNil ifTrue:[ lnNr := 0 ].   "/ not dropable for item
  2202 
  2203     "/ redraw drop indication
  2204     self changeDropLineTo:lnNr in:aDropContext.
  2205 
  2206     "Modified: / 29-11-2011 / 11:28:17 / cg"
  2207     "Modified: / 15-06-2018 / 02:27:44 / Claus Gittinger"
  2208 ! !
  2209 
  2210 !MenuEditor methodsFor:'event processing'!
  2211 
  2212 processEvent:anEvent
  2213     "filter keyboard edit-events typed into the listOfItemsView.
  2214      Return true, if I have eaten the event"
  2215 
  2216     <resource: #keyboard (#Delete #BackSpace #Cut #Copy #Paste #CtrlCursorUp #CtrlCursorDown
  2217                           #CtrlCursorLeft #CtrlCursorRight #Accept)>
  2218 
  2219     |evView rawKey key|
  2220 
  2221     anEvent isKeyPressEvent ifFalse:[^ false].
  2222 
  2223     key    := anEvent key.
  2224 
  2225     evView := anEvent targetView.
  2226     evView isNil ifTrue:[^ false ].
  2227 
  2228     "/ only handle keyboard events for the left item list
  2229     "/ (otherwise, copy-paste would not work in the editFields on the right)
  2230     (evView isSameOrComponentOf:listOfItemsView) ifFalse:[
  2231         key == #Accept ifTrue:[
  2232             self accept.
  2233         ].
  2234         ^ false
  2235     ].
  2236 
  2237     rawKey := anEvent rawKey.
  2238 
  2239     (    key == #Delete
  2240      or:[key == #BackSpace
  2241      or:[key == #Cut]]
  2242     ) ifTrue:[
  2243         self doCut.
  2244         ^ true.
  2245     ].
  2246 
  2247     key == #Copy  ifTrue:[ self doCopy.  ^ true ].
  2248     key == #Paste ifTrue:[ self doPaste. ^ true ].
  2249 
  2250     (rawKey == #CtrlCursorUp) ifTrue:[
  2251         self doMoveUp.
  2252         ^ true.
  2253     ].
  2254     (rawKey == #CtrlCursorDown) ifTrue:[
  2255         self doMoveDown.
  2256         ^ true.
  2257     ].
  2258     (rawKey == #CtrlCursorLeft) ifTrue:[
  2259         self doMoveOut.
  2260         ^ true.
  2261     ].
  2262     (rawKey == #CtrlCursorRight) ifTrue:[
  2263         self doMoveInNext.
  2264         ^ true.
  2265     ].
  2266 
  2267     ^ false.
  2268 
  2269     "Modified: / 12-02-2019 / 10:56:08 / Claus Gittinger"
  2270 ! !
  2271 
  2272 !MenuEditor methodsFor:'initialization & release'!
  2273 
  2274 closeRequest
  2275     "asks for permission before closing"
  2276 
  2277     self askForModification ifFalse:[^self].
  2278 
  2279 "/    self enablingCommitButtonsHolder value ifTrue:[
  2280 "/        self setModified.
  2281 "/        self askForListModification.
  2282 "/        modified ifTrue:[^ self].
  2283 "/        self clearModified.
  2284 "/    ].
  2285     super closeRequest
  2286 
  2287     "Modified: / 05-09-2006 / 18:44:15 / cg"
  2288 !
  2289 
  2290 commonPostBuild
  2291     self autoAcceptOnSelectionChange addDependent:self.
  2292     self autoAcceptOnSelectionChange value ifTrue:[
  2293         (builder componentAt:'okButton') label:(resources string:'Apply')
  2294     ].
  2295 
  2296     "/ using masters infoHolder ?
  2297     self useAlienInfoLabel ifTrue:[
  2298         (builder componentAt:#mainPanel) layout bottomOffset:0.
  2299         (builder componentAt:#infoBarSubSpec) beInvisible
  2300     ]
  2301 
  2302     "Modified: / 20-02-2018 / 13:05:21 / stefan"
  2303 !
  2304 
  2305 commonPostOpen
  2306     "reset keyboardProcessor for menuBar"
  2307 
  2308     super commonPostOpen.
  2309     builder keyboardProcessor menuBar:nil.
  2310     self windowGroup addPreEventHook:self.
  2311 !
  2312 
  2313 initialize
  2314     "setup aspects, ...
  2315     "
  2316     super initialize.
  2317     notifyDisabledCounter := 0.
  2318 
  2319     Item withAllSubclasses do:[:aClass|
  2320 	aClass addBindingsTo:aspects for:self.
  2321     ].
  2322 
  2323     selectionHolder    := #() asValue.
  2324     selectionHolder addDependent:self.
  2325 
  2326     listOfItems := HierarchicalList new.
  2327     listOfItems application:self.
  2328     listOfItems root:(RootItem new).
  2329 
  2330     tabHolder := nil asValue.
  2331     tabHolder addDependent:self.
  2332 
  2333     listOfTabs := List new.
  2334     wizards    := IdentityDictionary new.
  2335 !
  2336 
  2337 loadFromResourceSpec:aResourceSpec
  2338     self loadFromMenu:aResourceSpec selector:nil
  2339 !
  2340 
  2341 openModalOnMenu:aMenuOrNil
  2342     "build a tree from aMenu and open it modal"
  2343 
  2344     self openModalOnResourceSpec:aMenuOrNil
  2345 !
  2346 
  2347 postBuildListOfItemsView:aSrollableView
  2348     listOfItemsView := aSrollableView scrolledView.
  2349 !
  2350 
  2351 postBuildNoteBook:aNoteBook
  2352     aNoteBook tabLabelInset:16@4.
  2353 ! !
  2354 
  2355 !MenuEditor methodsFor:'menus-dynamic'!
  2356 
  2357 submenuTest
  2358     "returns a menu on the current editing menu
  2359     "
  2360     |menu indication choice submenu retriever|
  2361 
  2362     menu := listOfItems root submenu.
  2363     menu isNil ifTrue:[^ nil ].
  2364 
  2365     menu allItemsDo:[:anItem|
  2366         anItem ignoreShortcutKeys:true.
  2367         anItem isVisible:true.
  2368         anItem enabled:true.
  2369         anItem translateLabel:false.
  2370 
  2371         anItem itemValue notNil ifTrue:[
  2372             anItem itemValue:[ Transcript showCR:(anItem label) ].
  2373         ].
  2374         anItem indication notNil ifTrue:[
  2375             indication isNil ifTrue:[ indication := true asValue ].
  2376             anItem indication:indication
  2377         ].
  2378         anItem choice notNil ifTrue:[
  2379             choice isNil ifTrue:[ choice := anItem choiceValue asValue ].
  2380             anItem choice:choice
  2381         ].
  2382         anItem isMenuSlice ifTrue:[
  2383             anItem submenuChannel:nil.
  2384             anItem label:'... Slice Menu ...'.
  2385         ].
  2386         anItem submenuChannel notNil ifTrue:[
  2387             anItem submenuChannel:nil.
  2388             anItem submenu isNil ifTrue:[
  2389                 submenu isNil ifTrue:[
  2390                     submenu := Menu new.
  2391                     submenu addItem:(MenuItem label:'Linked Menu...').
  2392                 ].
  2393                 anItem submenu:submenu.
  2394             ].
  2395         ].
  2396         retriever := anItem resourceRetriever.
  2397         retriever notNil ifTrue:[
  2398             retriever labelText notNil ifTrue:[ retriever labelText:(anItem label) ]
  2399         ].
  2400     ].
  2401     menu findGuiResourcesIn:(self resolveName:specClass).
  2402     ^ menu
  2403 ! !
  2404 
  2405 !MenuEditor methodsFor:'private'!
  2406 
  2407 addAndSelectValueOf:aBlockOrItem
  2408     "add an item(s) derived from the block; test if add operation
  2409      is enabled. On success the new item(s) are returned otherwise nil.
  2410     "
  2411     |intoItem index newItem|
  2412 
  2413     intoItem := self selectedItem.
  2414     intoItem isNil ifTrue:[ ^ nil].
  2415 
  2416     self askForItemModification ifFalse:[ ^ nil ].
  2417 
  2418     index := 1.
  2419 
  2420     (intoItem canAddChildren and:[intoItem isExpanded]) ifFalse:[
  2421 	intoItem parent notNil ifTrue:[
  2422 	    [ intoItem parent canAddChildren ] whileFalse:[
  2423 		intoItem := intoItem parent.
  2424 	    ].
  2425 	    index := intoItem parent identityIndexOf:intoItem.
  2426 	    index := index + 1.
  2427 	    intoItem := intoItem parent.
  2428 	].
  2429     ].
  2430     newItem := aBlockOrItem value.
  2431 
  2432     newItem notNil ifTrue:[
  2433 	selectionHolder setValue:nil.
  2434 	intoItem expand.
  2435 
  2436 	newItem isCollection ifTrue:[
  2437 	    intoItem addAll:newItem beforeIndex:index.
  2438 	    selectionHolder value:newItem.
  2439 	] ifFalse:[
  2440 	    intoItem add:newItem beforeIndex:index.
  2441 	    selectionHolder value:(Array with:newItem).
  2442 	].
  2443 	self setModified.
  2444     ].
  2445     ^ newItem
  2446 
  2447     "Modified: / 29-11-2011 / 11:28:06 / cg"
  2448 !
  2449 
  2450 clearModified
  2451     "clear the modifiedChannel and the commitPanel"
  2452 
  2453     super clearModified.
  2454     self enablingCommitButtonsHolder value:false.
  2455     self clearModifiedFlag.
  2456 !
  2457 
  2458 generateMenuSpec
  2459     "generate and returns the current menu spec or nil"
  2460 
  2461     ^ self generateMenuSpecFor:listOfItems root
  2462 !
  2463 
  2464 generateMenuSpecFor:aMenuItem
  2465     "generate and returns a menu spec or nil"
  2466 
  2467     |menu|
  2468 
  2469     menu := aMenuItem submenu.
  2470     menu isNil ifTrue:[^ nil].
  2471 
  2472     ^ menu literalArrayEncoding.
  2473 !
  2474 
  2475 generateMenuSpecString
  2476     "generate and returns the current menu spec as string or nil"
  2477 
  2478     ^ self generateMenuSpecStringFor:listOfItems root 
  2479 !
  2480 
  2481 generateMenuSpecStringFor:aMenuItem
  2482     "generate and returns the current menu spec as string or nil"
  2483 
  2484     |menu specStream|
  2485 
  2486     menu := self generateMenuSpecFor:aMenuItem.
  2487     menu isNil ifTrue:[^ nil].
  2488 
  2489     specStream := WriteStream on:''.
  2490     UISpecification prettyPrintSpecArray:menu on:specStream indent:5.
  2491     ^ specStream contents.
  2492 !
  2493 
  2494 withoutNotifyDo:aBlock
  2495     "evaluate the block; all change notifications are
  2496      discard during the block is evaluated"
  2497 
  2498     |blockResult|
  2499 
  2500     [
  2501 	notifyDisabledCounter := notifyDisabledCounter + 1.
  2502 	blockResult := aBlock value.
  2503     ] ensure:[
  2504 	notifyDisabledCounter := notifyDisabledCounter - 1
  2505     ].
  2506     ^ blockResult
  2507 ! !
  2508 
  2509 !MenuEditor methodsFor:'queries'!
  2510 
  2511 hasValidSpecClass
  2512     "returns true if a valid specClass exists
  2513     "
  2514     specClass isNil ifTrue:[^ false].
  2515     ^ (self resolveName:specClass) notNil
  2516 
  2517     "Modified: / 19-11-2016 / 20:19:30 / cg"
  2518 !
  2519 
  2520 isEditingSpecOnly
  2521     ^ masterApplication notNil
  2522     and:[ masterApplication perform:#isEditingSpecOnly ifNotUnderstood:false]
  2523 !
  2524 
  2525 isNotEditingSpecOnly
  2526     ^ self isEditingSpecOnly not
  2527 !
  2528 
  2529 isNotEditingSpecOnlyAndNotEmbeddedInBrowser
  2530     ^ self isNotEditingSpecOnly and:[ self isEmbeddedInBrowser not ]
  2531 ! !
  2532 
  2533 !MenuEditor methodsFor:'selection'!
  2534 
  2535 canSelect:anIndex
  2536     "called whenever the selection changed; test whether
  2537      current item is not modified ....
  2538     "
  2539     |oldSelectedItem newSelectedItem anythingChanged|
  2540 
  2541     self enablingCommitButtonsHolder value ifFalse:[
  2542 	^ true
  2543     ].
  2544     oldSelectedItem := self selectedItem.
  2545     oldSelectedItem isNil ifTrue:[^ true].
  2546 
  2547     newSelectedItem := listOfItems at:anIndex ifAbsent:nil.
  2548     oldSelectedItem == newSelectedItem ifTrue:[
  2549 	^ true
  2550     ].
  2551 
  2552     anythingChanged := self enablingCommitButtonsHolder value.
  2553     anythingChanged ifTrue:[
  2554 	self autoAcceptOnSelectionChange value ifTrue:[
  2555 	    self accept.
  2556 	    ^ true
  2557 	].
  2558     ].
  2559 
  2560     ^ self askForItemModification
  2561 !
  2562 
  2563 hasSelection
  2564     "returns true if a selection exists
  2565     "
  2566     ^ selectionHolder value size ~~ 0
  2567 !
  2568 
  2569 selectedItem
  2570     "returns the selected item or nil (none or multiple selected)"
  2571 
  2572     |selection|
  2573 
  2574     selection := selectionHolder value.
  2575     selection size == 1 ifTrue:[ ^ selection first ].
  2576     ^ nil
  2577 
  2578     "Modified: / 18-01-2012 / 11:33:42 / cg"
  2579 !
  2580 
  2581 selectedItem:anItem
  2582     "change selection to an item
  2583     "
  2584     |selection|
  2585 
  2586     anItem notNil ifTrue:[ selection := Array with:anItem ]
  2587 		 ifFalse:[ selection := #() ].
  2588 
  2589     selectionHolder value:selection.
  2590 !
  2591 
  2592 selectedItems
  2593     "returns the selected items or an empty collection"
  2594 
  2595     ^ selectionHolder value.
  2596 
  2597     "Created: / 18-01-2012 / 11:32:20 / cg"
  2598 !
  2599 
  2600 selectedItems:aCollectionOfItems
  2601     "set the selected items"
  2602 
  2603     selectionHolder value:aCollectionOfItems.
  2604 
  2605     "Created: / 18-01-2012 / 11:32:37 / cg"
  2606 ! !
  2607 
  2608 !MenuEditor methodsFor:'user actions-aspects'!
  2609 
  2610 collectActionSelectors
  2611     |selectors|
  2612 
  2613     selectors := IdentitySet new.
  2614 
  2615     listOfItems root recursiveDo:[:el|
  2616 	el actionSelectors do:[:s| selectors add:s ].
  2617     ].
  2618     ^ selectors asOrderedCollection
  2619 !
  2620 
  2621 collectAspectSelectors
  2622     |selectors|
  2623 
  2624     selectors := IdentitySet new.
  2625 
  2626     listOfItems root recursiveDo:[:el|
  2627 	selectors addAll:(el aspectSelectors).
  2628     ].
  2629     ^ selectors asOrderedCollection
  2630 !
  2631 
  2632 doBrowseActionMethod
  2633     "open a browser on the action callback method (create if not yet existing)"
  2634 
  2635     self doBrowseApplicationMethodFor:#itemValue
  2636 
  2637     "Modified: / 21-10-2010 / 14:09:33 / cg"
  2638 !
  2639 
  2640 doBrowseApplicationMethodFor:aspect
  2641     |selector cls implClass browsedClass category|
  2642 
  2643     specClass isNil ifTrue:[
  2644         self warn:('Please define the application class first.').
  2645         ^ self
  2646     ].
  2647 
  2648     selector := (self aspectValueFor:aspect).
  2649     selector isEmptyOrNil ifTrue:[
  2650         Dialog information:(resources string:'Missing name for the action/aspect method.').
  2651         ^ self
  2652     ].
  2653     (selector = 'true' or:[selector = 'false']) ifTrue:[^ self].
  2654     (selector == true or:[selector == false]) ifTrue:[^ self].
  2655 
  2656     selector := selector asSymbol.
  2657 
  2658     cls := self resolveName:specClass.
  2659     cls isNil ifTrue:[
  2660         self warn:(resources string:'Class %1 does not exist!!' with:specClass asString).
  2661         ^ self
  2662     ].
  2663 
  2664     browsedClass := cls.
  2665     (cls includesSelector:selector) ifFalse:[
  2666         | generate |    
  2667         (implClass := cls whichClassImplements:selector) notNil ifTrue:[
  2668             generate := (Dialog 
  2669                 confirm:(resources 
  2670                             stringWithCRs:'The application does not directly implement %1.\However it inherits this from %2.\\Create a redefinition in %1?'
  2671                             with:cls name
  2672                             with:implClass name)
  2673                 initialAnswer:false)
  2674         ] ifFalse:[ 
  2675             generate := true.
  2676         ].
  2677         category := UserPreferences current categoryForMenuActionsMethods.
  2678 
  2679         SmalltalkCodeGeneratorTool
  2680             createActionMethodFor:selector in:cls
  2681             category:category
  2682             redefine:(self redefineAspectMethodsChannel value).
  2683     ].
  2684 
  2685     browsedClass browserClass openInClass:browsedClass selector:selector
  2686 
  2687     "Created: / 21-10-2010 / 14:07:32 / cg"
  2688     "Modified: / 31-01-2011 / 18:28:59 / cg"
  2689     "Modified: / 17-03-2014 / 12:25:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2690     "Modified: / 09-08-2018 / 15:31:11 / Claus Gittinger"
  2691 !
  2692 
  2693 doBrowseChoiceMethod
  2694     "open a browser on the choice aspect method (create if not yet existing)"
  2695 
  2696     self doBrowseApplicationMethodFor:#choice
  2697 !
  2698 
  2699 doBrowseEnabledMethod
  2700     "open a browser on the enabled method (create if not yet existing)"
  2701 
  2702     self doBrowseApplicationMethodFor:#enabled
  2703 
  2704     "Created: / 21-10-2010 / 14:09:41 / cg"
  2705 !
  2706 
  2707 doBrowseIndicationMethod
  2708     "open a browser on the indicator aspect method (create if not yet existing)"
  2709 
  2710     self doBrowseApplicationMethodFor:#indication
  2711 !
  2712 
  2713 doBrowseVisibilityMethod
  2714     "open a browser on the visibility method (create if not yet existing)"
  2715 
  2716     self doBrowseApplicationMethodFor:#isVisible
  2717 
  2718     "Created: / 21-10-2010 / 14:09:56 / cg"
  2719 !
  2720 
  2721 doGenerateAspectMethods
  2722     "compile aspect and action methods"
  2723 
  2724     |cls redefineAspectMethods category|
  2725 
  2726     specClass isNil ifTrue:[
  2727 	self warn:'Define the class first !!'.
  2728 	^ self
  2729     ].
  2730     redefineAspectMethods := self redefineAspectMethodsChannel value.
  2731 
  2732     cls := self resolveName:specClass.
  2733     cls isNil ifTrue:[
  2734 	self warn:'Class ', specClass asString, ' does not exist!!'.
  2735 	^ self
  2736     ].
  2737 
  2738     category := UserPreferences current categoryForMenuActionsMethods.
  2739 
  2740     self collectActionSelectors do:[:aSelector|
  2741 	SmalltalkCodeGeneratorTool
  2742 	    createActionMethodFor:aSelector in:cls
  2743 	    category:category
  2744 	    redefine:redefineAspectMethods.
  2745     ].
  2746 
  2747     self collectAspectSelectors do:[:anAspect|
  2748 	SmalltalkCodeGeneratorTool
  2749 	    createAspectMethodFor:anAspect in:cls
  2750 	    category:category
  2751 	    redefine:redefineAspectMethods
  2752     ].
  2753 
  2754     "Modified: / 31-01-2011 / 18:29:06 / cg"
  2755 ! !
  2756 
  2757 !MenuEditor methodsFor:'user actions-building'!
  2758 
  2759 compileSpecMethodFor:aMenuItem selector:specSelector
  2760     "save current editing menu to
  2761            class: specClass
  2762         selector: specSelector
  2763     "
  2764     |cls specCode mthd category s|
  2765 
  2766     specCode := self generateMenuSpecStringFor:aMenuItem.
  2767     specCode isNil ifTrue:[^ nil].
  2768 
  2769     cls  := self resolveName:specClass.
  2770 
  2771     "/ if that method already exists, do not overwrite the category
  2772 
  2773     category := 'menu specs'.
  2774     (mthd := cls theMetaclass compiledMethodAt:specSelector) notNil ifTrue:[
  2775         category := mthd category.
  2776     ].
  2777 
  2778     s := '' writeStream.
  2779 
  2780     s nextPutChunkSeparator;
  2781       nextPutAll:(cls name);
  2782       nextPutAll:' class methodsFor:';
  2783       nextPutAll:category storeString;
  2784       nextPutChunkSeparator;
  2785       cr; cr;
  2786       nextPutAll:specSelector;
  2787       cr;
  2788       nextPutAllAsChunk:(self class codeGenerationComment) withCRs;
  2789       cr; cr;
  2790       nextPutLine:'    "';
  2791       nextPutLine:('     MenuEditor new openOnClass:' , cls name , ' andSelector:#' , specSelector);
  2792       nextPutLine:('     (Menu new fromLiteralArrayEncoding:(' , cls name , ' ' , specSelector , ')) startUp');
  2793       nextPutLine:'    "';
  2794       cr;
  2795       nextPutLine:'    <resource: #menu>';
  2796       cr;
  2797       nextPutAll:'    ^ ';
  2798       nextChunkPut:specCode;
  2799       space;
  2800       nextPutChunkSeparator;
  2801       cr.
  2802 
  2803     Class packageQuerySignal answer:cls package do:[
  2804         (ReadStream on:s contents) fileIn.
  2805     ].
  2806 !
  2807 
  2808 doChooseAMenu
  2809     "pick a menu and edit its spec method"
  2810 
  2811     |view subSpec app bldr spec menuSelector1 menuSelector2 info|
  2812 
  2813     self askForModification ifTrue:[
  2814 	view := Screen current viewFromUser.
  2815 	(view isNil or:[view == Screen current rootView]) ifTrue:[
  2816 	    ^ self
  2817 	].
  2818 	view specClass == MenuPanelSpec ifTrue:[
  2819 	    (app := view application) isNil ifTrue:[
  2820 		info := 'Could not figure out the application class.'
  2821 	    ] ifFalse:[
  2822 		(bldr := app builder) isNil ifTrue:[
  2823 		    info := 'Application has no builder.'
  2824 		] ifFalse:[
  2825 		    menuSelector1 := bldr namedComponents keyAtValue:view ifAbsent:nil.
  2826 		    (spec := bldr spec) isNil ifTrue:[
  2827 			info := 'Cannot fetch spec from applications builder.'
  2828 		    ] ifFalse:[
  2829 			subSpec := spec findSpecForWhich:[:subSpec | subSpec name = view name].
  2830 			subSpec isNil ifTrue:[
  2831 			    info := 'Cannot find view-spec for ',view name asString,'.'
  2832 			] ifFalse:[
  2833 			    menuSelector2 := subSpec menu.
  2834 			]
  2835 		    ].
  2836 		    (menuSelector1 isNil and:[ menuSelector2 isNil ]) ifTrue:[
  2837 			info := 'menu is probably not provided by a menuSelector.'
  2838 		    ] ifFalse:[
  2839 			(app class respondsTo:menuSelector1) ifTrue:[
  2840 			    self loadFromClass:app class andSelector:menuSelector1.
  2841 			    ^ self.
  2842 			].
  2843 			(app class respondsTo:menuSelector2) ifTrue:[
  2844 			    self loadFromClass:app class andSelector:menuSelector2.
  2845 			    ^ self.
  2846 			].
  2847 			info := 'menu is probably not provided by a menuSelector.'
  2848 		    ].
  2849 		]
  2850 	    ].
  2851 	    info notNil ifTrue:[
  2852 		app notNil ifTrue:[
  2853 		    (Dialog confirm:(info,'\\Browse ?' withCRs)) ifTrue:[
  2854 			app browse.
  2855 		    ].
  2856 		] ifFalse:[
  2857 		    Dialog information:info.
  2858 		].
  2859 	    ].
  2860 	    ^ self.
  2861 	].
  2862     ].
  2863 !
  2864 
  2865 doNew
  2866     "clear editing menu; start from scratch
  2867     "
  2868     super doNew ifTrue:[ self helpTool doNew ].
  2869 !
  2870 
  2871 doPickAMenu
  2872     "let user pick a menu and create a new spec"
  2873 
  2874     |view|
  2875 
  2876     self askForModification ifTrue:[
  2877 	view := Screen current viewFromUser.
  2878 	(view isNil or:[view == Screen current rootView]) ifTrue:[
  2879 	    ^ self
  2880 	].
  2881 	view specClass == MenuPanelSpec ifTrue:[
  2882 	    specSelector := #pickedMenu.
  2883 	    self buildFromMenu:(view asMenu) selector:specSelector.
  2884 	].
  2885     ].
  2886 !
  2887 
  2888 doSave
  2889     "save current editing menu to
  2890            class: specClass
  2891         selector: specSelector
  2892     "
  2893     self isEditingSpecOnly ifTrue:[
  2894         savedSpec := self generateMenuSpec.
  2895         hasSaved := true.
  2896         self clearModified.
  2897         ^ self
  2898     ].
  2899 
  2900     super doSave ifFalse: [^nil].
  2901 
  2902     self compileSpecMethodFor:listOfItems root selector:specSelector.
  2903     self isStandAlone ifTrue:[
  2904         self helpTool doSave
  2905     ].
  2906 
  2907     self updateHistory.
  2908     hasSaved := true.
  2909     self clearModified.
  2910 
  2911     "Modified: / 28-01-2014 / 21:57:24 / cg"
  2912 !
  2913 
  2914 doSaveAs
  2915     "save current editing menu to class and selector
  2916      defined by the user.
  2917     "
  2918     super doSaveAs ifTrue:[
  2919 	listOfItems root rawLabel:specSelector
  2920     ].
  2921 !
  2922 
  2923 doShowMenuSpec
  2924     "opens a code view with the contents of the menu spec"
  2925 
  2926     |code|
  2927 
  2928     code := self generateMenuSpecString.
  2929 
  2930     code notNil ifTrue:[
  2931 	CodeView openWith:code title: 'Menu Spec'
  2932     ].
  2933 
  2934     "Modified: / 29-11-2011 / 11:28:12 / cg"
  2935 !
  2936 
  2937 save
  2938     self doSave
  2939 ! !
  2940 
  2941 !MenuEditor methodsFor:'user actions-creation'!
  2942 
  2943 doCreateDelayedMenu:what
  2944     |selectedItem delayedItem|
  2945 
  2946     selectedItem := self selectedItem.
  2947     selectedItem isNil ifTrue:[^ self].
  2948 
  2949     selectedItem canAddDelayedMenu      ifFalse:[ ^ self ].
  2950     self askForItemModification ifFalse:[ ^ self ].
  2951 
  2952     what == #menu ifTrue:[ delayedItem := RegularMenuItem new ]
  2953 		 ifFalse:[ delayedItem := LinkedMenuItem new ].
  2954 
  2955     delayedItem setExpanded:true.
  2956     delayedItem := selectedItem add:delayedItem.
  2957 
  2958     delayedItem notNil ifTrue:[
  2959 	self selectedItem:delayedItem.
  2960     ].
  2961 
  2962     "Modified: / 29-11-2011 / 11:28:09 / cg"
  2963 !
  2964 
  2965 doCreateItem
  2966     "create a new Item
  2967     "
  2968     self addAndSelectValueOf:[ ActionItem new translateLabel:true ].
  2969 !
  2970 
  2971 doCreateLinkedMenu
  2972     "create a new Linked Menu
  2973     "
  2974     self addAndSelectValueOf:[ LinkedMenuItem new ].
  2975 !
  2976 
  2977 doCreateMenu
  2978     "create a new Menu
  2979     "
  2980     self addAndSelectValueOf:
  2981 	[ |item|
  2982 	    item := RegularMenuItem new.
  2983 	    "/ --- do not add it expanded - because that makes it hard to add multipe menus
  2984 	    "/ item expand.
  2985 	    item
  2986 	].
  2987 !
  2988 
  2989 doCreateMenuSliceItem
  2990     "create a new MenuSlice Item
  2991     "
  2992     self addAndSelectValueOf:[ MenuSliceItem new ].
  2993 !
  2994 
  2995 doCreateSep
  2996     "create a new Separator Item
  2997     "
  2998     self addAndSelectValueOf:[ SeparatorItem new ].
  2999 !
  3000 
  3001 doCreateStandardEditMenu
  3002     "create a standard edit menu
  3003     "
  3004     self addAndSelectValueOf:[
  3005 	RegularMenuItem menu:(self class standardEditMenu) labeled:'Edit' translateLabel:true
  3006     ].
  3007 !
  3008 
  3009 doCreateStandardFileMenu
  3010     "create a standard file menu
  3011     "
  3012     self addAndSelectValueOf:[
  3013 	RegularMenuItem menu:(self class standardFileMenu) labeled:'File' translateLabel:true
  3014     ].
  3015 !
  3016 
  3017 doCreateStandardHelpMenu
  3018     "create a standard help menu
  3019     "
  3020     |item|
  3021 
  3022     self addAndSelectValueOf:[
  3023 	item := RegularMenuItem menu:(self class standardHelpMenu) labeled:'Help' translateLabel:true.
  3024 	item aspectAt:#startGroup put:#conditionalRight.
  3025 	item
  3026     ].
  3027 
  3028     "Modified: / 16-10-2006 / 12:49:27 / cg"
  3029 ! !
  3030 
  3031 !MenuEditor methodsFor:'user actions-editing'!
  3032 
  3033 doCopy
  3034     "copy selected menuItems to the clipboard
  3035     "
  3036     |clip items|
  3037 
  3038     items := self selectedSuperItems.
  3039     items isEmpty ifTrue:[ ^ self ].
  3040 
  3041     clip := OrderedCollection new.
  3042     items do:[:el| clip add:(el menuItem) ].
  3043 
  3044     self clipboard:clip.
  3045     self updateAllToolInstances.
  3046 !
  3047 
  3048 doCut
  3049     "copy selected menuItems to the clipboard and delete
  3050     "
  3051     self doCopy.
  3052     self doDelete.
  3053 !
  3054 
  3055 doDelete
  3056     "delete selected menuItems
  3057     "
  3058     |selectedItem parent toDelete behind nextItem prevItem|
  3059 
  3060     toDelete := self selectedSuperItems.
  3061     toDelete isEmpty ifTrue:[ ^ self ].
  3062 
  3063     self clearModified.
  3064 
  3065     selectedItem := toDelete first.
  3066 
  3067     selectedItem isRootItem ifTrue:[
  3068 	^ selectedItem removeAll.
  3069     ].
  3070     "/ compute the new selection
  3071 
  3072     prevItem := parent := selectedItem parent.
  3073     nextItem := nil.
  3074 
  3075     parent children size ~~ 1 ifTrue:[
  3076 	behind := false.
  3077 
  3078 	parent do:[:el|
  3079 	    behind ifTrue:[
  3080 		(nextItem notNil or:[toDelete includesIdentical:el]) ifFalse:[ nextItem := el ].
  3081 	    ] ifFalse:[
  3082 		behind := el == selectedItem.
  3083 		(behind or:[toDelete includesIdentical:el]) ifFalse:[ prevItem := el ].
  3084 	    ]
  3085 	]
  3086     ].
  3087     self withoutNotifyDo:[
  3088 	toDelete do:[:el| el remove ].
  3089     ].
  3090     self selectedItem:(nextItem ? prevItem).
  3091     self setModified.
  3092     self updateChannels.
  3093 !
  3094 
  3095 doPaste
  3096     "paste from clipboard
  3097     "
  3098     ^ self doPaste:(self clipboard)
  3099 !
  3100 
  3101 doPaste:aCollection
  3102     "paste collection of MenuItems
  3103     "
  3104     |item loMenuItems|
  3105 
  3106     aCollection size == 0 ifTrue:[ ^ self ].
  3107 
  3108     item := self selectedItem.
  3109     item isNil ifTrue:[ ^ self ].
  3110 
  3111     loMenuItems := OrderedCollection new.
  3112     aCollection do:[:el|
  3113 	(el askFor:#isMenuItem) ifTrue:[ loMenuItems add:el ].
  3114     ].
  3115     loMenuItems isEmpty ifTrue:[ ^ self ].
  3116 
  3117     self addAndSelectValueOf:[
  3118 	loMenuItems collect:[:el| Item menuItem:el ]
  3119     ].
  3120 ! !
  3121 
  3122 !MenuEditor methodsFor:'user actions-hierarchy'!
  3123 
  3124 doMakeLinkedMenu
  3125     "the selected item must be a regular submenu.
  3126      create a new menuspec for it,
  3127      and chenge the item to a linke menu item."
  3128 
  3129     |cls subSelector oldMenuItem newLinkedMenuItem index|
  3130 
  3131     oldMenuItem := self selectionHolder value first.
  3132 
  3133     subSelector := Dialog 
  3134                     request:'Name of spec method for submenu:'
  3135                     initialAnswer:((oldMenuItem label reject:[:ch | ch isLetterOrDigit not]),'MenuSpec') asLowercaseFirst.
  3136     subSelector isEmptyOrNil ifTrue:[^ self].
  3137     subSelector := subSelector asSymbol.
  3138 
  3139     cls  := self resolveName:specClass.
  3140     (cls theMetaclass compiledMethodAt:subSelector) notNil ifTrue:[
  3141         (Dialog confirm:'Overwrite existing spec?') ifFalse:[^ self].
  3142     ].
  3143 
  3144     self compileSpecMethodFor:oldMenuItem selector:subSelector.
  3145 
  3146     newLinkedMenuItem := LinkedMenuItem new.
  3147     newLinkedMenuItem submenuChannel:subSelector.
  3148     newLinkedMenuItem menuItem nameKey:(oldMenuItem menuItem nameKey).
  3149     newLinkedMenuItem menuItem label:oldMenuItem menuItem label.
  3150     newLinkedMenuItem menuItem rawLabel:oldMenuItem menuItem rawLabel.
  3151     newLinkedMenuItem menuItem translateLabel:(oldMenuItem menuItem translateLabel).
  3152     newLinkedMenuItem menuItem hasMenuIndicator:(oldMenuItem menuItem hasMenuIndicator).
  3153 
  3154     index := oldMenuItem parent identityIndexOf:oldMenuItem.
  3155     oldMenuItem parent at:index put:newLinkedMenuItem.
  3156 
  3157     self selectedItem:newLinkedMenuItem.
  3158 
  3159     "Modified: / 09-08-2018 / 17:09:40 / Claus Gittinger"
  3160 !
  3161 
  3162 doMoveDown
  3163     "move selected item down"
  3164 
  3165     self doMoveUpOrDown:#down
  3166 !
  3167 
  3168 doMoveIn:aDirection
  3169     "move selected item into the next (#inNext) or previous (#inPrev) item
  3170     "
  3171     |item idx parent toParent|
  3172 
  3173     item := self selectedItem.
  3174     item isNil ifTrue:[^ self].
  3175 
  3176     aDirection == #inNext ifTrue:[ item canMoveInNext  ifFalse:[^ self] ]
  3177 			 ifFalse:[ item canMoveInAbove ifFalse:[^ self] ].
  3178 
  3179     self askForItemModification ifFalse:[ ^ self ].
  3180 
  3181     parent := item parent.
  3182     idx    := parent identityIndexOf:item.
  3183 
  3184     aDirection == #inNext ifTrue:[ toParent := parent at:(idx + 1) ifAbsent:nil ]
  3185 			 ifFalse:[ toParent := parent at:(idx - 1) ifAbsent:nil ].
  3186 
  3187     self withoutNotifyDo:[
  3188 	selectionHolder setValue:#().
  3189 	parent removeIndex:idx.
  3190 
  3191 	aDirection == #inNext ifTrue:[ toParent addFirst:item ]
  3192 			     ifFalse:[ toParent  addLast:item ].
  3193 	item makeVisible.
  3194     ].
  3195     self selectedItem:item.
  3196     self setModified.
  3197 !
  3198 
  3199 doMoveInNext
  3200     "move selected item into the next item"
  3201 
  3202     self doMoveIn:#inNext.
  3203 !
  3204 
  3205 doMoveInPrevious
  3206     "move selected item into the previous item"
  3207 
  3208     self doMoveIn:#inPrev.
  3209 !
  3210 
  3211 doMoveOut
  3212     "move selected item out of current item
  3213     "
  3214     |item parent grandParent index|
  3215 
  3216     item := self selectedItem.
  3217     item isNil ifTrue:[^ self].
  3218     item canMoveOut ifFalse:[^ self].
  3219 
  3220     self askForItemModification ifFalse:[ ^ self ].
  3221 
  3222     parent      := item parent.
  3223     grandParent := parent parent.
  3224     index       := grandParent identityIndexOf:parent.
  3225 
  3226     self withoutNotifyDo:[
  3227 	selectionHolder setValue:#().
  3228 	parent remove:item.
  3229 	index > grandParent size ifTrue:[ grandParent add:item ]
  3230 				ifFalse:[ grandParent add:item afterIndex:index ]
  3231     ].
  3232     self selectedItem:item.
  3233     self setModified.
  3234 !
  3235 
  3236 doMoveUp
  3237     "move selected item up"
  3238 
  3239     self doMoveUpOrDown:#up
  3240 !
  3241 
  3242 doMoveUpOrDown:aDirectionSymbol
  3243     "move selected item up (#up) or down (#down)"
  3244 
  3245     |items itemsSortedByIndex index parent children|
  3246 
  3247     items := self selectedItems.
  3248     items isEmptyOrNil ifTrue:[^ self].
  3249     (items conform:[:i | i canMoveUpOrDown]) ifFalse:[^ self].
  3250 
  3251     self askForItemModification ifFalse:[ ^ self ].
  3252 
  3253     self withoutNotifyDo:[
  3254 	itemsSortedByIndex := items copy.
  3255 	(items collect:[:i | listOfItems identityIndexOf:i])
  3256 	    sortWith:itemsSortedByIndex.
  3257 
  3258 	aDirectionSymbol == #down ifTrue:[
  3259 	    itemsSortedByIndex := itemsSortedByIndex reversed
  3260 	].
  3261 	itemsSortedByIndex do:[:item |
  3262 	    parent   := item parent.
  3263 	    children := parent children.
  3264 	    index    := children identityIndexOf:item.
  3265 
  3266 	    selectionHolder setValue:#().
  3267 	    children removeIndex:index.
  3268 
  3269 	    aDirectionSymbol == #up ifTrue:[
  3270 		index == 1 ifTrue:[ children add:item ]
  3271 			ifFalse:[ children add:item beforeIndex:index - 1 ]
  3272 	    ] ifFalse:[
  3273 		index > children size ifTrue:[ children addFirst:item ]
  3274 				    ifFalse:[ children add:item afterIndex:index ]
  3275 	    ].
  3276 	    parent childrenOrderChanged.
  3277 	]
  3278     ].
  3279     self selectedItems:items.
  3280     self setModified.
  3281 
  3282     "Modified: / 18-01-2012 / 11:35:38 / cg"
  3283 ! !
  3284 
  3285 !MenuEditor::Item class methodsFor:'defaults'!
  3286 
  3287 defaultLabel
  3288     ^ self subclassResponsibility
  3289 ! !
  3290 
  3291 !MenuEditor::Item class methodsFor:'image specs'!
  3292 
  3293 iconDelayedLinkedMenu
  3294     "This resource specification was automatically generated
  3295      by the ImageEditor of ST/X."
  3296 
  3297     "Do not manually edit this!! If it is corrupted,
  3298      the ImageEditor may not be able to read the specification."
  3299 
  3300     "
  3301      self iconDelayedLinkedMenu inspect
  3302      ImageEditor openOnClass:self andSelector:#iconDelayedLinkedMenu
  3303      Icon flushCachedIcons
  3304     "
  3305 
  3306     <resource: #image>
  3307 
  3308     ^Icon
  3309         constantNamed:'MenuEditor::Item iconDelayedLinkedMenu'
  3310         ifAbsentPut:[(Depth4Image new) width:20; height:16; bits:(ByteArray fromPackedString:'
  3311 @@@@@@@@@@@@@@DQDQDQDQDQDR@AH"H"H"H"H"H0@@@BH"H"@@@BL@QDPBH"H"@@H#@DQDPBH@H"@"H0ADQDPBA@H"H"L@@@QDP@Q@@@@C@ADPQDQDQ@DQD:
  3312 @RH QDQDQ@H"L@D"H QDQD@"H#@A@@@@@DP@@@@0@QDQDQA@DQDQL@D"H"H @"H"H#@BL3L3L3L3L3L0@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 127 127 127 255 0 0]; mask:((ImageMask new) width:20; height:16; bits:(ByteArray fromPackedString:'???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0') ; yourself); yourself]
  3313 !
  3314 
  3315 iconDelayedMenu
  3316     <resource: #image>
  3317     "This resource specification was automatically generated
  3318      by the ImageEditor of ST/X."
  3319     "Do not manually edit this!! If it is corrupted,
  3320      the ImageEditor may not be able to read the specification."
  3321     "
  3322      self iconDelayedMenu inspect
  3323      ImageEditor openOnClass:self andSelector:#iconDelayedMenu
  3324      Icon flushCachedIcons"
  3325     
  3326     ^ Icon constantNamed:'MenuEditor::Item class iconDelayedMenu'
  3327         ifAbsentPut:[
  3328             (Depth2Image new)
  3329                 width:20;
  3330                 height:16;
  3331                 photometric:(#palette);
  3332                 bitsPerSample:(#( 2 ));
  3333                 samplesPerPixel:(1);
  3334                 bits:(ByteArray 
  3335                             fromPackedString:'@@@@@@@UUUUUVA*****,F***@B0Z***@+A****J,F*****0@@@@@@AUUUUUXF*****0Z****+A@@@@@LEUUUUU0Z****+B?????<@@@@@@@b');
  3336                 colorMapFromArray:#[ 0 0 0 255 255 255 170 170 170 127 127 127 ];
  3337                 mask:((ImageMask new)
  3338                             width:20;
  3339                             height:16;
  3340                             bits:(ByteArray 
  3341                                         fromPackedString:'???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0');
  3342                             yourself);
  3343                 yourself
  3344         ]
  3345 !
  3346 
  3347 iconItem
  3348     <resource: #image>
  3349     "This resource specification was automatically generated
  3350      by the ImageEditor of ST/X."
  3351     "Do not manually edit this!! If it is corrupted,
  3352      the ImageEditor may not be able to read the specification."
  3353     "
  3354      self iconItem inspect
  3355      ImageEditor openOnClass:self andSelector:#iconItem
  3356      Icon flushCachedIcons"
  3357     
  3358     ^ Icon constantNamed:'MenuEditor::Item class iconItem'
  3359         ifAbsentPut:[
  3360             (Depth2Image new)
  3361                 width:20;
  3362                 height:16;
  3363                 photometric:(#palette);
  3364                 bitsPerSample:(#( 2 ));
  3365                 samplesPerPixel:(1);
  3366                 bits:(ByteArray 
  3367                             fromPackedString:'UUUUUUUUUUUUUP@@@@@@EUUUUU Z****+A.?/;+,F:::/>0[++>:;A...++,F::?..0Z****+B?????<@@@@@@@@@@@@@@@@@@@@@@@@@@@b');
  3368                 colorMapFromArray:#[ 0 0 0 255 255 255 170 170 170 127 127 127 ];
  3369                 mask:((ImageMask new)
  3370                             width:20;
  3371                             height:16;
  3372                             bits:(ByteArray 
  3373                                         fromPackedString:'@@@@@@@@???0???0???0???0???0???0???0???0???0???0???0@@@@@@@@@@@@');
  3374                             yourself);
  3375                 yourself
  3376         ]
  3377 !
  3378 
  3379 iconLinkedMenu
  3380     <resource: #image>
  3381     "This resource specification was automatically generated
  3382      by the ImageEditor of ST/X."
  3383     "Do not manually edit this!! If it is corrupted,
  3384      the ImageEditor may not be able to read the specification."
  3385     "
  3386      self iconLinkedMenu inspect
  3387      ImageEditor openOnClass:self andSelector:#iconLinkedMenu
  3388      Icon flushCachedIcons"
  3389     
  3390     ^ Icon constantNamed:'MenuEditor::Item class iconLinkedMenu'
  3391         ifAbsentPut:[
  3392             (Depth4Image new)
  3393                 width:20;
  3394                 height:16;
  3395                 photometric:(#palette);
  3396                 bitsPerSample:(#( 4 ));
  3397                 samplesPerPixel:(1);
  3398                 bits:(ByteArray 
  3399                             fromPackedString:'
  3400 @@@@@@@@@@@@@@QDQDQDQDQDQA@DH"H"H"H"H"HPABH@@@H"H"H"D@PQ@3L0DQDQDQ@D@@L3L0@@@@@PADPCL3L0PCADD@P"@@@3L0@3@!!@DH"H"@3L3L3@P
  3401 AADQDQ@3L3L3@@P@@@@@@3L3LA@DQDQDQD@@L0PPABH"H"H"HC@"D@P"H"H"H"@BH!!@BDQDQDQDQDQDP@@@@@@@@@@@@@@@a');
  3402                 colorMapFromArray:#[ 0 0 0 127 127 127 170 170 170 255 0 0 255 255 255 ];
  3403                 mask:((ImageMask new)
  3404                             width:20;
  3405                             height:16;
  3406                             bits:(ByteArray 
  3407                                         fromPackedString:'???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0');
  3408                             yourself);
  3409                 yourself
  3410         ]
  3411 !
  3412 
  3413 iconMenu
  3414     <resource: #image>
  3415     "This resource specification was automatically generated
  3416      by the ImageEditor of ST/X."
  3417     "Do not manually edit this!! If it is corrupted,
  3418      the ImageEditor may not be able to read the specification."
  3419     "
  3420      self iconMenu inspect
  3421      ImageEditor openOnClass:self andSelector:#iconMenu
  3422      Icon flushCachedIcons"
  3423     
  3424     ^ Icon constantNamed:'MenuEditor::Item class iconMenu'
  3425         ifAbsentPut:[
  3426             (Depth2Image new)
  3427                 width:20;
  3428                 height:16;
  3429                 photometric:(#palette);
  3430                 bitsPerSample:(#( 2 ));
  3431                 samplesPerPixel:(1);
  3432                 bits:(ByteArray 
  3433                             fromPackedString:'@@@@@@@?????=C*****$N*****P5UUUUUC@@@@@DO?????P:****)C*****$MUUUUUP0@@@@AC?????4N*****P:****)BUUUUUT@@@@@@@b');
  3434                 colorMapFromArray:#[ 0 0 0 127 127 127 170 170 170 255 255 255 ];
  3435                 mask:((ImageMask new)
  3436                             width:20;
  3437                             height:16;
  3438                             bits:(ByteArray 
  3439                                         fromPackedString:'???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0???0');
  3440                             yourself);
  3441                 yourself
  3442         ]
  3443 !
  3444 
  3445 iconSeparator
  3446     <resource: #image>
  3447     "This resource specification was automatically generated
  3448      by the ImageEditor of ST/X."
  3449     "Do not manually edit this!! If it is corrupted,
  3450      the ImageEditor may not be able to read the specification."
  3451     "
  3452      self iconSeparator inspect
  3453      ImageEditor openOnClass:self andSelector:#iconSeparator
  3454      Icon flushCachedIcons"
  3455     
  3456     ^ Icon constantNamed:'MenuEditor::Item class iconSeparator'
  3457         ifAbsentPut:[
  3458             (Depth2Image new)
  3459                 width:20;
  3460                 height:16;
  3461                 photometric:(#palette);
  3462                 bitsPerSample:(#( 2 ));
  3463                 samplesPerPixel:(1);
  3464                 bits:(ByteArray 
  3465                             fromPackedString:'UUUUUUUUUUUUUP@@@@@@EUUUUU Z****+A*****,F????:0[@@@@[A)UUUU,F*****0Z****+B?????<@@@@@@@@@@@@@@@@@@@@@@@@@@@b');
  3466                 colorMapFromArray:#[ 0 0 0 255 255 255 170 170 170 127 127 127 ];
  3467                 mask:((ImageMask new)
  3468                             width:20;
  3469                             height:16;
  3470                             bits:(ByteArray 
  3471                                         fromPackedString:'@@@@@@@@???0???0???0???0???0???0???0???0???0???0???0@@@@@@@@@@@@');
  3472                             yourself);
  3473                 yourself
  3474         ]
  3475 !
  3476 
  3477 iconSliceMenu
  3478     <resource: #image>
  3479     "This resource specification was automatically generated
  3480      by the ImageEditor of ST/X."
  3481     "Do not manually edit this!! If it is corrupted,
  3482      the ImageEditor may not be able to read the specification."
  3483     "
  3484      self iconSliceMenu inspect
  3485      ImageEditor openOnClass:self andSelector:#iconSliceMenu
  3486      Icon flushCachedIcons"
  3487     
  3488     ^ Icon constantNamed:'MenuEditor::Item class iconSliceMenu'
  3489         ifAbsentPut:[
  3490             (Depth2Image new)
  3491                 width:20;
  3492                 height:16;
  3493                 photometric:(#palette);
  3494                 bitsPerSample:(#( 2 ));
  3495                 samplesPerPixel:(1);
  3496                 bits:(ByteArray 
  3497                             fromPackedString:'@@@@@@@@@@@@@@@@@@@@O?????0:*****C/?6??XN:*[*) ;*).*&C.*&:*XN5U[UU :*****C*****(@@@@@@@@@@@@@@@@@@@@@@@@@@@b');
  3498                 colorMapFromArray:#[ 0 0 0 127 127 127 170 170 170 255 255 255 ];
  3499                 mask:((ImageMask new)
  3500                             width:20;
  3501                             height:16;
  3502                             bits:(ByteArray 
  3503                                         fromPackedString:'@@@@@@@@???0???0???0???0???0???0???0???0???0???0???0@@@@@@@@@@@@');
  3504                             yourself);
  3505                 yourself
  3506         ]
  3507 ! !
  3508 
  3509 !MenuEditor::Item class methodsFor:'instance creation'!
  3510 
  3511 classFor:aMenuItem
  3512 
  3513     aMenuItem isNil ifTrue:[ ^ nil ].
  3514 
  3515     aMenuItem itemValue isNil ifTrue:[
  3516 	aMenuItem isMenuSlice ifTrue:[ ^ MenuEditor::MenuSliceItem ].
  3517 	aMenuItem submenu notNil ifTrue:[ ^ MenuEditor::RegularMenuItem ].
  3518 	aMenuItem submenuChannel notNil ifTrue:[ ^ MenuEditor::LinkedMenuItem ].
  3519 
  3520 	(self separatorTypeOf:(aMenuItem rawLabel)) notNil ifTrue:[
  3521 	    ^ MenuEditor::SeparatorItem
  3522 	]
  3523     ].
  3524     ^ MenuEditor::ActionItem
  3525 !
  3526 
  3527 menuItem:aMenuItem
  3528     |item cls|
  3529 
  3530     cls := self classFor:aMenuItem.
  3531     cls isNil ifTrue:[^ nil].
  3532 
  3533     item := cls new.
  3534     item menuItem:aMenuItem.
  3535     ^ item
  3536 ! !
  3537 
  3538 !MenuEditor::Item class methodsFor:'interface specs'!
  3539 
  3540 detailsEditSpec
  3541     "This resource specification was automatically generated
  3542      by the UIPainter of ST/X."
  3543 
  3544     "Do not manually edit this!! If it is corrupted,
  3545      the UIPainter may not be able to read the specification."
  3546 
  3547     "
  3548      UIPainter new openOnClass:MenuEditor::Item andSelector:#detailsEditSpec
  3549     "
  3550 
  3551     <resource: #canvas>
  3552 
  3553     ^
  3554      #(FullSpec
  3555 	name: detailsEditSpec
  3556 	window:
  3557        (WindowSpec
  3558 	  label: 'Details Edit'
  3559 	  name: 'Details Edit'
  3560 	  min: (Point 10 10)
  3561 	  bounds: (Rectangle 0 0 407 291)
  3562 	)
  3563 	component:
  3564        (SpecCollection
  3565 	  collection: (
  3566 	   (LabelSpec
  3567 	      label: 'Accelerator:'
  3568 	      name: 'shortcutKeyLabel'
  3569 	      layout: (AlignmentOrigin 107 0 26 0 1 0.5)
  3570 	      activeHelpKey: detailsAccelerator
  3571 	      translateLabel: true
  3572 	      resizeForLabel: true
  3573 	      adjust: right
  3574 	    )
  3575 	   (InputFieldSpec
  3576 	      name: 'shortcutKeyField'
  3577 	      layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  3578 	      activeHelpKey: detailsAccelerator
  3579 	      tabable: true
  3580 	      model: shortcutKeyCharacter
  3581 	      group: inputGroup
  3582 	      type: symbolOrNil
  3583 	      immediateAccept: false
  3584 	      acceptOnReturn: true
  3585 	      acceptOnTab: true
  3586 	      acceptChannel: acceptChannel
  3587 	      modifiedChannel: modifiedChannel
  3588 	      acceptOnPointerLeave: false
  3589 	    )
  3590 	   (LabelSpec
  3591 	      label: 'Enabled:'
  3592 	      name: 'enabledLabel'
  3593 	      layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  3594 	      activeHelpKey: detailsEnabled
  3595 	      translateLabel: true
  3596 	      resizeForLabel: true
  3597 	      adjust: right
  3598 	    )
  3599 	   (InputFieldSpec
  3600 	      name: 'enabledField'
  3601 	      layout: (LayoutFrame 110 0 40 0 -25 1.0 62 0)
  3602 	      activeHelpKey: detailsEnabled
  3603 	      tabable: true
  3604 	      model: enabled
  3605 	      group: inputGroup
  3606 	      type: symbolOrBooleanOrNil
  3607 	      immediateAccept: false
  3608 	      acceptOnReturn: true
  3609 	      acceptOnTab: true
  3610 	      acceptChannel: acceptChannel
  3611 	      modifiedChannel: modifiedChannel
  3612 	      acceptOnPointerLeave: false
  3613 	    )
  3614 	   (ActionButtonSpec
  3615 	      label: 'browseActionImage'
  3616 	      name: 'Button1'
  3617 	      layout: (LayoutFrame -25 1 40 0 -5 1 62 0)
  3618 	      activeHelpKey: browseMethod
  3619 	      hasCharacterOrientedLabel: false
  3620 	      translateLabel: true
  3621 	      resizeForLabel: true
  3622 	      tabable: true
  3623 	      model: doBrowseEnabledMethod
  3624 	    )
  3625 	   (LabelSpec
  3626 	      label: 'Visibility:'
  3627 	      name: 'visibilityLabel'
  3628 	      layout: (AlignmentOrigin 107 0 76 0 1 0.5)
  3629 	      activeHelpKey: detailsVisibility
  3630 	      translateLabel: true
  3631 	      resizeForLabel: true
  3632 	      adjust: right
  3633 	    )
  3634 	   (InputFieldSpec
  3635 	      name: 'isVisibleInputField'
  3636 	      layout: (LayoutFrame 110 0 65 0 -25 1.0 87 0)
  3637 	      activeHelpKey: detailsVisibility
  3638 	      tabable: true
  3639 	      model: isVisible
  3640 	      group: inputGroup
  3641 	      type: symbolOrBooleanOrNil
  3642 	      immediateAccept: false
  3643 	      acceptOnReturn: true
  3644 	      acceptOnTab: true
  3645 	      acceptChannel: acceptChannel
  3646 	      modifiedChannel: modifiedChannel
  3647 	      acceptOnPointerLeave: false
  3648 	    )
  3649 	   (ActionButtonSpec
  3650 	      label: 'browseActionImage'
  3651 	      name: 'Button2'
  3652 	      layout: (LayoutFrame -25 1 65 0 -5 1 87 0)
  3653 	      activeHelpKey: browseMethod
  3654 	      hasCharacterOrientedLabel: false
  3655 	      translateLabel: true
  3656 	      resizeForLabel: true
  3657 	      tabable: true
  3658 	      model: doBrowseVisibilityMethod
  3659 	    )
  3660 	   (LabelSpec
  3661 	      label: 'Aux Value'
  3662 	      name: 'auxLabel'
  3663 	      layout: (AlignmentOrigin 107 0 101 0 1 0.5)
  3664 	      activeHelpKey: detailsAuxValue
  3665 	      translateLabel: true
  3666 	      resizeForLabel: true
  3667 	      adjust: right
  3668 	    )
  3669 	   (InputFieldSpec
  3670 	      name: 'auxInputField'
  3671 	      layout: (LayoutFrame 110 0 90 0 -5 1.0 112 0)
  3672 	      activeHelpKey: detailsAuxValue
  3673 	      tabable: true
  3674 	      model: auxValue
  3675 	      group: inputGroup
  3676 	      type: smalltalkObjectOrNil
  3677 	      immediateAccept: false
  3678 	      acceptOnReturn: true
  3679 	      acceptOnTab: true
  3680 	      acceptChannel: acceptChannel
  3681 	      modifiedChannel: modifiedChannel
  3682 	      acceptOnPointerLeave: false
  3683 	    )
  3684 	   (LabelSpec
  3685 	      label: 'Start Group:'
  3686 	      name: 'StartGroupLabel'
  3687 	      layout: (AlignmentOrigin 107 0 139 0 1 0.5)
  3688 	      activeHelpKey: detailsStartGroup
  3689 	      translateLabel: true
  3690 	      resizeForLabel: true
  3691 	      adjust: right
  3692 	    )
  3693 	   (PopUpListSpec
  3694 	      label: 'left'
  3695 	      name: 'StartGroupPopUp'
  3696 	      layout: (LayoutFrame 110 0 128 0 -5 1.0 150 0)
  3697 	      activeHelpKey: detailsStartGroup
  3698 	      tabable: true
  3699 	      model: startGroup
  3700 	      menu:
  3701 	     (Array
  3702 		left right
  3703 		conditionalRight
  3704 	      )
  3705 	    )
  3706 	   (LabelSpec
  3707 	      label: 'Access Character Position:'
  3708 	      name: 'accessCharLabel'
  3709 	      layout: (AlignmentOrigin 217 0 170 0 1 0.5)
  3710 	      translateLabel: true
  3711 	      resizeForLabel: true
  3712 	      adjust: right
  3713 	    )
  3714 	   (InputFieldSpec
  3715 	      name: 'accessCharField'
  3716 	      layout: (LayoutFrame 220 0 159 0 -5 1.0 181 0)
  3717 	      activeHelpKey: detailsAccessCharaterPosition
  3718 	      tabable: true
  3719 	      model: accessCharacterPosition
  3720 	      group: inputGroup
  3721 	      type: numberOrNil
  3722 	      immediateAccept: false
  3723 	      acceptOnReturn: true
  3724 	      acceptOnTab: true
  3725 	      acceptChannel: acceptChannel
  3726 	      modifiedChannel: modifiedChannel
  3727 	      acceptOnPointerLeave: false
  3728 	    )
  3729 	   (CheckBoxSpec
  3730 	      label: 'Ignore Accelerator (i.e. Display Only)'
  3731 	      name: 'ignoreShortcutKeysInItem'
  3732 	      layout: (AlignmentOrigin 42 0 204 0 0 0.5)
  3733 	      activeHelpKey: detailsIgnoreAcceleratorKeys
  3734 	      visibilityChannel: hasNoSubmenu
  3735 	      model: ignoreShortcutKeys
  3736 	      translateLabel: true
  3737 	      resizeForLabel: true
  3738 	    )
  3739 	   (CheckBoxSpec
  3740 	      label: 'Ignore Accelerators in Submenu'
  3741 	      name: 'ignoreShortcutKeys'
  3742 	      layout: (AlignmentOrigin 42 0 204 0 0 0.5)
  3743 	      activeHelpKey: detailsIgnoreAcceleratorKeys
  3744 	      visibilityChannel: hasSubmenu
  3745 	      model: ignoreShortcutKeys
  3746 	      translateLabel: true
  3747 	      resizeForLabel: true
  3748 	    )
  3749 	   (CheckBoxSpec
  3750 	      label: 'Ignore Mnemonics in Submenu'
  3751 	      name: 'ignoreMnemonicKeys'
  3752 	      layout: (AlignmentOrigin 42 0 232 0 0 0.5)
  3753 	      activeHelpKey: detailsIgnoreMnemonicKeys
  3754 	      visibilityChannel: hasSubmenu
  3755 	      model: ignoreMnemonicKeys
  3756 	      translateLabel: true
  3757 	      resizeForLabel: true
  3758 	    )
  3759 	   (LabelSpec
  3760 	      label: 'Font:'
  3761 	      name: 'fontLabel'
  3762 	      layout: (AlignmentOrigin 107 0 271 0 1 0.5)
  3763 	      translateLabel: true
  3764 	      resizeForLabel: true
  3765 	      adjust: right
  3766 	    )
  3767 	   (FontMenuSpec
  3768 	      name: 'fontMenu'
  3769 	      layout: (LayoutFrame 110 0 260 0 -5 1.0 282 0)
  3770 	      activeHelpKey: fontMenu
  3771 	      model: font
  3772 	      allowSymbolicFonts: true
  3773 	    )
  3774 	   )
  3775 
  3776 	)
  3777       )
  3778 
  3779     "Modified: / 21-10-2010 / 14:15:09 / cg"
  3780 ! !
  3781 
  3782 !MenuEditor::Item class methodsFor:'interface-editor'!
  3783 
  3784 addBindingsTo:aspects for:aMenuEditor
  3785     "add additional bindings to the aspects
  3786     "
  3787     aspects at:#notDelayedMenu ifAbsentPut:[true asValue].
  3788     aspects at:#hasSubmenu ifAbsentPut:[false asValue].
  3789     aspects at:#hasNoSubmenu ifAbsentPut:[true asValue].
  3790 ! !
  3791 
  3792 !MenuEditor::Item class methodsFor:'testing'!
  3793 
  3794 separatorTypeOf:aString
  3795     |size first|
  3796 
  3797     size := aString size.
  3798 
  3799     size == 0 ifTrue:[ ^ #blank ].
  3800 
  3801     size == 1 ifTrue:[
  3802 	first := aString first.
  3803 	first == $-                ifTrue:[ ^ #single ].
  3804 	first == $=                ifTrue:[ ^ #double ].
  3805 	first == (Character space) ifTrue:[ ^ #blank  ].
  3806     ].
  3807     ^ nil
  3808 ! !
  3809 
  3810 !MenuEditor::Item methodsFor:'accessing'!
  3811 
  3812 children
  3813     "optimize access; do not ask the model for unspecified children
  3814     "
  3815     ^ children
  3816 !
  3817 
  3818 hasMenuIndicator:aBoolean
  3819     menuItem hasMenuIndicator:aBoolean
  3820 
  3821     "Created: / 09-08-2018 / 17:03:06 / Claus Gittinger"
  3822 !
  3823 
  3824 menuItem
  3825      "returns self as a MenuItem
  3826     "
  3827     ^ MenuItem decodeFromLiteralArray:(menuItem literalArrayEncoding).
  3828 
  3829     "Modified: / 27-03-2007 / 08:43:14 / cg"
  3830 !
  3831 
  3832 menuItem:aMenuItem
  3833     "rebuild self from a MenuItem
  3834     "
  3835     |value|
  3836 
  3837     menuItem := MenuItem label:(self rawLabel).
  3838 
  3839     MenuEditor aspects do:[:aKey|
  3840         value := self validateValue:(aMenuItem perform:aKey).
  3841 
  3842         value notNil ifTrue:[
  3843             self aspectAt:aKey put:value.
  3844         ].
  3845     ].
  3846 !
  3847 
  3848 rawLabel
  3849     "returns the label assigned to the item
  3850     "
  3851     ^ menuItem rawLabel
  3852 !
  3853 
  3854 rawLabel:aValue
  3855     "set the label assigned to the item
  3856     "
  3857     aValue isString ifTrue:[
  3858 	"/ KLUDGE alarm: '-' and '' indicate a separator
  3859 	"/ (there is no separate menuItem class for them)
  3860 
  3861 	(self isKindOfMenu or:[(self class separatorTypeOf:aValue) isNil]) ifTrue:[
  3862 	    menuItem rawLabel:aValue
  3863 	]
  3864     ].
  3865 !
  3866 
  3867 slices
  3868     "returns a sequence of supported slices
  3869     "
  3870     ^ self subclassResponsibility
  3871 !
  3872 
  3873 submenu
  3874     "returns the submenu (of class Menu) or nil
  3875     "
  3876     ^ nil
  3877 !
  3878 
  3879 translateLabel:aBoolean
  3880     menuItem translateLabel:aBoolean
  3881 ! !
  3882 
  3883 !MenuEditor::Item methodsFor:'aspects'!
  3884 
  3885 aspectAt:aKey put:aValue
  3886     "set a specific aspect named aKey to the aValue"
  3887 
  3888     aKey == #rawLabel       ifTrue:[ ^ self rawLabel:aValue ].
  3889     aKey == #submenuChannel ifTrue:[ ^ self ].
  3890     menuItem perform:(aKey asMutator) with:aValue.
  3891 
  3892     "Modified: / 05-09-2006 / 17:47:19 / cg"
  3893 !
  3894 
  3895 fromAspects:aspects
  3896     "read values from aspects
  3897     "
  3898     MenuEditor aspects do:[:aKey|
  3899 	self aspectAt:aKey put:((aspects at:aKey) value).
  3900     ].
  3901     self validateMenuItem.
  3902     self changed.
  3903 !
  3904 
  3905 toAspects:aspects
  3906     "write values to aspects
  3907     "
  3908     MenuEditor aspects do:[:aKey|
  3909 	(aspects at:aKey) value:(menuItem perform:aKey)
  3910     ].
  3911     (aspects at:#notDelayedMenu) value:(self isDelayedMenu not).
  3912     (aspects at:#hasSubmenu)     value:(self isKindOfMenu or:[self children size ~~ 0]).
  3913     (aspects at:#hasNoSubmenu)   value:(self isKindOfMenu not ).
  3914 !
  3915 
  3916 validateMenuItem
  3917     "validate the menuItem for correctness"
  3918 
  3919     menuItem isNil ifTrue:[^ self].
  3920 
  3921     menuItem choice isEmptyOrNil ifTrue:[
  3922 	menuItem choice:nil.
  3923 	menuItem choiceValue:nil.
  3924     ].
  3925 ! !
  3926 
  3927 !MenuEditor::Item methodsFor:'displaying'!
  3928 
  3929 displayLabel
  3930     "returns the label on default displayed on the screen
  3931     "
  3932     ^ menuItem rawLabel
  3933 !
  3934 
  3935 displayOn:aGC x:x y:y h:h isHighlightedAsSelected:isHighlightedAsSelected
  3936     "display the item in the graphicsContext, aGC"
  3937 
  3938     |label|
  3939 
  3940     label := self displayLabel.
  3941 
  3942     label notNil ifTrue:[
  3943         self displayLabel:label h:(self heightOn:aGC) on:aGC x:x y:y h:h isHighlightedAsSelected:isHighlightedAsSelected
  3944     ].
  3945 !
  3946 
  3947 heightOn:aGC
  3948     "returns the height of the label on a GC
  3949     "
  3950     height isNil ifTrue:[ height := parent heightOn:aGC ].
  3951     ^ height
  3952 !
  3953 
  3954 label
  3955     "get the rawLabel assigned to the item
  3956     "
  3957     ^ menuItem rawLabel
  3958 !
  3959 
  3960 label:aLabel
  3961     "set the rawLabel assigned to the item
  3962     "
  3963     self rawLabel:aLabel
  3964 !
  3965 
  3966 widthOn:aGC
  3967     "returns the height of the displayLabel on a GC
  3968     "
  3969     width isNil ifTrue:[ width := self widthOf:(self displayLabel) on:aGC ].
  3970     ^ width
  3971 ! !
  3972 
  3973 !MenuEditor::Item methodsFor:'initialization'!
  3974 
  3975 initialize
  3976     <modifier: #super> "must be called if redefined"
  3977 
  3978     super initialize.
  3979     menuItem := MenuItem label:(self class defaultLabel).
  3980 
  3981     "Modified: / 08-02-2017 / 00:28:44 / cg"
  3982 ! !
  3983 
  3984 !MenuEditor::Item methodsFor:'private'!
  3985 
  3986 validateValue:aValue
  3987     "if we pick a menupanel, the values of an item can be
  3988      a block model, ....
  3989     "
  3990     aValue notNil ifTrue:[
  3991 	aValue isBlock      ifTrue:[ ^ #block ].
  3992 	aValue isValueModel ifTrue:[ ^ #valueModel ].
  3993     ].
  3994     ^ aValue
  3995 ! !
  3996 
  3997 !MenuEditor::Item methodsFor:'queries'!
  3998 
  3999 isAction
  4000     "returns true if the item is an Action
  4001     "
  4002     ^ false
  4003 !
  4004 
  4005 isDelayedMenu
  4006     "returns true if the item is a Delayed (Linked) Menu
  4007     "
  4008     ^ parent isAction
  4009 !
  4010 
  4011 isKindOfLinkedMenu
  4012     "returns true if the item is a Linked Menu
  4013     "
  4014     ^ false
  4015 !
  4016 
  4017 isKindOfMenu
  4018     "returns true if the item is a Linked Menu or Menu
  4019     "
  4020     ^ false
  4021 !
  4022 
  4023 isKindOfNonLinkedMenu
  4024     "returns true if the item is a Linked Menu
  4025     "
  4026     ^ false
  4027 !
  4028 
  4029 isMenuEditItem
  4030     ^ true
  4031 !
  4032 
  4033 isRootItem
  4034     "returns true if the item is the root item
  4035     "
  4036     ^ false
  4037 ! !
  4038 
  4039 !MenuEditor::Item methodsFor:'queries-editor'!
  4040 
  4041 actionSelectors
  4042     "return my action selectors"
  4043 
  4044     |value|
  4045 
  4046     value := menuItem value.
  4047     value isSymbol ifTrue:[ ^ Array with:value ].
  4048     ^ #()
  4049 !
  4050 
  4051 aspectSelectors
  4052     "return my aspect selectors"
  4053 
  4054     |aspects|
  4055 
  4056     aspects := OrderedCollection new.
  4057 
  4058     #( indication choice enabled isVisible ) do:[:aKey| |sel|
  4059 	sel := menuItem perform:aKey.
  4060 	sel isSymbol ifTrue:[ aspects add:sel ]
  4061     ].
  4062     ^ aspects
  4063 ! !
  4064 
  4065 !MenuEditor::Item methodsFor:'queries-operation'!
  4066 
  4067 canAddChildren
  4068     "returns true if children can be added
  4069     "
  4070     ^ false
  4071 !
  4072 
  4073 canAddDelayedMenu
  4074     "returns true if a delayed menu can be added;
  4075      on default false is returned
  4076     "
  4077     ^ false
  4078 !
  4079 
  4080 canMoveInAbove
  4081     "returns true if the item can become a child of its previous sibling
  4082     "
  4083     |siblings index nextItem|
  4084 
  4085     siblings := parent children.
  4086     siblings size > 1 ifFalse:[ ^ false ].
  4087 
  4088     index    := siblings identityIndexOf:self.
  4089     nextItem := siblings at:(index - 1)  ifAbsent:nil.
  4090 
  4091     nextItem isNil ifTrue:[^ false].
  4092     ^ nextItem canAddChildren
  4093 !
  4094 
  4095 canMoveInNext
  4096     "returns true if the item can become a child of its next sibling
  4097     "
  4098     |siblings index nextItem|
  4099 
  4100     siblings := parent children.
  4101     siblings size > 1 ifFalse:[ ^ false ].
  4102 
  4103     index    := siblings identityIndexOf:self.
  4104     nextItem := siblings at:(index + 1)  ifAbsent:nil.
  4105 
  4106     nextItem isNil ifTrue:[^ false].
  4107     ^ nextItem canAddChildren
  4108 !
  4109 
  4110 canMoveOut
  4111     "returns true if the item can be moved out from its current parent
  4112     "
  4113     self   isDelayedMenu ifTrue:[^ false].
  4114     parent isDelayedMenu ifTrue:[^ false].
  4115 
  4116   ^ parent parent notNil
  4117 !
  4118 
  4119 canMoveUpOrDown
  4120     "returns true if the item can change its vertical order in its sibling
  4121     "
  4122     ^ parent children size > 1
  4123 ! !
  4124 
  4125 !MenuEditor::ImageResourceEditor class methodsFor:'interface specs'!
  4126 
  4127 windowSpec
  4128     "This resource specification was automatically generated
  4129      by the UIPainter of ST/X."
  4130 
  4131     "Do not manually edit this!! If it is corrupted,
  4132      the UIPainter may not be able to read the specification."
  4133 
  4134     "
  4135      UIPainter new openOnClass:MenuEditor::ImageResourceEditor andSelector:#windowSpec
  4136      MenuEditor::ImageResourceEditor new openInterface:#windowSpec
  4137      MenuEditor::ImageResourceEditor open
  4138     "
  4139 
  4140     <resource: #canvas>
  4141 
  4142     ^
  4143      #(FullSpec
  4144 	name: windowSpec
  4145 	window:
  4146        (WindowSpec
  4147 	  label: 'Image Item'
  4148 	  name: 'Image Item'
  4149 	  min: (Point 10 10)
  4150 	  bounds: (Rectangle 0 0 303 304)
  4151 	)
  4152 	component:
  4153        (SpecCollection
  4154 	  collection: (
  4155 	   (LabelSpec
  4156 	      label: 'Retriever:'
  4157 	      name: 'retrieverLabel'
  4158 	      layout: (AlignmentOrigin 107 0 26 0 1 0.5)
  4159 	      activeHelpKey: imageRetriever
  4160 	      translateLabel: true
  4161 	      resizeForLabel: true
  4162 	      adjust: right
  4163 	    )
  4164 	   (ComboBoxSpec
  4165 	      name: 'retrieverHolder'
  4166 	      layout: (LayoutFrame 110 0 15 0 -2 1.0 37 0)
  4167 	      activeHelpKey: imageRetriever
  4168 	      tabable: true
  4169 	      model: retrieverHolder
  4170 	      type: symbolOrNil
  4171 	      immediateAccept: true
  4172 	      acceptOnReturn: false
  4173 	      acceptOnTab: false
  4174 	      acceptOnPointerLeave: false
  4175 	      entryCompletionBlock: entryCompletionForRetriever
  4176 	      comboList: retrieverList
  4177 	      isFilenameBox: false
  4178 	    )
  4179 	   (LabelSpec
  4180 	      label: 'Selector:'
  4181 	      name: 'iconLabel'
  4182 	      layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  4183 	      activeHelpKey: imageSelector
  4184 	      translateLabel: true
  4185 	      resizeForLabel: true
  4186 	      adjust: right
  4187 	    )
  4188 	   (InputFieldSpec
  4189 	      name: 'selectorHolder'
  4190 	      layout: (LayoutFrame 110 0 40 0 -24 1.0 62 0)
  4191 	      activeHelpKey: imageSelector
  4192 	      tabable: true
  4193 	      model: selectorHolder
  4194 	      group: inputGroup
  4195 	      type: symbolOrNil
  4196 	      immediateAccept: true
  4197 	      acceptOnReturn: false
  4198 	      acceptOnTab: false
  4199 	      modifiedChannel: modifiedChannel
  4200 	      acceptOnPointerLeave: false
  4201 	    )
  4202 	   (ActionButtonSpec
  4203 	      label: '...'
  4204 	      name: 'browseButton'
  4205 	      layout: (LayoutFrame -22 1 40 0 -2 1 62 0)
  4206 	      activeHelpKey: browseResource
  4207 	      tabable: true
  4208 	      model: doBrowseForImageResource
  4209 	    )
  4210 	   (DividerSpec
  4211 	      name: 'Separator1'
  4212 	      layout: (LayoutFrame 0 0.0 66 0 0 1.0 70 0)
  4213 	    )
  4214 	   (ViewSpec
  4215 	      name: 'SelectorFilterBox2'
  4216 	      layout: (LayoutFrame 0 0.0 74 0 0 1.0 96 0)
  4217 	      activeHelpKey: selectorFilter
  4218 	      component:
  4219 	     (SpecCollection
  4220 		collection: (
  4221 		 (LabelSpec
  4222 		    label: 'Filter:'
  4223 		    name: 'Label1'
  4224 		    layout: (AlignmentOrigin 107 0 11 0 1 0.5)
  4225 		    activeHelpKey: selectorFilter
  4226 		    translateLabel: true
  4227 		    resizeForLabel: true
  4228 		    adjust: right
  4229 		  )
  4230 		 (InputFieldSpec
  4231 		    name: 'EntryField1'
  4232 		    layout: (LayoutFrame 110 0 0 0 -2 1 22 0)
  4233 		    model: selectorFilterHolder
  4234 		    immediateAccept: true
  4235 		    acceptOnLeave: true
  4236 		    acceptOnReturn: false
  4237 		    acceptOnTab: false
  4238 		    acceptOnPointerLeave: false
  4239 		    activeHelpKey: selectorFilter
  4240 		  )
  4241 		 )
  4242 
  4243 	      )
  4244 	    )
  4245 	   (HierarchicalListViewSpec
  4246 	      name: 'imageList'
  4247 	      layout: (LayoutFrame 2 0.0 100 0 -2 1.0 -60 1.0)
  4248 	      activeHelpKey: imageImageList
  4249 	      model: imageHolder
  4250 	      menu: menuEditImage
  4251 	      hasHorizontalScrollBar: true
  4252 	      hasVerticalScrollBar: true
  4253 	      miniScrollerHorizontal: true
  4254 	      listModel: imageList
  4255 	      useIndex: false
  4256 	      highlightMode: label
  4257 	      postBuildCallback: postBuildImageViewer:
  4258 	    )
  4259 	   (ViewSpec
  4260 	      name: 'Box1'
  4261 	      layout: (LayoutFrame 20 0.0 -60 1.0 -20 1.0 0 1.0)
  4262 	      level: 0
  4263 	      component:
  4264 	     (SpecCollection
  4265 		collection: (
  4266 		 (CheckBoxSpec
  4267 		    label: 'Image & Label'
  4268 		    name: 'iconAndLabelCheckBox'
  4269 		    layout: (AlignmentOrigin 0 0 17 0 0 0.5)
  4270 		    activeHelpKey: imageImageAndLabel
  4271 		    tabable: true
  4272 		    model: iconAndLabelHolder
  4273 		    translateLabel: true
  4274 		  )
  4275 		 (ActionButtonSpec
  4276 		    label: 'Image Editor'
  4277 		    name: 'imageEditorButton'
  4278 		    layout: (AlignmentOrigin -69 1.0 17 0 0 0.5)
  4279 		    activeHelpKey: imageImageEditor
  4280 		    hasCharacterOrientedLabel: false
  4281 		    foregroundColor: (Color 0.0 0.0 66.9993133440146)
  4282 		    tabable: true
  4283 		    model: doEditImage
  4284 		  )
  4285 		 (ActionButtonSpec
  4286 		    label: 'Browse'
  4287 		    name: 'Button1'
  4288 		    layout: (AlignmentOrigin -69 1.0 41 0 0 0.5)
  4289 		    activeHelpKey: imageBrowseImageClass
  4290 		    hasCharacterOrientedLabel: false
  4291 		    foregroundColor: (Color 0.0 0.0 66.9993133440146)
  4292 		    tabable: true
  4293 		    model: doBrowseImageClass
  4294 		  )
  4295 		 )
  4296 
  4297 	      )
  4298 	    )
  4299 	   )
  4300 
  4301 	)
  4302       )
  4303 
  4304     "Modified: / 03-08-2011 / 10:16:13 / cg"
  4305 ! !
  4306 
  4307 !MenuEditor::ImageResourceEditor methodsFor:'accessing'!
  4308 
  4309 resourceRetriever
  4310     |rcv sel cls clsName|
  4311 
  4312     sel := selectorHolder value.
  4313     sel size == 0 ifTrue:[ ^ nil ].
  4314     cls := self retrieverClass.
  4315     cls notNil ifTrue:[
  4316 	clsName := retrieverHolder value.
  4317 	clsName isEmptyOrNil ifTrue:[
  4318 	    clsName := cls name.
  4319 	].
  4320 	clsName := clsName asSymbol.
  4321     ].
  4322 
  4323     rcv := ResourceRetriever new.
  4324     rcv className:clsName.
  4325     rcv selector:sel.
  4326 
  4327     iconAndLabelHolder value ifTrue:[ rcv labelText:'' ].
  4328     ^ rcv
  4329 !
  4330 
  4331 resourceRetriever:aResourceRetriever
  4332     |className sel isOn|
  4333 
  4334     aResourceRetriever notNil ifTrue:[
  4335 	className := aResourceRetriever className.
  4336 	className isBehavior ifTrue:[
  4337 	    className := className name asSymbol
  4338 	].
  4339 	sel  := aResourceRetriever selector.
  4340 	isOn := aResourceRetriever labelText notNil.
  4341     ] ifFalse:[
  4342 	className := sel := nil.
  4343 	isOn := false.
  4344     ].
  4345 
  4346     retrieverHolder value:className.
  4347     selectorHolder  value:sel.
  4348     iconAndLabelHolder value:isOn.
  4349 !
  4350 
  4351 retrieverClass
  4352     |clsName cls|
  4353 
  4354     clsName  := retrieverHolder value.
  4355     clsName notEmptyOrNil ifTrue:[
  4356 	cls := Smalltalk at:clsName ifAbsent:nil.
  4357 	(cls isBehavior) ifTrue:[
  4358 	    ^ cls
  4359 	].
  4360     ].
  4361     ^ nil
  4362 ! !
  4363 
  4364 !MenuEditor::ImageResourceEditor methodsFor:'actions'!
  4365 
  4366 doBrowseForImageResource
  4367     "opens a browser on image-resource methods"
  4368 
  4369     |classAndSelector|
  4370 
  4371     classAndSelector := ResourceSelectionBrowser
  4372 		request:'Use Image From Class'
  4373 		onSuperclass:nil
  4374 		andClass:(self retrieverClass)
  4375 		andSelector:(selectorHolder value)
  4376 		withResourceTypes:#(image fileImage programImage).
  4377 
  4378     classAndSelector isNil ifTrue:[ ^ self ].
  4379 
  4380     retrieverHolder value:(classAndSelector methodClass) name.
  4381     selectorHolder  value:(classAndSelector methodSelector).
  4382 !
  4383 
  4384 doBrowseImageClass
  4385     |cls sel image|
  4386 
  4387     (cls := retrieverHolder value) isNil ifTrue:[
  4388         Dialog warn:'No resource retriever is defined.'.
  4389     ] ifFalse:[
  4390         sel := selectorHolder value.
  4391 
  4392         cls := Smalltalk classNamed:cls.
  4393         cls isNil ifTrue:[
  4394             Dialog warn:'No such resource retriever class.'.
  4395         ] ifFalse:[
  4396             (cls respondsTo:#visualFor:) ifTrue:[
  4397                 Error handle:[:ex |
  4398                     self warn:'The class seems to not understand #',sel.
  4399                 ] do:[
  4400                     image := cls visualFor:sel.
  4401                 ].
  4402                 (image notNil and:[image ~~ (cls perform:sel ifNotUnderstood:nil)]) ifTrue:[
  4403                     self warn:'The image as returned by #visualFor: is probably provided by another class.\\Showing all implementors of #',sel.
  4404                     "/ sel := #visualFor:.
  4405                     SystemBrowser default browseImplementorsOf:sel.
  4406                     ^ self.
  4407                 ].
  4408             ].
  4409             SystemBrowser default openInClass:(cls class) selector:sel
  4410         ]
  4411     ]
  4412 
  4413     "Created: / 20-09-2010 / 13:27:34 / cg"
  4414     "Modified: / 01-09-2017 / 14:21:02 / cg"
  4415     "Modified: / 08-07-2018 / 15:41:37 / Claus Gittinger"
  4416 !
  4417 
  4418 doEditImage
  4419     |sel cls item image|
  4420 
  4421     item := imageHolder value.
  4422     item notNil ifTrue:[
  4423 	item doEdit.
  4424 	^ self.
  4425     ].
  4426 
  4427     sel := selectorHolder value.
  4428     sel isNil ifTrue:[
  4429 	Dialog warn:'No selector is defined.'.
  4430 	^ self.
  4431     ].
  4432     cls := retrieverHolder value.
  4433     cls isNil ifTrue:[
  4434 	Dialog warn:'No resource retriever is defined.'.
  4435 	^ self.
  4436     ].
  4437     cls := Smalltalk classNamed:cls.
  4438     cls isNil ifTrue:[
  4439 	Dialog warn:'No such resource retriever class.'.
  4440 	^ self.
  4441     ].
  4442     (cls respondsTo:#visualFor:) ifTrue:[
  4443 	image := cls visualFor:sel.
  4444 	image ~~ (cls perform:sel ifNotUnderstood:nil) ifTrue:[
  4445 	    self warn:'The image is resolved via #visualFor: from some unknown class'.
  4446 	    image notNil ifTrue:[
  4447 		ImageEditor openOnImage:image.
  4448 	    ].
  4449 	    ^ self.
  4450 	].
  4451     ].
  4452 
  4453     ImageEditor openOnClass:cls andSelector:sel
  4454 ! !
  4455 
  4456 !MenuEditor::ImageResourceEditor methodsFor:'aspects'!
  4457 
  4458 entryCompletionForRetriever
  4459     ^ DoWhatIMeanSupport classNameEntryCompletionBlock.
  4460 
  4461     "Modified: / 10-08-2006 / 12:55:22 / cg"
  4462 !
  4463 
  4464 iconAndLabelHolder
  4465     ^ iconAndLabelHolder
  4466 !
  4467 
  4468 imageHolder
  4469     ^ imageHolder.
  4470 !
  4471 
  4472 imageList
  4473     ^ imageList
  4474 !
  4475 
  4476 modifiedChannel
  4477     ^ builder booleanValueAspectFor: #modifiedChannel
  4478 !
  4479 
  4480 modifiedChannel:aChannel
  4481     builder aspectAt:#modifiedChannel put:aChannel.
  4482 !
  4483 
  4484 retrieverHolder
  4485     ^ retrieverHolder
  4486 !
  4487 
  4488 retrieverList
  4489     |listOfClassNames cls owner|
  4490 
  4491     listOfClassNames := builder bindingAt:#retrieverList.
  4492     listOfClassNames isNil ifTrue:[
  4493         listOfClassNames := MenuEditor imageRetrieverClasses asList.
  4494         builder aspectAt:#retrieverList put:listOfClassNames.
  4495     ].
  4496     (masterApplication notNil
  4497      and:[(cls := masterApplication specClass) notNil]) ifTrue:[
  4498         (listOfClassNames includes:cls name) ifFalse:[ listOfClassNames addFirst:cls name ].
  4499         cls isPrivate ifTrue:[
  4500             (owner := cls owningClass) notNil ifTrue:[
  4501                 (listOfClassNames includes:owner name) ifFalse:[ listOfClassNames addFirst:owner name ].   
  4502             ].
  4503         ].
  4504     ].
  4505     ^ listOfClassNames
  4506 !
  4507 
  4508 selectorFilterHolder
  4509     ^ selectorFilterHolder
  4510 
  4511     "Created: / 03-08-2011 / 10:01:05 / cg"
  4512 !
  4513 
  4514 selectorHolder
  4515     ^ selectorHolder.
  4516 ! !
  4517 
  4518 !MenuEditor::ImageResourceEditor methodsFor:'change & update'!
  4519 
  4520 retrieverChanged
  4521     |retriever list name|
  4522 
  4523     retriever := self retrieverClass.
  4524     imageHolder setValue:nil.
  4525 
  4526     self updateImageList.
  4527     self updateSelectedImage.
  4528 
  4529     (retriever notNil and:[imageList size ~~ 0]) ifTrue:[
  4530 	list := self retrieverList.
  4531 	name := retriever name.
  4532 
  4533 	(list includes:name) ifFalse:[
  4534 	    list add:(name asSymbol).
  4535 	]
  4536     ].
  4537 
  4538     "Modified: / 03-08-2011 / 10:56:58 / cg"
  4539 !
  4540 
  4541 selectorChanged
  4542     self updateSelectedImage.
  4543 
  4544     "Modified: / 03-08-2011 / 10:56:04 / cg"
  4545 !
  4546 
  4547 selectorFilterChanged
  4548     self updateImageList.
  4549     self updateSelectedImage.
  4550 
  4551     "Created: / 03-08-2011 / 10:58:47 / cg"
  4552 !
  4553 
  4554 update:what with:aPara from:aModel
  4555     |item|
  4556 
  4557     self modifiedChannel value:true.
  4558 
  4559     aModel == retrieverHolder ifTrue:[ self retrieverChanged. ^ self ].
  4560     aModel == selectorHolder ifTrue:[ self selectorChanged. ^ self  ].
  4561     aModel == selectorFilterHolder ifTrue:[ self selectorFilterChanged. ^ self  ].
  4562 
  4563     aModel == imageHolder ifTrue:[
  4564 	item := imageHolder value.
  4565 	item notNil ifTrue:[
  4566 	    selectorHolder value:(item label)
  4567 	].
  4568 	^ self
  4569     ].
  4570     super update:what with:aPara from:aModel
  4571 
  4572     "Modified: / 29-11-2011 / 11:28:26 / cg"
  4573 !
  4574 
  4575 updateImageList
  4576     |retriever selectorFilterString filter|
  4577 
  4578     retriever := self retrieverClass.
  4579 
  4580     filter := [:sel | true].
  4581     (selectorFilterString := selectorFilterHolder value) notEmptyOrNil ifTrue:[
  4582         selectorFilterString includesMatchCharacters ifTrue:[
  4583             filter := [:sel | selectorFilterString match:sel caseSensitive:false].
  4584         ] ifFalse:[
  4585             filter := [:sel | sel includesString:selectorFilterString caseSensitive:false].
  4586         ].
  4587     ].
  4588 
  4589     imageList root updateFromClass:retriever selectorFilter:filter.
  4590 
  4591     "Created: / 03-08-2011 / 10:56:41 / cg"
  4592     "Modified: / 27-03-2017 / 12:54:00 / stefan"
  4593 !
  4594 
  4595 updateSelectedImage
  4596     "provider or selector has changed; select it in the list"
  4597 
  4598     |item selector line|
  4599 
  4600     imageList isEmpty ifTrue:[^ self].
  4601 
  4602     selector := selectorHolder value.
  4603     selector isEmptyOrNil ifTrue:[
  4604 	imageHolder value:nil.
  4605 	^ self
  4606     ].
  4607 
  4608     item     := nil.
  4609     selector := selector asSymbol.
  4610 
  4611     imageList do:[:anItem|
  4612 	|sel|
  4613 
  4614 	sel := anItem selector.
  4615 	selector == sel ifTrue:[
  4616 	    imageHolder value:anItem.
  4617 	    ^ self
  4618 	].
  4619 	item isNil ifTrue:[
  4620 	    (sel startsWith:selector) ifTrue:[ item := anItem ]
  4621 	]
  4622     ].
  4623     imageHolder value:nil.
  4624 
  4625     item notNil ifTrue:[
  4626 	line := imageList identityIndexOf:item.
  4627 	line ~~ 0 ifTrue:[
  4628 	    "/ imageListView scrollToLine:line
  4629 	    imageListView makeLineVisible:line
  4630 	]
  4631     ].
  4632 
  4633     "Created: / 03-08-2011 / 10:55:45 / cg"
  4634 ! !
  4635 
  4636 !MenuEditor::ImageResourceEditor methodsFor:'initialization'!
  4637 
  4638 initialize
  4639     super initialize.
  4640 
  4641     iconAndLabelHolder := true asValue.
  4642     iconAndLabelHolder addDependent:self.
  4643 
  4644     imageHolder := nil asValue.
  4645 
  4646     selectorHolder := nil asValue.
  4647     selectorHolder addDependent:self.
  4648 
  4649     imageList := HierarchicalList new.
  4650     imageList application:self.
  4651     imageList root:(ImageResourceEditorItem new).
  4652     imageList showRoot:false.
  4653 
  4654     imageHolder := nil asValue.
  4655     imageHolder addDependent:self.
  4656 
  4657     retrieverHolder := nil asValue.
  4658     retrieverHolder addDependent:self.
  4659 
  4660     selectorFilterHolder := '' asValue.
  4661     selectorFilterHolder addDependent:self.
  4662 
  4663     "Modified: / 03-08-2011 / 10:18:46 / cg"
  4664 !
  4665 
  4666 postBuildImageViewer:aWidget
  4667     imageListView := aWidget.
  4668 ! !
  4669 
  4670 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'accessing'!
  4671 
  4672 icon
  4673     ^ icon
  4674 !
  4675 
  4676 label
  4677     ^ selector
  4678 !
  4679 
  4680 selector
  4681     ^ selector
  4682 ! !
  4683 
  4684 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'instance creation'!
  4685 
  4686 forClass:aClass selector:aSelector
  4687     |w h magnify iconOrSymbol|
  4688 
  4689     selector := aSelector asSymbol.
  4690     selector numArgs == 0 ifFalse:[^ self].
  4691 
  4692     "do what the ResourceRetriever will do"
  4693     (aClass respondsTo:#visualFor:) ifTrue:[
  4694 	iconOrSymbol := aClass visualFor:selector.
  4695     ].
  4696     iconOrSymbol isNil ifTrue:[
  4697 	iconOrSymbol := aClass perform:selector.
  4698     ].
  4699     iconOrSymbol isNil ifTrue:[^ self].
  4700 
  4701     iconOrSymbol isSymbol ifTrue:[
  4702 	icon := ToolbarIconLibrary perform:iconOrSymbol.
  4703     ] ifFalse:[
  4704 	icon := iconOrSymbol.
  4705     ].
  4706 
  4707     w := icon width.
  4708     h := icon height.
  4709 
  4710     w > 32 ifTrue:[
  4711 	magnify := 32 / w.
  4712 	h > 32 ifTrue:[ magnify := (32 / h) max:magnify ].
  4713     ] ifFalse:[
  4714 	h > 32 ifFalse:[^ self].
  4715 	magnify := 32 / h.
  4716     ].
  4717     icon := icon magnifiedBy: magnify.
  4718 
  4719     "Modified: / 13-04-2011 / 18:56:45 / cg"
  4720     "Created: / 03-08-2011 / 10:47:16 / cg"
  4721 !
  4722 
  4723 initialize
  4724     <modifier: #super> "must be called if redefined"
  4725 
  4726     super initialize.
  4727     children := #().
  4728 
  4729     "Modified: / 08-02-2017 / 00:28:37 / cg"
  4730 !
  4731 
  4732 updateFromClass:aClass selectorFilter:aFilterBlock
  4733     (aClass notNil and:[aClass isBehavior]) ifFalse:[
  4734         ^ self collapse.
  4735     ].
  4736 "/    aClass == selector ifTrue:[
  4737 "/        ^ self expand
  4738 "/    ].
  4739     self collapse.
  4740 
  4741     selector := aClass.
  4742 
  4743     self application withWaitCursorDo:[
  4744         |methods|
  4745         methods := aClass methodsWithAnyResource:#(image programImage).
  4746         children := methods 
  4747                         select:[:each| aFilterBlock value:each selector]
  4748                         thenCollect:[:each|
  4749                                 |item|
  4750                                 item := self class new forClass:aClass selector:each selector.
  4751                                 item parent:self.
  4752                         ].
  4753 
  4754         children sort:[:a :b | a label < b label ].
  4755         self expand
  4756     ].
  4757 
  4758     "Created: / 03-08-2011 / 10:48:10 / cg"
  4759 ! !
  4760 
  4761 !MenuEditor::ImageResourceEditor::ImageResourceEditorItem methodsFor:'user operations'!
  4762 
  4763 doEdit
  4764     "open image browser on self"
  4765 
  4766     |parent aClass image|
  4767 
  4768     parent := self parent.
  4769     parent notNil ifTrue:[
  4770 	aClass := parent selector.
  4771 	(aClass respondsTo:#visualFor:) ifTrue:[
  4772 	    image := aClass visualFor:selector.
  4773 	    image ~~ (aClass perform:selector) ifTrue:[
  4774 		self warn:'The image is resolved via #visualFor: from some unknown class'.
  4775 		ImageEditor openOnImage:image.
  4776 		^ self.
  4777 	    ].
  4778 	].
  4779 	ImageEditor openOnClass:aClass andSelector:selector.
  4780     ].
  4781 ! !
  4782 
  4783 !MenuEditor::ActionItem class methodsFor:'defaults'!
  4784 
  4785 defaultLabel
  4786     ^ 'Action'
  4787 ! !
  4788 
  4789 !MenuEditor::ActionItem class methodsFor:'interface specs'!
  4790 
  4791 basicsEditSpec
  4792     "This resource specification was automatically generated
  4793      by the UIPainter of ST/X."
  4794 
  4795     "Do not manually edit this!! If it is corrupted,
  4796      the UIPainter may not be able to read the specification."
  4797 
  4798     "
  4799      UIPainter new openOnClass:MenuEditor::ActionItem andSelector:#basicsEditSpec
  4800     "
  4801 
  4802     <resource: #canvas>
  4803 
  4804     ^ 
  4805      #(FullSpec
  4806         name: basicsEditSpec
  4807         window: 
  4808        (WindowSpec
  4809           label: 'basicsEditSpec'
  4810           name: 'basicsEditSpec'
  4811           min: (Point 10 10)
  4812           bounds: (Rectangle 0 0 340 340)
  4813         )
  4814         component: 
  4815        (SpecCollection
  4816           collection: (
  4817            (LabelSpec
  4818               label: 'Name Key:'
  4819               name: 'nameKeyLabel'
  4820               layout: (AlignmentOrigin 107 0 25 0 1 0.5)
  4821               activeHelpKey: basicsKey
  4822               translateLabel: true
  4823               resizeForLabel: true
  4824               adjust: right
  4825             )
  4826            (InputFieldSpec
  4827               name: 'nameKeyField'
  4828               layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  4829               activeHelpKey: basicsKey
  4830               tabable: true
  4831               model: nameKey
  4832               group: inputGroup
  4833               type: symbolOrNil
  4834               immediateAccept: false
  4835               acceptOnLeave: false
  4836               acceptOnReturn: true
  4837               acceptOnTab: true
  4838               acceptOnLostFocus: false
  4839               acceptChannel: acceptChannel
  4840               modifiedChannel: modifiedChannel
  4841               acceptOnPointerLeave: false
  4842             )
  4843            (LabelSpec
  4844               label: 'Label:'
  4845               name: 'labelLabel'
  4846               layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  4847               activeHelpKey: basicsLabel
  4848               translateLabel: true
  4849               resizeForLabel: true
  4850               adjust: right
  4851             )
  4852            (InputFieldSpec
  4853               name: 'labelField'
  4854               layout: (LayoutFrame 110 0 40 0 -5 1.0 62 0)
  4855               activeHelpKey: basicsLabel
  4856               tabable: true
  4857               model: rawLabel
  4858               group: inputGroup
  4859               immediateAccept: false
  4860               acceptOnReturn: true
  4861               acceptOnTab: true
  4862               acceptOnLostFocus: false
  4863               acceptChannel: acceptChannel
  4864               modifiedChannel: modifiedChannel
  4865               acceptOnPointerLeave: false
  4866             )
  4867            (LabelSpec
  4868               label: 'Action:'
  4869               name: 'valueLabel'
  4870               layout: (AlignmentOrigin 107 0 82 0 1 0.5)
  4871               activeHelpKey: basicsAction
  4872               translateLabel: true
  4873               resizeForLabel: true
  4874               adjust: right
  4875             )
  4876            (InputFieldSpec
  4877               name: 'valueField'
  4878               layout: (LayoutFrame 110 0 71 0 -25 1.0 93 0)
  4879               activeHelpKey: basicsAction
  4880               tabable: true
  4881               model: itemValue
  4882               group: inputGroup
  4883               type: symbolOrNil
  4884               immediateAccept: false
  4885               acceptOnLeave: true
  4886               acceptOnReturn: true
  4887               acceptOnTab: true
  4888               acceptOnLostFocus: true
  4889               acceptChannel: acceptChannel
  4890               modifiedChannel: modifiedChannel
  4891               acceptOnPointerLeave: true
  4892             )
  4893            (ActionButtonSpec
  4894               label: 'browseActionImage'
  4895               name: 'Button1'
  4896               layout: (LayoutFrame -25 1 71 0 -5 1 93 0)
  4897               activeHelpKey: browseMethod
  4898               hasCharacterOrientedLabel: false
  4899               translateLabel: true
  4900               resizeForLabel: true
  4901               tabable: true
  4902               model: doBrowseActionMethod
  4903             )
  4904            (LabelSpec
  4905               label: 'Argument:'
  4906               name: 'argumentLabel'
  4907               layout: (AlignmentOrigin 107 0 107 0 1 0.5)
  4908               activeHelpKey: basicsArgument
  4909               translateLabel: true
  4910               resizeForLabel: true
  4911               adjust: right
  4912             )
  4913            (InputFieldSpec
  4914               name: 'argumentField'
  4915               layout: (LayoutFrame 110 0 96 0 -5 1.0 118 0)
  4916               activeHelpKey: basicsArgument
  4917               tabable: true
  4918               model: argument
  4919               group: inputGroup
  4920               type: smalltalkObjectOrNil
  4921               immediateAccept: false
  4922               acceptOnReturn: true
  4923               acceptOnTab: true
  4924               acceptOnLostFocus: false
  4925               acceptChannel: acceptChannel
  4926               modifiedChannel: modifiedChannel
  4927               acceptOnPointerLeave: false
  4928             )
  4929            (LabelSpec
  4930               label: 'Indication:'
  4931               name: 'indicationLabel'
  4932               layout: (AlignmentOrigin 107 0 138 0 1 0.5)
  4933               activeHelpKey: basicsIndication
  4934               translateLabel: true
  4935               resizeForLabel: true
  4936               adjust: right
  4937             )
  4938            (InputFieldSpec
  4939               name: 'indicationField'
  4940               layout: (LayoutFrame 110 0 127 0 -25 1.0 149 0)
  4941               activeHelpKey: basicsIndication
  4942               enableChannel: indicationEnabled
  4943               tabable: true
  4944               model: indication
  4945               group: inputGroup
  4946               type: symbolOrNil
  4947               immediateAccept: true
  4948               acceptOnReturn: false
  4949               acceptOnTab: false
  4950               acceptOnLostFocus: false
  4951               modifiedChannel: modifiedChannel
  4952               acceptOnPointerLeave: false
  4953             )
  4954            (ActionButtonSpec
  4955               label: 'browseActionImage'
  4956               name: 'Button2'
  4957               layout: (LayoutFrame -25 1 127 0 -5 1 149 0)
  4958               activeHelpKey: browseMethod
  4959               hasCharacterOrientedLabel: false
  4960               translateLabel: true
  4961               resizeForLabel: true
  4962               tabable: true
  4963               model: doBrowseIndicationMethod
  4964             )
  4965            (LabelSpec
  4966               label: 'Choice:'
  4967               name: 'choiceLabel'
  4968               layout: (AlignmentOrigin 107 0 163 0 1 0.5)
  4969               activeHelpKey: basicsChoice
  4970               translateLabel: true
  4971               resizeForLabel: true
  4972               adjust: right
  4973             )
  4974            (InputFieldSpec
  4975               name: 'choiceField'
  4976               layout: (LayoutFrame 110 0 152 0 -25 1.0 174 0)
  4977               activeHelpKey: basicsChoice
  4978               enableChannel: choiceEnabled
  4979               tabable: true
  4980               model: choice
  4981               group: inputGroup
  4982               type: symbolOrNil
  4983               immediateAccept: true
  4984               acceptOnReturn: false
  4985               acceptOnTab: false
  4986               acceptOnLostFocus: false
  4987               modifiedChannel: modifiedChannel
  4988               acceptOnPointerLeave: false
  4989             )
  4990            (ActionButtonSpec
  4991               label: 'browseActionImage'
  4992               name: 'Button3'
  4993               layout: (LayoutFrame -25 1 152 0 -5 1 174 0)
  4994               activeHelpKey: browseMethod
  4995               hasCharacterOrientedLabel: false
  4996               translateLabel: true
  4997               resizeForLabel: true
  4998               tabable: true
  4999               model: doBrowseChoiceMethod
  5000             )
  5001            (LabelSpec
  5002               label: 'Value:'
  5003               name: 'choiceValueLabel'
  5004               layout: (AlignmentOrigin 107 0 188 0 1 0.5)
  5005               activeHelpKey: basicsChoiceValue
  5006               translateLabel: true
  5007               resizeForLabel: true
  5008               adjust: right
  5009             )
  5010            (InputFieldSpec
  5011               name: 'choiceValueField'
  5012               layout: (LayoutFrame 110 0 177 0 -5 1.0 199 0)
  5013               activeHelpKey: basicsChoiceValue
  5014               enableChannel: choiceValueEnabled
  5015               tabable: true
  5016               model: choiceValue
  5017               group: inputGroup
  5018               type: smalltalkObjectOrNil
  5019               immediateAccept: false
  5020               acceptOnLeave: false
  5021               acceptOnReturn: true
  5022               acceptOnTab: true
  5023               acceptOnLostFocus: false
  5024               acceptChannel: acceptChannel
  5025               modifiedChannel: modifiedChannel
  5026               acceptOnPointerLeave: false
  5027             )
  5028            (CheckBoxSpec
  5029               label: 'Translate Label'
  5030               name: 'translateLabelCheckBox'
  5031               layout: (AlignmentOrigin 7 0 213 0 0 0)
  5032               activeHelpKey: basicsTranslateLabel
  5033               tabable: true
  5034               model: translateLabel
  5035               translateLabel: true
  5036             )
  5037            (CheckBoxSpec
  5038               label: 'Is Button'
  5039               name: 'isButtonCheckBox'
  5040               layout: (AlignmentOrigin 7 0 238 0 0 0)
  5041               activeHelpKey: basicsIsButton
  5042               tabable: true
  5043               model: isButton
  5044               translateLabel: true
  5045             )
  5046            (CheckBoxSpec
  5047               label: 'Hide Menu after Activation'
  5048               name: 'hideMenuOnActivated'
  5049               layout: (AlignmentOrigin 7 0 263 0 0 0)
  5050               activeHelpKey: hideMenuOnActivated
  5051               tabable: true
  5052               model: hideMenuOnActivated
  5053               translateLabel: true
  5054             )
  5055            (CheckBoxSpec
  5056               label: 'BusyCursor while Active'
  5057               name: 'showBusyCursorWhilePerforming'
  5058               layout: (AlignmentOrigin 7 0 288 0 0 0)
  5059               activeHelpKey: showBusyCursorWhilePerforming
  5060               tabable: true
  5061               model: showBusyCursorWhilePerforming
  5062               translateLabel: true
  5063             )
  5064            (CheckBoxSpec
  5065               label: 'Trigger on Down'
  5066               name: 'triggerOnDown'
  5067               layout: (AlignmentOrigin 25 0.5 238 0 0 0)
  5068               activeHelpKey: triggerOnDown
  5069               enableChannel: hasNoDelayedMenuValue
  5070               tabable: true
  5071               model: triggerOnDown
  5072               translateLabel: true
  5073             )
  5074            (CheckBoxSpec
  5075               label: 'Send to Originating Widget'
  5076               name: 'sendToOriginator'
  5077               layout: (AlignmentOrigin 7 0 313 0 0 0)
  5078               activeHelpKey: sendToOriginator
  5079               enableChannel: hasItemValue
  5080               tabable: true
  5081               model: sendToOriginator
  5082               translateLabel: true
  5083             )
  5084            )
  5085          
  5086         )
  5087       )
  5088 ! !
  5089 
  5090 !MenuEditor::ActionItem class methodsFor:'interface-editor'!
  5091 
  5092 addBindingsTo:aspects for:aMenuEditor
  5093     "add additional bindings to the aspects
  5094     "
  5095     aspects
  5096 	at:#indicationEnabled
  5097 	ifAbsentPut:[ BlockValue with:[:a | a size == 0 ] argument:(aspects at:#choice)].
  5098 
  5099     aspects
  5100 	at:#choiceEnabled
  5101 	ifAbsentPut:[ BlockValue with:[:a | a size == 0 ] argument:(aspects at:#indication)].
  5102 
  5103     aspects
  5104 	at:#choiceValueEnabled
  5105 	ifAbsentPut:[ BlockValue with:[:a | a size ~~ 0 ] argument:(aspects at:#choice)].
  5106 
  5107     aspects
  5108 	at:#hasNoDelayedMenuValue
  5109 	ifAbsentPut:[true asValue].
  5110 ! !
  5111 
  5112 !MenuEditor::ActionItem methodsFor:'accessing'!
  5113 
  5114 menuItem
  5115     |item|
  5116 
  5117     item := super menuItem.
  5118     self hasDelayedMenu ifTrue:[
  5119 	children first setDelayedAttributesTo:item.
  5120 
  5121 	menuItem value isNil ifTrue:[
  5122 	    menuItem value:#unspecified
  5123 	]
  5124     ].
  5125     ^ item
  5126 !
  5127 
  5128 menuItem:anItem
  5129     |submenu item|
  5130 
  5131     super menuItem:anItem.
  5132     submenu := anItem submenu.
  5133 
  5134     submenu notNil ifTrue:[
  5135 	item := MenuEditor::RegularMenuItem new
  5136     ] ifFalse:[
  5137 	anItem submenuChannel isNil ifTrue:[
  5138 	    ^ self
  5139 	].
  5140 	item := MenuEditor::LinkedMenuItem new
  5141     ].
  5142     item getDelayedAttributesFrom:anItem.
  5143     self add:item.
  5144 !
  5145 
  5146 slices
  5147     ^ #(
  5148 	    (Basics   basicsEditSpec )
  5149 	    (Details  detailsEditSpec)
  5150 	    (Image    image  )
  5151 	    (Help     help)
  5152        )
  5153 ! !
  5154 
  5155 !MenuEditor::ActionItem methodsFor:'adding & removing'!
  5156 
  5157 add:anItem
  5158     "add an item; test whether the item is a delayed menu and
  5159      not already a delayed menu exists."
  5160 
  5161     (anItem isKindOfMenu and:[ self canAddDelayedMenu ]) ifFalse:[
  5162 	^ nil
  5163     ].
  5164 
  5165     menuItem triggerOnDown:false.
  5166     anItem argument:(menuItem argument).
  5167     isExpanded := false.
  5168     anItem parent:self.
  5169     children := Array with:anItem.
  5170     self expand.
  5171     ^ anItem
  5172 
  5173     "Modified: / 05-09-2006 / 17:49:57 / cg"
  5174 ! !
  5175 
  5176 !MenuEditor::ActionItem methodsFor:'aspects'!
  5177 
  5178 aspectAt:aKey put:aValue
  5179     "set a specific aspect named aKey to the aValue"
  5180 
  5181     aKey == #argument ifTrue:[
  5182 	self hasDelayedMenu ifTrue:[
  5183 	    children first argument:aValue
  5184 	].
  5185 	menuItem argument:aValue.
  5186 	^ self
  5187     ].
  5188 
  5189     aKey == #triggerOnDown ifTrue:[
  5190 	|triggerOnDown|
  5191 
  5192 	self hasDelayedMenu ifTrue:[
  5193 	    triggerOnDown := false
  5194 	] ifFalse:[
  5195 	    triggerOnDown := aValue
  5196 	].
  5197 	menuItem triggerOnDown:triggerOnDown.
  5198 	^ self.
  5199     ].
  5200     super aspectAt:aKey put:aValue.
  5201 
  5202     "Modified: / 05-09-2006 / 17:47:24 / cg"
  5203 !
  5204 
  5205 toAspects:aspects
  5206     "write values to aspects
  5207     "
  5208     |hasDelayedMenu|
  5209 
  5210     super toAspects:aspects.
  5211 
  5212     hasDelayedMenu := self hasDelayedMenu.
  5213     (aspects at:#hasNoDelayedMenuValue) value:(hasDelayedMenu not).
  5214 
  5215     hasDelayedMenu ifTrue:[
  5216 	(aspects at:#triggerOnDown) value:false
  5217     ].
  5218 ! !
  5219 
  5220 !MenuEditor::ActionItem methodsFor:'displaying'!
  5221 
  5222 icon
  5223     ^ self class iconItem
  5224 ! !
  5225 
  5226 !MenuEditor::ActionItem methodsFor:'initialization'!
  5227 
  5228 initialize
  5229     <modifier: #super> "must be called if redefined"
  5230 
  5231     super initialize.
  5232     isExpanded := true.
  5233 
  5234     "Modified: / 08-02-2017 / 00:28:28 / cg"
  5235 ! !
  5236 
  5237 !MenuEditor::ActionItem methodsFor:'queries'!
  5238 
  5239 canCollapse
  5240     ^ false
  5241 !
  5242 
  5243 hasDelayedMenu
  5244     "returns true if a delayed menu exists
  5245     "
  5246     ^ children size ~~ 0
  5247 !
  5248 
  5249 hasIndicator
  5250     ^ false
  5251 !
  5252 
  5253 isAction
  5254     ^ true
  5255 ! !
  5256 
  5257 !MenuEditor::ActionItem methodsFor:'queries-operation'!
  5258 
  5259 canAddDelayedMenu
  5260     "returns true if a delayed menu can be added
  5261     "
  5262     ^ self hasDelayedMenu not
  5263 ! !
  5264 
  5265 !MenuEditor::LinkedMenuItem class methodsFor:'defaults'!
  5266 
  5267 defaultLabel
  5268     ^ 'Linked Menu'
  5269 ! !
  5270 
  5271 !MenuEditor::LinkedMenuItem class methodsFor:'interface specs'!
  5272 
  5273 basicsEditSpec
  5274     "This resource specification was automatically generated
  5275      by the UIPainter of ST/X."
  5276 
  5277     "Do not manually edit this!! If it is corrupted,
  5278      the UIPainter may not be able to read the specification."
  5279 
  5280     "
  5281      UIPainter new openOnClass:MenuEditor::LinkedMenuItem andSelector:#basicsEditSpec
  5282     "
  5283 
  5284     <resource: #canvas>
  5285 
  5286     ^
  5287      #(FullSpec
  5288 	name: basicsEditSpec
  5289 	window:
  5290        (WindowSpec
  5291 	  label: 'basicsEditSpec'
  5292 	  name: 'basicsEditSpec'
  5293 	  min: (Point 10 10)
  5294 	  bounds: (Rectangle 0 0 340 340)
  5295 	)
  5296 	component:
  5297        (SpecCollection
  5298 	  collection: (
  5299 	   (LabelSpec
  5300 	      label: 'Name Key:'
  5301 	      name: 'nameKeyLabel'
  5302 	      layout: (AlignmentOrigin 107 0 25 0 1 0.5)
  5303 	      activeHelpKey: basicsKey
  5304 	      visibilityChannel: notDelayedMenu
  5305 	      translateLabel: true
  5306 	      resizeForLabel: true
  5307 	      adjust: right
  5308 	    )
  5309 	   (InputFieldSpec
  5310 	      name: 'nameKeyField'
  5311 	      layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  5312 	      activeHelpKey: basicsKey
  5313 	      visibilityChannel: notDelayedMenu
  5314 	      tabable: true
  5315 	      model: nameKey
  5316 	      group: inputGroup
  5317 	      type: symbolOrNil
  5318 	      immediateAccept: false
  5319 	      acceptOnLeave: false
  5320 	      acceptOnReturn: true
  5321 	      acceptOnTab: true
  5322 	      acceptOnLostFocus: false
  5323 	      acceptChannel: acceptChannel
  5324 	      modifiedChannel: modifiedChannel
  5325 	      acceptOnPointerLeave: false
  5326 	    )
  5327 	   (LabelSpec
  5328 	      label: 'Label:'
  5329 	      name: 'labelLabel'
  5330 	      layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  5331 	      activeHelpKey: basicsLabel
  5332 	      visibilityChannel: notDelayedMenu
  5333 	      translateLabel: true
  5334 	      resizeForLabel: true
  5335 	      adjust: right
  5336 	    )
  5337 	   (InputFieldSpec
  5338 	      name: 'labelField'
  5339 	      layout: (LayoutFrame 110 0 40 0 -5 1.0 62 0)
  5340 	      activeHelpKey: basicsLabel
  5341 	      visibilityChannel: notDelayedMenu
  5342 	      tabable: true
  5343 	      model: rawLabel
  5344 	      group: inputGroup
  5345 	      immediateAccept: false
  5346 	      acceptOnReturn: true
  5347 	      acceptOnTab: true
  5348 	      acceptOnLostFocus: false
  5349 	      acceptChannel: acceptChannel
  5350 	      modifiedChannel: modifiedChannel
  5351 	      acceptOnPointerLeave: false
  5352 	    )
  5353 	   (LabelSpec
  5354 	      label: 'Menu:'
  5355 	      name: 'menuLabel'
  5356 	      layout: (AlignmentOrigin 107 0 90 0 1 0.5)
  5357 	      activeHelpKey: basicsLabel
  5358 	      translateLabel: true
  5359 	      resizeForLabel: true
  5360 	      adjust: right
  5361 	    )
  5362 	   (InputFieldSpec
  5363 	      name: 'menuField'
  5364 	      layout: (LayoutFrame 110 0 79 0 -5 1.0 101 0)
  5365 	      activeHelpKey: basicsMenu
  5366 	      tabable: true
  5367 	      model: submenuChannel
  5368 	      group: inputGroup
  5369 	      type: symbolOrNil
  5370 	      immediateAccept: false
  5371 	      acceptOnReturn: true
  5372 	      acceptOnTab: true
  5373 	      acceptOnLostFocus: false
  5374 	      acceptChannel: acceptChannel
  5375 	      modifiedChannel: modifiedChannel
  5376 	      acceptOnPointerLeave: false
  5377 	    )
  5378 	   (LabelSpec
  5379 	      label: 'Argument:'
  5380 	      name: 'argumentLabel'
  5381 	      layout: (AlignmentOrigin 107 0 115 0 1 0.5)
  5382 	      activeHelpKey: basicsLabel
  5383 	      translateLabel: true
  5384 	      resizeForLabel: true
  5385 	      adjust: right
  5386 	    )
  5387 	   (InputFieldSpec
  5388 	      name: 'argumentField'
  5389 	      layout: (LayoutFrame 110 0 104 0 -5 1.0 126 0)
  5390 	      activeHelpKey: basicsMenuArgument
  5391 	      enableChannel: notDelayedMenu
  5392 	      tabable: true
  5393 	      model: argument
  5394 	      group: inputGroup
  5395 	      type: smalltalkObjectOrNil
  5396 	      immediateAccept: false
  5397 	      acceptOnReturn: true
  5398 	      acceptOnTab: true
  5399 	      acceptOnLostFocus: false
  5400 	      acceptChannel: acceptChannel
  5401 	      modifiedChannel: modifiedChannel
  5402 	      acceptOnPointerLeave: false
  5403 	    )
  5404 	   (CheckBoxSpec
  5405 	      label: 'Translate Label'
  5406 	      name: 'translateLabelCheckBox'
  5407 	      layout: (Point 20 213)
  5408 	      activeHelpKey: basicsTranslateLabel
  5409 	      visibilityChannel: notDelayedMenu
  5410 	      tabable: true
  5411 	      model: translateLabel
  5412 	      translateLabel: true
  5413 	    )
  5414 	   (CheckBoxSpec
  5415 	      label: 'Is Button'
  5416 	      name: 'isButtonCheckBox'
  5417 	      layout: (Point 20 238)
  5418 	      activeHelpKey: basicsIsButton
  5419 	      visibilityChannel: notDelayedMenu
  5420 	      tabable: true
  5421 	      model: isButton
  5422 	      translateLabel: true
  5423 	    )
  5424 	   (CheckBoxSpec
  5425 	      label: 'Horizontal Layout'
  5426 	      name: 'horizontalLayout'
  5427 	      layout: (Point 20 263)
  5428 	      activeHelpKey: horizontalLayout
  5429 	      tabable: true
  5430 	      model: horizontalLayout
  5431 	      translateLabel: true
  5432 	    )
  5433 	   (CheckBoxSpec
  5434 	      label: 'Do not Destroy Linked Menu'
  5435 	      name: 'keepLinkedMenu'
  5436 	      layout: (Point 20 288)
  5437 	      activeHelpKey: keepLinkedMenu
  5438 	      tabable: true
  5439 	      model: keepLinkedMenu
  5440 	      translateLabel: true
  5441 	    )
  5442 	   )
  5443 
  5444 	)
  5445       )
  5446 ! !
  5447 
  5448 !MenuEditor::LinkedMenuItem methodsFor:'accessing'!
  5449 
  5450 argument:aValue
  5451     menuItem argument:aValue.
  5452 !
  5453 
  5454 menuItem
  5455      "returns self as a MenuItem
  5456     "
  5457     |item|
  5458 
  5459     item := super menuItem.
  5460     item submenuChannel:(self submenuChannel).
  5461   ^ item
  5462 !
  5463 
  5464 slices
  5465     self isDelayedMenu ifTrue:[
  5466 	^ #(
  5467 		(Basics   basicsEditSpec )
  5468 	   )
  5469     ].
  5470 
  5471     ^ #(
  5472 	    (Basics   basicsEditSpec )
  5473 	    (Details  detailsEditSpec)
  5474 	    (Image    image  )
  5475 	    (Help     help)
  5476        )
  5477 ! !
  5478 
  5479 !MenuEditor::LinkedMenuItem methodsFor:'accessing-channels'!
  5480 
  5481 submenuChannel
  5482     ^ menuItem submenuChannel ? #unspecified
  5483 !
  5484 
  5485 submenuChannel:aValue
  5486     menuItem submenuChannel:aValue.
  5487 ! !
  5488 
  5489 !MenuEditor::LinkedMenuItem methodsFor:'aspects'!
  5490 
  5491 aspectAt:aKey put:aValue
  5492     "set a specific aspect named aKey to the aValue"
  5493 
  5494     aKey == #submenuChannel ifTrue:[ ^ self submenuChannel:aValue ].
  5495     super aspectAt:aKey put:aValue.
  5496 
  5497     "Modified: / 05-09-2006 / 17:47:39 / cg"
  5498 !
  5499 
  5500 getDelayedAttributesFrom:anItem
  5501 
  5502     menuItem rawLabel:'Delayed'.
  5503 
  5504     menuItem   submenuChannel:(self validateValue:(anItem submenuChannel)).
  5505     menuItem horizontalLayout:(self validateValue:(anItem horizontalLayout)).
  5506     menuItem   keepLinkedMenu:(self validateValue:(anItem keepLinkedMenu)).
  5507 !
  5508 
  5509 setDelayedAttributesTo:aMenuItem
  5510     aMenuItem   submenuChannel:(self submenuChannel).
  5511     aMenuItem horizontalLayout:(menuItem horizontalLayout).
  5512     aMenuItem   keepLinkedMenu:(menuItem keepLinkedMenu).
  5513 ! !
  5514 
  5515 !MenuEditor::LinkedMenuItem methodsFor:'displaying'!
  5516 
  5517 displayLabel
  5518     "returns the label dependent on is delayed or not
  5519     "
  5520     self isDelayedMenu ifTrue:[ ^ self submenuChannel ].
  5521   ^ menuItem rawLabel
  5522 !
  5523 
  5524 icon
  5525     self isDelayedMenu ifTrue:[ ^ self class iconDelayedLinkedMenu ].
  5526   ^ self class iconLinkedMenu
  5527 ! !
  5528 
  5529 !MenuEditor::LinkedMenuItem methodsFor:'initialization'!
  5530 
  5531 initialize
  5532     "setup default values on the item"
  5533 
  5534     <modifier: #super> "must be called if redefined"
  5535 
  5536     super initialize.
  5537 
  5538     "setting default values
  5539     "
  5540     "/ CG: Thu, 08 May 2008 11:16:54 GMT
  5541     "/     I think having keepLinkedMenu true by default
  5542     "/     will confuse newcomers (even me occasionally)
  5543     "/     (will search, why the menu is not updated...)
  5544 
  5545     "/ menuItem keepLinkedMenu:true.
  5546     menuItem keepLinkedMenu:false.
  5547 
  5548     "Modified (comment): / 08-02-2017 / 00:29:14 / cg"
  5549 ! !
  5550 
  5551 !MenuEditor::LinkedMenuItem methodsFor:'queries'!
  5552 
  5553 isKindOfLinkedMenu
  5554     ^ true
  5555 !
  5556 
  5557 isKindOfMenu
  5558     ^ true
  5559 ! !
  5560 
  5561 !MenuEditor::MenuSliceItem class methodsFor:'defaults'!
  5562 
  5563 defaultLabel
  5564     ^ 'Menu Slice'
  5565 ! !
  5566 
  5567 !MenuEditor::MenuSliceItem class methodsFor:'interface specs'!
  5568 
  5569 basicsEditSpec
  5570     "This resource specification was automatically generated
  5571      by the UIPainter of ST/X."
  5572 
  5573     "Do not manually edit this!! If it is corrupted,
  5574      the UIPainter may not be able to read the specification."
  5575 
  5576     "
  5577      UIPainter new openOnClass:MenuEditor::MenuSliceItem andSelector:#basicsEditSpec
  5578     "
  5579 
  5580     <resource: #canvas>
  5581 
  5582     ^
  5583      #(FullSpec
  5584 	name: basicsEditSpec
  5585 	window:
  5586        (WindowSpec
  5587 	  label: 'basicsEditSpec'
  5588 	  name: 'basicsEditSpec'
  5589 	  min: (Point 10 10)
  5590 	  bounds: (Rectangle 0 0 344 146)
  5591 	)
  5592 	component:
  5593        (SpecCollection
  5594 	  collection: (
  5595 	   (LabelSpec
  5596 	      label: 'Name Key:'
  5597 	      name: 'nameKeyLabel'
  5598 	      layout: (AlignmentOrigin 107 0 25 0 1 0.5)
  5599 	      activeHelpKey: basicsKey
  5600 	      visibilityChannel: notDelayedMenu
  5601 	      translateLabel: true
  5602 	      resizeForLabel: true
  5603 	      adjust: right
  5604 	    )
  5605 	   (InputFieldSpec
  5606 	      name: 'nameKeyField'
  5607 	      layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  5608 	      activeHelpKey: basicsKey
  5609 	      visibilityChannel: notDelayedMenu
  5610 	      tabable: true
  5611 	      model: nameKey
  5612 	      group: inputGroup
  5613 	      type: symbolOrNil
  5614 	      immediateAccept: false
  5615 	      acceptOnLeave: false
  5616 	      acceptOnReturn: true
  5617 	      acceptOnTab: true
  5618 	      acceptOnLostFocus: false
  5619 	      acceptChannel: acceptChannel
  5620 	      modifiedChannel: modifiedChannel
  5621 	      acceptOnPointerLeave: false
  5622 	    )
  5623 	   (LabelSpec
  5624 	      label: 'Label:'
  5625 	      name: 'labelLabel'
  5626 	      layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  5627 	      activeHelpKey: basicsLabel
  5628 	      visibilityChannel: notDelayedMenu
  5629 	      translateLabel: true
  5630 	      resizeForLabel: true
  5631 	      adjust: right
  5632 	    )
  5633 	   (InputFieldSpec
  5634 	      name: 'labelField'
  5635 	      layout: (LayoutFrame 110 0 40 0 -5 1.0 62 0)
  5636 	      activeHelpKey: basicsLabel
  5637 	      visibilityChannel: notDelayedMenu
  5638 	      tabable: true
  5639 	      model: rawLabel
  5640 	      group: inputGroup
  5641 	      immediateAccept: false
  5642 	      acceptOnReturn: true
  5643 	      acceptOnTab: true
  5644 	      acceptOnLostFocus: false
  5645 	      acceptChannel: acceptChannel
  5646 	      modifiedChannel: modifiedChannel
  5647 	      acceptOnPointerLeave: false
  5648 	    )
  5649 	   (LabelSpec
  5650 	      label: 'Menu:'
  5651 	      name: 'menuLabel'
  5652 	      layout: (AlignmentOrigin 107 0 90 0 1 0.5)
  5653 	      activeHelpKey: basicsLabel
  5654 	      translateLabel: true
  5655 	      resizeForLabel: true
  5656 	      adjust: right
  5657 	    )
  5658 	   (InputFieldSpec
  5659 	      name: 'menuField'
  5660 	      layout: (LayoutFrame 110 0 79 0 -5 1.0 101 0)
  5661 	      activeHelpKey: basicsMenu
  5662 	      tabable: true
  5663 	      model: submenuChannel
  5664 	      group: inputGroup
  5665 	      type: symbolOrNil
  5666 	      immediateAccept: false
  5667 	      acceptOnReturn: true
  5668 	      acceptOnTab: true
  5669 	      acceptOnLostFocus: false
  5670 	      acceptChannel: acceptChannel
  5671 	      modifiedChannel: modifiedChannel
  5672 	      acceptOnPointerLeave: false
  5673 	    )
  5674 	   (LabelSpec
  5675 	      label: 'Argument:'
  5676 	      name: 'argumentLabel'
  5677 	      layout: (AlignmentOrigin 107 0 115 0 1 0.5)
  5678 	      activeHelpKey: basicsLabel
  5679 	      translateLabel: true
  5680 	      resizeForLabel: true
  5681 	      adjust: right
  5682 	    )
  5683 	   (InputFieldSpec
  5684 	      name: 'argumentField'
  5685 	      layout: (LayoutFrame 110 0 104 0 -5 1.0 126 0)
  5686 	      activeHelpKey: basicsMenuArgument
  5687 	      enableChannel: notDelayedMenu
  5688 	      tabable: true
  5689 	      model: argument
  5690 	      group: inputGroup
  5691 	      type: smalltalkObjectOrNil
  5692 	      immediateAccept: false
  5693 	      acceptOnReturn: true
  5694 	      acceptOnTab: true
  5695 	      acceptOnLostFocus: false
  5696 	      acceptChannel: acceptChannel
  5697 	      modifiedChannel: modifiedChannel
  5698 	      acceptOnPointerLeave: false
  5699 	    )
  5700 	   )
  5701 
  5702 	)
  5703       )
  5704 ! !
  5705 
  5706 !MenuEditor::MenuSliceItem methodsFor:'accessing'!
  5707 
  5708 icon
  5709     ^ self class iconSliceMenu
  5710 !
  5711 
  5712 menuItem
  5713      "returns self as a MenuItem
  5714     "
  5715     |item|
  5716 
  5717     item := super menuItem.
  5718     item submenuChannel:(self submenuChannel).
  5719     item isMenuSlice:true.
  5720   ^ item
  5721 !
  5722 
  5723 slices
  5724     ^ #(
  5725 	    (Basics   basicsEditSpec)
  5726        )
  5727 ! !
  5728 
  5729 !MenuEditor::MenuSliceItem methodsFor:'aspects'!
  5730 
  5731 argument:aValue
  5732     menuItem argument:aValue.
  5733 !
  5734 
  5735 aspectAt:aKey put:aValue
  5736     "set a specific aspect named aKey to the aValue"
  5737 
  5738     aKey == #submenuChannel ifTrue:[ ^ self submenuChannel:aValue ].
  5739     aKey == #isSliceMenu    ifTrue:[ ^ self ].
  5740 
  5741     super aspectAt:aKey put:aValue.
  5742 
  5743     "Modified: / 05-09-2006 / 17:47:42 / cg"
  5744 !
  5745 
  5746 submenuChannel
  5747     ^ menuItem submenuChannel ? #unspecified
  5748 !
  5749 
  5750 submenuChannel:aValue
  5751     menuItem submenuChannel:aValue.
  5752 ! !
  5753 
  5754 !MenuEditor::RegularMenuItem class methodsFor:'defaults'!
  5755 
  5756 defaultDelayedLabel
  5757     ^ 'delayed'
  5758 !
  5759 
  5760 defaultLabel
  5761     ^ 'Menu'
  5762 ! !
  5763 
  5764 !MenuEditor::RegularMenuItem class methodsFor:'instance creation'!
  5765 
  5766 menu:aMenu labeled:aString
  5767     |item|
  5768 
  5769     item := self new.
  5770     item menu:aMenu labeled:aString.
  5771     ^ item
  5772 !
  5773 
  5774 menu:aMenu labeled:aString translateLabel:translateLabel
  5775     |item|
  5776 
  5777     item := self new.
  5778     item menu:aMenu labeled:aString.
  5779     item translateLabel:translateLabel.
  5780     ^ item
  5781 ! !
  5782 
  5783 !MenuEditor::RegularMenuItem class methodsFor:'interface specs'!
  5784 
  5785 basicsEditSpec
  5786     "This resource specification was automatically generated
  5787      by the UIPainter of ST/X."
  5788 
  5789     "Do not manually edit this!! If it is corrupted,
  5790      the UIPainter may not be able to read the specification."
  5791 
  5792     "
  5793      UIPainter new openOnClass:MenuEditor::RegularMenuItem andSelector:#basicsEditSpec
  5794     "
  5795 
  5796     <resource: #canvas>
  5797 
  5798     ^ 
  5799     #(FullSpec
  5800        name: basicsEditSpec
  5801        uuid: '62cf58f0-9bea-11e8-8c6e-b8f6b1108e05'
  5802        window: 
  5803       (WindowSpec
  5804          label: 'basicsEditSpec'
  5805          name: 'basicsEditSpec'
  5806          uuid: 'd6768940-9be5-11e8-8c6e-b8f6b1108e05'
  5807          min: (Point 10 10)
  5808          bounds: (Rectangle 0 0 340 340)
  5809        )
  5810        component: 
  5811       (SpecCollection
  5812          collection: (
  5813           (LabelSpec
  5814              label: 'Name Key:'
  5815              name: 'nameKeyLabel'
  5816              layout: (AlignmentOrigin 107 0 25 0 1 0.5)
  5817              activeHelpKey: basicsKey
  5818              uuid: 'd676e930-9be5-11e8-8c6e-b8f6b1108e05'
  5819              visibilityChannel: notDelayedMenu
  5820              translateLabel: true
  5821              resizeForLabel: true
  5822              adjust: right
  5823            )
  5824           (InputFieldSpec
  5825              name: 'nameKeyField'
  5826              layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  5827              activeHelpKey: basicsKey
  5828              uuid: 'd676ec64-9be5-11e8-8c6e-b8f6b1108e05'
  5829              visibilityChannel: notDelayedMenu
  5830              tabable: true
  5831              model: nameKey
  5832              group: inputGroup
  5833              type: symbolOrNil
  5834              immediateAccept: false
  5835              acceptOnLeave: false
  5836              acceptOnReturn: true
  5837              acceptOnTab: true
  5838              acceptOnLostFocus: false
  5839              acceptChannel: acceptChannel
  5840              modifiedChannel: modifiedChannel
  5841              acceptOnPointerLeave: false
  5842            )
  5843           (LabelSpec
  5844              label: 'Label:'
  5845              name: 'labelLabel'
  5846              layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  5847              activeHelpKey: basicsLabel
  5848              uuid: 'd676effc-9be5-11e8-8c6e-b8f6b1108e05'
  5849              visibilityChannel: notDelayedMenu
  5850              translateLabel: true
  5851              resizeForLabel: true
  5852              adjust: right
  5853            )
  5854           (InputFieldSpec
  5855              name: 'labelField'
  5856              layout: (LayoutFrame 110 0 40 0 -5 1.0 62 0)
  5857              activeHelpKey: basicsLabel
  5858              uuid: 'd676f150-9be5-11e8-8c6e-b8f6b1108e05'
  5859              visibilityChannel: notDelayedMenu
  5860              tabable: true
  5861              model: rawLabel
  5862              group: inputGroup
  5863              immediateAccept: false
  5864              acceptOnReturn: true
  5865              acceptOnTab: true
  5866              acceptOnLostFocus: false
  5867              acceptChannel: acceptChannel
  5868              modifiedChannel: modifiedChannel
  5869              acceptOnPointerLeave: false
  5870            )
  5871           (VerticalPanelViewSpec
  5872              name: 'VerticalPanel1'
  5873              layout: (LayoutFrame 6 0 188 0 0 1 323 0)
  5874              uuid: 'd676f326-9be5-11e8-8c6e-b8f6b1108e05'
  5875              horizontalLayout: fit
  5876              verticalLayout: top
  5877              horizontalSpace: 3
  5878              verticalSpace: 3
  5879              component: 
  5880             (SpecCollection
  5881                collection: (
  5882                 (CheckBoxSpec
  5883                    label: 'Translate Label'
  5884                    name: 'translateLabelCheckBox'
  5885                    activeHelpKey: basicsTranslateLabel
  5886                    uuid: 'd676f54c-9be5-11e8-8c6e-b8f6b1108e05'
  5887                    visibilityChannel: notDelayedMenu
  5888                    tabable: true
  5889                    model: translateLabel
  5890                    translateLabel: true
  5891                    extent: (Point 334 30)
  5892                  )
  5893                 (CheckBoxSpec
  5894                    label: 'Is Button'
  5895                    name: 'isButtonCheckBox'
  5896                    activeHelpKey: basicsIsButton
  5897                    uuid: 'd676f786-9be5-11e8-8c6e-b8f6b1108e05'
  5898                    visibilityChannel: notDelayedMenu
  5899                    tabable: true
  5900                    model: isButton
  5901                    translateLabel: true
  5902                    extent: (Point 334 30)
  5903                  )
  5904                 (CheckBoxSpec
  5905                    label: 'Horizontal Layout'
  5906                    name: 'horizontalLayout'
  5907                    activeHelpKey: horizontalLayout
  5908                    uuid: 'd676f8d0-9be5-11e8-8c6e-b8f6b1108e05'
  5909                    tabable: true
  5910                    model: horizontalLayout
  5911                    translateLabel: true
  5912                    extent: (Point 334 30)
  5913                  )
  5914                 (CheckBoxSpec
  5915                    label: 'Force Menu Indicator'
  5916                    name: 'CheckBox1'
  5917                    activeHelpKey: forceMenuIndicator
  5918                    uuid: 'd676fa06-9be5-11e8-8c6e-b8f6b1108e05'
  5919                    tabable: true
  5920                    model: hasMenuIndicator
  5921                    translateLabel: true
  5922                    extent: (Point 334 30)
  5923                  )
  5924                 )
  5925               
  5926              )
  5927            )
  5928           )
  5929         
  5930        )
  5931      )
  5932 ! !
  5933 
  5934 !MenuEditor::RegularMenuItem methodsFor:'accessing'!
  5935 
  5936 argument:aValue
  5937     "/ ignorred.
  5938 !
  5939 
  5940 menu:aMenu labeled:aString
  5941     |expanded item menu|
  5942 
  5943     self synchronized:[
  5944         self isRootItem ifTrue:[ expanded := true ]
  5945                        ifFalse:[ expanded := isExpanded ].
  5946 
  5947         self removeAll.
  5948         self rawLabel:aString.
  5949 
  5950         menu := aMenu value.
  5951 
  5952         (menu isNil or:[menu isString]) ifTrue:[
  5953             menu := nil
  5954         ] ifFalse:[
  5955             aMenu isCollection ifTrue:[ menu := Menu decodeFromLiteralArray:aMenu ]
  5956                               ifFalse:[ menu := aMenu ].
  5957 
  5958             menu hasItems ifFalse:[
  5959                 menu := nil
  5960             ].
  5961         ].
  5962         menu notNil ifTrue:[
  5963             isExpanded := false.        "/ discard change notifications
  5964             children   := OrderedCollection new.
  5965 
  5966             menu itemsDo:[:el|
  5967                 item := self class menuItem:el.
  5968                 item parent:self.
  5969                 children add:item.
  5970             ].
  5971             expanded ifTrue:[ self expand ].
  5972         ].
  5973         isExpanded := expanded.
  5974     ].
  5975     self changed
  5976 
  5977     "Modified: / 29-11-2011 / 11:28:33 / cg"
  5978     "Modified: / 28-07-2018 / 15:49:52 / Claus Gittinger"
  5979 !
  5980 
  5981 menuItem
  5982     "returns self as a MenuItem
  5983     "
  5984     |item|
  5985 
  5986     item := super menuItem.
  5987     item submenu:(self submenu).
  5988   ^ item
  5989 !
  5990 
  5991 menuItem:anItem
  5992 
  5993     super menuItem:anItem.
  5994     self  menu:(anItem submenu) labeled:nil.
  5995 !
  5996 
  5997 slices
  5998     self isDelayedMenu ifTrue:[
  5999 	^ #(
  6000 		(Basics   basicsEditSpec )
  6001 	   )
  6002     ].
  6003 
  6004     ^ #(
  6005 	    (Basics   basicsEditSpec )
  6006 	    (Details  detailsEditSpec)
  6007 	    (Image    image  )
  6008 	    (Help     help)
  6009        )
  6010 !
  6011 
  6012 submenu
  6013     |menu|
  6014 
  6015     menu := Menu new.
  6016 
  6017     children size ~~ 0 ifTrue:[
  6018 	children do:[:el| menu addItem:(el menuItem) ].
  6019     ].
  6020     ^ menu
  6021 ! !
  6022 
  6023 !MenuEditor::RegularMenuItem methodsFor:'aspects'!
  6024 
  6025 getDelayedAttributesFrom:aMenuItem
  6026 
  6027     |menu|
  6028 
  6029     menu := self validateValue:(aMenuItem submenu value).
  6030 
  6031     self menu:menu labeled:nil.
  6032     menuItem horizontalLayout:(aMenuItem horizontalLayout).
  6033 !
  6034 
  6035 setDelayedAttributesTo:aMenuItem
  6036     aMenuItem          submenu:(self submenu).
  6037     aMenuItem horizontalLayout:(menuItem horizontalLayout).
  6038 ! !
  6039 
  6040 !MenuEditor::RegularMenuItem methodsFor:'displaying'!
  6041 
  6042 displayLabel
  6043     "returns the label dependent on is delayed or not
  6044     "
  6045     self isDelayedMenu ifTrue:[ ^ self class defaultDelayedLabel ].
  6046   ^ menuItem rawLabel
  6047 !
  6048 
  6049 icon
  6050     self isDelayedMenu ifTrue:[ ^ self class iconDelayedMenu ].
  6051   ^ self class iconMenu
  6052 ! !
  6053 
  6054 !MenuEditor::RegularMenuItem methodsFor:'queries'!
  6055 
  6056 canAddChildren
  6057     "children can be added
  6058     "
  6059     ^ true
  6060 !
  6061 
  6062 canExpand
  6063     "returns true if the item is expandable
  6064     "
  6065     ^ isExpanded == false
  6066 !
  6067 
  6068 hasIndicator
  6069     ^ true
  6070 !
  6071 
  6072 isKindOfMenu
  6073     ^ true
  6074 !
  6075 
  6076 isKindOfNonLinkedMenu
  6077     ^ true
  6078 ! !
  6079 
  6080 !MenuEditor::RootItem class methodsFor:'defaults'!
  6081 
  6082 defaultLabel
  6083     ^ MenuEditor resourceType
  6084 ! !
  6085 
  6086 !MenuEditor::RootItem class methodsFor:'interface specs'!
  6087 
  6088 basicsEditSpec
  6089     "This resource specification was automatically generated
  6090      by the UIPainter of ST/X."
  6091 
  6092     "Do not manually edit this!! If it is corrupted,
  6093      the UIPainter may not be able to read the specification."
  6094 
  6095     "
  6096      UIPainter new openOnClass:MenuEditor::RootItem andSelector:#basicsEditSpec
  6097     "
  6098 
  6099     <resource: #canvas>
  6100 
  6101     ^
  6102      #(FullSpec
  6103 	name: basicsEditSpec
  6104 	window:
  6105        (WindowSpec
  6106 	  label: 'basicsEditSpec'
  6107 	  name: 'basicsEditSpec'
  6108 	  min: (Point 10 10)
  6109 	  bounds: (Rectangle 0 0 260 46)
  6110 	)
  6111 	component:
  6112        (SpecCollection
  6113 	  collection: (
  6114 	   (LabelSpec
  6115 	      label: 'Selector:'
  6116 	      name: 'selectorLabel'
  6117 	      layout: (AlignmentOrigin 107 0 26 0 1 0.5)
  6118 	      activeHelpKey: basicsSelector
  6119 	      translateLabel: true
  6120 	      resizeForLabel: true
  6121 	      adjust: right
  6122 	    )
  6123 	   (InputFieldSpec
  6124 	      name: 'selectorField'
  6125 	      layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  6126 	      activeHelpKey: basicsSelector
  6127 	      tabable: true
  6128 	      model: rawLabel
  6129 	      group: inputGroup
  6130 	      type: string
  6131 	      immediateAccept: false
  6132 	      acceptOnReturn: true
  6133 	      acceptOnTab: true
  6134 	      acceptChannel: acceptChannel
  6135 	      modifiedChannel: modifiedChannel
  6136 	      acceptOnPointerLeave: false
  6137 	    )
  6138 	   )
  6139 
  6140 	)
  6141       )
  6142 ! !
  6143 
  6144 !MenuEditor::RootItem class methodsFor:'interface-editor'!
  6145 
  6146 addBindingsTo:aspects for:aMenuEditor
  6147     "add additional bindings to the aspects
  6148     "
  6149 ! !
  6150 
  6151 !MenuEditor::RootItem methodsFor:'accessing'!
  6152 
  6153 menuItem:aMenuItem
  6154     "rebuild self from a MenuItem
  6155     "
  6156     |submenu selector|
  6157 
  6158     aMenuItem notNil ifTrue:[
  6159 	submenu  := aMenuItem submenu.
  6160 	selector := aMenuItem rawLabel.
  6161     ] ifFalse:[
  6162 	selector := submenu := nil.
  6163     ].
  6164     self menu:submenu labeled:selector.
  6165 !
  6166 
  6167 rawLabel:aValue
  6168     "set the label assigned to the item
  6169     "
  6170     |value|
  6171 
  6172     aValue isString ifTrue:[
  6173 	value := aValue withoutSeparators.
  6174 
  6175 	(value notEmpty and:[value first isLetter]) ifTrue:[
  6176 	    menuItem rawLabel:(value asSymbol)
  6177 	].
  6178     ].
  6179 !
  6180 
  6181 slices
  6182     ^ #(
  6183 	    (Basics   basicsEditSpec)
  6184        )
  6185 ! !
  6186 
  6187 !MenuEditor::RootItem methodsFor:'adding & removing'!
  6188 
  6189 remove
  6190     "cannot remove the root item; delete all my children
  6191     "
  6192     self removeAll.
  6193 ! !
  6194 
  6195 !MenuEditor::RootItem methodsFor:'aspects'!
  6196 
  6197 aspectAt:aKey put:aValue
  6198     "ignore all aspects other than the rawLabel"
  6199 
  6200     aKey == #rawLabel ifTrue:[ self rawLabel:aValue ].
  6201 
  6202     "Modified: / 05-09-2006 / 17:48:01 / cg"
  6203 ! !
  6204 
  6205 !MenuEditor::RootItem methodsFor:'displaying'!
  6206 
  6207 heightOn:aGC
  6208     height isNil ifTrue:[ height := aGC font heightOn:aGC device ].
  6209     ^ height
  6210 ! !
  6211 
  6212 !MenuEditor::RootItem methodsFor:'initialization'!
  6213 
  6214 initialize
  6215     <modifier: #super> "must be called if redefined"
  6216 
  6217     super initialize.
  6218     isExpanded := true.
  6219 
  6220     "Modified: / 08-02-2017 / 00:29:29 / cg"
  6221 ! !
  6222 
  6223 !MenuEditor::RootItem methodsFor:'queries'!
  6224 
  6225 canCollapse
  6226     ^ false
  6227 !
  6228 
  6229 hasIndicator
  6230     ^ false
  6231 !
  6232 
  6233 isDelayedMenu
  6234     ^ false
  6235 !
  6236 
  6237 isRootItem
  6238     ^ true
  6239 ! !
  6240 
  6241 !MenuEditor::RootItem methodsFor:'queries-editor'!
  6242 
  6243 actionSelectors
  6244     "return my action selectors"
  6245 
  6246     ^ #()
  6247 !
  6248 
  6249 aspectSelectors
  6250     "returns my aspect selectors
  6251     "
  6252     ^ #()
  6253 ! !
  6254 
  6255 !MenuEditor::RootItem methodsFor:'queries-operation'!
  6256 
  6257 canMoveInAbove
  6258     ^ false
  6259 !
  6260 
  6261 canMoveInNext
  6262     ^ false
  6263 !
  6264 
  6265 canMoveOut
  6266     ^ false
  6267 !
  6268 
  6269 canMoveUpOrDown
  6270    ^ false
  6271 ! !
  6272 
  6273 !MenuEditor::SeparatorItem class methodsFor:'interface specs'!
  6274 
  6275 basicsEditSpec
  6276     "This resource specification was automatically generated
  6277      by the UIPainter of ST/X."
  6278 
  6279     "Do not manually edit this!! If it is corrupted,
  6280      the UIPainter may not be able to read the specification."
  6281 
  6282     "
  6283      UIPainter new openOnClass:MenuEditor::SeparatorItem andSelector:#basicsEditSpec
  6284     "
  6285 
  6286     <resource: #canvas>
  6287 
  6288     ^
  6289      #(FullSpec
  6290 	name: basicsEditSpec
  6291 	window:
  6292        (WindowSpec
  6293 	  label: 'basicsEditSpec'
  6294 	  name: 'basicsEditSpec'
  6295 	  min: (Point 10 10)
  6296 	  bounds: (Rectangle 0 0 260 245)
  6297 	)
  6298 	component:
  6299        (SpecCollection
  6300 	  collection: (
  6301 	   (LabelSpec
  6302 	      label: 'Separator:'
  6303 	      name: 'separatorLabel'
  6304 	      layout: (AlignmentOrigin 107 0 26 0 1 0.5)
  6305 	      translateLabel: true
  6306 	      resizeForLabel: true
  6307 	      adjust: right
  6308 	    )
  6309 	   (ComboListSpec
  6310 	      name: 'seperatorList'
  6311 	      layout: (LayoutFrame 110 0 15 0 -5 1.0 37 0)
  6312 	      activeHelpKey: basicsSeparatorType
  6313 	      tabable: true
  6314 	      model: seperatorSelection
  6315 	      comboList: seperatorList
  6316 	      useIndex: true
  6317 	    )
  6318 	   (LabelSpec
  6319 	      label: 'Visibility:'
  6320 	      name: 'visibilityLabel'
  6321 	      layout: (AlignmentOrigin 107 0 51 0 1 0.5)
  6322 	      translateLabel: true
  6323 	      resizeForLabel: true
  6324 	      adjust: right
  6325 	    )
  6326 	   (InputFieldSpec
  6327 	      name: 'visibilityInputField'
  6328 	      layout: (LayoutFrame 110 0 40 0 -5 1.0 62 0)
  6329 	      activeHelpKey: detailsVisibility
  6330 	      tabable: true
  6331 	      model: isVisible
  6332 	      group: inputGroup
  6333 	      type: symbolOrBooleanOrNil
  6334 	      immediateAccept: false
  6335 	      acceptOnReturn: true
  6336 	      acceptOnTab: true
  6337 	      acceptChannel: acceptChannel
  6338 	      modifiedChannel: modifiedChannel
  6339 	      acceptOnPointerLeave: false
  6340 	    )
  6341 	   (LabelSpec
  6342 	      label: 'Start Group:'
  6343 	      name: 'startGroupLabel'
  6344 	      layout: (AlignmentOrigin 107 0 88 0 1 0.5)
  6345 	      translateLabel: true
  6346 	      resizeForLabel: true
  6347 	      adjust: right
  6348 	    )
  6349 	   (PopUpListSpec
  6350 	      label: 'left'
  6351 	      name: 'startGroupPopUp'
  6352 	      layout: (LayoutFrame 110 0 77 0 -5 1.0 99 0)
  6353 	      activeHelpKey: detailsStartGroup
  6354 	      tabable: true
  6355 	      model: startGroup
  6356 	      menu: (left right conditionalRight)
  6357 	    )
  6358 	   )
  6359 
  6360 	)
  6361       )
  6362 
  6363     "Modified: / 16-10-2006 / 12:48:30 / cg"
  6364 ! !
  6365 
  6366 !MenuEditor::SeparatorItem class methodsFor:'interface-editor'!
  6367 
  6368 addBindingsTo:aspects for:aMenuEditor
  6369     "add additional bindings to the aspects
  6370     "
  6371     |holder|
  6372 
  6373     aspects
  6374 	at:#seperatorList
  6375 	ifAbsentPut:
  6376 	    [
  6377 		|l|
  6378 
  6379 		l := self separatorSlices collect:[:el| el last ].
  6380 		l := l collect:[:s | self classResources string:s ].
  6381 		l
  6382 	    ].
  6383 
  6384     aspects at:#seperatorSelection ifAbsentPut:[
  6385 	holder := 0 asValue.
  6386 	holder addDependent:aMenuEditor.
  6387 	holder
  6388     ].
  6389 !
  6390 
  6391 defaultLabel
  6392     ^ '-'
  6393 !
  6394 
  6395 separatorSlices
  6396     "get the list of menu spec values of the corresponding separator types
  6397     "
  6398     ^ #(
  6399 	( #blank        ''      'blank' )
  6400 	( #single       '-'     'single line')
  6401 	( #double       '='     'double line')
  6402       )
  6403 ! !
  6404 
  6405 !MenuEditor::SeparatorItem methodsFor:'accessing'!
  6406 
  6407 icon
  6408     ^ self class iconSeparator
  6409 !
  6410 
  6411 rawLabel:aValue
  6412     |value|
  6413 
  6414     aValue isString ifTrue:[
  6415 	value := aValue withoutSeparators.
  6416 
  6417 	(self class separatorTypeOf:value) notNil ifTrue:[
  6418 	    menuItem rawLabel:value
  6419 	]
  6420     ].
  6421 
  6422     "Modified: / 29-11-2011 / 11:28:39 / cg"
  6423 !
  6424 
  6425 separatorType
  6426     ^ self class separatorTypeOf:(menuItem rawLabel).
  6427 !
  6428 
  6429 slices
  6430     ^ #(
  6431 	    (Basics   basicsEditSpec)
  6432        )
  6433 ! !
  6434 
  6435 !MenuEditor::SeparatorItem methodsFor:'aspects'!
  6436 
  6437 fromAspects:aspects
  6438     "put my values into the values of aspects
  6439     "
  6440     |index slice|
  6441 
  6442     index  := (aspects at:#seperatorSelection) value ? 0.
  6443     slice  := self class separatorSlices at:index ifAbsent:nil.
  6444 
  6445     slice notNil ifTrue:[ slice := slice at:2 ].
  6446 
  6447     (aspects at:#rawLabel) value:slice.
  6448   ^ super fromAspects:aspects.
  6449 
  6450     "Modified: / 29-11-2011 / 11:28:36 / cg"
  6451 !
  6452 
  6453 toAspects:aspects
  6454     "put my values into the values of aspects
  6455     "
  6456     |index type|
  6457 
  6458     type   := self separatorType.
  6459     index  := self class separatorSlices findFirst:[:el| el first == type ].
  6460 
  6461     (aspects at:#seperatorSelection) value:index.
  6462   ^ super  toAspects:aspects.
  6463 ! !
  6464 
  6465 !MenuEditor::SeparatorItem methodsFor:'displaying'!
  6466 
  6467 displayOn:aGC x:x y:y h:h isHighlightedAsSelected:isHighlightedAsSelected
  6468     "draw the receiver in the graphicsContext, aGC"
  6469 
  6470     |x1 y0 type|
  6471 
  6472     type := self separatorType.
  6473     type == #blank ifTrue:[ ^ self ].
  6474 
  6475     x1 := x + (self widthOn:aGC).
  6476     y0 := y + (h // 2) - 1.
  6477 
  6478     type == #double ifTrue:[
  6479         y0 := y0 + 1.
  6480         aGC displayLineFromX:x y:y0 toX:x1 y:y0.
  6481         y0 := y0 - 2
  6482     ].
  6483     aGC displayLineFromX:x y:y0 toX:x1 y:y0
  6484 !
  6485 
  6486 widthOn:aGC
  6487     width isNil ifTrue:[ width := 60 ].
  6488     ^ width
  6489 ! !
  6490 
  6491 !MenuEditor class methodsFor:'documentation'!
  6492 
  6493 version
  6494     ^ '$Header$'
  6495 !
  6496 
  6497 version_CVS
  6498     ^ '$Header$'
  6499 ! !
  6500 
  6501 
  6502 MenuEditor initialize!