author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:05:49 +0100 | |
changeset 114 | e577a2f332d0 |
parent 96 | 948318b2fbd4 |
child 125 | fa5b5e4336bf |
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 |
||
62 | 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 |
||
36 |
version |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
96
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libview2/ValueHolder.st,v 1.9 1995-11-11 16:05:27 cg Exp $' |
69 | 38 |
! |
39 |
||
68 | 40 |
documentation |
41 |
" |
|
69 | 42 |
a valueHolder can be used as a model for editFields, buttons etc. |
68 | 43 |
It stores some value internally, and sends update messages to its |
44 |
dependents when changed. |
|
45 |
||
46 |
Notice: this class was implemented using protocol information |
|
47 |
from alpha testers - it may not be complete or compatible to |
|
48 |
the corresponding ST-80 class. If you encounter any incompatibilities, |
|
49 |
please forward a note to the ST/X team. |
|
50 |
" |
|
71 | 51 |
! |
52 |
||
53 |
examples |
|
54 |
" |
|
55 |
edit strings: |
|
56 |
||
57 |
|firstName lastName dialog| |
|
58 |
||
59 |
firstName := ValueHolder newString. |
|
60 |
lastName := ValueHolder newString. |
|
61 |
||
62 |
dialog := Dialog new. |
|
83 | 63 |
(dialog addTextLabel:'Name:') adjust:#left. |
71 | 64 |
dialog addInputFieldOn:firstName. |
65 |
dialog addVerticalSpace. |
|
83 | 66 |
(dialog addTextLabel:'Address:') adjust:#left. |
71 | 67 |
dialog addInputFieldOn:lastName. |
68 |
||
69 |
dialog addAbortButton; addOkButton. |
|
70 |
||
71 |
dialog open. |
|
72 |
dialog accepted ifTrue:[ |
|
73 |
Transcript show:firstName value; show:' '; showCr:lastName value |
|
74 |
] |
|
75 |
" |
|
68 | 76 |
! ! |
77 |
||
62 | 78 |
!ValueHolder class methodsFor:'instance creation'! |
79 |
||
80 |
with:anObject |
|
68 | 81 |
"return a new ValueHolder holding anObject as initial value" |
82 |
||
69 | 83 |
^ (super new) setValue:anObject |
62 | 84 |
! |
85 |
||
86 |
newString |
|
68 | 87 |
"return a new ValueHolder holding an empty string as initial value" |
88 |
||
62 | 89 |
^ self with:'' |
90 |
! |
|
91 |
||
92 |
newBoolean |
|
68 | 93 |
"return a new ValueHolder holding false as initial value" |
94 |
||
62 | 95 |
^ self with:false |
68 | 96 |
! |
97 |
||
98 |
newNumber |
|
99 |
"return a new ValueHolder holding 0 as initial value" |
|
100 |
||
101 |
^ self with:0 |
|
102 |
! |
|
103 |
||
104 |
newFraction |
|
105 |
"return a new ValueHolder holding 0.0 as initial value. |
|
106 |
The name is somewhat missleading - actually it should be called newFloat." |
|
107 |
||
108 |
^ self with:0.0 |
|
62 | 109 |
! ! |
110 |
||
111 |
!ValueHolder methodsFor:'accessing'! |
|
112 |
||
69 | 113 |
setValue:anObject |
114 |
"set my value without notification." |
|
62 | 115 |
|
116 |
value := anObject. |
|
117 |
! |
|
118 |
||
119 |
value |
|
68 | 120 |
"return my value" |
121 |
||
62 | 122 |
^ value |
123 |
! ! |