diff -r b560339667cf -r aa3e56929a5a SelectionInList.st --- a/SelectionInList.st Thu Nov 23 11:37:10 1995 +0100 +++ b/SelectionInList.st Thu Nov 23 11:42:48 1995 +0100 @@ -33,10 +33,6 @@ " ! -version - ^ '$Header: /cvs/stx/stx/libwidg/SelectionInList.st,v 1.5 1995-11-11 16:22:48 cg Exp $' -! - documentation " Instances of SelectionInList can be used as model for @@ -90,6 +86,10 @@ ]. b open " +! + +version + ^ '$Header: /cvs/stx/stx/libwidg/SelectionInList.st,v 1.6 1995-11-23 10:42:48 cg Exp $' ! ! !SelectionInList class methodsFor:'instance creation'! @@ -102,11 +102,50 @@ ^ self new listHolder:(ValueHolder with:aList) ! ! -!SelectionInList methodsFor:'initialization'! +!SelectionInList methodsFor:'accessing-holders'! + +listHolder + "return the one holding the list" + + ^ listHolder +! + +listHolder:aValueHolder + "set the one holding the list. + Q: should we forward a change-notification ?" + + listHolder notNil ifTrue:[ + listHolder removeDependent:self + ]. + listHolder := aValueHolder. + listHolder addDependent:self +! -initialize - self listHolder:(nil asValue). "/ could also use an empty collection here - self selectionIndexHolder:(nil asValue). +selectionHolder + "return someone holding on the selection itself + (not the index). Since we have no one, we need an adapter, + to get up-to-date values." + + ^ AspectAdaptor + subject:self sendsUpdates:true + accessWith:#selection assignWith:#'selection:' aspect:#selectionIndex +! + +selectionIndexHolder + "return the one holding the index" + + ^ selectionIndexHolder +! + +selectionIndexHolder:aValueHolder + "set the one holding the index. + Q: should we forward a change-notification ?" + + selectionIndexHolder notNil ifTrue:[ + selectionIndexHolder removeDependent:self + ]. + selectionIndexHolder := aValueHolder. + selectionIndexHolder addDependent:self ! ! !SelectionInList methodsFor:'accessing-values'! @@ -119,16 +158,6 @@ listHolder value:aCollection. ! -selectionIndex - ^ selectionIndexHolder value -! - -selectionIndex:newIndex - selectionIndexHolder value ~= newIndex ifTrue:[ - selectionIndexHolder value:newIndex - ] -! - selection "return the selections value (i.e. the entry in the list" @@ -144,6 +173,16 @@ If anObject is not in the list, the selection is cleared" ^ self selectionIndex:(self list indexOf:anObject ifAbsent:0) +! + +selectionIndex + ^ selectionIndexHolder value +! + +selectionIndex:newIndex + selectionIndexHolder value ~= newIndex ifTrue:[ + selectionIndexHolder value:newIndex + ] ! ! !SelectionInList methodsFor:'change & update'! @@ -168,6 +207,13 @@ ] ! ! +!SelectionInList methodsFor:'initialization'! + +initialize + self listHolder:(nil asValue). "/ could also use an empty collection here + self selectionIndexHolder:(nil asValue). +! ! + !SelectionInList methodsFor:'obsolete backward compatibility'! index @@ -198,48 +244,3 @@ ^ self selectionIndexHolder:aValueHolder ! ! -!SelectionInList methodsFor:'accessing-holders'! - -listHolder - "return the one holding the list" - - ^ listHolder -! - -listHolder:aValueHolder - "set the one holding the list. - Q: should we forward a change-notification ?" - - listHolder notNil ifTrue:[ - listHolder removeDependent:self - ]. - listHolder := aValueHolder. - listHolder addDependent:self -! - -selectionIndexHolder - "return the one holding the index" - - ^ selectionIndexHolder -! - -selectionIndexHolder:aValueHolder - "set the one holding the index. - Q: should we forward a change-notification ?" - - selectionIndexHolder notNil ifTrue:[ - selectionIndexHolder removeDependent:self - ]. - selectionIndexHolder := aValueHolder. - selectionIndexHolder addDependent:self -! - -selectionHolder - "return someone holding on the selection itself - (not the index). Since we have no one, we need an adapter, - to get up-to-date values." - - ^ AspectAdaptor - subject:self sendsUpdates:true - accessWith:#selection assignWith:#'selection:' aspect:#selectionIndex -! !