ValueHolder.st
author Claus Gittinger <cg@exept.de>
Mon, 02 Aug 1999 10:59:32 +0200
changeset 1212 816bee31f949
parent 700 67f1dccb8333
child 1362 7536d349a9b6
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
claus
parents: 71
diff changeset
     1
"
claus
parents: 71
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 71
diff changeset
     3
	      All Rights Reserved
claus
parents: 71
diff changeset
     4
claus
parents: 71
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 71
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 71
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 71
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 71
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 71
diff changeset
    10
 hereby transferred.
claus
parents: 71
diff changeset
    11
"
claus
parents: 71
diff changeset
    12
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
    13
'From Smalltalk/X, Version:3.1.10 on 20-sep-1997 at 11:52:10 pm'                !
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
    14
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    15
ValueModel subclass:#ValueHolder
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    16
	instanceVariableNames:'value'
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    17
	classVariableNames:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    18
	poolDictionaries:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    19
	category:'Interface-Support-Models'
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    20
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
    21
68
claus
parents: 66
diff changeset
    22
!ValueHolder class methodsFor:'documentation'!
claus
parents: 66
diff changeset
    23
69
claus
parents: 68
diff changeset
    24
copyright
claus
parents: 68
diff changeset
    25
"
claus
parents: 68
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
71
claus
parents: 69
diff changeset
    27
	      All Rights Reserved
69
claus
parents: 68
diff changeset
    28
claus
parents: 68
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents: 68
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents: 68
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents: 68
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents: 68
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents: 68
diff changeset
    34
 hereby transferred.
claus
parents: 68
diff changeset
    35
"
claus
parents: 68
diff changeset
    36
!
claus
parents: 68
diff changeset
    37
68
claus
parents: 66
diff changeset
    38
documentation
claus
parents: 66
diff changeset
    39
"
69
claus
parents: 68
diff changeset
    40
    a valueHolder can be used as a model for editFields, buttons etc.
68
claus
parents: 66
diff changeset
    41
    It stores some value internally, and sends update messages to its
claus
parents: 66
diff changeset
    42
    dependents when changed.
claus
parents: 66
diff changeset
    43
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    44
    Notice: 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    45
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    46
        from alpha testers - it may not be complete or compatible to
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    47
        the corresponding ST-80 class. 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    48
        If you encounter any incompatibilities, please forward a note 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    49
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    50
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    51
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    52
        Claus Gittinger
68
claus
parents: 66
diff changeset
    53
"
71
claus
parents: 69
diff changeset
    54
!
claus
parents: 69
diff changeset
    55
claus
parents: 69
diff changeset
    56
examples 
claus
parents: 69
diff changeset
    57
"
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    58
    See many examples in DialogBox & EditField
71
claus
parents: 69
diff changeset
    59
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    60
    edit strings:
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    61
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    62
        |firstName lastName dialog|
71
claus
parents: 69
diff changeset
    63
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    64
        firstName := ValueHolder newString.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    65
        lastName := ValueHolder newString.
71
claus
parents: 69
diff changeset
    66
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    67
        dialog := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    68
        (dialog addTextLabel:'Name:') adjust:#left.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    69
        dialog addInputFieldOn:firstName.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    70
        dialog addVerticalSpace.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    71
        (dialog addTextLabel:'Address:') adjust:#left.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    72
        dialog addInputFieldOn:lastName.
71
claus
parents: 69
diff changeset
    73
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    74
        dialog addAbortButton; addOkButton.
71
claus
parents: 69
diff changeset
    75
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    76
        dialog open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    77
        dialog accepted ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    78
            Transcript show:firstName value; show:' '; showCR:lastName value
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    79
        ]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    80
                                                                        [exEnd]
71
claus
parents: 69
diff changeset
    81
"
68
claus
parents: 66
diff changeset
    82
! !
claus
parents: 66
diff changeset
    83
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    84
!ValueHolder class methodsFor:'instance creation'!
194eb0590b1e Initial revision
claus
parents:
diff changeset
    85
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    86
newBoolean
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    87
    "return a new ValueHolder holding false as initial value"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    88
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    89
    ^ self with:false
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    90
!
68
claus
parents: 66
diff changeset
    91
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    92
newFraction
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    93
    "return a new ValueHolder holding 0.0 as initial value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    94
     The name is somewhat missleading - actually it should be called newFloat."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    95
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    96
    ^ self with:0.0 
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    97
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    98
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    99
newNumber
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   100
    "return a new ValueHolder holding 0 as initial value"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   101
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   102
    ^ self with:0 
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   103
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   104
194eb0590b1e Initial revision
claus
parents:
diff changeset
   105
newString
68
claus
parents: 66
diff changeset
   106
    "return a new ValueHolder holding an empty string as initial value"
claus
parents: 66
diff changeset
   107
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   108
    ^ self with:''
194eb0590b1e Initial revision
claus
parents:
diff changeset
   109
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   110
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   111
with:anObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   112
    "return a new ValueHolder holding anObject as initial value"
68
claus
parents: 66
diff changeset
   113
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   114
    ^ (super new) setValue:anObject
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   115
! !
194eb0590b1e Initial revision
claus
parents:
diff changeset
   116
194eb0590b1e Initial revision
claus
parents:
diff changeset
   117
!ValueHolder methodsFor:'accessing'!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   118
69
claus
parents: 68
diff changeset
   119
setValue:anObject
claus
parents: 68
diff changeset
   120
    "set my value without notification."
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   121
194eb0590b1e Initial revision
claus
parents:
diff changeset
   122
    value := anObject.
194eb0590b1e Initial revision
claus
parents:
diff changeset
   123
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   124
194eb0590b1e Initial revision
claus
parents:
diff changeset
   125
value
68
claus
parents: 66
diff changeset
   126
    "return my value"
claus
parents: 66
diff changeset
   127
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   128
    ^ value
194eb0590b1e Initial revision
claus
parents:
diff changeset
   129
! !
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   130
385
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   131
!ValueHolder methodsFor:'converting'!
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   132
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   133
asValue
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   134
    ^ self
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   135
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   136
    "Created: 25.1.1997 / 18:49:45 / cg"
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   137
! !
319da90bf85a reimplemented asValue to return the receiver
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   138
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   139
!ValueHolder methodsFor:'printing & storing'!
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   140
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   141
displayString
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   142
    "return a string for display in inspectors etc."
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   143
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   144
    ^ self class name , '(' , value displayString , ')'
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   145
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   146
    "Modified: 20.9.1997 / 11:42:02 / cg"
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   147
! !
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   148
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   149
!ValueHolder class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   150
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   151
version
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   152
    ^ '$Header: /cvs/stx/stx/libview2/ValueHolder.st,v 1.17 1997-09-20 22:19:46 cg Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   153
! !