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