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