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