1797
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
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 |
|
1796
|
13 |
"{ Package: 'stx:libview2' }"
|
|
14 |
|
|
15 |
ValueModel subclass:#IndirectValue
|
|
16 |
instanceVariableNames:'valueHolder'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-Support-Models'
|
|
20 |
!
|
|
21 |
|
|
22 |
!IndirectValue class methodsFor:'documentation'!
|
|
23 |
|
1797
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
27 |
All Rights Reserved
|
|
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 |
|
1796
|
38 |
documentation
|
|
39 |
"
|
|
40 |
IndirectValue referes to another valueHolder and presents that holders value
|
|
41 |
as my own value.
|
|
42 |
However, the holder can be changed, which results in a change message from myself.
|
|
43 |
Can be used if a valueHolder is needed which represents different values over
|
|
44 |
time, for example, a line/column holder for a notebook-like multi-codeView
|
|
45 |
application, where the line/col holder is switched whenever the tab is switched.
|
|
46 |
(use an IndirectValue as holder of the line/col labels).
|
|
47 |
|
|
48 |
[author:]
|
|
49 |
Claus Gittinger
|
|
50 |
"
|
|
51 |
!
|
|
52 |
|
|
53 |
examples
|
|
54 |
"
|
|
55 |
a label alternatively showing the value of 2 other valueHolders:
|
|
56 |
[exBegin]
|
|
57 |
|holder1 holder2 indirVal lbl|
|
|
58 |
|
|
59 |
holder1 := '1' asValue.
|
|
60 |
holder2 := '2' asValue.
|
|
61 |
indirVal := IndirectValue for:holder1.
|
|
62 |
|
|
63 |
lbl := Label new.
|
|
64 |
lbl labelChannel:indirVal.
|
|
65 |
lbl open.
|
|
66 |
lbl waitUntilVisible.
|
|
67 |
|
|
68 |
Delay waitForSeconds:2.
|
|
69 |
indirVal valueHolder:holder2.
|
|
70 |
|
|
71 |
Delay waitForSeconds:2.
|
|
72 |
indirVal valueHolder:holder1.
|
|
73 |
[exEnd]
|
|
74 |
"
|
|
75 |
! !
|
|
76 |
|
|
77 |
!IndirectValue class methodsFor:'instance creation'!
|
|
78 |
|
|
79 |
for:aValueHolder
|
|
80 |
"return a new IndirectValue presenting aValueHolder"
|
|
81 |
|
|
82 |
^ self new setValueHolder:aValueHolder
|
|
83 |
! !
|
|
84 |
|
|
85 |
!IndirectValue methodsFor:'accessing'!
|
|
86 |
|
|
87 |
setValue:newValue
|
|
88 |
"physically set my value, without change notifications"
|
|
89 |
|
|
90 |
valueHolder setValue:newValue
|
|
91 |
!
|
|
92 |
|
|
93 |
setValueHolder:aValueHolder
|
|
94 |
"change my holder"
|
|
95 |
|
|
96 |
valueHolder notNil ifTrue:[
|
|
97 |
valueHolder removeDependent:self.
|
|
98 |
].
|
|
99 |
valueHolder := aValueHolder.
|
|
100 |
valueHolder notNil ifTrue:[
|
|
101 |
valueHolder addDependent:self.
|
|
102 |
].
|
|
103 |
!
|
|
104 |
|
|
105 |
value
|
|
106 |
"return my value"
|
|
107 |
|
|
108 |
^ valueHolder value
|
|
109 |
!
|
|
110 |
|
1984
|
111 |
valueHolder
|
|
112 |
"return my valueHolder"
|
|
113 |
|
|
114 |
^ valueHolder
|
|
115 |
!
|
|
116 |
|
1796
|
117 |
valueHolder:aValueHolder
|
|
118 |
"change my holder"
|
|
119 |
|
|
120 |
|oldValue|
|
|
121 |
|
|
122 |
oldValue := valueHolder value.
|
|
123 |
self setValueHolder:aValueHolder.
|
|
124 |
oldValue ~~ valueHolder value ifTrue:[
|
|
125 |
self changed:#value
|
|
126 |
].
|
|
127 |
! !
|
|
128 |
|
1921
|
129 |
!IndirectValue methodsFor:'change & update'!
|
1796
|
130 |
|
|
131 |
update:something with:aParameter from:someone
|
|
132 |
"the holder I depend on has changed - send a change notification to my dependents"
|
|
133 |
|
|
134 |
self changed:#value
|
|
135 |
! !
|
|
136 |
|
|
137 |
!IndirectValue class methodsFor:'documentation'!
|
|
138 |
|
|
139 |
version
|
1984
|
140 |
^ '$Header: /cvs/stx/stx/libview2/IndirectValue.st,v 1.4 2004-05-18 11:47:52 cg Exp $'
|
1796
|
141 |
! !
|