ValueHolder.st
author Claus Gittinger <cg@exept.de>
Fri, 04 Apr 2003 19:07:54 +0200
changeset 1737 a1ed08195ee7
parent 1362 7536d349a9b6
child 2770 e7356633519a
permissions -rw-r--r--
refactorings
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
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    13
ValueModel subclass:#ValueHolder
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    14
	instanceVariableNames:'value'
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    15
	classVariableNames:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    16
	poolDictionaries:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    17
	category:'Interface-Support-Models'
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    18
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
    19
68
claus
parents: 66
diff changeset
    20
!ValueHolder class methodsFor:'documentation'!
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: 69
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
"
69
claus
parents: 68
diff changeset
    38
    a valueHolder can be used as a model for editFields, buttons etc.
68
claus
parents: 66
diff changeset
    39
    It stores some value internally, and sends update messages to its
claus
parents: 66
diff changeset
    40
    dependents when changed.
claus
parents: 66
diff changeset
    41
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    42
    Notice: 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    43
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    44
        from alpha testers - it may not be complete or compatible to
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    45
        the corresponding ST-80 class. 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    46
        If you encounter any incompatibilities, please forward a note 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    47
        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
    48
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    49
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
    50
        Claus Gittinger
68
claus
parents: 66
diff changeset
    51
"
71
claus
parents: 69
diff changeset
    52
!
claus
parents: 69
diff changeset
    53
claus
parents: 69
diff changeset
    54
examples 
claus
parents: 69
diff changeset
    55
"
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    56
    See many examples in DialogBox & EditField
71
claus
parents: 69
diff changeset
    57
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    58
    edit strings:
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    59
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    60
        |firstName lastName dialog|
71
claus
parents: 69
diff changeset
    61
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    62
        firstName := ValueHolder newString.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    63
        lastName := ValueHolder newString.
71
claus
parents: 69
diff changeset
    64
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    65
        dialog := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    66
        (dialog addTextLabel:'Name:') adjust:#left.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    67
        dialog addInputFieldOn:firstName.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    68
        dialog addVerticalSpace.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    69
        (dialog addTextLabel:'Address:') adjust:#left.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    70
        dialog addInputFieldOn:lastName.
71
claus
parents: 69
diff changeset
    71
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    72
        dialog addAbortButton; addOkButton.
71
claus
parents: 69
diff changeset
    73
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    74
        dialog open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    75
        dialog accepted ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    76
            Transcript show:firstName value; show:' '; showCR:lastName value
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    77
        ]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    78
                                                                        [exEnd]
71
claus
parents: 69
diff changeset
    79
"
68
claus
parents: 66
diff changeset
    80
! !
claus
parents: 66
diff changeset
    81
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
    82
!ValueHolder class methodsFor:'instance creation'!
194eb0590b1e Initial revision
claus
parents:
diff changeset
    83
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    84
newBoolean
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    85
    "return a new ValueHolder holding false as initial value"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    86
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    87
    ^ self with:false
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    88
!
68
claus
parents: 66
diff changeset
    89
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    90
newFraction
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    91
    "return a new ValueHolder holding 0.0 as initial value.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    92
     The name is somewhat missleading - actually it should be called newFloat."
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    93
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    94
    ^ self with:0.0 
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
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    97
newNumber
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    98
    "return a new ValueHolder holding 0 as initial value"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    99
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   100
    ^ self with:0 
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   101
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   102
194eb0590b1e Initial revision
claus
parents:
diff changeset
   103
newString
68
claus
parents: 66
diff changeset
   104
    "return a new ValueHolder holding an empty string as initial value"
claus
parents: 66
diff changeset
   105
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   106
    ^ self with:''
194eb0590b1e Initial revision
claus
parents:
diff changeset
   107
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   108
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   109
with:anObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   110
    "return a new ValueHolder holding anObject as initial value"
68
claus
parents: 66
diff changeset
   111
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   112
    ^ (super new) setValue:anObject
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   113
! !
194eb0590b1e Initial revision
claus
parents:
diff changeset
   114
194eb0590b1e Initial revision
claus
parents:
diff changeset
   115
!ValueHolder methodsFor:'accessing'!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   116
69
claus
parents: 68
diff changeset
   117
setValue:anObject
claus
parents: 68
diff changeset
   118
    "set my value without notification."
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   119
194eb0590b1e Initial revision
claus
parents:
diff changeset
   120
    value := anObject.
194eb0590b1e Initial revision
claus
parents:
diff changeset
   121
!
194eb0590b1e Initial revision
claus
parents:
diff changeset
   122
194eb0590b1e Initial revision
claus
parents:
diff changeset
   123
value
68
claus
parents: 66
diff changeset
   124
    "return my value"
claus
parents: 66
diff changeset
   125
62
194eb0590b1e Initial revision
claus
parents:
diff changeset
   126
    ^ value
194eb0590b1e Initial revision
claus
parents:
diff changeset
   127
! !
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   128
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   129
!ValueHolder methodsFor:'printing & storing'!
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   130
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   131
displayString
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   132
    "return a string for display in inspectors etc."
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   133
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   134
    ^ self class name , '(' , value displayString , ')'
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   135
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
   136
    "Modified: 20.9.1997 / 11:42:02 / cg"
156
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   137
! !
c1b01254e4cd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
   138
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   139
!ValueHolder class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   140
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   141
version
1362
7536d349a9b6 #asValue is defined in superclass
Stefan Vogel <sv@exept.de>
parents: 700
diff changeset
   142
    ^ '$Header: /cvs/stx/stx/libview2/ValueHolder.st,v 1.18 2000-03-14 17:16:44 stefan Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   143
! !