MenuEditor.st
changeset 1378 5643f9638250
parent 1372 421b2a1f4b31
child 1389 85a41c80e8dc
equal deleted inserted replaced
1377:243baa3fce51 1378:5643f9638250
    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 
       
    32 Object subclass:#Item
    25 Object subclass:#Item
    33 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    26 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    34 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    27 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    35 		startGroup argument translateLabel isButton isVisible choice
    28 		startGroup argument translateLabel isButton isVisible choice
    36 		choiceValue auxValue hideMenuOnActivated font
    29 		choiceValue auxValue hideMenuOnActivated font
    37 		showBusyCursorWhilePerforming'
    30 		showBusyCursorWhilePerforming keepLinkedMenu'
       
    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 
   120         accessCharacterPos
   120         accessCharacterPos
   121         showBusyCursorWhilePerforming
   121         showBusyCursorWhilePerforming
   122         font
   122         font
   123         argument
   123         argument
   124         submenuChannel
   124         submenuChannel
       
   125         keepLinkedMenu
   125         enabled
   126         enabled
   126         value
   127         value
   127         nameKey
   128         nameKey
   128         indication
   129         indication
   129         choice
   130         choice
   273 #imageRetriever
   274 #imageRetriever
   274 'Class implementing the image resource method. If no class is given, the current application class will be taken.'
   275 'Class implementing the image resource method. If no class is given, the current application class will be taken.'
   275 
   276 
   276 #imageSelector
   277 #imageSelector
   277 'Selector returning an image (sent to above or the application).'
   278 'Selector returning an image (sent to above or the application).'
       
   279 
       
   280 #keepLinkedMenu
       
   281 'Keep the linked menu after activation (do not destroy)'
   278 
   282 
   279 )
   283 )
   280 
   284 
   281     "Modified: / 4.2.2000 / 12:24:53 / cg"
   285     "Modified: / 4.2.2000 / 12:24:53 / cg"
   282 ! !
   286 ! !
   610        #(#WindowSpec
   614        #(#WindowSpec
   611           #label: 'Basics Link'
   615           #label: 'Basics Link'
   612           #name: 'Basics Link'
   616           #name: 'Basics Link'
   613           #min: #(#Point 10 10)
   617           #min: #(#Point 10 10)
   614           #max: #(#Point 1280 1024)
   618           #max: #(#Point 1280 1024)
   615           #bounds: #(#Rectangle 94 229 361 548)
   619           #bounds: #(#Rectangle 900 124 1167 443)
   616         )
   620         )
   617         #component: 
   621         #component: 
   618        #(#SpecCollection
   622        #(#SpecCollection
   619           #collection: #(
   623           #collection: #(
   620            #(#LabelSpec
   624            #(#LabelSpec
   702               #name: 'translateLabelCheckBox'
   706               #name: 'translateLabelCheckBox'
   703               #layout: #(#Point 20 190)
   707               #layout: #(#Point 20 190)
   704               #activeHelpKey: #basicsTranslateLabel
   708               #activeHelpKey: #basicsTranslateLabel
   705               #tabable: true
   709               #tabable: true
   706               #model: #translateLabel
   710               #model: #translateLabel
       
   711             )
       
   712            #(#CheckBoxSpec
       
   713               #label: 'Do not destroy linked Menu'
       
   714               #name: 'keepLinkedMenu'
       
   715               #layout: #(#Point 20 217)
       
   716               #tabable: true
       
   717               #activeHelpKey: #keepLinkedMenu
       
   718               #model: #keepLinkedMenu
       
   719               #translateLabel: true
   707             )
   720             )
   708            )
   721            )
   709          
   722          
   710         )
   723         )
   711       )
   724       )
  2682 
  2695 
  2683     treeView selectedNodeChangeSequenceOrder:-1.
  2696     treeView selectedNodeChangeSequenceOrder:-1.
  2684     modified := true.
  2697     modified := true.
  2685 ! !
  2698 ! !
  2686 
  2699 
       
  2700 !MenuEditor::Item class methodsFor:'constants'!
       
  2701 
       
  2702 separatorList
       
  2703     "get the list of available separator types"
       
  2704 
       
  2705     ^#('blank' 'single line' 'double line')
       
  2706 !
       
  2707 
       
  2708 separatorSlices
       
  2709     "get the list of menu spec values of the corresponding separator types"
       
  2710 
       
  2711    ^ #(
       
  2712         ( #blank        ''  )
       
  2713         ( #single       '-' )
       
  2714         ( #double       '=' )
       
  2715       )
       
  2716 ! !
       
  2717 
       
  2718 !MenuEditor::Item class methodsFor:'documentation'!
       
  2719 
       
  2720 documentation
       
  2721 "
       
  2722     implements the contents assigned to a TreeItem. An instance
       
  2723     is associated with one item and keeps all its information
       
  2724 
       
  2725     [see also:]
       
  2726         TreeItem
       
  2727         MenuEditor
       
  2728 
       
  2729     [author:]
       
  2730         Claus Atzkern
       
  2731 "
       
  2732 
       
  2733 
       
  2734 ! !
       
  2735 
       
  2736 !MenuEditor::Item methodsFor:'accessing'!
       
  2737 
       
  2738 activeHelpKey
       
  2739     "get the help key of the menu item"
       
  2740 
       
  2741     ^activeHelpKey
       
  2742 !
       
  2743 
       
  2744 activeHelpKey:aKey
       
  2745     "set the help key of the menu item"
       
  2746 
       
  2747     activeHelpKey := aKey
       
  2748 !
       
  2749 
       
  2750 label
       
  2751     "get the value of the menu item"
       
  2752 
       
  2753     ^label
       
  2754 !
       
  2755 
       
  2756 label:something
       
  2757     "set the value of the menu item"
       
  2758 
       
  2759     label := something ? '-'
       
  2760 !
       
  2761 
       
  2762 separatorType
       
  2763     "get the separator type assigned to item or nil"
       
  2764 
       
  2765     label size > 1 
       
  2766     ifFalse:
       
  2767     [
       
  2768         label size  == 0  ifTrue:[^#blank].
       
  2769         label first == $- ifTrue:[^#single].
       
  2770         label first == $= ifTrue:[^#double].
       
  2771     ].    
       
  2772     ^nil
       
  2773 
       
  2774 !
       
  2775 
       
  2776 startGroup:aSymbolOrNil
       
  2777     "set the startGroup attribute"
       
  2778 
       
  2779     startGroup := aSymbolOrNil
       
  2780 
       
  2781     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  2782 !
       
  2783 
       
  2784 submenuChannel
       
  2785     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  2786 
       
  2787     ^submenuChannel
       
  2788 !
       
  2789 
       
  2790 submenuChannel:aChannel
       
  2791     "get the submenuChannel"
       
  2792 
       
  2793     submenuChannel := aChannel
       
  2794 !
       
  2795 
       
  2796 translateLabel:aBoolean
       
  2797     "set/clear the translate to national-language flag"
       
  2798 
       
  2799     translateLabel := aBoolean
       
  2800 
       
  2801     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  2802 !
       
  2803 
       
  2804 value:aSymbol
       
  2805     "set the value attribute"
       
  2806 
       
  2807     value := aSymbol
       
  2808 
       
  2809     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  2810 ! !
       
  2811 
       
  2812 !MenuEditor::Item methodsFor:'building'!
       
  2813 
       
  2814 buildFromAspects:aspects
       
  2815     "read the values of the aspects into my values"
       
  2816 
       
  2817     |name|
       
  2818     self isSeparator 
       
  2819     ifFalse:
       
  2820     [
       
  2821         name  := label.
       
  2822         label := (aspects at:#label) value.
       
  2823 
       
  2824         (label isNil or:[self isSeparator]) ifTrue:[
       
  2825             (aspects at:#label) value:(label := name)
       
  2826         ].
       
  2827 
       
  2828         enabled            := (aspects at:#enabled) value.
       
  2829         value              := (aspects at:#value) value.
       
  2830         nameKey            := (aspects at:#nameKey) value.
       
  2831         indication         := (aspects at:#indication) value.
       
  2832         choice             := (aspects at:#choice) value.
       
  2833         choiceValue        := (aspects at:#choiceValue) value.
       
  2834         shortcutKey        := (aspects at:#shortcutKey) value.
       
  2835         startGroup         := (aspects at:#startGroup) value.
       
  2836         accessCharacterPos := (aspects at:#accessCharacterPos) value.
       
  2837         showBusyCursorWhilePerforming := (aspects at:#showBusyCursorWhilePerforming) value.
       
  2838         keepLinkedMenu     := (aspects at:#keepLinkedMenu) value ? false.
       
  2839         font               := (aspects at:#font) value.
       
  2840         argument           := (aspects at:#argument) value.
       
  2841         translateLabel     := (aspects at:#translateLabel) value.
       
  2842         isButton           := (aspects at:#isButton) value.
       
  2843         auxValue           := (aspects at:#auxValue) value.
       
  2844 
       
  2845         argument isString ifTrue:[
       
  2846             argument size > 1 ifTrue:[
       
  2847                 (argument at:1) == $# ifTrue:[
       
  2848                     argument := (argument copyFrom:2) asSymbol
       
  2849                 ]
       
  2850             ]
       
  2851         ].
       
  2852         submenuChannel    := (aspects at:#submenuChannel) value.
       
  2853         retriever         := (aspects at:#retriever) value.
       
  2854         icon              := (aspects at:#icon) value.
       
  2855         iconAndLabel      := (aspects at:#iconAndLabel) value.
       
  2856     ]
       
  2857     ifTrue:
       
  2858     [
       
  2859         name  := (aspects at:#seperatorSelection) selectionIndex.
       
  2860         label := (self class separatorSlices at:name) last.
       
  2861     ].
       
  2862     isVisible := (aspects at:#isVisible) value.
       
  2863     hideMenuOnActivated := (aspects at:#hideMenuOnActivated) value.
       
  2864 
       
  2865     "Modified: / 14.8.1998 / 15:36:38 / cg"
       
  2866 !
       
  2867 
       
  2868 buildFromMenuItem:anItem
       
  2869     "read the attributes of anItem into my values"
       
  2870 
       
  2871     |rtv|
       
  2872 
       
  2873     self label:(anItem rawLabel).
       
  2874     activeHelpKey := anItem activeHelpKey.
       
  2875 
       
  2876     (enabled := anItem enabled) isSymbol ifFalse:[
       
  2877         enabled := nil
       
  2878     ].
       
  2879     (value := anItem value) isSymbol ifFalse:[
       
  2880         value := nil.
       
  2881     ].
       
  2882     (indication := anItem indication) isSymbol ifFalse:[
       
  2883         indication := nil
       
  2884     ].
       
  2885     (choice := anItem choice) isSymbol ifFalse:[
       
  2886         choice := nil
       
  2887     ].
       
  2888     choiceValue         := anItem choiceValue.
       
  2889     nameKey             := anItem nameKey.
       
  2890     shortcutKey         := anItem shortcutKeyCharacter.
       
  2891     startGroup          := anItem startGroup.
       
  2892     accessCharacterPos  := anItem accessCharacterPosition.
       
  2893     showBusyCursorWhilePerforming  := anItem showBusyCursorWhilePerforming.
       
  2894     keepLinkedMenu      := anItem keepLinkedMenu.
       
  2895     font                := anItem font.
       
  2896     argument            := anItem argument.
       
  2897 
       
  2898     submenuChannel      := anItem submenuChannel.
       
  2899     translateLabel      := anItem translateLabel.
       
  2900     isButton            := anItem isButton.
       
  2901     isVisible           := anItem isVisible.
       
  2902     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  2903     auxValue            := anItem auxValue.
       
  2904 
       
  2905     (((rtv := anItem adornment) notNil)
       
  2906     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  2907     ifTrue:
       
  2908     [
       
  2909         retriever := rtv className.
       
  2910         icon      := rtv selector.
       
  2911         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  2912             label := rtv labelText.
       
  2913         ]
       
  2914     ]
       
  2915 
       
  2916     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  2917 ! !
       
  2918 
       
  2919 !MenuEditor::Item methodsFor:'conversion'!
       
  2920 
       
  2921 asMenuItem
       
  2922     "converts self to a menu item"
       
  2923 
       
  2924     |item rcv|
       
  2925 
       
  2926     item := MenuItem labeled:label.
       
  2927     item isVisible:isVisible.
       
  2928     item hideMenuOnActivated:hideMenuOnActivated.
       
  2929 
       
  2930     self isSeparator ifFalse:[    
       
  2931         item activeHelpKey:activeHelpKey.
       
  2932         item enabled:enabled.
       
  2933         item accessCharacterPosition:accessCharacterPos.
       
  2934         item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
       
  2935         item keepLinkedMenu:keepLinkedMenu.
       
  2936         item font:font.
       
  2937         item argument:argument.
       
  2938         item submenuChannel:submenuChannel.
       
  2939         item nameKey:nameKey.
       
  2940         item shortcutKeyCharacter:shortcutKey.
       
  2941         item startGroup:startGroup.
       
  2942         item value:value.
       
  2943         item indication:indication.
       
  2944         item choice:choice.
       
  2945         item choiceValue:choiceValue.
       
  2946         item translateLabel: translateLabel.
       
  2947         item isButton: isButton.
       
  2948         item auxValue: auxValue.
       
  2949 
       
  2950         icon notNil ifTrue:[
       
  2951             rcv := ResourceRetriever new.
       
  2952             rcv className:retriever.
       
  2953             rcv selector:icon.
       
  2954             iconAndLabel == true ifTrue:[
       
  2955                 rcv labelText:label
       
  2956             ].
       
  2957             item labelImage:rcv
       
  2958         ]
       
  2959     ].
       
  2960     ^item
       
  2961 
       
  2962     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  2963 !
       
  2964 
       
  2965 toAspects:aspects
       
  2966     "put my values into the values of aspects"
       
  2967 
       
  2968     |type|
       
  2969     (type := self separatorType) notNil ifTrue: [
       
  2970         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  2971         (aspects at:#seperatorSelection) selectionIndex:type.
       
  2972     ] ifFalse: [
       
  2973         (aspects at:#label)                value:label.
       
  2974         (aspects at:#enabled)              value:enabled.
       
  2975         (aspects at:#value)                value:value.
       
  2976         (aspects at:#nameKey)              value:nameKey.
       
  2977         (aspects at:#indication)           value:indication.
       
  2978         (aspects at:#choice)               value:choice.
       
  2979         (aspects at:#choiceValue)          value:choiceValue.
       
  2980         (aspects at:#shortcutKey)          value:shortcutKey.
       
  2981         (aspects at:#startGroup)           value:startGroup.
       
  2982         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  2983         (aspects at:#showBusyCursorWhilePerforming)   value:showBusyCursorWhilePerforming.
       
  2984         (aspects at:#keepLinkedMenu)       value:(keepLinkedMenu ? false).
       
  2985         (aspects at:#font)                 value:font.
       
  2986         (aspects at:#translateLabel)       value:translateLabel.
       
  2987         (aspects at:#submenuChannel)       value:submenuChannel.
       
  2988         (aspects at:#retriever)            value:retriever.
       
  2989         (aspects at:#icon)                 value:icon.
       
  2990         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  2991         (aspects at:#isButton)             value:isButton.
       
  2992         (aspects at:#auxValue)             value:auxValue.
       
  2993 
       
  2994         (aspects at:#argument)
       
  2995             value:(argument isSymbol
       
  2996                         ifTrue: ['#', argument] 
       
  2997                         ifFalse:[argument]).
       
  2998     ].
       
  2999     (aspects at:#isVisible) value:isVisible.
       
  3000     (aspects at:#hideMenuOnActivated) value:(hideMenuOnActivated ? true).
       
  3001 
       
  3002     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  3003 ! !
       
  3004 
       
  3005 !MenuEditor::Item methodsFor:'queries'!
       
  3006 
       
  3007 iconFor: aNode
       
  3008     "get the icon of the menu item for the tree view"
       
  3009 
       
  3010     (aNode hasChildren or: [aNode parent isNil])
       
  3011     ifTrue:
       
  3012     [
       
  3013         ^MenuEditor submenuImage
       
  3014     ]
       
  3015     ifFalse:
       
  3016     [
       
  3017         submenuChannel notNil 
       
  3018         ifTrue:
       
  3019         [
       
  3020             ^MenuEditor linkSubmenuImage
       
  3021         ]
       
  3022         ifFalse:
       
  3023         [
       
  3024             self isSeparator 
       
  3025                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3026                 ifFalse: [^MenuEditor menuItemImage]
       
  3027         ]
       
  3028     ]
       
  3029 !
       
  3030 
       
  3031 isSeparator
       
  3032     "return true if item is a seperator"
       
  3033 
       
  3034     ^self separatorType notNil
       
  3035 !
       
  3036 
       
  3037 treeViewLabel
       
  3038     "get the label of the menu item for the tree view"
       
  3039 
       
  3040     ^label
       
  3041 " asBoldText, 
       
  3042         (value notNil ifTrue: [': [', 
       
  3043                 value ,
       
  3044                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3045                  ']'] ifFalse: [''])
       
  3046 
       
  3047 
       
  3048 "
       
  3049 ! !
       
  3050 
  2687 !MenuEditor::TreeView class methodsFor:'documentation'!
  3051 !MenuEditor::TreeView class methodsFor:'documentation'!
  2688 
  3052 
  2689 documentation
  3053 documentation
  2690 "
  3054 "
  2691     This tree view class provides a hierarchical representation
  3055     This tree view class provides a hierarchical representation
  3147 
  3511 
  3148     (app := self topView application) modified: true.
  3512     (app := self topView application) modified: true.
  3149     app updateChannels
  3513     app updateChannels
  3150 ! !
  3514 ! !
  3151 
  3515 
  3152 !MenuEditor::Item class methodsFor:'constants'!
       
  3153 
       
  3154 separatorList
       
  3155     "get the list of available separator types"
       
  3156 
       
  3157     ^#('blank' 'single line' 'double line')
       
  3158 !
       
  3159 
       
  3160 separatorSlices
       
  3161     "get the list of menu spec values of the corresponding separator types"
       
  3162 
       
  3163    ^ #(
       
  3164         ( #blank        ''  )
       
  3165         ( #single       '-' )
       
  3166         ( #double       '=' )
       
  3167       )
       
  3168 ! !
       
  3169 
       
  3170 !MenuEditor::Item class methodsFor:'documentation'!
       
  3171 
       
  3172 documentation
       
  3173 "
       
  3174     implements the contents assigned to a TreeItem. An instance
       
  3175     is associated with one item and keeps all its information
       
  3176 
       
  3177     [see also:]
       
  3178         TreeItem
       
  3179         MenuEditor
       
  3180 
       
  3181     [author:]
       
  3182         Claus Atzkern
       
  3183 "
       
  3184 
       
  3185 
       
  3186 ! !
       
  3187 
       
  3188 !MenuEditor::Item methodsFor:'accessing'!
       
  3189 
       
  3190 activeHelpKey
       
  3191     "get the help key of the menu item"
       
  3192 
       
  3193     ^activeHelpKey
       
  3194 !
       
  3195 
       
  3196 activeHelpKey:aKey
       
  3197     "set the help key of the menu item"
       
  3198 
       
  3199     activeHelpKey := aKey
       
  3200 !
       
  3201 
       
  3202 label
       
  3203     "get the value of the menu item"
       
  3204 
       
  3205     ^label
       
  3206 !
       
  3207 
       
  3208 label:something
       
  3209     "set the value of the menu item"
       
  3210 
       
  3211     label := something ? '-'
       
  3212 !
       
  3213 
       
  3214 separatorType
       
  3215     "get the separator type assigned to item or nil"
       
  3216 
       
  3217     label size > 1 
       
  3218     ifFalse:
       
  3219     [
       
  3220         label size  == 0  ifTrue:[^#blank].
       
  3221         label first == $- ifTrue:[^#single].
       
  3222         label first == $= ifTrue:[^#double].
       
  3223     ].    
       
  3224     ^nil
       
  3225 
       
  3226 !
       
  3227 
       
  3228 startGroup:aSymbolOrNil
       
  3229     "set the startGroup attribute"
       
  3230 
       
  3231     startGroup := aSymbolOrNil
       
  3232 
       
  3233     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  3234 !
       
  3235 
       
  3236 submenuChannel
       
  3237     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  3238 
       
  3239     ^submenuChannel
       
  3240 !
       
  3241 
       
  3242 submenuChannel:aChannel
       
  3243     "get the submenuChannel"
       
  3244 
       
  3245     submenuChannel := aChannel
       
  3246 !
       
  3247 
       
  3248 translateLabel:aBoolean
       
  3249     "set/clear the translate to national-language flag"
       
  3250 
       
  3251     translateLabel := aBoolean
       
  3252 
       
  3253     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  3254 !
       
  3255 
       
  3256 value:aSymbol
       
  3257     "set the value attribute"
       
  3258 
       
  3259     value := aSymbol
       
  3260 
       
  3261     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  3262 ! !
       
  3263 
       
  3264 !MenuEditor::Item methodsFor:'building'!
       
  3265 
       
  3266 buildFromAspects:aspects
       
  3267     "read the values of the aspects into my values"
       
  3268 
       
  3269     |name|
       
  3270     self isSeparator 
       
  3271     ifFalse:
       
  3272     [
       
  3273         name  := label.
       
  3274         label := (aspects at:#label) value.
       
  3275 
       
  3276         (label isNil or:[self isSeparator]) ifTrue:[
       
  3277             (aspects at:#label) value:(label := name)
       
  3278         ].
       
  3279 
       
  3280         enabled            := (aspects at:#enabled) value.
       
  3281         value              := (aspects at:#value) value.
       
  3282         nameKey            := (aspects at:#nameKey) value.
       
  3283         indication         := (aspects at:#indication) value.
       
  3284         choice             := (aspects at:#choice) value.
       
  3285         choiceValue        := (aspects at:#choiceValue) value.
       
  3286         shortcutKey        := (aspects at:#shortcutKey) value.
       
  3287         startGroup         := (aspects at:#startGroup) value.
       
  3288         accessCharacterPos := (aspects at:#accessCharacterPos) value.
       
  3289         showBusyCursorWhilePerforming := (aspects at:#showBusyCursorWhilePerforming) value.
       
  3290         font               := (aspects at:#font) value.
       
  3291         argument           := (aspects at:#argument) value.
       
  3292         translateLabel     := (aspects at:#translateLabel) value.
       
  3293         isButton           := (aspects at:#isButton) value.
       
  3294         auxValue           := (aspects at:#auxValue) value.
       
  3295 
       
  3296         argument isString ifTrue:[
       
  3297             argument size > 1 ifTrue:[
       
  3298                 (argument at:1) == $# ifTrue:[
       
  3299                     argument := (argument copyFrom:2) asSymbol
       
  3300                 ]
       
  3301             ]
       
  3302         ].
       
  3303         submenuChannel    := (aspects at:#submenuChannel) value.
       
  3304         retriever         := (aspects at:#retriever) value.
       
  3305         icon              := (aspects at:#icon) value.
       
  3306         iconAndLabel      := (aspects at:#iconAndLabel) value.
       
  3307     ]
       
  3308     ifTrue:
       
  3309     [
       
  3310         name  := (aspects at:#seperatorSelection) selectionIndex.
       
  3311         label := (self class separatorSlices at:name) last.
       
  3312     ].
       
  3313     isVisible := (aspects at:#isVisible) value.
       
  3314     hideMenuOnActivated := (aspects at:#hideMenuOnActivated) value.
       
  3315 
       
  3316     "Modified: / 14.8.1998 / 15:36:38 / cg"
       
  3317 !
       
  3318 
       
  3319 buildFromMenuItem:anItem
       
  3320     "read the attributes of anItem into my values"
       
  3321 
       
  3322     |rtv|
       
  3323 
       
  3324     self label:(anItem rawLabel).
       
  3325     activeHelpKey := anItem activeHelpKey.
       
  3326 
       
  3327     (enabled := anItem enabled) isSymbol ifFalse:[
       
  3328         enabled := nil
       
  3329     ].
       
  3330     (value := anItem value) isSymbol ifFalse:[
       
  3331         value := nil.
       
  3332     ].
       
  3333     (indication := anItem indication) isSymbol ifFalse:[
       
  3334         indication := nil
       
  3335     ].
       
  3336     (choice := anItem choice) isSymbol ifFalse:[
       
  3337         choice := nil
       
  3338     ].
       
  3339     choiceValue         := anItem choiceValue.
       
  3340     nameKey             := anItem nameKey.
       
  3341     shortcutKey         := anItem shortcutKeyCharacter.
       
  3342     startGroup          := anItem startGroup.
       
  3343     accessCharacterPos  := anItem accessCharacterPosition.
       
  3344     showBusyCursorWhilePerforming  := anItem showBusyCursorWhilePerforming.
       
  3345     font                := anItem font.
       
  3346     argument            := anItem argument.
       
  3347 
       
  3348     submenuChannel      := anItem submenuChannel.
       
  3349     translateLabel      := anItem translateLabel.
       
  3350     isButton            := anItem isButton.
       
  3351     isVisible           := anItem isVisible.
       
  3352     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  3353     auxValue            := anItem auxValue.
       
  3354 
       
  3355     (((rtv := anItem adornment) notNil)
       
  3356     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  3357     ifTrue:
       
  3358     [
       
  3359         retriever := rtv className.
       
  3360         icon      := rtv selector.
       
  3361         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  3362             label := rtv labelText.
       
  3363         ]
       
  3364     ]
       
  3365 
       
  3366     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  3367 ! !
       
  3368 
       
  3369 !MenuEditor::Item methodsFor:'conversion'!
       
  3370 
       
  3371 asMenuItem
       
  3372     "converts self to a menu item"
       
  3373 
       
  3374     |item rcv|
       
  3375 
       
  3376     item := MenuItem labeled:label.
       
  3377     item isVisible:isVisible.
       
  3378     item hideMenuOnActivated:hideMenuOnActivated.
       
  3379 
       
  3380     self isSeparator ifFalse:[    
       
  3381         item activeHelpKey:activeHelpKey.
       
  3382         item enabled:enabled.
       
  3383         item accessCharacterPosition:accessCharacterPos.
       
  3384         item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
       
  3385         item font:font.
       
  3386         item argument:argument.
       
  3387         item submenuChannel:submenuChannel.
       
  3388         item nameKey:nameKey.
       
  3389         item shortcutKeyCharacter:shortcutKey.
       
  3390         item startGroup:startGroup.
       
  3391         item value:value.
       
  3392         item indication:indication.
       
  3393         item choice:choice.
       
  3394         item choiceValue:choiceValue.
       
  3395         item translateLabel: translateLabel.
       
  3396         item isButton: isButton.
       
  3397         item auxValue: auxValue.
       
  3398 
       
  3399         icon notNil ifTrue:[
       
  3400             rcv := ResourceRetriever new.
       
  3401             rcv className:retriever.
       
  3402             rcv selector:icon.
       
  3403             iconAndLabel == true ifTrue:[
       
  3404                 rcv labelText:label
       
  3405             ].
       
  3406             item labelImage:rcv
       
  3407         ]
       
  3408     ].
       
  3409     ^item
       
  3410 
       
  3411     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  3412 !
       
  3413 
       
  3414 toAspects:aspects
       
  3415     "put my values into the values of aspects"
       
  3416 
       
  3417     |type|
       
  3418     (type := self separatorType) notNil ifTrue: [
       
  3419         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  3420         (aspects at:#seperatorSelection) selectionIndex:type.
       
  3421     ] ifFalse: [
       
  3422         (aspects at:#label)                value:label.
       
  3423         (aspects at:#enabled)              value:enabled.
       
  3424         (aspects at:#value)                value:value.
       
  3425         (aspects at:#nameKey)              value:nameKey.
       
  3426         (aspects at:#indication)           value:indication.
       
  3427         (aspects at:#choice)               value:choice.
       
  3428         (aspects at:#choiceValue)          value:choiceValue.
       
  3429         (aspects at:#shortcutKey)          value:shortcutKey.
       
  3430         (aspects at:#startGroup)           value:startGroup.
       
  3431         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  3432         (aspects at:#showBusyCursorWhilePerforming)   value:showBusyCursorWhilePerforming.
       
  3433         (aspects at:#font)                 value:font.
       
  3434         (aspects at:#translateLabel)       value:translateLabel.
       
  3435         (aspects at:#submenuChannel)       value:submenuChannel.
       
  3436         (aspects at:#retriever)            value:retriever.
       
  3437         (aspects at:#icon)                 value:icon.
       
  3438         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  3439         (aspects at:#isButton)             value:isButton.
       
  3440         (aspects at:#auxValue)             value:auxValue.
       
  3441 
       
  3442         (aspects at:#argument)
       
  3443             value:(argument isSymbol
       
  3444                         ifTrue: ['#', argument] 
       
  3445                         ifFalse:[argument]).
       
  3446     ].
       
  3447     (aspects at:#isVisible) value:isVisible.
       
  3448     (aspects at:#hideMenuOnActivated) value:(hideMenuOnActivated ? true).
       
  3449 
       
  3450     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  3451 ! !
       
  3452 
       
  3453 !MenuEditor::Item methodsFor:'queries'!
       
  3454 
       
  3455 iconFor: aNode
       
  3456     "get the icon of the menu item for the tree view"
       
  3457 
       
  3458     (aNode hasChildren or: [aNode parent isNil])
       
  3459     ifTrue:
       
  3460     [
       
  3461         ^MenuEditor submenuImage
       
  3462     ]
       
  3463     ifFalse:
       
  3464     [
       
  3465         submenuChannel notNil 
       
  3466         ifTrue:
       
  3467         [
       
  3468             ^MenuEditor linkSubmenuImage
       
  3469         ]
       
  3470         ifFalse:
       
  3471         [
       
  3472             self isSeparator 
       
  3473                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3474                 ifFalse: [^MenuEditor menuItemImage]
       
  3475         ]
       
  3476     ]
       
  3477 !
       
  3478 
       
  3479 isSeparator
       
  3480     "return true if item is a seperator"
       
  3481 
       
  3482     ^self separatorType notNil
       
  3483 !
       
  3484 
       
  3485 treeViewLabel
       
  3486     "get the label of the menu item for the tree view"
       
  3487 
       
  3488     ^label
       
  3489 " asBoldText, 
       
  3490         (value notNil ifTrue: [': [', 
       
  3491                 value ,
       
  3492                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3493                  ']'] ifFalse: [''])
       
  3494 
       
  3495 
       
  3496 "
       
  3497 ! !
       
  3498 
       
  3499 !MenuEditor class methodsFor:'documentation'!
  3516 !MenuEditor class methodsFor:'documentation'!
  3500 
  3517 
  3501 version
  3518 version
  3502     ^ '$Header$'
  3519     ^ '$Header$'
  3503 ! !
  3520 ! !