ValModel.st
author Claus Gittinger <cg@exept.de>
Tue, 27 Jan 1998 12:12:49 +0100
changeset 773 b6337f784d05
parent 504 b77cdd860259
child 796 5aca7d7a8f30
permissions -rw-r--r--
added #isBuffering (read not from trevis griggs)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
claus
parents: 73
diff changeset
     1
"
claus
parents: 73
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 73
diff changeset
     3
	      All Rights Reserved
claus
parents: 73
diff changeset
     4
claus
parents: 73
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 73
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 73
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 73
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 73
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 73
diff changeset
    10
 hereby transferred.
claus
parents: 73
diff changeset
    11
"
claus
parents: 73
diff changeset
    12
69
claus
parents: 68
diff changeset
    13
Model subclass:#ValueModel
441
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    14
	instanceVariableNames:''
175
df08e5b663d0 let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    15
	classVariableNames:''
df08e5b663d0 let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    16
	poolDictionaries:''
df08e5b663d0 let objects interest implementation do things
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    17
	category:'Interface-Support-Models'
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    18
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
    19
441
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    20
!ValueModel class methodsFor:'documentation'!
68
claus
parents: 66
diff changeset
    21
69
claus
parents: 68
diff changeset
    22
copyright
claus
parents: 68
diff changeset
    23
"
claus
parents: 68
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
71
claus
parents: 70
diff changeset
    25
	      All Rights Reserved
69
claus
parents: 68
diff changeset
    26
claus
parents: 68
diff changeset
    27
 This software is furnished under a license and may be used
claus
parents: 68
diff changeset
    28
 only in accordance with the terms of that license and with the
claus
parents: 68
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
claus
parents: 68
diff changeset
    30
 be provided or otherwise made available to, or used by, any
claus
parents: 68
diff changeset
    31
 other person.  No title to or ownership of the software is
claus
parents: 68
diff changeset
    32
 hereby transferred.
claus
parents: 68
diff changeset
    33
"
claus
parents: 68
diff changeset
    34
!
claus
parents: 68
diff changeset
    35
68
claus
parents: 66
diff changeset
    36
documentation
claus
parents: 66
diff changeset
    37
"
claus
parents: 66
diff changeset
    38
    abstract superclass for ValueHolders and Adaptors.
69
claus
parents: 68
diff changeset
    39
    It does not itself know how and where the value is stored,
143
ae38792bd85c interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    40
    but knows about interested objects (which get informed, whenever
69
claus
parents: 68
diff changeset
    41
    the value changes) and keeps track if the value was ever accepted.
68
claus
parents: 66
diff changeset
    42
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    43
    Notice: 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    44
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    45
        from alpha testers - it may not be complete or compatible to
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    46
        the corresponding ST-80 class. 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    47
        If you encounter any incompatibilities, please forward a note 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    48
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
69
claus
parents: 68
diff changeset
    49
claus
parents: 68
diff changeset
    50
    subclasses must redefine: #setValue: and #value
claus
parents: 68
diff changeset
    51
    (and optionally redefine #value:)
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
    52
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
    53
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 175
diff changeset
    54
        Claus Gittinger
68
claus
parents: 66
diff changeset
    55
"
claus
parents: 66
diff changeset
    56
! !
claus
parents: 66
diff changeset
    57
441
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    58
!ValueModel class methodsFor:'instance creation'!
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    59
194eb0590b1e Initial revision
claus
parents:
diff changeset
    60
new
194eb0590b1e Initial revision
claus
parents:
diff changeset
    61
    ^ (super new) initialize
194eb0590b1e Initial revision
claus
parents:
diff changeset
    62
! !
194eb0590b1e Initial revision
claus
parents:
diff changeset
    63
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    64
!ValueModel methodsFor:'accessing'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    65
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    66
setValue:newValue 
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    67
    "physically set my value, without change notifications"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    68
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    69
    ^ self subclassResponsibility
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    70
!
73
claus
parents: 71
diff changeset
    71
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    72
value 
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    73
    "return my value"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    74
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    75
    ^ self subclassResponsibility
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    76
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    77
504
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    78
value:newValue
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    79
    "set my value & send change notifications to my dependents
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    80
     if it changed."
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    81
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    82
    |oldValue|
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    83
504
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    84
    oldValue := self value.
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    85
    oldValue ~~ newValue ifTrue:[
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    86
        self setValue:newValue.
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    87
        self changed:#value
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    88
    ]
326
ab4e3df5c5d5 only ignore new value if identical to previous value.
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    89
504
b77cdd860259 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 492
diff changeset
    90
    "Modified: 27.3.1997 / 15:14:04 / cg"
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    91
! !
194eb0590b1e Initial revision
claus
parents:
diff changeset
    92
492
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    93
!ValueModel methodsFor:'converting'!
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    94
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    95
compute:aBlock
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    96
    "return a BlockValue on the receiver, which computes aBlock"
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    97
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    98
    ^ BlockValue with:aBlock arguments:(Array with:self)
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
    99
! !
4a308c56cb06 added #compute: - conversion
ca
parents: 441
diff changeset
   100
69
claus
parents: 68
diff changeset
   101
!ValueModel methodsFor:'initialization'!
claus
parents: 68
diff changeset
   102
claus
parents: 68
diff changeset
   103
initialize
441
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   104
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   105
    "Modified: 21.2.1997 / 16:29:38 / cg"
69
claus
parents: 68
diff changeset
   106
! !
claus
parents: 68
diff changeset
   107
773
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   108
!ValueModel methodsFor:'queries'!
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   109
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   110
isBuffering
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   111
    "return true, if the receiver is buffering something.
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   112
     For compatibility with BufferedValueHolder, false is returned here"
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   113
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   114
    ^ false
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   115
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   116
    "Created: / 27.1.1998 / 12:12:08 / cg"
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   117
! !
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   118
441
b0d486981a62 unconditionally send a change notification;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   119
!ValueModel class methodsFor:'documentation'!
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   120
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   121
version
773
b6337f784d05 added #isBuffering (read not from trevis griggs)
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   122
    ^ '$Header: /cvs/stx/stx/libview2/Attic/ValModel.st,v 1.22 1998-01-27 11:12:41 cg Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   123
! !