MenuEditor.st
changeset 953 1aecad8bf33a
parent 943 b9ba76358fbd
child 955 f4f7d2ebd3ce
equal deleted inserted replaced
952:c6408190dc6d 953:1aecad8bf33a
    20 !
    20 !
    21 
    21 
    22 Object subclass:#Item
    22 Object subclass:#Item
    23 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    23 	instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey
    24 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    24 		accessCharacterPos retriever icon iconAndLabel submenuChannel
    25 		startGroup argument translateLabel isButton isVisible'
    25 		startGroup argument translateLabel isButton isVisible choice
       
    26 		choiceValue'
    26 	classVariableNames:''
    27 	classVariableNames:''
    27 	poolDictionaries:''
    28 	poolDictionaries:''
    28 	privateIn:MenuEditor
    29 	privateIn:MenuEditor
    29 !
    30 !
    30 
    31 
   117         submenuChannel
   118         submenuChannel
   118         enabled
   119         enabled
   119         value
   120         value
   120         nameKey
   121         nameKey
   121         indication
   122         indication
       
   123         choice
       
   124         choiceValue
   122         translateLabel
   125         translateLabel
   123         isButton
   126         isButton
   124         shortcutKey
   127         shortcutKey
   125         startGroup
   128         startGroup
   126         retriever
   129         retriever
   127         iconAndLabel
   130         iconAndLabel
   128         icon
   131         icon
   129         isVisible
   132         isVisible
   130      )
   133      )
   131 
   134 
       
   135     "Modified: / 14.8.1998 / 14:46:36 / cg"
   132 ! !
   136 ! !
   133 
   137 
   134 !MenuEditor class methodsFor:'help specs'!
   138 !MenuEditor class methodsFor:'help specs'!
   135 
   139 
   136 helpSpec
   140 helpSpec
   332      
   336      
   333        #(#FullSpec
   337        #(#FullSpec
   334           #window: 
   338           #window: 
   335            #(#WindowSpec
   339            #(#WindowSpec
   336               #name: 'Basics Item'
   340               #name: 'Basics Item'
   337               #layout: #(#LayoutFrame 473 0 301 0 739 0 619 0)
   341               #layout: #(#LayoutFrame 216 0 173 0 482 0 491 0)
   338               #label: 'Basics Item'
   342               #label: 'Basics Item'
   339               #min: #(#Point 10 10)
   343               #min: #(#Point 10 10)
   340               #max: #(#Point 1160 870)
   344               #max: #(#Point 1160 870)
   341               #bounds: #(#Rectangle 473 301 740 620)
   345               #bounds: #(#Rectangle 216 173 483 492)
   342               #usePreferredExtent: false
   346               #usePreferredExtent: false
   343           )
   347           )
   344           #component: 
   348           #component: 
   345            #(#SpecCollection
   349            #(#SpecCollection
   346               #collection: 
   350               #collection: 
   355                  #(#InputFieldSpec
   359                  #(#InputFieldSpec
   356                     #name: 'nameKeyField'
   360                     #name: 'nameKeyField'
   357                     #layout: #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
   361                     #layout: #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
   358                     #tabable: true
   362                     #tabable: true
   359                     #model: #nameKey
   363                     #model: #nameKey
       
   364                     #group: #inputGroup
   360                     #type: #symbolOrNil
   365                     #type: #symbolOrNil
   361                     #acceptOnReturn: false
   366                     #acceptOnReturn: false
   362                     #acceptOnTab: false
   367                     #acceptOnTab: false
   363                     #group: #inputGroup
       
   364                 )
   368                 )
   365                  #(#LabelSpec
   369                  #(#LabelSpec
   366                     #name: 'labelLabel'
   370                     #name: 'labelLabel'
   367                     #layout: #(#AlignmentOrigin 107 0 51 0 1 0.5)
   371                     #layout: #(#AlignmentOrigin 107 0 51 0 1 0.5)
   368                     #label: 'Label:'
   372                     #label: 'Label:'
   373                     #name: 'labelField'
   377                     #name: 'labelField'
   374                     #layout: #(#LayoutFrame 110 0 40 0 -5 1.0 62 0)
   378                     #layout: #(#LayoutFrame 110 0 40 0 -5 1.0 62 0)
   375                     #activeHelpKey: #basicsLabel
   379                     #activeHelpKey: #basicsLabel
   376                     #tabable: true
   380                     #tabable: true
   377                     #model: #label
   381                     #model: #label
       
   382                     #group: #inputGroup
   378                     #acceptOnReturn: false
   383                     #acceptOnReturn: false
   379                     #acceptOnTab: false
   384                     #acceptOnTab: false
   380                     #group: #inputGroup
       
   381                 )
   385                 )
   382                  #(#LabelSpec
   386                  #(#LabelSpec
   383                     #name: 'valueLabel'
   387                     #name: 'valueLabel'
   384                     #layout: #(#AlignmentOrigin 107 0 90 0 1 0.5)
   388                     #layout: #(#AlignmentOrigin 107 0 90 0 1 0.5)
   385                     #label: 'Action:'
   389                     #label: 'Action:'
   390                     #name: 'valueField'
   394                     #name: 'valueField'
   391                     #layout: #(#LayoutFrame 110 0 79 0 -5 1.0 101 0)
   395                     #layout: #(#LayoutFrame 110 0 79 0 -5 1.0 101 0)
   392                     #activeHelpKey: #basicsAction
   396                     #activeHelpKey: #basicsAction
   393                     #tabable: true
   397                     #tabable: true
   394                     #model: #value
   398                     #model: #value
       
   399                     #group: #inputGroup
   395                     #type: #symbolOrNil
   400                     #type: #symbolOrNil
   396                     #acceptOnReturn: false
   401                     #acceptOnReturn: false
   397                     #acceptOnTab: false
   402                     #acceptOnTab: false
   398                     #group: #inputGroup
       
   399                 )
   403                 )
   400                  #(#LabelSpec
   404                  #(#LabelSpec
   401                     #name: 'argumentLabel'
   405                     #name: 'argumentLabel'
   402                     #layout: #(#AlignmentOrigin 107 0 115 0 1 0.5)
   406                     #layout: #(#AlignmentOrigin 107 0 115 0 1 0.5)
   403                     #label: 'Argument:'
   407                     #label: 'Argument:'
   408                     #name: 'argumentField'
   412                     #name: 'argumentField'
   409                     #layout: #(#LayoutFrame 110 0 104 0 -5 1.0 126 0)
   413                     #layout: #(#LayoutFrame 110 0 104 0 -5 1.0 126 0)
   410                     #activeHelpKey: #basicsArgument
   414                     #activeHelpKey: #basicsArgument
   411                     #tabable: true
   415                     #tabable: true
   412                     #model: #argument
   416                     #model: #argument
       
   417                     #group: #inputGroup
   413                     #type: #string
   418                     #type: #string
   414                     #acceptOnReturn: false
   419                     #acceptOnReturn: false
   415                     #acceptOnTab: false
   420                     #acceptOnTab: false
   416                     #group: #inputGroup
       
   417                 )
   421                 )
   418                  #(#LabelSpec
   422                  #(#LabelSpec
   419                     #name: 'indicationLabel'
   423                     #name: 'indicationLabel'
   420                     #layout: #(#AlignmentOrigin 107 0 155 0 1 0.5)
   424                     #layout: #(#AlignmentOrigin 107 0 155 0 1 0.5)
   421                     #label: 'Indication:'
   425                     #label: 'Indication:'
   424                 )
   428                 )
   425                  #(#InputFieldSpec
   429                  #(#InputFieldSpec
   426                     #name: 'indicationField'
   430                     #name: 'indicationField'
   427                     #layout: #(#LayoutFrame 110 0 144 0 -5 1.0 166 0)
   431                     #layout: #(#LayoutFrame 110 0 144 0 -5 1.0 166 0)
   428                     #activeHelpKey: #basicsIndication
   432                     #activeHelpKey: #basicsIndication
       
   433                     #enableChannel: #indicationEnabled
   429                     #tabable: true
   434                     #tabable: true
   430                     #model: #indication
   435                     #model: #indication
       
   436                     #group: #inputGroup
   431                     #type: #symbolOrNil
   437                     #type: #symbolOrNil
   432                     #acceptOnReturn: false
   438                     #acceptOnReturn: false
   433                     #acceptOnTab: false
   439                     #acceptOnTab: false
   434                     #group: #inputGroup
       
   435                 )
   440                 )
   436                  #(#CheckBoxSpec
   441                  #(#CheckBoxSpec
   437                     #name: 'translateLabelCheckBox'
   442                     #name: 'translateLabelCheckBox'
   438                     #layout: #(#Point 20 190)
   443                     #layout: #(#Point 20 230)
   439                     #activeHelpKey: #basicsTranslateLabel
   444                     #activeHelpKey: #basicsTranslateLabel
   440                     #tabable: true
   445                     #tabable: true
   441                     #model: #translateLabel
   446                     #model: #translateLabel
   442                     #label: 'Translate Label'
   447                     #label: 'Translate Label'
   443                 )
   448                 )
   444                  #(#CheckBoxSpec
   449                  #(#CheckBoxSpec
   445                     #name: 'isButtonCheckBox'
   450                     #name: 'isButtonCheckBox'
   446                     #layout: #(#Point 20 219)
   451                     #layout: #(#Point 20 259)
   447                     #activeHelpKey: #basicsIsButton
   452                     #activeHelpKey: #basicsIsButton
   448                     #tabable: true
   453                     #tabable: true
   449                     #model: #isButton
   454                     #model: #isButton
   450                     #label: 'Is Button'
   455                     #label: 'Is Button'
   451                 )
   456                 )
       
   457                  #(#LabelSpec
       
   458                     #name: 'choiceLabel'
       
   459                     #layout: #(#AlignmentOrigin 107 0 180 0 1 0.5)
       
   460                     #label: 'Choice:'
       
   461                     #translateLabel: true
       
   462                     #adjust: #right
       
   463                     #resizeForLabel: true
       
   464                 )
       
   465                  #(#InputFieldSpec
       
   466                     #name: 'choiceField'
       
   467                     #layout: #(#LayoutFrame 110 0 169 0 -5 1.0 191 0)
       
   468                     #activeHelpKey: #basicsIndication
       
   469                     #enableChannel: #choiceEnabled
       
   470                     #tabable: true
       
   471                     #model: #choice
       
   472                     #group: #inputGroup
       
   473                     #type: #symbolOrNil
       
   474                     #acceptOnReturn: false
       
   475                     #acceptOnTab: false
       
   476                 )
       
   477                  #(#LabelSpec
       
   478                     #name: 'choiceValueLabel'
       
   479                     #layout: #(#AlignmentOrigin 107 0 205 0 1 0.5)
       
   480                     #label: 'Value:'
       
   481                     #translateLabel: true
       
   482                     #adjust: #right
       
   483                     #resizeForLabel: true
       
   484                 )
       
   485                  #(#InputFieldSpec
       
   486                     #name: 'choiceValueField'
       
   487                     #layout: #(#LayoutFrame 110 0 194 0 -5 1.0 216 0)
       
   488                     #activeHelpKey: #basicsIndication
       
   489                     #enableChannel: #choiceValueEnabled
       
   490                     #tabable: true
       
   491                     #model: #choiceValue
       
   492                     #group: #inputGroup
       
   493                     #type: #smalltalkObject
       
   494                     #acceptOnReturn: true
       
   495                     #acceptOnTab: true
       
   496                     #acceptOnLeave: true
       
   497                     #acceptOnLostFocus: true
       
   498                     #immediateAccept: false
       
   499                 )
   452               )
   500               )
   453           )
   501           )
   454       )
   502       )
   455 
   503 
   456     "Modified: / 31.7.1998 / 01:18:03 / cg"
   504     "Modified: / 14.8.1998 / 15:43:35 / cg"
   457 !
   505 !
   458 
   506 
   459 basicsLinkSpec
   507 basicsLinkSpec
   460     "This resource specification was automatically generated
   508     "This resource specification was automatically generated
   461      by the UIPainter of ST/X."
   509      by the UIPainter of ST/X."
  1985 
  2033 
  1986     |node item slc sel old|
  2034     |node item slc sel old|
  1987 
  2035 
  1988     aspects do: [:holder| holder removeDependent:self].
  2036     aspects do: [:holder| holder removeDependent:self].
  1989     (node := self treeView selectedNode) notNil ifTrue:[
  2037     (node := self treeView selectedNode) notNil ifTrue:[
  1990         aspects do:[:anAspect| anAspect value:nil ].
  2038         aspects do:[:anAspect| 
       
  2039                         anAspect isBlock ifFalse:[anAspect value:nil]
       
  2040                    ].
  1991         item := node contents.
  2041         item := node contents.
  1992         item toAspects:aspects.
  2042         item toAspects:aspects.
  1993 
  2043 
  1994         item isSeparator ifFalse:[
  2044         item isSeparator ifFalse:[
  1995             node parent isNil ifFalse:[
  2045             node parent isNil ifFalse:[
  2032             self tabSelection:0.
  2082             self tabSelection:0.
  2033         ]
  2083         ]
  2034     ].
  2084     ].
  2035     self updateChannels.
  2085     self updateChannels.
  2036     aspects do: [:holder| holder addDependent:self].
  2086     aspects do: [:holder| holder addDependent:self].
       
  2087 
       
  2088     "Modified: / 14.8.1998 / 14:52:32 / cg"
  2037 !
  2089 !
  2038 
  2090 
  2039 tabSelection: aSelection
  2091 tabSelection: aSelection
  2040     "put the section aSelection into the note book"
  2092     "put the section aSelection into the note book"
  2041 
  2093 
  2056 
  2108 
  2057     self isHelpToolSelected ifTrue:[  
  2109     self isHelpToolSelected ifTrue:[  
  2058         self helpTool helpKey:(self helpKey).
  2110         self helpTool helpKey:(self helpKey).
  2059         helpCanvas raise.
  2111         helpCanvas raise.
  2060     ] ifFalse:[       
  2112     ] ifFalse:[       
  2061         aspects do: [:holder| holder release].
  2113         aspects do: [:holder| holder removeDependent:self].
  2062         specCanvas client:self spec:(self class perform:(slices at:tabSelection) last) builder:builder.
  2114         specCanvas client:self spec:(self class perform:(slices at:tabSelection) last) builder:builder.
  2063         aspects do: [:holder| holder addDependent:self].
  2115         aspects do: [:holder| holder addDependent:self].
  2064         self updateFonts.
  2116         self updateFonts.
  2065         specCanvas raise.
  2117         specCanvas raise.
  2066     ]
  2118     ]
       
  2119 
       
  2120     "Modified: / 14.8.1998 / 15:07:06 / cg"
  2067 ! !
  2121 ! !
  2068 
  2122 
  2069 !MenuEditor methodsFor:'startup / release'!
  2123 !MenuEditor methodsFor:'startup / release'!
  2070 
  2124 
  2071 initialize
  2125 initialize
  2077 
  2131 
  2078     aspects at:#seperatorSelection put:(holder := SelectionInList new).
  2132     aspects at:#seperatorSelection put:(holder := SelectionInList new).
  2079     holder list: Item separatorList.
  2133     holder list: Item separatorList.
  2080     holder addDependent:self.
  2134     holder addDependent:self.
  2081 
  2135 
  2082     "Modified: / 20.6.1998 / 14:53:26 / cg"
  2136     aspects at:#indicationEnabled  put:(BlockValue 
       
  2137                                             with:[:a | a size == 0]
       
  2138                                             argument:(aspects at:#choice)).
       
  2139     aspects at:#choiceEnabled      put:(BlockValue
       
  2140                                             with:[:a | a size == 0]
       
  2141                                             argument:(aspects at:#indication)).
       
  2142     aspects at:#choiceValueEnabled put:(BlockValue
       
  2143                                             with:[:a | a size > 0]
       
  2144                                             argument:(aspects at:#choice)).
       
  2145 
       
  2146     "Modified: / 14.8.1998 / 15:07:58 / cg"
  2083 !
  2147 !
  2084 
  2148 
  2085 openModalOnMenu: aMenu
  2149 openModalOnMenu: aMenu
  2086     "build a tree from aMenu and open it modal"
  2150     "build a tree from aMenu and open it modal"
  2087 
  2151 
  2396 
  2460 
  2397         enabled            := (aspects at:#enabled) value.
  2461         enabled            := (aspects at:#enabled) value.
  2398         value              := (aspects at:#value) value.
  2462         value              := (aspects at:#value) value.
  2399         nameKey            := (aspects at:#nameKey) value.
  2463         nameKey            := (aspects at:#nameKey) value.
  2400         indication         := (aspects at:#indication) value.
  2464         indication         := (aspects at:#indication) value.
       
  2465         choice             := (aspects at:#choice) value.
       
  2466         choiceValue        := (aspects at:#choiceValue) value.
  2401         shortcutKey        := (aspects at:#shortcutKey) value.
  2467         shortcutKey        := (aspects at:#shortcutKey) value.
  2402         startGroup         := (aspects at:#startGroup) value.
  2468         startGroup         := (aspects at:#startGroup) value.
  2403         accessCharacterPos := (aspects at:#accessCharacterPos) value.
  2469         accessCharacterPos := (aspects at:#accessCharacterPos) value.
  2404         argument           := (aspects at:#argument) value.
  2470         argument           := (aspects at:#argument) value.
  2405         translateLabel     := (aspects at:#translateLabel) value.
  2471         translateLabel     := (aspects at:#translateLabel) value.
  2422         name  := (aspects at:#seperatorSelection) selectionIndex.
  2488         name  := (aspects at:#seperatorSelection) selectionIndex.
  2423         label := (self class separatorSlices at:name) last.
  2489         label := (self class separatorSlices at:name) last.
  2424     ].
  2490     ].
  2425     isVisible := (aspects at:#isVisible) value.
  2491     isVisible := (aspects at:#isVisible) value.
  2426 
  2492 
  2427     "Modified: / 6.6.1998 / 17:20:59 / cg"
  2493     "Modified: / 14.8.1998 / 15:36:38 / cg"
  2428 !
  2494 !
  2429 
  2495 
  2430 buildFromMenuItem:anItem
  2496 buildFromMenuItem:anItem
  2431     "read the attributes of anItem into my values"
  2497     "read the attributes of anItem into my values"
  2432 
  2498 
  2436     activeHelpKey := anItem activeHelpKey.
  2502     activeHelpKey := anItem activeHelpKey.
  2437 
  2503 
  2438     (enabled := anItem enabled) isSymbol ifFalse:[
  2504     (enabled := anItem enabled) isSymbol ifFalse:[
  2439         enabled := nil
  2505         enabled := nil
  2440     ].
  2506     ].
  2441 
       
  2442     (value := anItem value) isSymbol ifFalse:[
  2507     (value := anItem value) isSymbol ifFalse:[
  2443         value := nil.
  2508         value := nil.
  2444     ].
  2509     ].
  2445 
       
  2446     (indication := anItem indication) isSymbol ifFalse:[
  2510     (indication := anItem indication) isSymbol ifFalse:[
  2447         indication := nil
  2511         indication := nil
  2448     ].
  2512     ].
       
  2513     (choice := anItem choice) isSymbol ifFalse:[
       
  2514         choice := nil
       
  2515     ].
       
  2516     choiceValue := anItem choiceValue.
  2449 
  2517 
  2450     nameKey            := anItem nameKey.
  2518     nameKey            := anItem nameKey.
  2451     shortcutKey        := anItem shortcutKeyCharacter.
  2519     shortcutKey        := anItem shortcutKeyCharacter.
  2452     startGroup         := anItem startGroup.
  2520     startGroup         := anItem startGroup.
  2453     accessCharacterPos := anItem accessCharacterPosition.
  2521     accessCharacterPos := anItem accessCharacterPosition.
  2466         icon      := rtv selector.
  2534         icon      := rtv selector.
  2467         (iconAndLabel := rtv labelText notNil) ifTrue:[
  2535         (iconAndLabel := rtv labelText notNil) ifTrue:[
  2468             label := rtv labelText.
  2536             label := rtv labelText.
  2469         ]
  2537         ]
  2470     ]
  2538     ]
       
  2539 
       
  2540     "Modified: / 14.8.1998 / 15:37:20 / cg"
  2471 ! !
  2541 ! !
  2472 
  2542 
  2473 !MenuEditor::Item methodsFor:'conversion'!
  2543 !MenuEditor::Item methodsFor:'conversion'!
  2474 
  2544 
  2475 asMenuItem
  2545 asMenuItem
  2489         item nameKey:nameKey.
  2559         item nameKey:nameKey.
  2490         item shortcutKeyCharacter:shortcutKey.
  2560         item shortcutKeyCharacter:shortcutKey.
  2491         item startGroup:startGroup.
  2561         item startGroup:startGroup.
  2492         item value:value.
  2562         item value:value.
  2493         item indication:indication.
  2563         item indication:indication.
       
  2564         item choice:choice.
       
  2565         item choiceValue:choiceValue.
  2494         item translateLabel: translateLabel.
  2566         item translateLabel: translateLabel.
  2495         item isButton: isButton.
  2567         item isButton: isButton.
  2496 
  2568 
  2497         icon notNil ifTrue:[
  2569         icon notNil ifTrue:[
  2498             rcv := ResourceRetriever new.
  2570             rcv := ResourceRetriever new.
  2503             ].
  2575             ].
  2504             item labelImage:rcv
  2576             item labelImage:rcv
  2505         ]
  2577         ]
  2506     ].
  2578     ].
  2507     ^item
  2579     ^item
       
  2580 
       
  2581     "Modified: / 14.8.1998 / 15:36:35 / cg"
  2508 !
  2582 !
  2509 
  2583 
  2510 toAspects:aspects
  2584 toAspects:aspects
  2511     "put my values into the values of aspects"
  2585     "put my values into the values of aspects"
  2512 
  2586 
  2522         (aspects at:#label)                value:label.
  2596         (aspects at:#label)                value:label.
  2523         (aspects at:#enabled)              value:enabled.
  2597         (aspects at:#enabled)              value:enabled.
  2524         (aspects at:#value)                value:value.
  2598         (aspects at:#value)                value:value.
  2525         (aspects at:#nameKey)              value:nameKey.
  2599         (aspects at:#nameKey)              value:nameKey.
  2526         (aspects at:#indication)           value:indication.
  2600         (aspects at:#indication)           value:indication.
       
  2601         (aspects at:#choice)               value:choice.
       
  2602         (aspects at:#choiceValue)          value:choiceValue.
  2527         (aspects at:#shortcutKey)          value:shortcutKey.
  2603         (aspects at:#shortcutKey)          value:shortcutKey.
  2528         (aspects at:#startGroup)           value:startGroup.
  2604         (aspects at:#startGroup)           value:startGroup.
  2529         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
  2605         (aspects at:#accessCharacterPos)   value:accessCharacterPos.
  2530         (aspects at:#translateLabel)       value:translateLabel.
  2606         (aspects at:#translateLabel)       value:translateLabel.
  2531         (aspects at:#submenuChannel)       value:submenuChannel.
  2607         (aspects at:#submenuChannel)       value:submenuChannel.
  2538             ifTrue: [(aspects at:#argument)value:'#', argument] 
  2614             ifTrue: [(aspects at:#argument)value:'#', argument] 
  2539             ifFalse:[(aspects at:#argument)value:argument].
  2615             ifFalse:[(aspects at:#argument)value:argument].
  2540     ].
  2616     ].
  2541     (aspects at:#isVisible) value:isVisible.
  2617     (aspects at:#isVisible) value:isVisible.
  2542 
  2618 
       
  2619     "Modified: / 14.8.1998 / 15:37:29 / cg"
  2543 ! !
  2620 ! !
  2544 
  2621 
  2545 !MenuEditor::Item methodsFor:'queries'!
  2622 !MenuEditor::Item methodsFor:'queries'!
  2546 
  2623 
  2547 iconFor: aNode
  2624 iconFor: aNode