MenuEditor.st
changeset 1348 48e25df6aa34
parent 1335 b80f8c8ec3d6
child 1349 47ccfd0fac75
equal deleted inserted replaced
1347:c4046d0b638e 1348:48e25df6aa34
    18 	classVariableNames:''
    18 	classVariableNames:''
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    21 !
    21 !
    22 
    22 
       
    23 SelectionInTreeView subclass:#TreeView
       
    24 	instanceVariableNames:''
       
    25 	classVariableNames:''
       
    26 	poolDictionaries:''
       
    27 	privateIn:MenuEditor
       
    28 !
       
    29 
    23 Object subclass:#Item
    30 Object subclass:#Item
    24 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    31 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    25 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    32 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    26 		startGroup argument translateLabel isButton isVisible choice
    33 		startGroup argument translateLabel isButton isVisible choice
    27 		choiceValue auxValue hideMenuOnActivated'
    34 		choiceValue auxValue hideMenuOnActivated
    28 	classVariableNames:''
    35 		showBusyCursorWhilePerforming'
    29 	poolDictionaries:''
       
    30 	privateIn:MenuEditor
       
    31 !
       
    32 
       
    33 SelectionInTreeView subclass:#TreeView
       
    34 	instanceVariableNames:''
       
    35 	classVariableNames:''
    36 	classVariableNames:''
    36 	poolDictionaries:''
    37 	poolDictionaries:''
    37 	privateIn:MenuEditor
    38 	privateIn:MenuEditor
    38 !
    39 !
    39 
    40 
   113     "get the aspects for the attributes of the menu components"
   114     "get the aspects for the attributes of the menu components"
   114 
   115 
   115     ^#(
   116     ^#(
   116         label
   117         label
   117         accessCharacterPos
   118         accessCharacterPos
       
   119         showBusyCursorWhilePerforming
   118         argument
   120         argument
   119         submenuChannel
   121         submenuChannel
   120         enabled
   122         enabled
   121         value
   123         value
   122         nameKey
   124         nameKey
   369        #(#WindowSpec
   371        #(#WindowSpec
   370           #label: 'Basics Item'
   372           #label: 'Basics Item'
   371           #name: 'Basics Item'
   373           #name: 'Basics Item'
   372           #min: #(#Point 10 10)
   374           #min: #(#Point 10 10)
   373           #max: #(#Point 1160 870)
   375           #max: #(#Point 1160 870)
   374           #bounds: #(#Rectangle 12 22 279 341)
   376           #bounds: #(#Rectangle 87 73 354 420)
   375         )
   377         )
   376         #component: 
   378         #component: 
   377        #(#SpecCollection
   379        #(#SpecCollection
   378           #collection: #(
   380           #collection: #(
   379            #(#LabelSpec
   381            #(#LabelSpec
   383               #activeHelpKey: #basicsKey
   385               #activeHelpKey: #basicsKey
   384               #resizeForLabel: true
   386               #resizeForLabel: true
   385               #adjust: #right
   387               #adjust: #right
   386             )
   388             )
   387            #(#InputFieldSpec
   389            #(#InputFieldSpec
   388               #attributes: 
       
   389              #(#tabable
       
   390                 true
       
   391               )
       
   392               #name: 'nameKeyField'
   390               #name: 'nameKeyField'
   393               #layout: #(#LayoutFrame 110 0 16 0 -5 1.0 38 0)
   391               #layout: #(#LayoutFrame 110 0 16 0 -5 1.0 38 0)
   394               #activeHelpKey: #basicsKey
   392               #activeHelpKey: #basicsKey
   395               #tabable: true
   393               #tabable: true
   396               #model: #nameKey
   394               #model: #nameKey
   411               #activeHelpKey: #basicsLabel
   409               #activeHelpKey: #basicsLabel
   412               #resizeForLabel: true
   410               #resizeForLabel: true
   413               #adjust: #right
   411               #adjust: #right
   414             )
   412             )
   415            #(#InputFieldSpec
   413            #(#InputFieldSpec
   416               #attributes: 
       
   417              #(#tabable
       
   418                 true
       
   419               )
       
   420               #name: 'labelField'
   414               #name: 'labelField'
   421               #layout: #(#LayoutFrame 110 0 40 0 -5 1.0 62 0)
   415               #layout: #(#LayoutFrame 110 0 40 0 -5 1.0 62 0)
   422               #activeHelpKey: #basicsLabel
   416               #activeHelpKey: #basicsLabel
   423               #tabable: true
   417               #tabable: true
   424               #model: #label
   418               #model: #label
   437               #activeHelpKey: #basicsAction
   431               #activeHelpKey: #basicsAction
   438               #resizeForLabel: true
   432               #resizeForLabel: true
   439               #adjust: #right
   433               #adjust: #right
   440             )
   434             )
   441            #(#InputFieldSpec
   435            #(#InputFieldSpec
   442               #attributes: 
       
   443              #(#tabable
       
   444                 true
       
   445               )
       
   446               #name: 'valueField'
   436               #name: 'valueField'
   447               #layout: #(#LayoutFrame 110 0 79 0 -5 1.0 101 0)
   437               #layout: #(#LayoutFrame 110 0 79 0 -5 1.0 101 0)
   448               #activeHelpKey: #basicsAction
   438               #activeHelpKey: #basicsAction
   449               #tabable: true
   439               #tabable: true
   450               #model: #value
   440               #model: #value
   464               #activeHelpKey: #basicsArgument
   454               #activeHelpKey: #basicsArgument
   465               #resizeForLabel: true
   455               #resizeForLabel: true
   466               #adjust: #right
   456               #adjust: #right
   467             )
   457             )
   468            #(#InputFieldSpec
   458            #(#InputFieldSpec
   469               #attributes: 
       
   470              #(#tabable
       
   471                 true
       
   472               )
       
   473               #name: 'argumentField'
   459               #name: 'argumentField'
   474               #layout: #(#LayoutFrame 110 0 104 0 -5 1.0 126 0)
   460               #layout: #(#LayoutFrame 110 0 104 0 -5 1.0 126 0)
   475               #activeHelpKey: #basicsArgument
   461               #activeHelpKey: #basicsArgument
   476               #tabable: true
   462               #tabable: true
   477               #model: #argument
   463               #model: #argument
   491               #activeHelpKey: #basicsIndication
   477               #activeHelpKey: #basicsIndication
   492               #resizeForLabel: true
   478               #resizeForLabel: true
   493               #adjust: #right
   479               #adjust: #right
   494             )
   480             )
   495            #(#InputFieldSpec
   481            #(#InputFieldSpec
   496               #attributes: 
       
   497              #(#tabable
       
   498                 true
       
   499               )
       
   500               #name: 'indicationField'
   482               #name: 'indicationField'
   501               #layout: #(#LayoutFrame 110 0 144 0 -5 1.0 166 0)
   483               #layout: #(#LayoutFrame 110 0 144 0 -5 1.0 166 0)
   502               #activeHelpKey: #basicsIndication
   484               #activeHelpKey: #basicsIndication
   503               #enableChannel: #indicationEnabled
   485               #enableChannel: #indicationEnabled
   504               #tabable: true
   486               #tabable: true
   521               #translateLabel: true
   503               #translateLabel: true
   522               #resizeForLabel: true
   504               #resizeForLabel: true
   523               #adjust: #right
   505               #adjust: #right
   524             )
   506             )
   525            #(#InputFieldSpec
   507            #(#InputFieldSpec
   526               #attributes: 
       
   527              #(#tabable
       
   528                 true
       
   529               )
       
   530               #name: 'choiceField'
   508               #name: 'choiceField'
   531               #layout: #(#LayoutFrame 110 0 169 0 -5 1.0 191 0)
   509               #layout: #(#LayoutFrame 110 0 169 0 -5 1.0 191 0)
   532               #activeHelpKey: #basicsChoice
   510               #activeHelpKey: #basicsChoice
   533               #enableChannel: #choiceEnabled
   511               #enableChannel: #choiceEnabled
   534               #tabable: true
   512               #tabable: true
   551               #translateLabel: true
   529               #translateLabel: true
   552               #resizeForLabel: true
   530               #resizeForLabel: true
   553               #adjust: #right
   531               #adjust: #right
   554             )
   532             )
   555            #(#InputFieldSpec
   533            #(#InputFieldSpec
   556               #attributes: 
       
   557              #(#tabable
       
   558                 true
       
   559               )
       
   560               #name: 'choiceValueField'
   534               #name: 'choiceValueField'
   561               #layout: #(#LayoutFrame 110 0 194 0 -5 1.0 216 0)
   535               #layout: #(#LayoutFrame 110 0 194 0 -5 1.0 216 0)
   562               #activeHelpKey: #basicsChoiceValue
   536               #activeHelpKey: #basicsChoiceValue
   563               #enableChannel: #choiceValueEnabled
   537               #enableChannel: #choiceValueEnabled
   564               #tabable: true
   538               #tabable: true
   572               #acceptChannel: #acceptChannel
   546               #acceptChannel: #acceptChannel
   573               #modifiedChannel: #modifiedChannel
   547               #modifiedChannel: #modifiedChannel
   574               #acceptOnPointerLeave: false
   548               #acceptOnPointerLeave: false
   575             )
   549             )
   576            #(#CheckBoxSpec
   550            #(#CheckBoxSpec
   577               #attributes: 
       
   578              #(#tabable
       
   579                 true
       
   580               )
       
   581               #label: 'Translate Label'
   551               #label: 'Translate Label'
   582               #name: 'translateLabelCheckBox'
   552               #name: 'translateLabelCheckBox'
   583               #layout: #(#Point 20 230)
   553               #layout: #(#Point 20 230)
   584               #activeHelpKey: #basicsTranslateLabel
   554               #activeHelpKey: #basicsTranslateLabel
   585               #tabable: true
   555               #tabable: true
   586               #model: #translateLabel
   556               #model: #translateLabel
   587             )
   557             )
   588            #(#CheckBoxSpec
   558            #(#CheckBoxSpec
   589               #attributes: 
       
   590              #(#tabable
       
   591                 true
       
   592               )
       
   593               #label: 'Is Button'
   559               #label: 'Is Button'
   594               #name: 'isButtonCheckBox'
   560               #name: 'isButtonCheckBox'
   595               #layout: #(#Point 20 256)
   561               #layout: #(#Point 20 256)
   596               #activeHelpKey: #basicsIsButton
   562               #activeHelpKey: #basicsIsButton
   597               #tabable: true
   563               #tabable: true
   598               #model: #isButton
   564               #model: #isButton
   599             )
   565             )
   600            #(#CheckBoxSpec
   566            #(#CheckBoxSpec
   601               #attributes: 
       
   602              #(#tabable
       
   603                 true
       
   604               )
       
   605               #label: 'Hide Menu after Activation'
   567               #label: 'Hide Menu after Activation'
   606               #name: 'hideMenuOnActivated'
   568               #name: 'hideMenuOnActivated'
   607               #layout: #(#Point 20 281)
   569               #layout: #(#Point 20 281)
   608               #activeHelpKey: #hideMenuOnActivated
   570               #activeHelpKey: #hideMenuOnActivated
   609               #tabable: true
   571               #tabable: true
   610               #model: #hideMenuOnActivated
   572               #model: #hideMenuOnActivated
       
   573             )
       
   574            #(#CheckBoxSpec
       
   575               #label: 'BusyCursor while Active'
       
   576               #name: 'showBusyCursorWhilePerforming'
       
   577               #layout: #(#Point 20 305)
       
   578               #activeHelpKey: #hideMenuOnActivated
       
   579               #tabable: true
       
   580               #model: #showBusyCursorWhilePerforming
       
   581               #translateLabel: true
   611             )
   582             )
   612            )
   583            )
   613          
   584          
   614         )
   585         )
   615       )
   586       )
  2698 
  2669 
  2699     treeView selectedNodeChangeSequenceOrder:-1.
  2670     treeView selectedNodeChangeSequenceOrder:-1.
  2700     modified := true.
  2671     modified := true.
  2701 ! !
  2672 ! !
  2702 
  2673 
  2703 !MenuEditor::Item class methodsFor:'constants'!
       
  2704 
       
  2705 separatorList
       
  2706     "get the list of available separator types"
       
  2707 
       
  2708     ^#('blank' 'single line' 'double line')
       
  2709 !
       
  2710 
       
  2711 separatorSlices
       
  2712     "get the list of menu spec values of the corresponding separator types"
       
  2713 
       
  2714    ^ #(
       
  2715         ( #blank        ''  )
       
  2716         ( #single       '-' )
       
  2717         ( #double       '=' )
       
  2718       )
       
  2719 ! !
       
  2720 
       
  2721 !MenuEditor::Item class methodsFor:'documentation'!
       
  2722 
       
  2723 documentation
       
  2724 "
       
  2725     implements the contents assigned to a TreeItem. An instance
       
  2726     is associated with one item and keeps all its information
       
  2727 
       
  2728     [see also:]
       
  2729         TreeItem
       
  2730         MenuEditor
       
  2731 
       
  2732     [author:]
       
  2733         Claus Atzkern
       
  2734 "
       
  2735 
       
  2736 
       
  2737 ! !
       
  2738 
       
  2739 !MenuEditor::Item methodsFor:'accessing'!
       
  2740 
       
  2741 activeHelpKey
       
  2742     "get the help key of the menu item"
       
  2743 
       
  2744     ^activeHelpKey
       
  2745 !
       
  2746 
       
  2747 activeHelpKey:aKey
       
  2748     "set the help key of the menu item"
       
  2749 
       
  2750     activeHelpKey := aKey
       
  2751 !
       
  2752 
       
  2753 label
       
  2754     "get the value of the menu item"
       
  2755 
       
  2756     ^label
       
  2757 !
       
  2758 
       
  2759 label:something
       
  2760     "set the value of the menu item"
       
  2761 
       
  2762     label := something ? '-'
       
  2763 !
       
  2764 
       
  2765 separatorType
       
  2766     "get the separator type assigned to item or nil"
       
  2767 
       
  2768     label size > 1 
       
  2769     ifFalse:
       
  2770     [
       
  2771         label size  == 0  ifTrue:[^#blank].
       
  2772         label first == $- ifTrue:[^#single].
       
  2773         label first == $= ifTrue:[^#double].
       
  2774     ].    
       
  2775     ^nil
       
  2776 
       
  2777 !
       
  2778 
       
  2779 startGroup:aSymbolOrNil
       
  2780     "set the startGroup attribute"
       
  2781 
       
  2782     startGroup := aSymbolOrNil
       
  2783 
       
  2784     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  2785 !
       
  2786 
       
  2787 submenuChannel
       
  2788     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  2789 
       
  2790     ^submenuChannel
       
  2791 !
       
  2792 
       
  2793 submenuChannel:aChannel
       
  2794     "get the submenuChannel"
       
  2795 
       
  2796     submenuChannel := aChannel
       
  2797 !
       
  2798 
       
  2799 translateLabel:aBoolean
       
  2800     "set/clear the translate to national-language flag"
       
  2801 
       
  2802     translateLabel := aBoolean
       
  2803 
       
  2804     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  2805 !
       
  2806 
       
  2807 value:aSymbol
       
  2808     "set the value attribute"
       
  2809 
       
  2810     value := aSymbol
       
  2811 
       
  2812     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  2813 ! !
       
  2814 
       
  2815 !MenuEditor::Item methodsFor:'building'!
       
  2816 
       
  2817 buildFromAspects:aspects
       
  2818     "read the values of the aspects into my values"
       
  2819 
       
  2820     |name|
       
  2821     self isSeparator 
       
  2822     ifFalse:
       
  2823     [
       
  2824         name  := label.
       
  2825         label := (aspects at:#label) value.
       
  2826 
       
  2827         (label isNil or:[self isSeparator]) ifTrue:[
       
  2828             (aspects at:#label) value:(label := name)
       
  2829         ].
       
  2830 
       
  2831         enabled            := (aspects at:#enabled) value.
       
  2832         value              := (aspects at:#value) value.
       
  2833         nameKey            := (aspects at:#nameKey) value.
       
  2834         indication         := (aspects at:#indication) value.
       
  2835         choice             := (aspects at:#choice) value.
       
  2836         choiceValue        := (aspects at:#choiceValue) value.
       
  2837         shortcutKey        := (aspects at:#shortcutKey) value.
       
  2838         startGroup         := (aspects at:#startGroup) value.
       
  2839         accessCharacterPos := (aspects at:#accessCharacterPos) 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     argument            := anItem argument.
       
  2894 
       
  2895     submenuChannel      := anItem submenuChannel.
       
  2896     translateLabel      := anItem translateLabel.
       
  2897     isButton            := anItem isButton.
       
  2898     isVisible           := anItem isVisible.
       
  2899     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  2900     auxValue            := anItem auxValue.
       
  2901 
       
  2902     (((rtv := anItem adornment) notNil)
       
  2903     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  2904     ifTrue:
       
  2905     [
       
  2906         retriever := rtv className.
       
  2907         icon      := rtv selector.
       
  2908         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  2909             label := rtv labelText.
       
  2910         ]
       
  2911     ]
       
  2912 
       
  2913     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  2914 ! !
       
  2915 
       
  2916 !MenuEditor::Item methodsFor:'conversion'!
       
  2917 
       
  2918 asMenuItem
       
  2919     "converts self to a menu item"
       
  2920 
       
  2921     |item rcv|
       
  2922 
       
  2923     item := MenuItem labeled:label.
       
  2924     item isVisible:isVisible.
       
  2925     item hideMenuOnActivated:hideMenuOnActivated.
       
  2926 
       
  2927     self isSeparator ifFalse:[    
       
  2928         item activeHelpKey:activeHelpKey.
       
  2929         item enabled:enabled.
       
  2930         item accessCharacterPosition:accessCharacterPos.
       
  2931         item argument:argument.
       
  2932         item submenuChannel:submenuChannel.
       
  2933         item nameKey:nameKey.
       
  2934         item shortcutKeyCharacter:shortcutKey.
       
  2935         item startGroup:startGroup.
       
  2936         item value:value.
       
  2937         item indication:indication.
       
  2938         item choice:choice.
       
  2939         item choiceValue:choiceValue.
       
  2940         item translateLabel: translateLabel.
       
  2941         item isButton: isButton.
       
  2942         item auxValue: auxValue.
       
  2943 
       
  2944         icon notNil ifTrue:[
       
  2945             rcv := ResourceRetriever new.
       
  2946             rcv className:retriever.
       
  2947             rcv selector:icon.
       
  2948             iconAndLabel == true ifTrue:[
       
  2949                 rcv labelText:label
       
  2950             ].
       
  2951             item labelImage:rcv
       
  2952         ]
       
  2953     ].
       
  2954     ^item
       
  2955 
       
  2956     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  2957 !
       
  2958 
       
  2959 toAspects:aspects
       
  2960     "put my values into the values of aspects"
       
  2961 
       
  2962     |type|
       
  2963     (type := self separatorType) notNil ifTrue: [
       
  2964         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  2965         (aspects at:#seperatorSelection) selectionIndex:type.
       
  2966     ] ifFalse: [
       
  2967         (aspects at:#label)                value:label.
       
  2968         (aspects at:#enabled)              value:enabled.
       
  2969         (aspects at:#value)                value:value.
       
  2970         (aspects at:#nameKey)              value:nameKey.
       
  2971         (aspects at:#indication)           value:indication.
       
  2972         (aspects at:#choice)               value:choice.
       
  2973         (aspects at:#choiceValue)          value:choiceValue.
       
  2974         (aspects at:#shortcutKey)          value:shortcutKey.
       
  2975         (aspects at:#startGroup)           value:startGroup.
       
  2976         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  2977         (aspects at:#translateLabel)       value:translateLabel.
       
  2978         (aspects at:#submenuChannel)       value:submenuChannel.
       
  2979         (aspects at:#retriever)            value:retriever.
       
  2980         (aspects at:#icon)                 value:icon.
       
  2981         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  2982         (aspects at:#isButton)             value:isButton.
       
  2983         (aspects at:#auxValue)             value:auxValue.
       
  2984 
       
  2985         (aspects at:#argument)
       
  2986             value:(argument isSymbol
       
  2987                         ifTrue: ['#', argument] 
       
  2988                         ifFalse:[argument]).
       
  2989     ].
       
  2990     (aspects at:#isVisible) value:isVisible.
       
  2991     (aspects at:#hideMenuOnActivated) value:hideMenuOnActivated.
       
  2992 
       
  2993     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  2994 ! !
       
  2995 
       
  2996 !MenuEditor::Item methodsFor:'queries'!
       
  2997 
       
  2998 iconFor: aNode
       
  2999     "get the icon of the menu item for the tree view"
       
  3000 
       
  3001     (aNode hasChildren or: [aNode parent isNil])
       
  3002     ifTrue:
       
  3003     [
       
  3004         ^MenuEditor submenuImage
       
  3005     ]
       
  3006     ifFalse:
       
  3007     [
       
  3008         submenuChannel notNil 
       
  3009         ifTrue:
       
  3010         [
       
  3011             ^MenuEditor linkSubmenuImage
       
  3012         ]
       
  3013         ifFalse:
       
  3014         [
       
  3015             self isSeparator 
       
  3016                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3017                 ifFalse: [^MenuEditor menuItemImage]
       
  3018         ]
       
  3019     ]
       
  3020 !
       
  3021 
       
  3022 isSeparator
       
  3023     "return true if item is a seperator"
       
  3024 
       
  3025     ^self separatorType notNil
       
  3026 !
       
  3027 
       
  3028 treeViewLabel
       
  3029     "get the label of the menu item for the tree view"
       
  3030 
       
  3031     ^label
       
  3032 " asBoldText, 
       
  3033         (value notNil ifTrue: [': [', 
       
  3034                 value ,
       
  3035                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3036                  ']'] ifFalse: [''])
       
  3037 
       
  3038 
       
  3039 "
       
  3040 ! !
       
  3041 
       
  3042 !MenuEditor::TreeView class methodsFor:'documentation'!
  2674 !MenuEditor::TreeView class methodsFor:'documentation'!
  3043 
  2675 
  3044 documentation
  2676 documentation
  3045 "
  2677 "
  3046     This tree view class provides a hierarchical representation
  2678     This tree view class provides a hierarchical representation
  3502 
  3134 
  3503     (app := self topView application) modified: true.
  3135     (app := self topView application) modified: true.
  3504     app updateChannels
  3136     app updateChannels
  3505 ! !
  3137 ! !
  3506 
  3138 
       
  3139 !MenuEditor::Item class methodsFor:'constants'!
       
  3140 
       
  3141 separatorList
       
  3142     "get the list of available separator types"
       
  3143 
       
  3144     ^#('blank' 'single line' 'double line')
       
  3145 !
       
  3146 
       
  3147 separatorSlices
       
  3148     "get the list of menu spec values of the corresponding separator types"
       
  3149 
       
  3150    ^ #(
       
  3151         ( #blank        ''  )
       
  3152         ( #single       '-' )
       
  3153         ( #double       '=' )
       
  3154       )
       
  3155 ! !
       
  3156 
       
  3157 !MenuEditor::Item class methodsFor:'documentation'!
       
  3158 
       
  3159 documentation
       
  3160 "
       
  3161     implements the contents assigned to a TreeItem. An instance
       
  3162     is associated with one item and keeps all its information
       
  3163 
       
  3164     [see also:]
       
  3165         TreeItem
       
  3166         MenuEditor
       
  3167 
       
  3168     [author:]
       
  3169         Claus Atzkern
       
  3170 "
       
  3171 
       
  3172 
       
  3173 ! !
       
  3174 
       
  3175 !MenuEditor::Item methodsFor:'accessing'!
       
  3176 
       
  3177 activeHelpKey
       
  3178     "get the help key of the menu item"
       
  3179 
       
  3180     ^activeHelpKey
       
  3181 !
       
  3182 
       
  3183 activeHelpKey:aKey
       
  3184     "set the help key of the menu item"
       
  3185 
       
  3186     activeHelpKey := aKey
       
  3187 !
       
  3188 
       
  3189 label
       
  3190     "get the value of the menu item"
       
  3191 
       
  3192     ^label
       
  3193 !
       
  3194 
       
  3195 label:something
       
  3196     "set the value of the menu item"
       
  3197 
       
  3198     label := something ? '-'
       
  3199 !
       
  3200 
       
  3201 separatorType
       
  3202     "get the separator type assigned to item or nil"
       
  3203 
       
  3204     label size > 1 
       
  3205     ifFalse:
       
  3206     [
       
  3207         label size  == 0  ifTrue:[^#blank].
       
  3208         label first == $- ifTrue:[^#single].
       
  3209         label first == $= ifTrue:[^#double].
       
  3210     ].    
       
  3211     ^nil
       
  3212 
       
  3213 !
       
  3214 
       
  3215 startGroup:aSymbolOrNil
       
  3216     "set the startGroup attribute"
       
  3217 
       
  3218     startGroup := aSymbolOrNil
       
  3219 
       
  3220     "Created: / 23.8.1998 / 15:56:03 / cg"
       
  3221 !
       
  3222 
       
  3223 submenuChannel
       
  3224     "return the value of the instance variable 'submenuChannel' (automatically generated)"
       
  3225 
       
  3226     ^submenuChannel
       
  3227 !
       
  3228 
       
  3229 submenuChannel:aChannel
       
  3230     "get the submenuChannel"
       
  3231 
       
  3232     submenuChannel := aChannel
       
  3233 !
       
  3234 
       
  3235 translateLabel:aBoolean
       
  3236     "set/clear the translate to national-language flag"
       
  3237 
       
  3238     translateLabel := aBoolean
       
  3239 
       
  3240     "Created: / 6.6.1998 / 17:23:33 / cg"
       
  3241 !
       
  3242 
       
  3243 value:aSymbol
       
  3244     "set the value attribute"
       
  3245 
       
  3246     value := aSymbol
       
  3247 
       
  3248     "Created: / 23.8.1998 / 16:02:10 / cg"
       
  3249 ! !
       
  3250 
       
  3251 !MenuEditor::Item methodsFor:'building'!
       
  3252 
       
  3253 buildFromAspects:aspects
       
  3254     "read the values of the aspects into my values"
       
  3255 
       
  3256     |name|
       
  3257     self isSeparator 
       
  3258     ifFalse:
       
  3259     [
       
  3260         name  := label.
       
  3261         label := (aspects at:#label) value.
       
  3262 
       
  3263         (label isNil or:[self isSeparator]) ifTrue:[
       
  3264             (aspects at:#label) value:(label := name)
       
  3265         ].
       
  3266 
       
  3267         enabled            := (aspects at:#enabled) value.
       
  3268         value              := (aspects at:#value) value.
       
  3269         nameKey            := (aspects at:#nameKey) value.
       
  3270         indication         := (aspects at:#indication) value.
       
  3271         choice             := (aspects at:#choice) value.
       
  3272         choiceValue        := (aspects at:#choiceValue) value.
       
  3273         shortcutKey        := (aspects at:#shortcutKey) value.
       
  3274         startGroup         := (aspects at:#startGroup) value.
       
  3275         accessCharacterPos := (aspects at:#accessCharacterPos) value.
       
  3276         showBusyCursorWhilePerforming := (aspects at:#showBusyCursorWhilePerforming) value.
       
  3277         argument           := (aspects at:#argument) value.
       
  3278         translateLabel     := (aspects at:#translateLabel) value.
       
  3279         isButton           := (aspects at:#isButton) value.
       
  3280         auxValue           := (aspects at:#auxValue) value.
       
  3281 
       
  3282         argument isString ifTrue:[
       
  3283             argument size > 1 ifTrue:[
       
  3284                 (argument at:1) == $# ifTrue:[
       
  3285                     argument := (argument copyFrom:2) asSymbol
       
  3286                 ]
       
  3287             ]
       
  3288         ].
       
  3289         submenuChannel    := (aspects at:#submenuChannel) value.
       
  3290         retriever         := (aspects at:#retriever) value.
       
  3291         icon              := (aspects at:#icon) value.
       
  3292         iconAndLabel      := (aspects at:#iconAndLabel) value.
       
  3293     ]
       
  3294     ifTrue:
       
  3295     [
       
  3296         name  := (aspects at:#seperatorSelection) selectionIndex.
       
  3297         label := (self class separatorSlices at:name) last.
       
  3298     ].
       
  3299     isVisible := (aspects at:#isVisible) value.
       
  3300     hideMenuOnActivated := (aspects at:#hideMenuOnActivated) value.
       
  3301 
       
  3302     "Modified: / 14.8.1998 / 15:36:38 / cg"
       
  3303 !
       
  3304 
       
  3305 buildFromMenuItem:anItem
       
  3306     "read the attributes of anItem into my values"
       
  3307 
       
  3308     |rtv|
       
  3309 
       
  3310     self label:(anItem rawLabel).
       
  3311     activeHelpKey := anItem activeHelpKey.
       
  3312 
       
  3313     (enabled := anItem enabled) isSymbol ifFalse:[
       
  3314         enabled := nil
       
  3315     ].
       
  3316     (value := anItem value) isSymbol ifFalse:[
       
  3317         value := nil.
       
  3318     ].
       
  3319     (indication := anItem indication) isSymbol ifFalse:[
       
  3320         indication := nil
       
  3321     ].
       
  3322     (choice := anItem choice) isSymbol ifFalse:[
       
  3323         choice := nil
       
  3324     ].
       
  3325     choiceValue         := anItem choiceValue.
       
  3326     nameKey             := anItem nameKey.
       
  3327     shortcutKey         := anItem shortcutKeyCharacter.
       
  3328     startGroup          := anItem startGroup.
       
  3329     accessCharacterPos  := anItem accessCharacterPosition.
       
  3330     showBusyCursorWhilePerforming  := anItem showBusyCursorWhilePerforming.
       
  3331     argument            := anItem argument.
       
  3332 
       
  3333     submenuChannel      := anItem submenuChannel.
       
  3334     translateLabel      := anItem translateLabel.
       
  3335     isButton            := anItem isButton.
       
  3336     isVisible           := anItem isVisible.
       
  3337     hideMenuOnActivated := anItem hideMenuOnActivated.
       
  3338     auxValue            := anItem auxValue.
       
  3339 
       
  3340     (((rtv := anItem adornment) notNil)
       
  3341     and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever])
       
  3342     ifTrue:
       
  3343     [
       
  3344         retriever := rtv className.
       
  3345         icon      := rtv selector.
       
  3346         (iconAndLabel := rtv labelText notNil) ifTrue:[
       
  3347             label := rtv labelText.
       
  3348         ]
       
  3349     ]
       
  3350 
       
  3351     "Modified: / 29.9.1998 / 11:18:25 / cg"
       
  3352 ! !
       
  3353 
       
  3354 !MenuEditor::Item methodsFor:'conversion'!
       
  3355 
       
  3356 asMenuItem
       
  3357     "converts self to a menu item"
       
  3358 
       
  3359     |item rcv|
       
  3360 
       
  3361     item := MenuItem labeled:label.
       
  3362     item isVisible:isVisible.
       
  3363     item hideMenuOnActivated:hideMenuOnActivated.
       
  3364 
       
  3365     self isSeparator ifFalse:[    
       
  3366         item activeHelpKey:activeHelpKey.
       
  3367         item enabled:enabled.
       
  3368         item accessCharacterPosition:accessCharacterPos.
       
  3369         item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming.
       
  3370         item argument:argument.
       
  3371         item submenuChannel:submenuChannel.
       
  3372         item nameKey:nameKey.
       
  3373         item shortcutKeyCharacter:shortcutKey.
       
  3374         item startGroup:startGroup.
       
  3375         item value:value.
       
  3376         item indication:indication.
       
  3377         item choice:choice.
       
  3378         item choiceValue:choiceValue.
       
  3379         item translateLabel: translateLabel.
       
  3380         item isButton: isButton.
       
  3381         item auxValue: auxValue.
       
  3382 
       
  3383         icon notNil ifTrue:[
       
  3384             rcv := ResourceRetriever new.
       
  3385             rcv className:retriever.
       
  3386             rcv selector:icon.
       
  3387             iconAndLabel == true ifTrue:[
       
  3388                 rcv labelText:label
       
  3389             ].
       
  3390             item labelImage:rcv
       
  3391         ]
       
  3392     ].
       
  3393     ^item
       
  3394 
       
  3395     "Modified: / 14.8.1998 / 15:36:35 / cg"
       
  3396 !
       
  3397 
       
  3398 toAspects:aspects
       
  3399     "put my values into the values of aspects"
       
  3400 
       
  3401     |type|
       
  3402     (type := self separatorType) notNil ifTrue: [
       
  3403         type := self class separatorSlices findFirst:[:el| el first == type ].
       
  3404         (aspects at:#seperatorSelection) selectionIndex:type.
       
  3405     ] ifFalse: [
       
  3406         (aspects at:#label)                value:label.
       
  3407         (aspects at:#enabled)              value:enabled.
       
  3408         (aspects at:#value)                value:value.
       
  3409         (aspects at:#nameKey)              value:nameKey.
       
  3410         (aspects at:#indication)           value:indication.
       
  3411         (aspects at:#choice)               value:choice.
       
  3412         (aspects at:#choiceValue)          value:choiceValue.
       
  3413         (aspects at:#shortcutKey)          value:shortcutKey.
       
  3414         (aspects at:#startGroup)           value:startGroup.
       
  3415         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
       
  3416         (aspects at:#showBusyCursorWhilePerforming)   value:showBusyCursorWhilePerforming.
       
  3417         (aspects at:#translateLabel)       value:translateLabel.
       
  3418         (aspects at:#submenuChannel)       value:submenuChannel.
       
  3419         (aspects at:#retriever)            value:retriever.
       
  3420         (aspects at:#icon)                 value:icon.
       
  3421         (aspects at:#iconAndLabel)         value:iconAndLabel.
       
  3422         (aspects at:#isButton)             value:isButton.
       
  3423         (aspects at:#auxValue)             value:auxValue.
       
  3424 
       
  3425         (aspects at:#argument)
       
  3426             value:(argument isSymbol
       
  3427                         ifTrue: ['#', argument] 
       
  3428                         ifFalse:[argument]).
       
  3429     ].
       
  3430     (aspects at:#isVisible) value:isVisible.
       
  3431     (aspects at:#hideMenuOnActivated) value:hideMenuOnActivated.
       
  3432 
       
  3433     "Modified: / 14.8.1998 / 15:37:29 / cg"
       
  3434 ! !
       
  3435 
       
  3436 !MenuEditor::Item methodsFor:'queries'!
       
  3437 
       
  3438 iconFor: aNode
       
  3439     "get the icon of the menu item for the tree view"
       
  3440 
       
  3441     (aNode hasChildren or: [aNode parent isNil])
       
  3442     ifTrue:
       
  3443     [
       
  3444         ^MenuEditor submenuImage
       
  3445     ]
       
  3446     ifFalse:
       
  3447     [
       
  3448         submenuChannel notNil 
       
  3449         ifTrue:
       
  3450         [
       
  3451             ^MenuEditor linkSubmenuImage
       
  3452         ]
       
  3453         ifFalse:
       
  3454         [
       
  3455             self isSeparator 
       
  3456                 ifTrue:  [^MenuEditor menuSeparatorImage]
       
  3457                 ifFalse: [^MenuEditor menuItemImage]
       
  3458         ]
       
  3459     ]
       
  3460 !
       
  3461 
       
  3462 isSeparator
       
  3463     "return true if item is a seperator"
       
  3464 
       
  3465     ^self separatorType notNil
       
  3466 !
       
  3467 
       
  3468 treeViewLabel
       
  3469     "get the label of the menu item for the tree view"
       
  3470 
       
  3471     ^label
       
  3472 " asBoldText, 
       
  3473         (value notNil ifTrue: [': [', 
       
  3474                 value ,
       
  3475                 (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']),
       
  3476                  ']'] ifFalse: [''])
       
  3477 
       
  3478 
       
  3479 "
       
  3480 ! !
       
  3481 
  3507 !MenuEditor class methodsFor:'documentation'!
  3482 !MenuEditor class methodsFor:'documentation'!
  3508 
  3483 
  3509 version
  3484 version
  3510     ^ '$Header$'
  3485     ^ '$Header$'
  3511 ! !
  3486 ! !