MenuEditor.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3365 51b676d98742
child 3396 efbf0e6f05b4
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

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