diff -r 23712b1d3f3d -r 1ecabfd468dc MenuEditor.st --- a/MenuEditor.st Wed Aug 20 17:55:38 1997 +0200 +++ b/MenuEditor.st Wed Aug 20 17:57:49 1997 +0200 @@ -13,7 +13,8 @@ ApplicationModel subclass:#MenuEditor - instanceVariableNames:'specClass tabSelection aspects slices activeHelpTool didInstall' + instanceVariableNames:'specClass specCanvas helpCanvas tabSelection aspects slices + didInstall' classVariableNames:'' poolDictionaries:'' category:'Interface-UIPainter' @@ -124,7 +125,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'ClassAndMethodSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'Painter' #'bounds:' #(#Rectangle 0 0 391 170) @@ -220,7 +221,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'ClassDefineSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'Painter' #'bounds:' #(#Rectangle 0 0 383 128) @@ -532,12 +533,12 @@ #(#MenuItem #'label:' 'from class ...' #'value:' #doFromClass - #'enabled:' #isOwnerOfHelpTool + #'enabled:' #isStandAlone ) #(#MenuItem #'label:' 'pick a menu' #'value:' #doPickAMenu - #'enabled:' #isOwnerOfHelpTool + #'enabled:' #isStandAlone ) #(#MenuItem #'label:' '=' @@ -596,7 +597,7 @@ #(#MenuItem #'label:' 'class' #'value:' #doDefineClass - #'enabled:' #isOwnerOfHelpTool + #'enabled:' #isStandAlone ) #(#MenuItem #'label:' '-' @@ -608,7 +609,7 @@ #(#MenuItem #'label:' 'install help spec.' #'value:' #doInstallHelp - #'enabled:' #isOwnerOfHelpTool + #'enabled:' #isStandAlone ) #(#MenuItem #'label:' '=' @@ -651,7 +652,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'MenuEditor' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'Menu Builder' #'bounds:' #(#Rectangle 0 0 580 384) @@ -677,7 +678,7 @@ #'model:' #tabModel #'tabWidget:' #Window #'useIndex:' true - #'canvas:' #tabCanvas + #'canvas:' #noteBookView ) #(#HorizontalPanelViewSpec #'name:' 'confirmationPanel' @@ -731,7 +732,6 @@ (Basics basicsItemSpec) (Details detailsEditSpec) (Misc miscEditSpec) - (Help help) ) ! @@ -741,7 +741,6 @@ (Basics basicsLinkSpec) (Details detailsEditSpec) (Misc miscEditSpec) - (Help help) ) ! @@ -751,7 +750,6 @@ (Basics basicsMenuSpec) (Details detailsEditSpec) (Misc miscEditSpec) - (Help help) ) ! @@ -790,7 +788,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'BasicsItemSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 267 319) @@ -879,7 +877,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'BasicsLinkSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 267 319) @@ -952,7 +950,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'BasicsMenuSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 267 319) @@ -1013,7 +1011,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'BasicsRootSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 267 319) @@ -1060,7 +1058,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'BasicsSeparatorSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 267 319) @@ -1107,7 +1105,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'DetailsEditSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 259 288) @@ -1183,7 +1181,7 @@ #(#FullSpec #'window:' #(#WindowSpec - #'name:' 'uIPainterView' + #'name:' 'MiscEditSpec' #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) #'label:' 'unnamed canvas' #'bounds:' #(#Rectangle 0 0 245 142) @@ -1281,6 +1279,13 @@ anItem enabled:true. ]. ^ menu +! + +useHelpDictionary:aDictionary + |tool| + + self noteBookView. + self helpTool dictionary:aDictionary. ! ! !MenuEditor methodsFor:'accessing menu'! @@ -1313,21 +1318,22 @@ node notNil ifTrue:[ self isHelpToolSelected ifTrue:[ - self activeHelpTool accept - ]. - cont := node contents buildFromAspects:aspects. - painter selectedNodeChanged + self helpTool accept. + node contents activeHelpKey:(self helpTool helpKey) + ] ifFalse:[ + cont := node contents buildFromAspects:aspects. + painter selectedNodeChanged + ] ]. self modifiedChannel value:false. didInstall := true - - "Modified: 31.7.1997 / 14:25:34 / cg" ! cancel |node| (node := self painter selectedNode) notNil ifTrue:[ + self helpTool helpKey:(self helpKey). aspects do:[:anAspect| anAspect value:nil ]. node contents toAspects:aspects. ]. @@ -1335,33 +1341,6 @@ ! ! -!MenuEditor methodsFor:'active help'! - -activeHelpTool - "access current active help editor - " - activeHelpTool isNil ifTrue:[ - self activeHelpTool:(UIHelpTool new) - ]. - ^ activeHelpTool -! - -activeHelpTool:anApplication - "change current active help editor - " - activeHelpTool := anApplication. - - activeHelpTool masterApplication isNil ifTrue:[ - activeHelpTool masterApplication:self. - ]. -! - -isOwnerOfHelpTool - "returns true in case of owner of the helptool - " - ^ self activeHelpTool masterApplication == self -! ! - !MenuEditor methodsFor:'aspects'! aspectFor:aKey @@ -1408,17 +1387,6 @@ "Modified: 28.7.1997 / 12:52:13 / cg" ! -menuPullDown - |menu| - - menu := Menu new. - menu fromLiteralArrayEncoding:(self class menuPullDown). - menu receiver:self. - ^ menu - - -! - modifiedChannel "automatically generated by UIPainter ..." @@ -1427,15 +1395,26 @@ "Modified: 28.7.1997 / 12:52:14 / cg" ! -tabCanvas +noteBookView "automatically generated by UIPainter ..." - |holder| - - (holder := builder bindingAt:#tabCanvas) isNil ifTrue:[ - builder aspectAt:#tabCanvas put:(holder := SubCanvas new). + |noteBook helpTool| + + (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[ + noteBook := View new. + helpTool := UIHelpTool new. + + helpTool masterApplication:self. + helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. + specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook. + + helpCanvas client:helpTool. + helpTool masterApplication:self. + helpTool modifiedHolder:(self modifiedChannel). + + builder aspectAt:#noteBookView put:noteBook. ]. - ^ holder + ^ noteBook ! tabList @@ -1517,6 +1496,155 @@ ! ! +!MenuEditor methodsFor:'interface specs'! + +menuPullDown + "this window spec was automatically generated by the ST/X MenuEditor" + + "do not manually edit this - the builder may not be able to + handle the specification if its corrupted." + + " + MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown + (Menu new fromLiteralArrayEncoding:(MenuEditor menuPullDown)) startUp + " + + + + ^ + + #(#Menu + + #( + #(#MenuItem + #'label:' 'file' + #'value:' #file + #'submenu:' + #(#Menu + + #( + #(#MenuItem + #'label:' 'new' + #'value:' #doNew + ) + #(#MenuItem + #'label:' 'from class ...' + #'value:' #doFromClass + #'enabled:' #isStandAlone + ) + #(#MenuItem + #'label:' 'pick a menu' + #'value:' #doPickAMenu + #'enabled:' #isStandAlone + ) + #(#MenuItem + #'label:' '=' + ) + #(#MenuItem + #'label:' 'quit' + #'value:' #closeRequest + ) + ) nil + nil + ) + ) + #(#MenuItem + #'label:' 'edit' + #'submenu:' + #(#Menu + + #( + #(#MenuItem + #'label:' 'cut' + #'value:' #doCut + ) + #(#MenuItem + #'label:' '=' + ) + #(#MenuItem + #'label:' 'create submenu static' + #'value:' #doCreateMenu + ) + #(#MenuItem + #'label:' 'create summenu dynamic' + #'value:' #doCreateLink + ) + #(#MenuItem + #'label:' '-' + ) + #(#MenuItem + #'label:' 'create item' + #'value:' #doCreateItem + ) + #(#MenuItem + #'label:' 'create separator' + #'value:' #doCreateSep + ) + ) nil + nil + ) + ) + #(#MenuItem + #'label:' 'code' + #'value:' #code + #'submenu:' + #(#Menu + + #( + #(#MenuItem + #'label:' 'class' + #'value:' #doDefineClass + #'enabled:' #isStandAlone + ) + #(#MenuItem + #'label:' '-' + ) + #(#MenuItem + #'label:' 'install menu spec.' + #'value:' #doInstallSpec + ) + #(#MenuItem + #'label:' 'install help spec.' + #'value:' #doInstallHelp + #'enabled:' #isStandAlone + ) + #(#MenuItem + #'label:' '=' + ) + #(#MenuItem + #'label:' 'browse application' + #'value:' #doBrowseAppClass + ) + ) nil + nil + ) + ) + #(#MenuItem + #'label:' 'test' + #'submenuChannel:' #submenuTest + ) + ) nil + nil + ) + + "Modified: 28.7.1997 / 18:12:10 / cg" +! ! + +!MenuEditor methodsFor:'private'! + +helpKey + |node| + + (node := self painter selectedNode) notNil ifTrue:[ + ^ node contents activeHelpKey + ]. + ^ nil +! + +helpTool + ^ helpCanvas application +! ! + !MenuEditor methodsFor:'queries'! didInstall @@ -1531,16 +1659,22 @@ isHelpToolSelected "returns true if current selection is help tool " - (slices notNil and:[tabSelection notNil]) ifTrue:[ - ^ (slices at:tabSelection) last == #help + slices notNil ifTrue:[ + ^ (slices at:tabSelection) first = UIHelpTool label ]. - ^ false + ^ false +! + +isStandAlone + "returns true in case of owner of the helptool + " + ^ self masterApplication isNil ! ! !MenuEditor methodsFor:'selection'! menuChanged - |node item slc sel| + |node item slc sel old| (node := self painter selectedNode) notNil ifTrue:[ aspects do:[:anAspect| anAspect value:nil ]. @@ -1555,24 +1689,31 @@ item submenuChannel isNil ifTrue:[slc := #slicesItem] ifFalse:[slc := #slicesLink] ]. + slc := (self class perform:slc) copyWith:#( 'Help' #dummy ). ] ifTrue:[ - slc := #slicesRootMenu - ] + slc := self class perform:#slicesRootMenu + ]. ] ifTrue:[ - slc := #slicesSeparatorMenu - ]. - slc := self class perform:slc. + slc := self class perform:#slicesSeparatorMenu. + ] ]. + self helpTool helpKey:(self helpKey). self modifiedChannel value:false. slc ~= slices ifTrue:[ + tabSelection notNil ifTrue:[ + old := (slices at:tabSelection) first + ]. + (slices := slc) notNil ifTrue:[ - tabSelection notNil ifTrue:[sel := tabSelection min:(slices size)] - ifFalse:[sel := 1]. - - self tabList value:(slices collect:[:s| s first]). - self tabModel setValue:nil. - self tabModel value:sel. + sel := slices collect:[:s| s first]. + tabSelection := nil. + self tabList value:sel. + + (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[ + sel := 1 + ]. + self tabModel value:sel ] ifFalse:[ self tabList value:nil. self tabSelection:nil. @@ -1588,19 +1729,26 @@ tabSelection:aSelection |tool sel| - tabSelection == aSelection ifTrue:[ + tabSelection = aSelection ifTrue:[ ^ self ]. (tabSelection := aSelection) isNil ifTrue:[ - ^ self tabCanvas client:nil + slices isNil ifTrue:[ + specCanvas client:nil. + ^ specCanvas raise. + ]. + tabSelection == 1 ifTrue:[^ self]. + tabSelection := 1 ]. + self isHelpToolSelected ifTrue:[ - self tabCanvas client:(tool := self activeHelpTool). - tool model:(self aspectFor:#activeHelpKey) + self helpTool helpKey:(self helpKey). + helpCanvas raise. ] ifFalse:[ sel := (slices at:tabSelection) last. - self tabCanvas client:self spec:(self class perform:sel) builder:builder + specCanvas client:self spec:(self class perform:sel) builder:builder. + specCanvas raise. ] ! ! @@ -1613,8 +1761,8 @@ self specClass:aClass. newClass := self specClass. - (self isOwnerOfHelpTool and:[oldClass ~= newClass]) ifTrue:[ - self activeHelpTool helpSpecFrom:newClass + (self isStandAlone and:[oldClass ~= newClass]) ifTrue:[ + self helpTool helpSpecFrom:newClass ]. self painter buildFrom:newClass andSelector:aSelector. ! @@ -1631,7 +1779,6 @@ label accessCharaterPos submenuChannel - activeHelpKey enabled value nameKey @@ -1742,7 +1889,9 @@ doInstallHelp "install help text " - self activeHelpTool installHelpSpecInto:(self specClass) + self isStandAlone ifTrue:[ + self helpTool installHelpSpecInto:(self specClass) + ] ! doInstallSpec @@ -1914,6 +2063,14 @@ !MenuEditor::Item methodsFor:'accessing'! +activeHelpKey + ^ activeHelpKey +! + +activeHelpKey:aKey + activeHelpKey := aKey +! + label "return the value of the instance variable 'label' (automatically generated)" @@ -1997,7 +2154,6 @@ (aspects at:#label) value:(label := name) ]. - activeHelpKey := (aspects at:#activeHelpKey) value. enabled := (aspects at:#enabled) value. value := (aspects at:#value) value. nameKey := (aspects at:#nameKey) value. @@ -2057,7 +2213,6 @@ (aspects at:#seperatorSelection) selectionIndex:type. ] ifFalse:[ (aspects at:#label) value:label. - (aspects at:#activeHelpKey) value:activeHelpKey. (aspects at:#enabled) value:enabled. (aspects at:#value) value:value. (aspects at:#nameKey) value:nameKey.