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 |
"
|
|
12 |
|
125
|
13 |
ValueModel subclass:#ValueHolder
|
69
|
14 |
instanceVariableNames:'value'
|
62
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
71
|
17 |
category:'Interface-Support-Models'
|
62
|
18 |
!
|
|
19 |
|
68
|
20 |
!ValueHolder class methodsFor:'documentation'!
|
|
21 |
|
69
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
71
|
25 |
All Rights Reserved
|
69
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
68
|
36 |
documentation
|
|
37 |
"
|
69
|
38 |
a valueHolder can be used as a model for editFields, buttons etc.
|
68
|
39 |
It stores some value internally, and sends update messages to its
|
|
40 |
dependents when changed.
|
|
41 |
|
|
42 |
Notice: this class was implemented using protocol information
|
|
43 |
from alpha testers - it may not be complete or compatible to
|
|
44 |
the corresponding ST-80 class. If you encounter any incompatibilities,
|
|
45 |
please forward a note to the ST/X team.
|
|
46 |
"
|
71
|
47 |
!
|
|
48 |
|
|
49 |
examples
|
|
50 |
"
|
|
51 |
edit strings:
|
|
52 |
|
|
53 |
|firstName lastName dialog|
|
|
54 |
|
|
55 |
firstName := ValueHolder newString.
|
|
56 |
lastName := ValueHolder newString.
|
|
57 |
|
|
58 |
dialog := Dialog new.
|
83
|
59 |
(dialog addTextLabel:'Name:') adjust:#left.
|
71
|
60 |
dialog addInputFieldOn:firstName.
|
|
61 |
dialog addVerticalSpace.
|
83
|
62 |
(dialog addTextLabel:'Address:') adjust:#left.
|
71
|
63 |
dialog addInputFieldOn:lastName.
|
|
64 |
|
|
65 |
dialog addAbortButton; addOkButton.
|
|
66 |
|
|
67 |
dialog open.
|
|
68 |
dialog accepted ifTrue:[
|
|
69 |
Transcript show:firstName value; show:' '; showCr:lastName value
|
|
70 |
]
|
|
71 |
"
|
68
|
72 |
! !
|
|
73 |
|
62
|
74 |
!ValueHolder class methodsFor:'instance creation'!
|
|
75 |
|
125
|
76 |
newBoolean
|
|
77 |
"return a new ValueHolder holding false as initial value"
|
|
78 |
|
|
79 |
^ self with:false
|
|
80 |
!
|
68
|
81 |
|
125
|
82 |
newFraction
|
|
83 |
"return a new ValueHolder holding 0.0 as initial value.
|
|
84 |
The name is somewhat missleading - actually it should be called newFloat."
|
|
85 |
|
|
86 |
^ self with:0.0
|
|
87 |
!
|
|
88 |
|
|
89 |
newNumber
|
|
90 |
"return a new ValueHolder holding 0 as initial value"
|
|
91 |
|
|
92 |
^ self with:0
|
62
|
93 |
!
|
|
94 |
|
|
95 |
newString
|
68
|
96 |
"return a new ValueHolder holding an empty string as initial value"
|
|
97 |
|
62
|
98 |
^ self with:''
|
|
99 |
!
|
|
100 |
|
125
|
101 |
with:anObject
|
|
102 |
"return a new ValueHolder holding anObject as initial value"
|
68
|
103 |
|
125
|
104 |
^ (super new) setValue:anObject
|
62
|
105 |
! !
|
|
106 |
|
|
107 |
!ValueHolder methodsFor:'accessing'!
|
|
108 |
|
69
|
109 |
setValue:anObject
|
|
110 |
"set my value without notification."
|
62
|
111 |
|
|
112 |
value := anObject.
|
|
113 |
!
|
|
114 |
|
|
115 |
value
|
68
|
116 |
"return my value"
|
|
117 |
|
62
|
118 |
^ value
|
|
119 |
! !
|
125
|
120 |
|
129
|
121 |
!ValueHolder class methodsFor:'documentation'!
|
|
122 |
|
|
123 |
version
|
|
124 |
^ '$Header: /cvs/stx/stx/libview2/Attic/ValHolder.st,v 1.11 1995-11-23 17:48:56 cg Exp $'
|
|
125 |
! !
|