author | Claus Gittinger <cg@exept.de> |
Fri, 03 Jan 2020 14:52:47 +0100 | |
changeset 4420 | 1ee60327c114 |
parent 3319 | 2b9a15e04435 |
permissions | -rw-r--r-- |
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 |
" |
|
1796 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
14 |
ValueModel subclass:#IndirectValue |
|
15 |
instanceVariableNames:'valueHolder' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Support-Models' |
|
19 |
! |
|
20 |
||
21 |
!IndirectValue class methodsFor:'documentation'! |
|
22 |
||
1797 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2003 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
1796 | 37 |
documentation |
38 |
" |
|
3319 | 39 |
IndirectValue refers to another valueHolder and presents that holder's value |
1796 | 40 |
as my own value. |
41 |
However, the holder can be changed, which results in a change message from myself. |
|
42 |
Can be used if a valueHolder is needed which represents different values over |
|
43 |
time, for example, a line/column holder for a notebook-like multi-codeView |
|
44 |
application, where the line/col holder is switched whenever the tab is switched. |
|
45 |
(use an IndirectValue as holder of the line/col labels). |
|
2817 | 46 |
Another possible use is to synchronize two notebools via a common valueHolder, |
47 |
which is used as indirect-value for the two individual indirect-selection-valueholders. |
|
1796 | 48 |
|
49 |
[author:] |
|
50 |
Claus Gittinger |
|
51 |
" |
|
52 |
! |
|
53 |
||
54 |
examples |
|
55 |
" |
|
56 |
a label alternatively showing the value of 2 other valueHolders: |
|
57 |
[exBegin] |
|
58 |
|holder1 holder2 indirVal lbl| |
|
59 |
||
60 |
holder1 := '1' asValue. |
|
61 |
holder2 := '2' asValue. |
|
62 |
indirVal := IndirectValue for:holder1. |
|
63 |
||
64 |
lbl := Label new. |
|
65 |
lbl labelChannel:indirVal. |
|
66 |
lbl open. |
|
67 |
lbl waitUntilVisible. |
|
68 |
||
69 |
Delay waitForSeconds:2. |
|
70 |
indirVal valueHolder:holder2. |
|
71 |
||
72 |
Delay waitForSeconds:2. |
|
73 |
indirVal valueHolder:holder1. |
|
74 |
[exEnd] |
|
75 |
" |
|
76 |
! ! |
|
77 |
||
78 |
!IndirectValue class methodsFor:'instance creation'! |
|
79 |
||
80 |
for:aValueHolder |
|
81 |
"return a new IndirectValue presenting aValueHolder" |
|
82 |
||
83 |
^ self new setValueHolder:aValueHolder |
|
84 |
! ! |
|
85 |
||
86 |
!IndirectValue methodsFor:'accessing'! |
|
87 |
||
88 |
setValue:newValue |
|
89 |
"physically set my value, without change notifications" |
|
90 |
||
2816 | 91 |
valueHolder |
92 |
value:newValue |
|
93 |
withoutNotifying:self |
|
1796 | 94 |
! |
95 |
||
96 |
setValueHolder:aValueHolder |
|
97 |
"change my holder" |
|
98 |
||
99 |
valueHolder notNil ifTrue:[ |
|
100 |
valueHolder removeDependent:self. |
|
101 |
]. |
|
102 |
valueHolder := aValueHolder. |
|
103 |
valueHolder notNil ifTrue:[ |
|
104 |
valueHolder addDependent:self. |
|
105 |
]. |
|
106 |
! |
|
107 |
||
108 |
value |
|
109 |
"return my value" |
|
110 |
||
111 |
^ valueHolder value |
|
112 |
! |
|
113 |
||
1984 | 114 |
valueHolder |
115 |
"return my valueHolder" |
|
116 |
||
117 |
^ valueHolder |
|
118 |
! |
|
119 |
||
1796 | 120 |
valueHolder:aValueHolder |
121 |
"change my holder" |
|
122 |
||
123 |
|oldValue| |
|
124 |
||
125 |
oldValue := valueHolder value. |
|
126 |
self setValueHolder:aValueHolder. |
|
127 |
oldValue ~~ valueHolder value ifTrue:[ |
|
128 |
self changed:#value |
|
129 |
]. |
|
130 |
! ! |
|
131 |
||
1921 | 132 |
!IndirectValue methodsFor:'change & update'! |
1796 | 133 |
|
134 |
update:something with:aParameter from:someone |
|
135 |
"the holder I depend on has changed - send a change notification to my dependents" |
|
136 |
||
2029
136dd7e8228a
pass change information from update
Claus Gittinger <cg@exept.de>
parents:
1984
diff
changeset
|
137 |
self changed:something with:aParameter |
1796 | 138 |
! ! |
139 |
||
140 |
!IndirectValue class methodsFor:'documentation'! |
|
141 |
||
142 |
version |
|
3319 | 143 |
^ '$Header: /cvs/stx/stx/libview2/IndirectValue.st,v 1.9 2014-03-26 21:59:54 cg Exp $' |
2816 | 144 |
! |
145 |
||
146 |
version_CVS |
|
3319 | 147 |
^ '$Header: /cvs/stx/stx/libview2/IndirectValue.st,v 1.9 2014-03-26 21:59:54 cg Exp $' |
1796 | 148 |
! ! |
3319 | 149 |