--- a/ValueModel.st Sat May 06 16:15:18 1995 +0200
+++ b/ValueModel.st Tue May 09 02:23:22 1995 +0200
@@ -1,5 +1,7 @@
-Model subclass:#ValueModel
- instanceVariableNames:'accepted'
+'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:03:02 pm'!
+
+Model subclass:#ValueModel
+ instanceVariableNames:'accepted interrest'
classVariableNames:''
poolDictionaries:''
category:'Interface-Support'
@@ -7,14 +9,42 @@
!ValueModel class methodsFor:'documentation'!
+Model class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+ 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.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libview2/ValueModel.st,v 1.4 1995-05-09 00:22:56 claus Exp $
+"
+!
+
documentation
"
abstract superclass for ValueHolders and Adaptors.
+ It does not itself know how and where the value is stored,
+ but knows about interrested objects (which get informed, whenever
+ the value changes) and keeps track if the value was ever accepted.
Notice: this class was implemented using protocol information
from alpha testers - it may not be complete or compatible to
the corresponding ST-80 class. If you encounter any incompatibilities,
please forward a note to the ST/X team.
+
+ subclasses must redefine: #setValue: and #value
+ (and optionally redefine #value:)
"
! !
@@ -24,14 +54,33 @@
^ (super new) initialize
! !
-!ValueModel methodsFor:'initialization'!
+!ValueModel methodsFor:'change notification'!
-initialize
- accepted := false
+notifyChange:aSymbol
+ interrest notNil ifTrue:[
+ interrest keysAndValuesDo:[:someone :selector |
+ someone perform:selector
+ ].
+ ].
+ self changed:aSymbol
! !
!ValueModel methodsFor:'accessing'!
+value:anObject
+ |oldValue|
+
+ oldValue := self value.
+ self setValue:anObject.
+ anObject ~= oldValue ifTrue:[
+ self notifyChange:#value
+ ]
+!
+
+accepted
+ ^ accepted
+!
+
accept
accepted := true
!
@@ -42,15 +91,35 @@
setValue:newValue
self subclassResponsibility
+! !
+
+!ValueModel methodsFor:'initialization'!
+
+initialize
+ accepted := false
+! !
+
+!ValueModel methodsFor:'interrest'!
+
+retractInterrestFor:someone
+ "release interrest i.e. do no longer send changeMsg to changeReceiver
+ iff someone is the changeReceiver.
+ This can be used to (temporarily) turn off information sends,
+ to break endless cycles (if two values change each other)"
+
+ interrest notNil ifTrue:[
+ interrest removeKey:someone ifAbsent:nil
+ ]
!
-value:anObject
- |oldValue|
+onChangeSend:selector to:someone
+ "add an interrest, arranging that
+ a message with selector will be sent to someone
+ when my value changes."
- oldValue := self value.
- self setValue:anObject.
- anObject ~= oldValue ifTrue:[
- self changed:#value
- ]
+ interrest isNil ifTrue:[
+ interrest := IdentityDictionary new
+ ].
+ interrest at:someone put:selector
! !