author | Claus Gittinger <cg@exept.de> |
Wed, 23 Aug 2006 01:58:25 +0200 | |
changeset 2165 | 308101564aa0 |
parent 1362 | 7536d349a9b6 |
child 2770 | e7356633519a |
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 |
||
125 | 13 |
ValueModel subclass:#ValueHolder |
223 | 14 |
instanceVariableNames:'value' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
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 |
||
231 | 42 |
Notice: |
43 |
this class was implemented using protocol information |
|
44 |
from alpha testers - it may not be complete or compatible to |
|
45 |
the corresponding ST-80 class. |
|
46 |
If you encounter any incompatibilities, please forward a note |
|
47 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
223 | 48 |
|
49 |
[author:] |
|
50 |
Claus Gittinger |
|
68 | 51 |
" |
71 | 52 |
! |
53 |
||
54 |
examples |
|
55 |
" |
|
231 | 56 |
See many examples in DialogBox & EditField |
71 | 57 |
|
231 | 58 |
edit strings: |
59 |
[exBegin] |
|
60 |
|firstName lastName dialog| |
|
71 | 61 |
|
231 | 62 |
firstName := ValueHolder newString. |
63 |
lastName := ValueHolder newString. |
|
71 | 64 |
|
231 | 65 |
dialog := Dialog new. |
66 |
(dialog addTextLabel:'Name:') adjust:#left. |
|
67 |
dialog addInputFieldOn:firstName. |
|
68 |
dialog addVerticalSpace. |
|
69 |
(dialog addTextLabel:'Address:') adjust:#left. |
|
70 |
dialog addInputFieldOn:lastName. |
|
71 | 71 |
|
231 | 72 |
dialog addAbortButton; addOkButton. |
71 | 73 |
|
231 | 74 |
dialog open. |
75 |
dialog accepted ifTrue:[ |
|
268 | 76 |
Transcript show:firstName value; show:' '; showCR:lastName value |
231 | 77 |
] |
78 |
[exEnd] |
|
71 | 79 |
" |
68 | 80 |
! ! |
81 |
||
62 | 82 |
!ValueHolder class methodsFor:'instance creation'! |
83 |
||
125 | 84 |
newBoolean |
85 |
"return a new ValueHolder holding false as initial value" |
|
86 |
||
87 |
^ self with:false |
|
88 |
! |
|
68 | 89 |
|
125 | 90 |
newFraction |
91 |
"return a new ValueHolder holding 0.0 as initial value. |
|
92 |
The name is somewhat missleading - actually it should be called newFloat." |
|
93 |
||
94 |
^ self with:0.0 |
|
95 |
! |
|
96 |
||
97 |
newNumber |
|
98 |
"return a new ValueHolder holding 0 as initial value" |
|
99 |
||
100 |
^ self with:0 |
|
62 | 101 |
! |
102 |
||
103 |
newString |
|
68 | 104 |
"return a new ValueHolder holding an empty string as initial value" |
105 |
||
62 | 106 |
^ self with:'' |
107 |
! |
|
108 |
||
125 | 109 |
with:anObject |
110 |
"return a new ValueHolder holding anObject as initial value" |
|
68 | 111 |
|
125 | 112 |
^ (super new) setValue:anObject |
62 | 113 |
! ! |
114 |
||
115 |
!ValueHolder methodsFor:'accessing'! |
|
116 |
||
69 | 117 |
setValue:anObject |
118 |
"set my value without notification." |
|
62 | 119 |
|
120 |
value := anObject. |
|
121 |
! |
|
122 |
||
123 |
value |
|
68 | 124 |
"return my value" |
125 |
||
62 | 126 |
^ value |
127 |
! ! |
|
125 | 128 |
|
156 | 129 |
!ValueHolder methodsFor:'printing & storing'! |
130 |
||
131 |
displayString |
|
700 | 132 |
"return a string for display in inspectors etc." |
133 |
||
156 | 134 |
^ self class name , '(' , value displayString , ')' |
700 | 135 |
|
136 |
"Modified: 20.9.1997 / 11:42:02 / cg" |
|
156 | 137 |
! ! |
138 |
||
129 | 139 |
!ValueHolder class methodsFor:'documentation'! |
140 |
||
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 | 143 |
! ! |