MenuEditor.st
changeset 1410 ec3abe12f662
parent 1407 5b6ce9f1988e
child 1413 5c00c266107e
equal deleted inserted replaced
1409:176ae89e0b31 1410:ec3abe12f662
    20 	classVariableNames:''
    20 	classVariableNames:''
    21 	poolDictionaries:''
    21 	poolDictionaries:''
    22 	category:'Interface-UIPainter'
    22 	category:'Interface-UIPainter'
    23 !
    23 !
    24 
    24 
       
    25 SelectionInTreeView subclass:#TreeView
       
    26 	instanceVariableNames:''
       
    27 	classVariableNames:''
       
    28 	poolDictionaries:''
       
    29 	privateIn:MenuEditor
       
    30 !
       
    31 
    25 Object subclass:#Item
    32 Object subclass:#Item
    26 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    33 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    27 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    34 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    28 		startGroup argument translateLabel isButton isVisible choice
    35 		startGroup argument translateLabel isButton isVisible choice
    29 		choiceValue auxValue hideMenuOnActivated font
    36 		choiceValue auxValue hideMenuOnActivated font
    30 		showBusyCursorWhilePerforming keepLinkedMenu'
    37 		showBusyCursorWhilePerforming keepLinkedMenu triggerOnDown'
    31 	classVariableNames:''
       
    32 	poolDictionaries:''
       
    33 	privateIn:MenuEditor
       
    34 !
       
    35 
       
    36 SelectionInTreeView subclass:#TreeView
       
    37 	instanceVariableNames:''
       
    38 	classVariableNames:''
    38 	classVariableNames:''
    39 	poolDictionaries:''
    39 	poolDictionaries:''
    40 	privateIn:MenuEditor
    40 	privateIn:MenuEditor
    41 !
    41 !
    42 
    42 
   113 
   113 
   114     ^#(
   114     ^#(
   115         label
   115         label
   116         accessCharacterPos
   116         accessCharacterPos
   117         showBusyCursorWhilePerforming
   117         showBusyCursorWhilePerforming
       
   118         triggerOnDown
   118         font
   119         font
   119         argument
   120         argument
   120         submenuChannel
   121         submenuChannel
   121         keepLinkedMenu
   122         keepLinkedMenu
   122         enabled
   123         enabled
   254 
   255 
   255 #fileSaveAs
   256 #fileSaveAs
   256 'Opens a dialog to save the menu spec (and the help spec, if modified).'
   257 'Opens a dialog to save the menu spec (and the help spec, if modified).'
   257 
   258 
   258 #hideMenuOnActivated
   259 #hideMenuOnActivated
   259 'Hide the menu after activation (turn off for checkToggles or radioButtons)'
   260 'if on, the action is triggered when pressed'
   260 
   261 
   261 #imageImageAndLabel
   262 #imageImageAndLabel
   262 'Toggles display of both image and textual label.'
   263 'Toggles display of both image and textual label.'
   263 
   264 
   264 #imageImageEditor
   265 #imageImageEditor
   275 
   276 
   276 #keepLinkedMenu
   277 #keepLinkedMenu
   277 'Keep the linked menu after activation (do not destroy)'
   278 'Keep the linked menu after activation (do not destroy)'
   278 
   279 
   279 )
   280 )
   280 
       
   281     "Modified: / 4.2.2000 / 12:24:53 / cg"
       
   282 ! !
   281 ! !
   283 
   282 
   284 !MenuEditor class methodsFor:'image specs'!
   283 !MenuEditor class methodsFor:'image specs'!
   285 
   284 
   286 linkSubmenuImage
   285 linkSubmenuImage
   374        #(#WindowSpec
   373        #(#WindowSpec
   375           #label: 'Basics Item'
   374           #label: 'Basics Item'
   376           #name: 'Basics Item'
   375           #name: 'Basics Item'
   377           #min: #(#Point 10 10)
   376           #min: #(#Point 10 10)
   378           #max: #(#Point 1160 870)
   377           #max: #(#Point 1160 870)
   379           #bounds: #(#Rectangle 218 175 485 522)
   378           #bounds: #(#Rectangle 898 390 1173 751)
   380         )
   379         )
   381         #component: 
   380         #component: 
   382        #(#SpecCollection
   381        #(#SpecCollection
   383           #collection: #(
   382           #collection: #(
   384            #(#LabelSpec
   383            #(#LabelSpec
   428               #acceptOnPointerLeave: false
   427               #acceptOnPointerLeave: false
   429             )
   428             )
   430            #(#LabelSpec
   429            #(#LabelSpec
   431               #label: 'Action:'
   430               #label: 'Action:'
   432               #name: 'valueLabel'
   431               #name: 'valueLabel'
   433               #layout: #(#AlignmentOrigin 107 0 90 0 1 0.5)
   432               #layout: #(#AlignmentOrigin 107 0 85 0 1 0.5)
   434               #activeHelpKey: #basicsAction
   433               #activeHelpKey: #basicsAction
   435               #resizeForLabel: true
   434               #resizeForLabel: true
   436               #adjust: #right
   435               #adjust: #right
   437             )
   436             )
   438            #(#InputFieldSpec
   437            #(#InputFieldSpec
   439               #name: 'valueField'
   438               #name: 'valueField'
   440               #layout: #(#LayoutFrame 110 0 79 0 -5 1.0 101 0)
   439               #layout: #(#LayoutFrame 110 0 74 0 -5 1.0 96 0)
   441               #activeHelpKey: #basicsAction
   440               #activeHelpKey: #basicsAction
   442               #tabable: true
   441               #tabable: true
   443               #model: #value
   442               #model: #value
   444               #group: #inputGroup1
   443               #group: #inputGroup1
   445               #type: #symbolOrNil
   444               #type: #symbolOrNil
   451               #acceptOnPointerLeave: false
   450               #acceptOnPointerLeave: false
   452             )
   451             )
   453            #(#LabelSpec
   452            #(#LabelSpec
   454               #label: 'Argument:'
   453               #label: 'Argument:'
   455               #name: 'argumentLabel'
   454               #name: 'argumentLabel'
   456               #layout: #(#AlignmentOrigin 107 0 115 0 1 0.5)
   455               #layout: #(#AlignmentOrigin 107 0 110 0 1 0.5)
   457               #activeHelpKey: #basicsArgument
   456               #activeHelpKey: #basicsArgument
   458               #resizeForLabel: true
   457               #resizeForLabel: true
   459               #adjust: #right
   458               #adjust: #right
   460             )
   459             )
   461            #(#InputFieldSpec
   460            #(#InputFieldSpec
   462               #name: 'argumentField'
   461               #name: 'argumentField'
   463               #layout: #(#LayoutFrame 110 0 104 0 -5 1.0 126 0)
   462               #layout: #(#LayoutFrame 110 0 99 0 -5 1.0 121 0)
   464               #activeHelpKey: #basicsArgument
   463               #activeHelpKey: #basicsArgument
   465               #tabable: true
   464               #tabable: true
   466               #model: #argument
   465               #model: #argument
   467               #group: #inputGroup1
   466               #group: #inputGroup1
   468               #type: #smalltalkObject
   467               #type: #smalltalkObject
   474               #acceptOnPointerLeave: false
   473               #acceptOnPointerLeave: false
   475             )
   474             )
   476            #(#LabelSpec
   475            #(#LabelSpec
   477               #label: 'Indication:'
   476               #label: 'Indication:'
   478               #name: 'indicationLabel'
   477               #name: 'indicationLabel'
   479               #layout: #(#AlignmentOrigin 107 0 155 0 1 0.5)
   478               #layout: #(#AlignmentOrigin 107 0 144 0 1 0.5)
   480               #activeHelpKey: #basicsIndication
   479               #activeHelpKey: #basicsIndication
   481               #resizeForLabel: true
   480               #resizeForLabel: true
   482               #adjust: #right
   481               #adjust: #right
   483             )
   482             )
   484            #(#InputFieldSpec
   483            #(#InputFieldSpec
   485               #name: 'indicationField'
   484               #name: 'indicationField'
   486               #layout: #(#LayoutFrame 110 0 144 0 -5 1.0 166 0)
   485               #layout: #(#LayoutFrame 110 0 133 0 -5 1.0 155 0)
   487               #activeHelpKey: #basicsIndication
   486               #activeHelpKey: #basicsIndication
   488               #enableChannel: #indicationEnabled
   487               #enableChannel: #indicationEnabled
   489               #tabable: true
   488               #tabable: true
   490               #model: #indication
   489               #model: #indication
   491               #group: #inputGroup1
   490               #group: #inputGroup1
   499               #acceptOnPointerLeave: false
   498               #acceptOnPointerLeave: false
   500             )
   499             )
   501            #(#LabelSpec
   500            #(#LabelSpec
   502               #label: 'Choice:'
   501               #label: 'Choice:'
   503               #name: 'choiceLabel'
   502               #name: 'choiceLabel'
   504               #layout: #(#AlignmentOrigin 107 0 180 0 1 0.5)
   503               #layout: #(#AlignmentOrigin 107 0 169 0 1 0.5)
   505               #activeHelpKey: #basicsChoice
   504               #activeHelpKey: #basicsChoice
   506               #translateLabel: true
   505               #translateLabel: true
   507               #resizeForLabel: true
   506               #resizeForLabel: true
   508               #adjust: #right
   507               #adjust: #right
   509             )
   508             )
   510            #(#InputFieldSpec
   509            #(#InputFieldSpec
   511               #name: 'choiceField'
   510               #name: 'choiceField'
   512               #layout: #(#LayoutFrame 110 0 169 0 -5 1.0 191 0)
   511               #layout: #(#LayoutFrame 110 0 158 0 -5 1.0 180 0)
   513               #activeHelpKey: #basicsChoice
   512               #activeHelpKey: #basicsChoice
   514               #enableChannel: #choiceEnabled
   513               #enableChannel: #choiceEnabled
   515               #tabable: true
   514               #tabable: true
   516               #model: #choice
   515               #model: #choice
   517               #group: #inputGroup1
   516               #group: #inputGroup1
   525               #acceptOnPointerLeave: false
   524               #acceptOnPointerLeave: false
   526             )
   525             )
   527            #(#LabelSpec
   526            #(#LabelSpec
   528               #label: 'Value:'
   527               #label: 'Value:'
   529               #name: 'choiceValueLabel'
   528               #name: 'choiceValueLabel'
   530               #layout: #(#AlignmentOrigin 107 0 205 0 1 0.5)
   529               #layout: #(#AlignmentOrigin 107 0 194 0 1 0.5)
   531               #activeHelpKey: #basicsChoiceValue
   530               #activeHelpKey: #basicsChoiceValue
   532               #translateLabel: true
   531               #translateLabel: true
   533               #resizeForLabel: true
   532               #resizeForLabel: true
   534               #adjust: #right
   533               #adjust: #right
   535             )
   534             )
   536            #(#InputFieldSpec
   535            #(#InputFieldSpec
   537               #name: 'choiceValueField'
   536               #name: 'choiceValueField'
   538               #layout: #(#LayoutFrame 110 0 194 0 -5 1.0 216 0)
   537               #layout: #(#LayoutFrame 110 0 183 0 -5 1.0 205 0)
   539               #activeHelpKey: #basicsChoiceValue
   538               #activeHelpKey: #basicsChoiceValue
   540               #enableChannel: #choiceValueEnabled
   539               #enableChannel: #choiceValueEnabled
   541               #tabable: true
   540               #tabable: true
   542               #model: #choiceValue
   541               #model: #choiceValue
   543               #group: #inputGroup1
   542               #group: #inputGroup1
   551               #acceptOnPointerLeave: false
   550               #acceptOnPointerLeave: false
   552             )
   551             )
   553            #(#CheckBoxSpec
   552            #(#CheckBoxSpec
   554               #label: 'Translate Label'
   553               #label: 'Translate Label'
   555               #name: 'translateLabelCheckBox'
   554               #name: 'translateLabelCheckBox'
   556               #layout: #(#Point 20 230)
   555               #layout: #(#Point 20 218)
   557               #activeHelpKey: #basicsTranslateLabel
   556               #activeHelpKey: #basicsTranslateLabel
   558               #tabable: true
   557               #tabable: true
   559               #model: #translateLabel
   558               #model: #translateLabel
   560             )
   559             )
   561            #(#CheckBoxSpec
   560            #(#CheckBoxSpec
   562               #label: 'Is Button'
   561               #label: 'Is Button'
   563               #name: 'isButtonCheckBox'
   562               #name: 'isButtonCheckBox'
   564               #layout: #(#Point 20 255)
   563               #layout: #(#Point 20 243)
   565               #activeHelpKey: #basicsIsButton
   564               #activeHelpKey: #basicsIsButton
   566               #tabable: true
   565               #tabable: true
   567               #model: #isButton
   566               #model: #isButton
   568             )
   567             )
   569            #(#CheckBoxSpec
   568            #(#CheckBoxSpec
   570               #label: 'Hide Menu after Activation'
   569               #label: 'Hide Menu after Activation'
   571               #name: 'hideMenuOnActivated'
   570               #name: 'hideMenuOnActivated'
   572               #layout: #(#Point 20 280)
   571               #layout: #(#Point 20 267)
   573               #activeHelpKey: #hideMenuOnActivated
   572               #activeHelpKey: #hideMenuOnActivated
   574               #tabable: true
   573               #tabable: true
   575               #model: #hideMenuOnActivated
   574               #model: #hideMenuOnActivated
   576             )
   575             )
   577            #(#CheckBoxSpec
   576            #(#CheckBoxSpec
   578               #label: 'BusyCursor while Active'
   577               #label: 'BusyCursor while Active'
   579               #name: 'showBusyCursorWhilePerforming'
   578               #name: 'showBusyCursorWhilePerforming'
   580               #layout: #(#Point 20 305)
   579               #layout: #(#Point 20 291)
   581               #activeHelpKey: #hideMenuOnActivated
   580               #activeHelpKey: #hideMenuOnActivated
   582               #tabable: true
   581               #tabable: true
   583               #model: #showBusyCursorWhilePerforming
   582               #model: #showBusyCursorWhilePerforming
       
   583               #translateLabel: true
       
   584             )
       
   585            #(#CheckBoxSpec
       
   586               #label: 'Trigger On Down'
       
   587               #name: 'triggerOnDown'
       
   588               #layout: #(#Point 20 315)
       
   589               #activeHelpKey: #hideMenuOnActivated
       
   590               #tabable: true
       
   591               #model: #triggerOnDown
   584               #translateLabel: true
   592               #translateLabel: true
   585             )
   593             )
   586            )
   594            )
   587          
   595          
   588         )
   596         )
  2691 
  2699 
  2692     treeView selectedNodeChangeSequenceOrder:-1.
  2700     treeView selectedNodeChangeSequenceOrder:-1.
  2693     modified := true.
  2701     modified := true.
  2694 ! !
  2702 ! !
  2695 
  2703 
  2696 !MenuEditor::Item class methodsFor:'constants'!
       
  2697 
       
  2698 separatorList
       
  2699     "get the list of available separator types"
       
  2700 
       
  2701     ^#('blank' 'single line' 'double line')
       
  2702 !
       
  2703 
       
  2704 separatorSlices
       
  2705     "get the list of menu spec values of the corresponding separator types"
       
  2706 
       
  2707    ^ #(
       
  2708         ( #blank        ''  )
       
  2709         ( #single       '-' )
       
  2710         ( #double       '=' )
       
  2711       )
       
  2712 ! !
       
  2713 
       
  2714 !MenuEditor::Item class methodsFor:'documentation'!
       
  2715 
       
  2716 documentation
       
  2717 "
       
  2718     implements the contents assigned to a TreeItem. An instance
       
  2719     is associated with one item and keeps all its information
       
  2720 
       
  2721     [see also:]
       
  2722         TreeItem
       
  2723         MenuEditor
       
  2724 
       
  2725     [author:]
       
  2726         Claus Atzkern
       
  2727 "
       
  2728 
       
  2729 
       
  2730 ! !
       
  2731 
       
  2732 !MenuEditor::Item methodsFor:'accessing'!
       
  2733 
       
  2734 activeHelpKey
       
  2735     "get the help key of the menu item"
       
  2736 
       
  2737     ^activeHelpKey
       
  2738 !
       
  2739 
       
  2740 activeHelpKey:aKey
       
  2741     "set the help key of the menu item"
       
  2742 
       
  2743     activeHelpKey := aKey
       
  2744 !
       
  2745 
       
  2746 label
       
  2747     "get the value of the menu item"
       
  2748 
       
  2749     ^label
       
  2750 !
       
  2751 
       
  2752 label:something
       
  2753     "set the value of the menu item"
       
  2754 
       
  2755     label := something ? '-'
       
  2756 !
       
  2757 
       
  2758 separatorType
       
  2759     "get the separator type assigned to item or nil"
       
  2760 
       
  2761     label size > 1 
       
  2762     ifFalse:
       
  2763     [
       
  2764         label size  == 0  ifTrue:[^#blank].
       
  2765         label first == $- ifTrue:[^#single].
       
  2766         label first == $= ifTrue:[^#double].
       
  2767     ].    
       
  2768     ^nil
       
  2769 
       
  2770 !
       
  2771 
       
  2772 startGroup:aSymbolOrNil
       
  2773     "set the startGroup attribute"
       
  2774 
       
  2775     startGroup := aSymbolOrNil
       
  2776 
       
  2777     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  2778 !
       
  2779 
       
  2780 submenuChannel
       
  2781     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  2782 
       
  2783     ^submenuChannel
       
  2784 !
       
  2785 
       
  2786 submenuChannel:aChannel
       
  2787     "get the submenuChannel"
       
  2788 
       
  2789     submenuChannel := aChannel
       
  2790 !
       
  2791 
       
  2792 translateLabel:aBoolean
       
  2793     "set/clear the translate to national-language flag"
       
  2794 
       
  2795     translateLabel := aBoolean
       
  2796 
       
  2797     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  2798 !
       
  2799 
       
  2800 value:aSymbol
       
  2801     "set the value attribute"
       
  2802 
       
  2803     value := aSymbol
       
  2804 
       
  2805     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  2806 ! !
       
  2807 
       
  2808 !MenuEditor::Item methodsFor:'building'!
       
  2809 
       
  2810 buildFromAspects:aspects
       
  2811     "read the values of the aspects into my values"
       
  2812 
       
  2813     |name|
       
  2814     self isSeparator 
       
  2815     ifFalse:
       
  2816     [
       
  2817         name  := label.
       
  2818         label := (aspects at:#label) value.
       
  2819 
       
  2820         (label isNil or:[self isSeparator]) ifTrue:[
       
  2821             (aspects at:#label) value:(label := name)
       
  2822         ].
       
  2823 
       
  2824         enabled            := (aspects at:#enabled) value.
       
  2825         value              := (aspects at:#value) value.
       
  2826         nameKey            := (aspects at:#nameKey) value.
       
  2827         indication         := (aspects at:#indication) value.
       
  2828         choice             := (aspects at:#choice) value.
       
  2829         choiceValue        := (aspects at:#choiceValue) value.
       
  2830         shortcutKey        := (aspects at:#shortcutKey) value.
       
  2831         startGroup         := (aspects at:#startGroup) value.
       
  2832         accessCharacterPos := (aspects at:#accessCharacterPos) value.
       
  2833         showBusyCursorWhilePerforming := (aspects at:#showBusyCursorWhilePerforming) value.
       
  2834         keepLinkedMenu     := (aspects at:#keepLinkedMenu) value ? false.
       
  2835         font               := (aspects at:#font) value.
       
  2836         argument           := (aspects at:#argument) value.
       
  2837         translateLabel     := (aspects at:#translateLabel) value.
       
  2838         isButton           := (aspects at:#isButton) value.
       
  2839         auxValue           := (aspects at:#auxValue) value.
       
  2840 
       
  2841         argument isString ifTrue:[
       
  2842             argument size > 1 ifTrue:[
       
  2843                 (argument at:1) == $# ifTrue:[
       
  2844                     argument := (argument copyFrom:2) asSymbol
       
  2845                 ]
       
  2846             ]
       
  2847         ].
       
  2848         submenuChannel    := (aspects at:#submenuChannel) value.
       
  2849         retriever         := (aspects at:#retriever) value.
       
  2850         icon              := (aspects at:#icon) value.
       
  2851         iconAndLabel      := (aspects at:#iconAndLabel) value.
       
  2852     ]
       
  2853     ifTrue:
       
  2854     [
       
  2855         name  := (aspects at:#seperatorSelection) selectionIndex.
       
  2856         label := (self class separatorSlices at:name) last.
       
  2857     ].
       
  2858     isVisible := (aspects at:#isVisible) value.
       
  2859     hideMenuOnActivated := (aspects at:#hideMenuOnActivated) value.
       
  2860 
       
  2861     "Modified: / 14.8.1998 / 15:36:38 / cg"
       
  2862 !
       
  2863 
       
  2864 buildFromMenuItem:anItem
       
  2865     "read the attributes of anItem into my values"
       
  2866 
       
  2867     |rtv|
       
  2868 
       
  2869     self label:(anItem rawLabel).
       
  2870     activeHelpKey := anItem activeHelpKey.
       
  2871 
       
  2872     (enabled := anItem enabled) isSymbol ifFalse:[
       
  2873         enabled := nil
       
  2874     ].
       
  2875     (value := anItem value) isSymbol ifFalse:[
       
  2876         value := nil.
       
  2877     ].
       
  2878     (indication := anItem indication) isSymbol ifFalse:[
       
  2879         indication := nil
       
  2880     ].
       
  2881     (choice := anItem choice) isSymbol ifFalse:[
       
  2882         choice := nil
       
  2883     ].
       
  2884     choiceValue         := anItem choiceValue.
       
  2885     nameKey             := anItem nameKey.
       
  2886     shortcutKey         := anItem shortcutKeyCharacter.
       
  2887     startGroup          := anItem startGroup.
       
  2888     accessCharacterPos  := anItem accessCharacterPosition.
       
  2889     showBusyCursorWhilePerforming  := anItem showBusyCursorWhilePerforming.
       
  2890     keepLinkedMenu      := anItem keepLinkedMenu.
       
  2891     font                := anItem font.
       
  2892     argument            := anItem argument.
       
  2893 
       
  2894     submenuChannel      := anItem submenuChannel.
       
  2895     translateLabel      := anItem translateLabel.
       
  2896     isButton            := anItem isButton.
       
  2897     isVisible           := anItem isVisible.
       
  2898     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  2899     auxValue            := anItem auxValue.
       
  2900 
       
  2901     (((rtv := anItem adornment) notNil)
       
  2902     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  2903     ifTrue:
       
  2904     [
       
  2905         retriever := rtv className.
       
  2906         icon      := rtv selector.
       
  2907         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  2908             label := rtv labelText.
       
  2909         ]
       
  2910     ]
       
  2911 
       
  2912     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  2913 ! !
       
  2914 
       
  2915 !MenuEditor::Item methodsFor:'conversion'!
       
  2916 
       
  2917 asMenuItem
       
  2918     "converts self to a menu item"
       
  2919 
       
  2920     |item rcv|
       
  2921 
       
  2922     item := MenuItem labeled:label.
       
  2923     item isVisible:isVisible.
       
  2924     item hideMenuOnActivated:hideMenuOnActivated.
       
  2925 
       
  2926     self isSeparator ifFalse:[    
       
  2927         item activeHelpKey:activeHelpKey.
       
  2928         item enabled:enabled.
       
  2929         item accessCharacterPosition:accessCharacterPos.
       
  2930         item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
       
  2931         item keepLinkedMenu:keepLinkedMenu.
       
  2932         item font:font.
       
  2933         item argument:argument.
       
  2934         item submenuChannel:submenuChannel.
       
  2935         item nameKey:nameKey.
       
  2936         item shortcutKeyCharacter:shortcutKey.
       
  2937         item startGroup:startGroup.
       
  2938         item value:value.
       
  2939         item indication:indication.
       
  2940         item choice:choice.
       
  2941         item choiceValue:choiceValue.
       
  2942         item translateLabel: translateLabel.
       
  2943         item isButton: isButton.
       
  2944         item auxValue: auxValue.
       
  2945 
       
  2946         icon notNil ifTrue:[
       
  2947             rcv := ResourceRetriever new.
       
  2948             rcv className:retriever.
       
  2949             rcv selector:icon.
       
  2950             iconAndLabel == true ifTrue:[
       
  2951                 rcv labelText:label
       
  2952             ].
       
  2953             item labelImage:rcv
       
  2954         ]
       
  2955     ].
       
  2956     ^item
       
  2957 
       
  2958     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  2959 !
       
  2960 
       
  2961 toAspects:aspects
       
  2962     "put my values into the values of aspects"
       
  2963 
       
  2964     |type|
       
  2965     (type := self separatorType) notNil ifTrue: [
       
  2966         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  2967         (aspects at:#seperatorSelection) selectionIndex:type.
       
  2968     ] ifFalse: [
       
  2969         (aspects at:#label)                value:label.
       
  2970         (aspects at:#enabled)              value:enabled.
       
  2971         (aspects at:#value)                value:value.
       
  2972         (aspects at:#nameKey)              value:nameKey.
       
  2973         (aspects at:#indication)           value:indication.
       
  2974         (aspects at:#choice)               value:choice.
       
  2975         (aspects at:#choiceValue)          value:choiceValue.
       
  2976         (aspects at:#shortcutKey)          value:shortcutKey.
       
  2977         (aspects at:#startGroup)           value:startGroup.
       
  2978         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  2979         (aspects at:#showBusyCursorWhilePerforming)   value:showBusyCursorWhilePerforming.
       
  2980         (aspects at:#keepLinkedMenu)       value:(keepLinkedMenu ? false).
       
  2981         (aspects at:#font)                 value:font.
       
  2982         (aspects at:#translateLabel)       value:translateLabel.
       
  2983         (aspects at:#submenuChannel)       value:submenuChannel.
       
  2984         (aspects at:#retriever)            value:retriever.
       
  2985         (aspects at:#icon)                 value:icon.
       
  2986         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  2987         (aspects at:#isButton)             value:isButton.
       
  2988         (aspects at:#auxValue)             value:auxValue.
       
  2989 
       
  2990         (aspects at:#argument)
       
  2991             value:(argument isSymbol
       
  2992                         ifTrue: ['#', argument] 
       
  2993                         ifFalse:[argument]).
       
  2994     ].
       
  2995     (aspects at:#isVisible) value:isVisible.
       
  2996     (aspects at:#hideMenuOnActivated) value:(hideMenuOnActivated ? true).
       
  2997 
       
  2998     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  2999 ! !
       
  3000 
       
  3001 !MenuEditor::Item methodsFor:'queries'!
       
  3002 
       
  3003 iconFor: aNode
       
  3004     "get the icon of the menu item for the tree view"
       
  3005 
       
  3006     (aNode hasChildren or: [aNode parent isNil])
       
  3007     ifTrue:
       
  3008     [
       
  3009         ^MenuEditor submenuImage
       
  3010     ]
       
  3011     ifFalse:
       
  3012     [
       
  3013         submenuChannel notNil 
       
  3014         ifTrue:
       
  3015         [
       
  3016             ^MenuEditor linkSubmenuImage
       
  3017         ]
       
  3018         ifFalse:
       
  3019         [
       
  3020             self isSeparator 
       
  3021                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3022                 ifFalse: [^MenuEditor menuItemImage]
       
  3023         ]
       
  3024     ]
       
  3025 !
       
  3026 
       
  3027 isSeparator
       
  3028     "return true if item is a seperator"
       
  3029 
       
  3030     ^self separatorType notNil
       
  3031 !
       
  3032 
       
  3033 treeViewLabel
       
  3034     "get the label of the menu item for the tree view"
       
  3035 
       
  3036     ^label
       
  3037 " asBoldText, 
       
  3038         (value notNil ifTrue: [': [', 
       
  3039                 value ,
       
  3040                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3041                  ']'] ifFalse: [''])
       
  3042 
       
  3043 
       
  3044 "
       
  3045 ! !
       
  3046 
       
  3047 !MenuEditor::TreeView class methodsFor:'documentation'!
  2704 !MenuEditor::TreeView class methodsFor:'documentation'!
  3048 
  2705 
  3049 documentation
  2706 documentation
  3050 "
  2707 "
  3051     This tree view class provides a hierarchical representation
  2708     This tree view class provides a hierarchical representation
  3540 
  3197 
  3541     (app := self topView application) modified: true.
  3198     (app := self topView application) modified: true.
  3542     app updateChannels
  3199     app updateChannels
  3543 ! !
  3200 ! !
  3544 
  3201 
       
  3202 !MenuEditor::Item class methodsFor:'constants'!
       
  3203 
       
  3204 separatorList
       
  3205     "get the list of available separator types"
       
  3206 
       
  3207     ^#('blank' 'single line' 'double line')
       
  3208 !
       
  3209 
       
  3210 separatorSlices
       
  3211     "get the list of menu spec values of the corresponding separator types"
       
  3212 
       
  3213    ^ #(
       
  3214         ( #blank        ''  )
       
  3215         ( #single       '-' )
       
  3216         ( #double       '=' )
       
  3217       )
       
  3218 ! !
       
  3219 
       
  3220 !MenuEditor::Item class methodsFor:'documentation'!
       
  3221 
       
  3222 documentation
       
  3223 "
       
  3224     implements the contents assigned to a TreeItem. An instance
       
  3225     is associated with one item and keeps all its information
       
  3226 
       
  3227     [see also:]
       
  3228         TreeItem
       
  3229         MenuEditor
       
  3230 
       
  3231     [author:]
       
  3232         Claus Atzkern
       
  3233 "
       
  3234 
       
  3235 
       
  3236 ! !
       
  3237 
       
  3238 !MenuEditor::Item methodsFor:'accessing'!
       
  3239 
       
  3240 activeHelpKey
       
  3241     "get the help key of the menu item"
       
  3242 
       
  3243     ^activeHelpKey
       
  3244 !
       
  3245 
       
  3246 activeHelpKey:aKey
       
  3247     "set the help key of the menu item"
       
  3248 
       
  3249     activeHelpKey := aKey
       
  3250 !
       
  3251 
       
  3252 label
       
  3253     "get the value of the menu item"
       
  3254 
       
  3255     ^label
       
  3256 !
       
  3257 
       
  3258 label:something
       
  3259     "set the value of the menu item"
       
  3260 
       
  3261     label := something ? '-'
       
  3262 !
       
  3263 
       
  3264 separatorType
       
  3265     "get the separator type assigned to item or nil"
       
  3266 
       
  3267     label size > 1 
       
  3268     ifFalse:
       
  3269     [
       
  3270         label size  == 0  ifTrue:[^#blank].
       
  3271         label first == $- ifTrue:[^#single].
       
  3272         label first == $= ifTrue:[^#double].
       
  3273     ].    
       
  3274     ^nil
       
  3275 
       
  3276 !
       
  3277 
       
  3278 startGroup:aSymbolOrNil
       
  3279     "set the startGroup attribute"
       
  3280 
       
  3281     startGroup := aSymbolOrNil
       
  3282 
       
  3283     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  3284 !
       
  3285 
       
  3286 submenuChannel
       
  3287     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  3288 
       
  3289     ^submenuChannel
       
  3290 !
       
  3291 
       
  3292 submenuChannel:aChannel
       
  3293     "get the submenuChannel"
       
  3294 
       
  3295     submenuChannel := aChannel
       
  3296 !
       
  3297 
       
  3298 translateLabel:aBoolean
       
  3299     "set/clear the translate to national-language flag"
       
  3300 
       
  3301     translateLabel := aBoolean
       
  3302 
       
  3303     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  3304 !
       
  3305 
       
  3306 value:aSymbol
       
  3307     "set the value attribute"
       
  3308 
       
  3309     value := aSymbol
       
  3310 
       
  3311     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  3312 ! !
       
  3313 
       
  3314 !MenuEditor::Item methodsFor:'building'!
       
  3315 
       
  3316 buildFromAspects:aspects
       
  3317     "read the values of the aspects into my values"
       
  3318 
       
  3319     |name|
       
  3320     self isSeparator 
       
  3321     ifFalse:
       
  3322     [
       
  3323         name  := label.
       
  3324         label := (aspects at:#label) value.
       
  3325 
       
  3326         (label isNil or:[self isSeparator]) ifTrue:[
       
  3327             (aspects at:#label) value:(label := name)
       
  3328         ].
       
  3329 
       
  3330         enabled            := (aspects at:#enabled) value.
       
  3331         value              := (aspects at:#value) value.
       
  3332         nameKey            := (aspects at:#nameKey) value.
       
  3333         indication         := (aspects at:#indication) value.
       
  3334         choice             := (aspects at:#choice) value.
       
  3335         choiceValue        := (aspects at:#choiceValue) value.
       
  3336         shortcutKey        := (aspects at:#shortcutKey) value.
       
  3337         startGroup         := (aspects at:#startGroup) value.
       
  3338         accessCharacterPos := (aspects at:#accessCharacterPos) value.
       
  3339         showBusyCursorWhilePerforming := (aspects at:#showBusyCursorWhilePerforming) value.
       
  3340         triggerOnDown      := (aspects at:#triggerOnDown) value.
       
  3341         keepLinkedMenu     := (aspects at:#keepLinkedMenu) value ? false.
       
  3342         font               := (aspects at:#font) value.
       
  3343         argument           := (aspects at:#argument) value.
       
  3344         translateLabel     := (aspects at:#translateLabel) value.
       
  3345         isButton           := (aspects at:#isButton) value.
       
  3346         auxValue           := (aspects at:#auxValue) value.
       
  3347 
       
  3348         argument isString ifTrue:[
       
  3349             argument size > 1 ifTrue:[
       
  3350                 (argument at:1) == $# ifTrue:[
       
  3351                     argument := (argument copyFrom:2) asSymbol
       
  3352                 ]
       
  3353             ]
       
  3354         ].
       
  3355         submenuChannel    := (aspects at:#submenuChannel) value.
       
  3356         retriever         := (aspects at:#retriever) value.
       
  3357         icon              := (aspects at:#icon) value.
       
  3358         iconAndLabel      := (aspects at:#iconAndLabel) value.
       
  3359     ]
       
  3360     ifTrue:
       
  3361     [
       
  3362         name  := (aspects at:#seperatorSelection) selectionIndex.
       
  3363         label := (self class separatorSlices at:name) last.
       
  3364     ].
       
  3365     isVisible := (aspects at:#isVisible) value.
       
  3366     hideMenuOnActivated := (aspects at:#hideMenuOnActivated) value.
       
  3367 
       
  3368     "Modified: / 14.8.1998 / 15:36:38 / cg"
       
  3369 !
       
  3370 
       
  3371 buildFromMenuItem:anItem
       
  3372     "read the attributes of anItem into my values"
       
  3373 
       
  3374     |rtv|
       
  3375 
       
  3376     self label:(anItem rawLabel).
       
  3377     activeHelpKey := anItem activeHelpKey.
       
  3378 
       
  3379     (enabled := anItem enabled) isSymbol ifFalse:[
       
  3380         enabled := nil
       
  3381     ].
       
  3382     (value := anItem value) isSymbol ifFalse:[
       
  3383         value := nil.
       
  3384     ].
       
  3385     (indication := anItem indication) isSymbol ifFalse:[
       
  3386         indication := nil
       
  3387     ].
       
  3388     (choice := anItem choice) isSymbol ifFalse:[
       
  3389         choice := nil
       
  3390     ].
       
  3391     choiceValue         := anItem choiceValue.
       
  3392     nameKey             := anItem nameKey.
       
  3393     shortcutKey         := anItem shortcutKeyCharacter.
       
  3394     startGroup          := anItem startGroup.
       
  3395     accessCharacterPos  := anItem accessCharacterPosition.
       
  3396     showBusyCursorWhilePerforming  := anItem showBusyCursorWhilePerforming.
       
  3397     triggerOnDown       := anItem triggerOnDown.
       
  3398     keepLinkedMenu      := anItem keepLinkedMenu.
       
  3399     font                := anItem font.
       
  3400     argument            := anItem argument.
       
  3401 
       
  3402     submenuChannel      := anItem submenuChannel.
       
  3403     translateLabel      := anItem translateLabel.
       
  3404     isButton            := anItem isButton.
       
  3405     isVisible           := anItem isVisible.
       
  3406     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  3407     auxValue            := anItem auxValue.
       
  3408 
       
  3409     (((rtv := anItem adornment) notNil)
       
  3410     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  3411     ifTrue:
       
  3412     [
       
  3413         retriever := rtv className.
       
  3414         icon      := rtv selector.
       
  3415         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  3416             label := rtv labelText.
       
  3417         ]
       
  3418     ]
       
  3419 
       
  3420     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  3421 ! !
       
  3422 
       
  3423 !MenuEditor::Item methodsFor:'conversion'!
       
  3424 
       
  3425 asMenuItem
       
  3426     "converts self to a menu item"
       
  3427 
       
  3428     |item rcv|
       
  3429 
       
  3430     item := MenuItem labeled:label.
       
  3431     item isVisible:isVisible.
       
  3432     item hideMenuOnActivated:hideMenuOnActivated.
       
  3433 
       
  3434     self isSeparator ifFalse:[    
       
  3435         item activeHelpKey:activeHelpKey.
       
  3436         item enabled:enabled.
       
  3437         item accessCharacterPosition:accessCharacterPos.
       
  3438         item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
       
  3439         item triggerOnDown:triggerOnDown.
       
  3440         item keepLinkedMenu:keepLinkedMenu.
       
  3441         item font:font.
       
  3442         item argument:argument.
       
  3443         item submenuChannel:submenuChannel.
       
  3444         item nameKey:nameKey.
       
  3445         item shortcutKeyCharacter:shortcutKey.
       
  3446         item startGroup:startGroup.
       
  3447         item value:value.
       
  3448         item indication:indication.
       
  3449         item choice:choice.
       
  3450         item choiceValue:choiceValue.
       
  3451         item translateLabel: translateLabel.
       
  3452         item isButton: isButton.
       
  3453         item auxValue: auxValue.
       
  3454 
       
  3455         icon notNil ifTrue:[
       
  3456             rcv := ResourceRetriever new.
       
  3457             rcv className:retriever.
       
  3458             rcv selector:icon.
       
  3459             iconAndLabel == true ifTrue:[
       
  3460                 rcv labelText:label
       
  3461             ].
       
  3462             item labelImage:rcv
       
  3463         ]
       
  3464     ].
       
  3465     ^item
       
  3466 
       
  3467     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  3468 !
       
  3469 
       
  3470 toAspects:aspects
       
  3471     "put my values into the values of aspects"
       
  3472 
       
  3473     |type|
       
  3474     (type := self separatorType) notNil ifTrue: [
       
  3475         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  3476         (aspects at:#seperatorSelection) selectionIndex:type.
       
  3477     ] ifFalse: [
       
  3478         (aspects at:#label)                value:label.
       
  3479         (aspects at:#enabled)              value:enabled.
       
  3480         (aspects at:#value)                value:value.
       
  3481         (aspects at:#nameKey)              value:nameKey.
       
  3482         (aspects at:#indication)           value:indication.
       
  3483         (aspects at:#choice)               value:choice.
       
  3484         (aspects at:#choiceValue)          value:choiceValue.
       
  3485         (aspects at:#shortcutKey)          value:shortcutKey.
       
  3486         (aspects at:#startGroup)           value:startGroup.
       
  3487         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  3488         (aspects at:#showBusyCursorWhilePerforming)   value:showBusyCursorWhilePerforming.
       
  3489         (aspects at:#triggerOnDown)        value:triggerOnDown.
       
  3490         (aspects at:#keepLinkedMenu)       value:(keepLinkedMenu ? false).
       
  3491         (aspects at:#font)                 value:font.
       
  3492         (aspects at:#translateLabel)       value:translateLabel.
       
  3493         (aspects at:#submenuChannel)       value:submenuChannel.
       
  3494         (aspects at:#retriever)            value:retriever.
       
  3495         (aspects at:#icon)                 value:icon.
       
  3496         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  3497         (aspects at:#isButton)             value:isButton.
       
  3498         (aspects at:#auxValue)             value:auxValue.
       
  3499 
       
  3500         (aspects at:#argument)
       
  3501             value:(argument isSymbol
       
  3502                         ifTrue: ['#', argument] 
       
  3503                         ifFalse:[argument]).
       
  3504     ].
       
  3505     (aspects at:#isVisible) value:isVisible.
       
  3506     (aspects at:#hideMenuOnActivated) value:(hideMenuOnActivated ? true).
       
  3507 
       
  3508     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  3509 ! !
       
  3510 
       
  3511 !MenuEditor::Item methodsFor:'queries'!
       
  3512 
       
  3513 iconFor: aNode
       
  3514     "get the icon of the menu item for the tree view"
       
  3515 
       
  3516     (aNode hasChildren or: [aNode parent isNil])
       
  3517     ifTrue:
       
  3518     [
       
  3519         ^MenuEditor submenuImage
       
  3520     ]
       
  3521     ifFalse:
       
  3522     [
       
  3523         submenuChannel notNil 
       
  3524         ifTrue:
       
  3525         [
       
  3526             ^MenuEditor linkSubmenuImage
       
  3527         ]
       
  3528         ifFalse:
       
  3529         [
       
  3530             self isSeparator 
       
  3531                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3532                 ifFalse: [^MenuEditor menuItemImage]
       
  3533         ]
       
  3534     ]
       
  3535 !
       
  3536 
       
  3537 isSeparator
       
  3538     "return true if item is a seperator"
       
  3539 
       
  3540     ^self separatorType notNil
       
  3541 !
       
  3542 
       
  3543 treeViewLabel
       
  3544     "get the label of the menu item for the tree view"
       
  3545 
       
  3546     ^label
       
  3547 " asBoldText, 
       
  3548         (value notNil ifTrue: [': [', 
       
  3549                 value ,
       
  3550                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3551                  ']'] ifFalse: [''])
       
  3552 
       
  3553 
       
  3554 "
       
  3555 ! !
       
  3556 
  3545 !MenuEditor class methodsFor:'documentation'!
  3557 !MenuEditor class methodsFor:'documentation'!
  3546 
  3558 
  3547 version
  3559 version
  3548     ^ '$Header$'
  3560     ^ '$Header$'
  3549 ! !
  3561 ! !