diff -r 71766a2845ab -r 8fa6afe1b929 UISelectionPanel.st --- a/UISelectionPanel.st Thu Dec 04 16:22:51 1997 +0100 +++ b/UISelectionPanel.st Mon Dec 08 18:55:19 1997 +0100 @@ -19,9 +19,9 @@ category:'Interface-UIPainter' ! -Object subclass:#ExampleUserDefinedGallery +Object subclass:#UserDefinedGallery instanceVariableNames:'' - classVariableNames:'' + classVariableNames:'LabelList SelectorList HolderList NextUniqueNumber' poolDictionaries:'' privateIn:UISelectionPanel ! @@ -70,9 +70,11 @@ initialize super initialize. - UserClass := UISelectionPanel::ExampleUserDefinedGallery. + UserClass := UISelectionPanel::UserDefinedGallery. UserSpecs := #listOfSelectors. UserLabels := #listOfLabels. + + "Modified: / 8.12.1997 / 18:53:06 / cg" ! ! !UISelectionPanel class methodsFor:'accessing'! @@ -99,6 +101,32 @@ #( 'User Def.' #userDefined ) ) +! + +userClass + "return the class which provides the user defined gallery specs." + + ^ UserClass + + "Created: / 5.12.1997 / 15:12:50 / cg" +! + +userClass:aClass specSelector:aSpecAccessSelector labelSelector:aLabelListAccessSelector + "change the class which provides the user defined gallery specs." + + UserClass := aClass. + UserSpecs := aSpecAccessSelector. + UserLabels := aLabelListAccessSelector. + + " + UISelectionPanel + userClass:UISelectionPanel::VariableUserDefinedGallery + specSelector:#listOfSelectors + labelSelector:#listOfLabels + " + + "Modified: / 5.12.1997 / 13:54:47 / cg" + "Created: / 5.12.1997 / 13:56:10 / cg" ! ! !UISelectionPanel class methodsFor:'interface specification'! @@ -1662,7 +1690,140 @@ ^ nil ! ! -!UISelectionPanel::ExampleUserDefinedGallery class methodsFor:'user defined gallery'! +!UISelectionPanel::UserDefinedGallery class methodsFor:'class initialization'! + +initialize + "initialize my default user-def from the superclasses specs. + I.e. provide a clocks entry" + + LabelList := self defaultListOfLabels asOrderedCollection. + SelectorList := self defaultListOfSelectors asOrderedCollection. + HolderList := OrderedCollection new grow:(SelectorList size). + NextUniqueNumber := 1. + + UISelectionPanel + userClass:self + specSelector:#listOfSelectors + labelSelector:#listOfLabels. + + " + self initialize + " + + "Modified: / 5.12.1997 / 14:25:22 / cg" + "Created: / 8.12.1997 / 18:49:42 / cg" +! ! + +!UISelectionPanel::UserDefinedGallery class methodsFor:'defaults'! + +defaultListOfLabels + ^ #( 'clocks' ) + + "Created: / 8.12.1997 / 18:50:06 / cg" +! + +defaultListOfSelectors + ^ #( clocksSpec ) + + "Modified: / 5.12.1997 / 14:03:55 / cg" + "Created: / 8.12.1997 / 18:50:21 / cg" +! ! + +!UISelectionPanel::UserDefinedGallery class methodsFor:'documentation'! + +copyright +" + COPYRIGHT (c) 1997 by eXept Software AG + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" + + + +! + +documentation +" + The standard user-defined selectionPanel entry. + Here, a single item named 'clocks' is provided, containing + an analog and digital clock. + This is a dump example; the actual user-defined panel may be + extended dynamically. + + Frameworks which provide additional widgets may dynamically + add more entries, by sending #addUserSpecHolder:label: + or #removeUserSpecWithLabel:. + Typically, this is done when a framework is loaded, by one of the + frameworks class-initialization methods. + + [start with:] + UISelectionPanel open + + [author:] + Claus Gittinger + Claus Atzkern + + [see also:] + TabView + NoteBookView + UIGalleryView + UIPainter + +" + + +! ! + +!UISelectionPanel::UserDefinedGallery class methodsFor:'installation / deinstallation'! + +addUserSpecHolder:aValueHolder label:aLabelString + "add a new entry with the given label. + The specHolder is typically either a spec, a valueHolder or a block. + In any case, it should return a valid spec from the #value message. + This spec is installed under that label." + + |syntheticSelector idx| + + syntheticSelector := ('userSpec' , NextUniqueNumber printString) asSymbol. + NextUniqueNumber := NextUniqueNumber + 1. + + idx := LabelList indexOf:aLabelString. + idx ~~ 0 ifTrue:[ + SelectorList at:idx put:syntheticSelector. + HolderList at:idx put:aValueHolder + ] ifFalse:[ + LabelList addLast:aLabelString. + SelectorList addLast:syntheticSelector. + HolderList addLast:aValueHolder + ] + + "Modified: / 5.12.1997 / 14:13:17 / cg" + "Created: / 8.12.1997 / 18:50:55 / cg" +! + +removeUserSpecWithLabel:aLabelString + "remove the spec which was previously installed under the given label" + + |idx| + + idx := LabelList indexOf:aLabelString. + idx ~~ 0 ifTrue:[ + LabelList removeIndex:idx. + SelectorList removeIndex:idx. + HolderList removeIndex:idx + ]. + + "Modified: / 5.12.1997 / 14:13:45 / cg" + "Created: / 8.12.1997 / 18:51:03 / cg" +! ! + +!UISelectionPanel::UserDefinedGallery class methodsFor:'user defined gallery'! clocksSpec "this window spec was automatically generated by the ST/X UIPainter" @@ -1709,60 +1870,57 @@ ) ) - "Modified: 4.10.1997 / 15:12:27 / cg" -! - -funSpec - "this window spec was automatically generated by the ST/X UIPainter" - - "do not manually edit this - the painter/builder may not be able to - handle the specification if its corrupted." - - " - UIPainter new openOnClass:UISelectionPanel::ExampleUserDefinedGallery andSelector:#funSpec - UISelectionPanel::ExampleUserDefinedGallery new openInterface:#funSpec - " - - - - ^ - - #(#FullSpec - #'window:' - #(#WindowSpec - #'name:' 'uIPainterView' - #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) - #'label:' 'Interface Builder' - #'bounds:' #(#Rectangle 0 0 393 182) - ) - #'component:' - #(#SpecCollection - #'collection:' - #( - #(#ArbitraryComponentSpec - #'name:' 'arbitraryComponent1' - #'layout:' #(#LayoutFrame 54 0 27 0 287 0 145 0) - #'hasHorizontalScrollBar:' false - #'hasVerticalScrollBar:' false - #'hasBorder:' false - #'miniScrollerHorizontal:' false - #'miniScrollerVertical:' false - ) - ) - ) - ) + "Modified: / 4.10.1997 / 15:12:27 / cg" + "Created: / 8.12.1997 / 18:40:22 / cg" ! listOfLabels - ^ #( 'clocks' 'fun') + ^ LabelList - + "Created: / 5.12.1997 / 13:43:03 / cg" + "Modified: / 8.12.1997 / 18:51:20 / cg" ! listOfSelectors - ^ #( clocksSpec funSpec ) + ^ SelectorList + + "Created: / 5.12.1997 / 13:43:13 / cg" + "Modified: / 8.12.1997 / 18:51:28 / cg" +! ! + +!UISelectionPanel::UserDefinedGallery class methodsFor:'user spec access'! + +doesNotUnderstand:aMessage + "catch queries for a userSpec" + + |sel idx| + ((sel := aMessage selector) startsWith:'userSpec') ifTrue:[ + idx := SelectorList indexOf:sel. + idx ~~ 0 ifTrue:[ + ^ (HolderList at:idx) value + ] + ]. + ^ super doesNotUnderstand:aMessage + "Modified: / 5.12.1997 / 14:23:24 / cg" + "Created: / 8.12.1997 / 18:51:50 / cg" +! + +respondsTo:aSelector + "catch queries for a userSpec" + + |idx| + + (aSelector startsWith:'userSpec') ifTrue:[ + idx := Number fromString:(aSelector copyFrom:9). + idx := SelectorList indexOf:aSelector. + idx ~~ 0 ifTrue:[^ true]. + ]. + ^ super respondsTo:aSelector + + "Modified: / 5.12.1997 / 14:19:55 / cg" + "Created: / 8.12.1997 / 18:51:57 / cg" ! ! !UISelectionPanel class methodsFor:'documentation'!