# HG changeset patch # User ca # Date 938702857 -7200 # Node ID c5425b3c8f3e83ab46c58cfa4c8666ebf167df0d # Parent fd0127c25b66f4918b6a1694259fe265177d10c6 checkin from browser diff -r fd0127c25b66 -r c5425b3c8f3e MenuEditor.st --- a/MenuEditor.st Mon Sep 27 14:42:24 1999 +0200 +++ b/MenuEditor.st Thu Sep 30 16:47:37 1999 +0200 @@ -20,6 +20,13 @@ category:'Interface-UIPainter' ! +SelectionInTreeView subclass:#TreeView + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + privateIn:MenuEditor +! + Object subclass:#Item instanceVariableNames:'activeHelpKey enabled label value nameKey indication shortcutKey accessCharacterPos retriever icon iconAndLabel submenuChannel @@ -30,13 +37,6 @@ privateIn:MenuEditor ! -SelectionInTreeView subclass:#TreeView - instanceVariableNames:'' - classVariableNames:'' - poolDictionaries:'' - privateIn:MenuEditor -! - !MenuEditor class methodsFor:'documentation'! copyright @@ -2296,8 +2296,10 @@ index := index max:1. ]. self tabModel value:index. + aspects do:[:a| a removeDependent:self]. + self cancel. self updateChannels. - self cancel. + aspects do:[:a| a addDependent:self]. ! @@ -2588,342 +2590,6 @@ modified := true. ! ! -!MenuEditor::Item class methodsFor:'constants'! - -separatorList - "get the list of available separator types" - - ^#('blank' 'single line' 'double line') -! - -separatorSlices - "get the list of menu spec values of the corresponding separator types" - - ^ #( - ( #blank '' ) - ( #single '-' ) - ( #double '=' ) - ) -! ! - -!MenuEditor::Item class methodsFor:'documentation'! - -documentation -" - implements the contents assigned to a TreeItem. An instance - is associated with one item and keeps all its information - - [see also:] - TreeItem - MenuEditor - - [author:] - Claus Atzkern -" - - -! ! - -!MenuEditor::Item methodsFor:'accessing'! - -activeHelpKey - "get the help key of the menu item" - - ^activeHelpKey -! - -activeHelpKey:aKey - "set the help key of the menu item" - - activeHelpKey := aKey -! - -label - "get the value of the menu item" - - ^label -! - -label:something - "set the value of the menu item" - - label := something ? '-' -! - -separatorType - "get the separator type assigned to item or nil" - - label size > 1 - ifFalse: - [ - label size == 0 ifTrue:[^#blank]. - label first == $- ifTrue:[^#single]. - label first == $= ifTrue:[^#double]. - ]. - ^nil - -! - -startGroup:aSymbolOrNil - "set the startGroup attribute" - - startGroup := aSymbolOrNil - - "Created: / 23.8.1998 / 15:56:03 / cg" -! - -submenuChannel - "return the value of the instance variable 'submenuChannel' (automatically generated)" - - ^submenuChannel -! - -submenuChannel:aChannel - "get the submenuChannel" - - submenuChannel := aChannel -! - -translateLabel:aBoolean - "set/clear the translate to national-language flag" - - translateLabel := aBoolean - - "Created: / 6.6.1998 / 17:23:33 / cg" -! - -value:aSymbol - "set the value attribute" - - value := aSymbol - - "Created: / 23.8.1998 / 16:02:10 / cg" -! ! - -!MenuEditor::Item methodsFor:'building'! - -buildFromAspects:aspects - "read the values of the aspects into my values" - - |name| - self isSeparator - ifFalse: - [ - name := label. - label := (aspects at:#label) value. - - (label isNil or:[self isSeparator]) ifTrue:[ - (aspects at:#label) value:(label := name) - ]. - - enabled := (aspects at:#enabled) value. - value := (aspects at:#value) value. - nameKey := (aspects at:#nameKey) value. - indication := (aspects at:#indication) value. - choice := (aspects at:#choice) value. - choiceValue := (aspects at:#choiceValue) value. - shortcutKey := (aspects at:#shortcutKey) value. - startGroup := (aspects at:#startGroup) value. - accessCharacterPos := (aspects at:#accessCharacterPos) value. - argument := (aspects at:#argument) value. - translateLabel := (aspects at:#translateLabel) value. - isButton := (aspects at:#isButton) value. - auxValue := (aspects at:#auxValue) value. - - argument isString ifTrue:[ - argument size > 1 ifTrue:[ - (argument at:1) == $# ifTrue:[ - argument := (argument copyFrom:2) asSymbol - ] - ] - ]. - submenuChannel := (aspects at:#submenuChannel) value. - retriever := (aspects at:#retriever) value. - icon := (aspects at:#icon) value. - iconAndLabel := (aspects at:#iconAndLabel) value. - ] - ifTrue: - [ - name := (aspects at:#seperatorSelection) selectionIndex. - label := (self class separatorSlices at:name) last. - ]. - isVisible := (aspects at:#isVisible) value. - - "Modified: / 14.8.1998 / 15:36:38 / cg" -! - -buildFromMenuItem:anItem - "read the attributes of anItem into my values" - - |rtv| - - self label:(anItem rawLabel). - activeHelpKey := anItem activeHelpKey. - - (enabled := anItem enabled) isSymbol ifFalse:[ - enabled := nil - ]. - (value := anItem value) isSymbol ifFalse:[ - value := nil. - ]. - (indication := anItem indication) isSymbol ifFalse:[ - indication := nil - ]. - (choice := anItem choice) isSymbol ifFalse:[ - choice := nil - ]. - choiceValue := anItem choiceValue. - - nameKey := anItem nameKey. - shortcutKey := anItem shortcutKeyCharacter. - startGroup := anItem startGroup. - accessCharacterPos := anItem accessCharacterPosition. - argument := anItem argument. - - submenuChannel := anItem submenuChannel. - translateLabel := anItem translateLabel. - isButton := anItem isButton. - isVisible := anItem isVisible. - auxValue := anItem auxValue. - - (((rtv := anItem adornment) notNil) - and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever]) - ifTrue: - [ - retriever := rtv className. - icon := rtv selector. - (iconAndLabel := rtv labelText notNil) ifTrue:[ - label := rtv labelText. - ] - ] - - "Modified: / 29.9.1998 / 11:18:25 / cg" -! ! - -!MenuEditor::Item methodsFor:'conversion'! - -asMenuItem - "converts self to a menu item" - - |item rcv| - - item := MenuItem labeled:label. - item isVisible:isVisible. - - self isSeparator ifFalse:[ - item activeHelpKey:activeHelpKey. - item enabled:enabled. - item accessCharacterPosition:accessCharacterPos. - item argument:argument. - item submenuChannel:submenuChannel. - item nameKey:nameKey. - item shortcutKeyCharacter:shortcutKey. - item startGroup:startGroup. - item value:value. - item indication:indication. - item choice:choice. - item choiceValue:choiceValue. - item translateLabel: translateLabel. - item isButton: isButton. - item auxValue: auxValue. - - icon notNil ifTrue:[ - rcv := ResourceRetriever new. - rcv className:retriever. - rcv selector:icon. - iconAndLabel == true ifTrue:[ - rcv labelText:label - ]. - item labelImage:rcv - ] - ]. - ^item - - "Modified: / 14.8.1998 / 15:36:35 / cg" -! - -toAspects:aspects - "put my values into the values of aspects" - - |type| - (type := self separatorType) notNil ifTrue: [ - type := self class separatorSlices findFirst:[:el| el first == type ]. - (aspects at:#seperatorSelection) selectionIndex:type. - ] ifFalse: [ - (aspects at:#label) value:label. - (aspects at:#enabled) value:enabled. - (aspects at:#value) value:value. - (aspects at:#nameKey) value:nameKey. - (aspects at:#indication) value:indication. - (aspects at:#choice) value:choice. - (aspects at:#choiceValue) value:choiceValue. - (aspects at:#shortcutKey) value:shortcutKey. - (aspects at:#startGroup) value:startGroup. - (aspects at:#accessCharacterPos) value:accessCharacterPos. - (aspects at:#translateLabel) value:translateLabel. - (aspects at:#submenuChannel) value:submenuChannel. - (aspects at:#retriever) value:retriever. - (aspects at:#icon) value:icon. - (aspects at:#iconAndLabel) value:iconAndLabel. - (aspects at:#isButton) value:isButton. - (aspects at:#auxValue) value:auxValue. - - (aspects at:#argument) - value:(argument isSymbol - ifTrue: ['#', argument] - ifFalse:[argument]). - ]. - (aspects at:#isVisible) value:isVisible. - - "Modified: / 14.8.1998 / 15:37:29 / cg" -! ! - -!MenuEditor::Item methodsFor:'queries'! - -iconFor: aNode - "get the icon of the menu item for the tree view" - - (aNode hasChildren or: [aNode parent isNil]) - ifTrue: - [ - ^MenuEditor submenuImage - ] - ifFalse: - [ - submenuChannel notNil - ifTrue: - [ - ^MenuEditor linkSubmenuImage - ] - ifFalse: - [ - self isSeparator - ifTrue: [^MenuEditor menuSeparatorImage] - ifFalse: [^MenuEditor menuItemImage] - ] - ] -! - -isSeparator - "return true if item is a seperator" - - ^self separatorType notNil -! - -treeViewLabel - "get the label of the menu item for the tree view" - - ^label -" asBoldText, - (value notNil ifTrue: [': [', - value , - (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']), - ']'] ifFalse: ['']) - - -" -! ! - !MenuEditor::TreeView class methodsFor:'documentation'! documentation @@ -3385,6 +3051,342 @@ app updateChannels ! ! +!MenuEditor::Item class methodsFor:'constants'! + +separatorList + "get the list of available separator types" + + ^#('blank' 'single line' 'double line') +! + +separatorSlices + "get the list of menu spec values of the corresponding separator types" + + ^ #( + ( #blank '' ) + ( #single '-' ) + ( #double '=' ) + ) +! ! + +!MenuEditor::Item class methodsFor:'documentation'! + +documentation +" + implements the contents assigned to a TreeItem. An instance + is associated with one item and keeps all its information + + [see also:] + TreeItem + MenuEditor + + [author:] + Claus Atzkern +" + + +! ! + +!MenuEditor::Item methodsFor:'accessing'! + +activeHelpKey + "get the help key of the menu item" + + ^activeHelpKey +! + +activeHelpKey:aKey + "set the help key of the menu item" + + activeHelpKey := aKey +! + +label + "get the value of the menu item" + + ^label +! + +label:something + "set the value of the menu item" + + label := something ? '-' +! + +separatorType + "get the separator type assigned to item or nil" + + label size > 1 + ifFalse: + [ + label size == 0 ifTrue:[^#blank]. + label first == $- ifTrue:[^#single]. + label first == $= ifTrue:[^#double]. + ]. + ^nil + +! + +startGroup:aSymbolOrNil + "set the startGroup attribute" + + startGroup := aSymbolOrNil + + "Created: / 23.8.1998 / 15:56:03 / cg" +! + +submenuChannel + "return the value of the instance variable 'submenuChannel' (automatically generated)" + + ^submenuChannel +! + +submenuChannel:aChannel + "get the submenuChannel" + + submenuChannel := aChannel +! + +translateLabel:aBoolean + "set/clear the translate to national-language flag" + + translateLabel := aBoolean + + "Created: / 6.6.1998 / 17:23:33 / cg" +! + +value:aSymbol + "set the value attribute" + + value := aSymbol + + "Created: / 23.8.1998 / 16:02:10 / cg" +! ! + +!MenuEditor::Item methodsFor:'building'! + +buildFromAspects:aspects + "read the values of the aspects into my values" + + |name| + self isSeparator + ifFalse: + [ + name := label. + label := (aspects at:#label) value. + + (label isNil or:[self isSeparator]) ifTrue:[ + (aspects at:#label) value:(label := name) + ]. + + enabled := (aspects at:#enabled) value. + value := (aspects at:#value) value. + nameKey := (aspects at:#nameKey) value. + indication := (aspects at:#indication) value. + choice := (aspects at:#choice) value. + choiceValue := (aspects at:#choiceValue) value. + shortcutKey := (aspects at:#shortcutKey) value. + startGroup := (aspects at:#startGroup) value. + accessCharacterPos := (aspects at:#accessCharacterPos) value. + argument := (aspects at:#argument) value. + translateLabel := (aspects at:#translateLabel) value. + isButton := (aspects at:#isButton) value. + auxValue := (aspects at:#auxValue) value. + + argument isString ifTrue:[ + argument size > 1 ifTrue:[ + (argument at:1) == $# ifTrue:[ + argument := (argument copyFrom:2) asSymbol + ] + ] + ]. + submenuChannel := (aspects at:#submenuChannel) value. + retriever := (aspects at:#retriever) value. + icon := (aspects at:#icon) value. + iconAndLabel := (aspects at:#iconAndLabel) value. + ] + ifTrue: + [ + name := (aspects at:#seperatorSelection) selectionIndex. + label := (self class separatorSlices at:name) last. + ]. + isVisible := (aspects at:#isVisible) value. + + "Modified: / 14.8.1998 / 15:36:38 / cg" +! + +buildFromMenuItem:anItem + "read the attributes of anItem into my values" + + |rtv| + + self label:(anItem rawLabel). + activeHelpKey := anItem activeHelpKey. + + (enabled := anItem enabled) isSymbol ifFalse:[ + enabled := nil + ]. + (value := anItem value) isSymbol ifFalse:[ + value := nil. + ]. + (indication := anItem indication) isSymbol ifFalse:[ + indication := nil + ]. + (choice := anItem choice) isSymbol ifFalse:[ + choice := nil + ]. + choiceValue := anItem choiceValue. + + nameKey := anItem nameKey. + shortcutKey := anItem shortcutKeyCharacter. + startGroup := anItem startGroup. + accessCharacterPos := anItem accessCharacterPosition. + argument := anItem argument. + + submenuChannel := anItem submenuChannel. + translateLabel := anItem translateLabel. + isButton := anItem isButton. + isVisible := anItem isVisible. + auxValue := anItem auxValue. + + (((rtv := anItem adornment) notNil) + and:[(rtv := rtv labelImage) isKindOf:ResourceRetriever]) + ifTrue: + [ + retriever := rtv className. + icon := rtv selector. + (iconAndLabel := rtv labelText notNil) ifTrue:[ + label := rtv labelText. + ] + ] + + "Modified: / 29.9.1998 / 11:18:25 / cg" +! ! + +!MenuEditor::Item methodsFor:'conversion'! + +asMenuItem + "converts self to a menu item" + + |item rcv| + + item := MenuItem labeled:label. + item isVisible:isVisible. + + self isSeparator ifFalse:[ + item activeHelpKey:activeHelpKey. + item enabled:enabled. + item accessCharacterPosition:accessCharacterPos. + item argument:argument. + item submenuChannel:submenuChannel. + item nameKey:nameKey. + item shortcutKeyCharacter:shortcutKey. + item startGroup:startGroup. + item value:value. + item indication:indication. + item choice:choice. + item choiceValue:choiceValue. + item translateLabel: translateLabel. + item isButton: isButton. + item auxValue: auxValue. + + icon notNil ifTrue:[ + rcv := ResourceRetriever new. + rcv className:retriever. + rcv selector:icon. + iconAndLabel == true ifTrue:[ + rcv labelText:label + ]. + item labelImage:rcv + ] + ]. + ^item + + "Modified: / 14.8.1998 / 15:36:35 / cg" +! + +toAspects:aspects + "put my values into the values of aspects" + + |type| + (type := self separatorType) notNil ifTrue: [ + type := self class separatorSlices findFirst:[:el| el first == type ]. + (aspects at:#seperatorSelection) selectionIndex:type. + ] ifFalse: [ + (aspects at:#label) value:label. + (aspects at:#enabled) value:enabled. + (aspects at:#value) value:value. + (aspects at:#nameKey) value:nameKey. + (aspects at:#indication) value:indication. + (aspects at:#choice) value:choice. + (aspects at:#choiceValue) value:choiceValue. + (aspects at:#shortcutKey) value:shortcutKey. + (aspects at:#startGroup) value:startGroup. + (aspects at:#accessCharacterPos) value:accessCharacterPos. + (aspects at:#translateLabel) value:translateLabel. + (aspects at:#submenuChannel) value:submenuChannel. + (aspects at:#retriever) value:retriever. + (aspects at:#icon) value:icon. + (aspects at:#iconAndLabel) value:iconAndLabel. + (aspects at:#isButton) value:isButton. + (aspects at:#auxValue) value:auxValue. + + (aspects at:#argument) + value:(argument isSymbol + ifTrue: ['#', argument] + ifFalse:[argument]). + ]. + (aspects at:#isVisible) value:isVisible. + + "Modified: / 14.8.1998 / 15:37:29 / cg" +! ! + +!MenuEditor::Item methodsFor:'queries'! + +iconFor: aNode + "get the icon of the menu item for the tree view" + + (aNode hasChildren or: [aNode parent isNil]) + ifTrue: + [ + ^MenuEditor submenuImage + ] + ifFalse: + [ + submenuChannel notNil + ifTrue: + [ + ^MenuEditor linkSubmenuImage + ] + ifFalse: + [ + self isSeparator + ifTrue: [^MenuEditor menuSeparatorImage] + ifFalse: [^MenuEditor menuItemImage] + ] + ] +! + +isSeparator + "return true if item is a seperator" + + ^self separatorType notNil +! + +treeViewLabel + "get the label of the menu item for the tree view" + + ^label +" asBoldText, + (value notNil ifTrue: [': [', + value , + (argument isString ifTrue: [' ', (Text string: argument emphasis: #italic)] ifFalse: ['']), + ']'] ifFalse: ['']) + + +" +! ! + !MenuEditor class methodsFor:'documentation'! version