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