MenuEditor.st
changeset 1702 ace326bd303f
parent 1691 a3f8baada9e6
child 1711 548d690e780f
equal deleted inserted replaced
1701:079827c2760d 1702:ace326bd303f
   325 
   325 
   326 #detailsAuxValue
   326 #detailsAuxValue
   327 'Some additional value - for arbitrary use by the program.'
   327 'Some additional value - for arbitrary use by the program.'
   328 
   328 
   329 #detailsEnabled
   329 #detailsEnabled
   330 'Aspect or binding providing a boolean value holder for the enable-state of the menu item.'
   330 'Aspect or binding providing a boolean value holder to enable/disable the menu item.'
   331 
   331 
   332 #detailsStartGroup
   332 #detailsStartGroup
   333 'Specify start of a right-aligned item group.'
   333 'Specify start of a right-aligned item group.'
   334 
   334 
   335 #detailsVisibility
   335 #detailsVisibility
   355 
   355 
   356 #generateAspectMethods
   356 #generateAspectMethods
   357 'Generates aspect methods for defined aspect selectors of the menu.'
   357 'Generates aspect methods for defined aspect selectors of the menu.'
   358 
   358 
   359 #hideMenuOnActivated
   359 #hideMenuOnActivated
   360 'If on, the menu hides itself after the item was activated.'
   360 'If on, the menu hides itself after the item was activated (PopUp/PullDown-Menus only).'
   361 
   361 
   362 #horizontalLayout
   362 #horizontalLayout
   363 'If on, the submenu organizes its items horizontal insteat of vertical (default).'
   363 'If on, the submenu organizes its items horizontal insteat of vertical (default).'
   364 
   364 
   365 #imageImageAndLabel
   365 #imageImageAndLabel
   370 
   370 
   371 #imageImageList
   371 #imageImageList
   372 'Currently existing image resources.'
   372 'Currently existing image resources.'
   373 
   373 
   374 #imageRetriever
   374 #imageRetriever
   375 'Class implementing the image resource method. If no class is given, the current application class will be taken.'
   375 'Class implementing the image resource method. If unspecified, the application class is taken.'
   376 
   376 
   377 #imageSelector
   377 #imageSelector
   378 'Selector returning an image (sent to above or the application).'
   378 'Selector returning an image (sent to above or the application).'
   379 
   379 
   380 #keepLinkedMenu
   380 #keepLinkedMenu
   381 'Keep the linked menu after activation (do not destroy).'
   381 'Keep the linked menu after activation (do not destroy).'
   382 
   382 
   383 #sendToOriginator
   383 #sendToOriginator
   384 'Send action-Message to widget (instead of application).'
   384 'Send action-Message to widget (instead of application); only valid for PopUpMenus.'
   385 
   385 
   386 #settingsRedefineAspectMethods
   386 #settingsRedefineAspectMethods
   387 'Toggles the permission to overwrite existing aspect methods.'
   387 'Toggles the permission to overwrite existing aspect methods.'
   388 
   388 
   389 #showBusyCursorWhilePerforming
   389 #showBusyCursorWhilePerforming
   390 'If on, a busy cursor is shown while the items action is performing.'
   390 'If on, a busy cursor is shown while the items action is performing.'
   391 
   391 
   392 #triggerOnDown
   392 #triggerOnDown
   393 'If on, the items action is performed on mouse-button press (default is on button-release).'
   393 'If on, the items action is performed on mouse-button press (default is: on button-release).'
   394 
   394 
   395 )
   395 )
   396 !
   396 !
   397 
   397 
   398 localFlyHelpSpecStrings
   398 localFlyHelpSpecStrings
   437 #addSubMenuLink
   437 #addSubMenuLink
   438 'Add Linked Submenu'
   438 'Add Linked Submenu'
   439 
   439 
   440 #fileNew
   440 #fileNew
   441 'New Spec'
   441 'New Spec'
   442 )
       
   443 !
       
   444 
       
   445 localHelpSpecStrings
       
   446     "This resource specification was automatically generated
       
   447      by the UIHelpTool of ST/X."
       
   448 
       
   449     "Do not manually edit this!! If it is corrupted,
       
   450      the UIHelpTool may not be able to read the specification."
       
   451 
       
   452     "
       
   453      UIHelpTool openOnClass:MenuEditor    
       
   454     "
       
   455 
       
   456     <resource: #help>
       
   457 
       
   458     ^ #(
       
   459 
       
   460 #addDelayedMenu
       
   461 'Add a new delayed menu to item.'
       
   462 
       
   463 #addDelayedSubMenuLink
       
   464 'Add a new linked delayed menu to item.'
       
   465 
       
   466 #addMenuItem
       
   467 'Add a new menu item.'
       
   468 
       
   469 #addMenuSeparator
       
   470 'Add a new menu separator.'
       
   471 
       
   472 #addSubMenu
       
   473 'Add a new sub menu.'
       
   474 
       
   475 #addSubMenuLink
       
   476 'Add a new linked sub menu.'
       
   477 
       
   478 #basicsAction
       
   479 'An action selector with 0, 1 (the argument field), or 2 (the selected item) arguments.'
       
   480 
       
   481 #basicsArgument
       
   482 'An optional arg passed with above selector, if it is a 1 or 2 arg selector (enter a Smalltalk literal).'
       
   483 
       
   484 #basicsChoice
       
   485 'Aspect for a boolean holder, block or method, specifying the choices state (RadioButton behavior).'
       
   486 
       
   487 #basicsChoiceValue
       
   488 'That choices value (typically number or symbol).'
       
   489 
       
   490 #basicsIndication
       
   491 'Aspect for boolean holder, block, or method, specifying the indication state (CheckToggle behavior).'
       
   492 
       
   493 #basicsIsButton
       
   494 'Button-like look and behavior.'
       
   495 
       
   496 #basicsKey
       
   497 'Internal key of the item (optional, for programmed accesses).'
       
   498 
       
   499 #basicsLabel
       
   500 'Label of the item.'
       
   501 
       
   502 #basicsMenu
       
   503 'Aspect providing the sub menu to be opened if item is selected (provide spec or valueHolder).'
       
   504 
       
   505 #basicsMenuArgument
       
   506 'An argument passed with the menu selector.'
       
   507 
       
   508 #basicsNameKey
       
   509 'Unique identifier of the item (optional).'
       
   510 
       
   511 #basicsSelector
       
   512 'Selector under which the generated menu spec is saved.'
       
   513 
       
   514 #basicsSeparatorType
       
   515 'List of valid separators.'
       
   516 
       
   517 #basicsTranslateLabel
       
   518 'Translate the label via the classes resource file (internationalization).'
       
   519 
       
   520 #browseResource
       
   521 'Search for methods with image resource.'
       
   522 
       
   523 #detailsAccelerator
       
   524 'Accelerator key to select the menu item from the keyboard (Cmdx or Ctrlx).'
       
   525 
       
   526 #detailsAccessCharaterPosition
       
   527 'Index of the access character position of the textual label (obsolete, VW compatibility).'
       
   528 
       
   529 #detailsAuxValue
       
   530 'Some additional value - for arbitrary use by the program.'
       
   531 
       
   532 #detailsEnabled
       
   533 'Aspect or binding providing a boolean value holder to enable/disable the menu item.'
       
   534 
       
   535 #detailsStartGroup
       
   536 'Specify start of a right-aligned item group.'
       
   537 
       
   538 #detailsVisibility
       
   539 'Boolean, or aspect or binding for a boolean holder controlling the visibility of the menu item.'
       
   540 
       
   541 #fileLoad
       
   542 'Open a dialog to select and load a menu spec from a class.'
       
   543 
       
   544 #fileNew
       
   545 'Create a new menu spec.'
       
   546 
       
   547 #filePickAMenu
       
   548 'Select a menu from an open view and read its specification'
       
   549 
       
   550 #fileSave
       
   551 'Save the menu spec (and the help spec, if modified).'
       
   552 
       
   553 #fileSaveAs
       
   554 'Open a dialog to save the menu spec (and the help spec, if modified).'
       
   555 
       
   556 #fileShowMenuSpec
       
   557 'Opens a Workspace showing the current menu spec.'
       
   558 
       
   559 #generateAspectMethods
       
   560 'Generates aspect methods for defined aspect selectors of the menu.'
       
   561 
       
   562 #hideMenuOnActivated
       
   563 'If on, the menu hides itself after the item was activated (PopUpMenus only).'
       
   564 
       
   565 #horizontalLayout
       
   566 'If on, the submenu organizes its items horizontal insteat of vertical (default).'
       
   567 
       
   568 #imageImageAndLabel
       
   569 'Toggle display of both image and textual label.'
       
   570 
       
   571 #imageImageEditor
       
   572 'Open an Image Editor on the resource method defined by retriever and selector.'
       
   573 
       
   574 #imageImageList
       
   575 'Currently existing image resources.'
       
   576 
       
   577 #imageRetriever
       
   578 'Class implementing the image resource method. If unspecified, the application class is taken.'
       
   579 
       
   580 #imageSelector
       
   581 'Selector returning an image (sent to above or the application).'
       
   582 
       
   583 #keepLinkedMenu
       
   584 'Keep the linked menu after activation (do not destroy).'
       
   585 
       
   586 #showBusyCursorWhilePerforming
       
   587 'If on, a busy cursor is shown while the items action is performing.'
       
   588 
       
   589 #sendToOriginator
       
   590 'Send action-Message to the widget (instead of application).'
       
   591 
       
   592 #settingsRedefineAspectMethods
       
   593 'Toggles the permission to overwrite existing aspect methods.'
       
   594 
       
   595 #triggerOnDown
       
   596 'If on, the items action is performed on mouse-button press (default is: on button-release).'
       
   597 
       
   598 )
   442 )
   599 ! !
   443 ! !
   600 
   444 
   601 !MenuEditor class methodsFor:'image specs'!
   445 !MenuEditor class methodsFor:'image specs'!
   602 
   446 
  1871 
  1715 
  1872     wizardHolder value:canvas.
  1716     wizardHolder value:canvas.
  1873 !
  1717 !
  1874 
  1718 
  1875 update:something with:aParameter from:changedObject
  1719 update:something with:aParameter from:changedObject
  1876     "Invoked when an object that I depend upon sends a change notification.
       
  1877     "
       
  1878     notifyDisabledCounter ~~ 0 ifTrue:[ ^ self ].
  1720     notifyDisabledCounter ~~ 0 ifTrue:[ ^ self ].
  1879 
  1721 
  1880     changedObject == selectionHolder ifTrue:[ ^ self selectionChanged ].
  1722     changedObject == selectionHolder ifTrue:[ ^ self selectionChanged ].
  1881     changedObject == tabHolder       ifTrue:[ ^ self tabChanged ].
  1723     changedObject == tabHolder       ifTrue:[ ^ self tabChanged ].
  1882 
  1724 
  2071         listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  1913         listOfItemsView displayLineFromX:x0 y:y0 toX:x1 y:y0.
  2072     ].
  1914     ].
  2073 !
  1915 !
  2074 
  1916 
  2075 doDrop:aContext
  1917 doDrop:aContext
  2076     "drop the DropContext into the hierachical list of items
  1918     "drop the dropContext into the hierachical list of items
  2077     "
  1919     "
  2078     |done item|
  1920     |done item|
  2079 
  1921 
  2080     dropOverLine ifNil:[^ false ].      "/ context not valid to me ...
  1922     dropOverLine ifNil:[^ false ].      "/ context not valid to me ...
  2081 
  1923 
  2085 
  1927 
  2086     selectionHolder setValue:(Array with:item).
  1928     selectionHolder setValue:(Array with:item).
  2087 
  1929 
  2088     done := false.
  1930     done := false.
  2089 
  1931 
  2090     self addAndSelect:[
  1932     self addAndSelectValueOf:[
  2091         done := true.
  1933         done := true.
  2092         aContext dropObjects collect:[:el| Item menuItem:(el theObject) ]
  1934         aContext dropObjects collect:[:el| Item menuItem:(el theObject) ]
  2093     ].
  1935     ].
  2094     ^ done
  1936     ^ done
  2095 !
  1937 !
  2259     self windowGroup addPreEventHook:self.
  2101     self windowGroup addPreEventHook:self.
  2260 ! !
  2102 ! !
  2261 
  2103 
  2262 !MenuEditor methodsFor:'private'!
  2104 !MenuEditor methodsFor:'private'!
  2263 
  2105 
  2264 addAndSelect:aNoneArgBlockOrItem
  2106 addAndSelectValueOf:aBlockOrItem
  2265     "add an item(s) derived from the block; test if add operation
  2107     "add an item(s) derived from the block; test if add operation
  2266      is enabled. On success the new item(s) are returned otherwise nil.
  2108      is enabled. On success the new item(s) are returned otherwise nil.
  2267     "
  2109     "
  2268     |intoItem index newItem|
  2110     |intoItem index newItem|
  2269 
  2111 
  2280         ].
  2122         ].
  2281         index := intoItem parent identityIndexOf:intoItem.
  2123         index := intoItem parent identityIndexOf:intoItem.
  2282         index := index + 1.
  2124         index := index + 1.
  2283         intoItem := intoItem parent.
  2125         intoItem := intoItem parent.
  2284     ].
  2126     ].
  2285     newItem := aNoneArgBlockOrItem value.
  2127     newItem := aBlockOrItem value.
  2286 
  2128 
  2287     newItem ifNotNil:[
  2129     newItem ifNotNil:[
  2288         selectionHolder setValue:nil.
  2130         selectionHolder setValue:nil.
  2289         intoItem expand.
  2131         intoItem expand.
  2290 
  2132 
  2617 !
  2459 !
  2618 
  2460 
  2619 doCreateItem
  2461 doCreateItem
  2620     "create a new Item
  2462     "create a new Item
  2621     "
  2463     "
  2622     self addAndSelect:[ ActionItem new translateLabel:true ].
  2464     self addAndSelectValueOf:[ ActionItem new translateLabel:true ].
  2623 !
  2465 !
  2624 
  2466 
  2625 doCreateLinkedMenu
  2467 doCreateLinkedMenu
  2626     "create a new Linked Menu
  2468     "create a new Linked Menu
  2627     "
  2469     "
  2628     self addAndSelect:[ LinkedMenuItem new ].
  2470     self addAndSelectValueOf:[ LinkedMenuItem new ].
  2629 !
  2471 !
  2630 
  2472 
  2631 doCreateMenu
  2473 doCreateMenu
  2632     "create a new Menu
  2474     "create a new Menu
  2633     "
  2475     "
  2634     self addAndSelect:[ |item|
  2476     self addAndSelectValueOf:
  2635         item := RegularMenuItem new.
  2477         [ |item|
  2636         item expand.
  2478             item := RegularMenuItem new.
  2637         item
  2479             item expand.
  2638     ].
  2480             item
       
  2481         ].
  2639 !
  2482 !
  2640 
  2483 
  2641 doCreateSep
  2484 doCreateSep
  2642     "create a new Separator Item
  2485     "create a new Separator Item
  2643     "
  2486     "
  2644     self addAndSelect:[ SeparatorItem new ].
  2487     self addAndSelectValueOf:[ SeparatorItem new ].
  2645 !
  2488 !
  2646 
  2489 
  2647 doCreateStandardEditMenu
  2490 doCreateStandardEditMenu
  2648     "create a standart edit menu
  2491     "create a standart edit menu
  2649     "
  2492     "
  2650     self addAndSelect:[
  2493     self addAndSelectValueOf:[
  2651         RegularMenuItem menu:(self class standardEditMenu) labeled:'Edit' translateLabel:true
  2494         RegularMenuItem menu:(self class standardEditMenu) labeled:'Edit' translateLabel:true
  2652     ].
  2495     ].
  2653 !
  2496 !
  2654 
  2497 
  2655 doCreateStandardFileMenu
  2498 doCreateStandardFileMenu
  2656     "create a standart file menu
  2499     "create a standart file menu
  2657     "
  2500     "
  2658     self addAndSelect:[
  2501     self addAndSelectValueOf:[
  2659         RegularMenuItem menu:(self class standardFileMenu) labeled:'File' translateLabel:true
  2502         RegularMenuItem menu:(self class standardFileMenu) labeled:'File' translateLabel:true
  2660     ].
  2503     ].
  2661 !
  2504 !
  2662 
  2505 
  2663 doCreateStandardHelpMenu
  2506 doCreateStandardHelpMenu
  2664     "create a standart help menu
  2507     "create a standart help menu
  2665     "
  2508     "
  2666     |item|
  2509     |item|
  2667 
  2510 
  2668     self addAndSelect:[
  2511     self addAndSelectValueOf:[
  2669         item := RegularMenuItem menu:(self class standardHelpMenu) labeled:'Help' translateLabel:true.
  2512         item := RegularMenuItem menu:(self class standardHelpMenu) labeled:'Help' translateLabel:true.
  2670         item aspectAt:#startGroup put:#right.
  2513         item aspectAt:#startGroup put:#right.
  2671         item
  2514         item
  2672     ].
  2515     ].
  2673 ! !
  2516 ! !
  2756     aCollection do:[:el|
  2599     aCollection do:[:el|
  2757         (el askFor:#isMenuItem) ifTrue:[ loMenuItems add:el ].
  2600         (el askFor:#isMenuItem) ifTrue:[ loMenuItems add:el ].
  2758     ].
  2601     ].
  2759     loMenuItems isEmpty ifTrue:[ ^ self ].
  2602     loMenuItems isEmpty ifTrue:[ ^ self ].
  2760 
  2603 
  2761     self addAndSelect:[
  2604     self addAndSelectValueOf:[
  2762         loMenuItems collect:[:el| Item menuItem:el ]
  2605         loMenuItems collect:[:el| Item menuItem:el ]
  2763     ].
  2606     ].
  2764 ! !
  2607 ! !
  2765 
  2608 
  2766 !MenuEditor methodsFor:'user actions - hierarchy'!
  2609 !MenuEditor methodsFor:'user actions - hierarchy'!
  4773 selectorChanged
  4616 selectorChanged
  4774     self updateImageHolder.
  4617     self updateImageHolder.
  4775 !
  4618 !
  4776 
  4619 
  4777 update:what with:aPara from:aModel
  4620 update:what with:aPara from:aModel
  4778     "Invoked when an object that I depend upon sends a change notification."
       
  4779 
       
  4780     |item|
  4621     |item|
  4781 
  4622 
  4782     self modifiedChannel value:true.
  4623     self modifiedChannel value:true.
  4783 
  4624 
  4784     aModel == retrieverHolder ifTrue:[ ^ self retrieverChanged ].
  4625     aModel == retrieverHolder ifTrue:[ ^ self retrieverChanged ].