120
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 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 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
Object subclass:#ResourceRetriever
|
|
17 |
instanceVariableNames:'className resourceOwner selector labelText'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
200
|
20 |
category:'Interface-Support-UI'
|
120
|
21 |
!
|
|
22 |
|
|
23 |
!ResourceRetriever class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
373
|
44 |
ST80 compatibility class.
|
|
45 |
|
|
46 |
The class is not completed yet and certainly not bug free.
|
|
47 |
Also, it is not guaranteed that all winSpecs are understood.
|
120
|
48 |
|
373
|
49 |
Notice:
|
|
50 |
this class was implemented using protocol information
|
|
51 |
from alpha testers, literature and by reading public domain code
|
|
52 |
- it may not be complete or compatible to
|
|
53 |
the corresponding ST-80 class.
|
|
54 |
If you encounter any incompatibilities, please forward a note
|
|
55 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
120
|
56 |
|
|
57 |
[author:]
|
|
58 |
Claus Atzkern
|
|
59 |
|
|
60 |
[see also:]
|
|
61 |
Application
|
|
62 |
Menu
|
|
63 |
MenuItem
|
|
64 |
"
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
! !
|
|
69 |
|
|
70 |
!ResourceRetriever methodsFor:'accessing'!
|
|
71 |
|
|
72 |
className
|
|
73 |
"return the value of the instance variable 'className' (automatically generated)"
|
|
74 |
|
|
75 |
^ className!
|
|
76 |
|
|
77 |
className:something
|
|
78 |
"set the class which provides the resources
|
|
79 |
"
|
|
80 |
className := something.
|
|
81 |
resourceOwner := nil.
|
|
82 |
!
|
|
83 |
|
198
|
84 |
labelText
|
|
85 |
^ labelText
|
|
86 |
!
|
|
87 |
|
|
88 |
labelText:aText
|
|
89 |
labelText := aText
|
|
90 |
!
|
|
91 |
|
120
|
92 |
selector
|
|
93 |
"return the value of the instance variable 'selector' (automatically generated)"
|
|
94 |
|
|
95 |
^ selector!
|
|
96 |
|
|
97 |
selector:something
|
|
98 |
"set the value of the instance variable 'selector' (automatically generated)"
|
|
99 |
|
|
100 |
selector := something.
|
|
101 |
!
|
|
102 |
|
|
103 |
value
|
373
|
104 |
"returns the value assigned to resource or nil
|
120
|
105 |
"
|
|
106 |
|resource|
|
|
107 |
|
|
108 |
(resource := self resource) isNil ifTrue:[
|
|
109 |
^ labelText
|
|
110 |
].
|
|
111 |
|
|
112 |
(labelText notNil and:[resource isImage]) ifTrue:[
|
|
113 |
^ LabelAndIcon icon:resource string:(Text string:labelText emphasis:#bold)
|
|
114 |
].
|
|
115 |
^ resource
|
373
|
116 |
|
|
117 |
"Modified: / 31.10.1997 / 12:10:05 / cg"
|
120
|
118 |
! !
|
|
119 |
|
|
120 |
!ResourceRetriever methodsFor:'accessing resource'!
|
|
121 |
|
|
122 |
findGuiResourcesIn:aResourceContainer
|
|
123 |
"setup a resource owner
|
|
124 |
"
|
|
125 |
className isNil ifTrue:[
|
|
126 |
resourceOwner := aResourceContainer
|
|
127 |
].
|
|
128 |
!
|
|
129 |
|
|
130 |
resource
|
373
|
131 |
"returns a form assigned to resource or nil
|
120
|
132 |
"
|
331
|
133 |
|img cls appl|
|
226
|
134 |
|
120
|
135 |
selector isNil ifTrue:[
|
|
136 |
^nil
|
|
137 |
].
|
|
138 |
|
|
139 |
resourceOwner isNil ifTrue:[
|
343
|
140 |
(resourceOwner := Smalltalk resolveName:className inClass:self class) isNil ifTrue:[
|
120
|
141 |
^ nil
|
|
142 |
]
|
|
143 |
].
|
320
|
144 |
|
226
|
145 |
(resourceOwner respondsTo:#visualFor:) ifTrue:[
|
|
146 |
(img := resourceOwner visualFor:selector) notNil ifTrue:[
|
|
147 |
^ img
|
|
148 |
]
|
|
149 |
].
|
320
|
150 |
|
|
151 |
(resourceOwner respondsTo:selector) ifTrue:[
|
|
152 |
^ resourceOwner perform:selector
|
|
153 |
].
|
|
154 |
|
|
155 |
resourceOwner isClass ifFalse:[
|
|
156 |
cls := resourceOwner class.
|
|
157 |
|
|
158 |
(cls respondsTo:selector) ifTrue:[
|
|
159 |
^ cls perform:selector
|
|
160 |
]
|
|
161 |
].
|
|
162 |
^ nil
|
|
163 |
|
373
|
164 |
"Modified: / 31.10.1997 / 12:09:52 / cg"
|
120
|
165 |
! !
|
|
166 |
|
|
167 |
!ResourceRetriever methodsFor:'converting'!
|
|
168 |
|
|
169 |
fromLiteralArrayEncoding:anArray
|
|
170 |
"read my values from an encoding.
|
|
171 |
"
|
|
172 |
className := anArray at: 2.
|
|
173 |
selector := anArray at: 3.
|
|
174 |
|
|
175 |
anArray size == 4 ifTrue:[
|
|
176 |
labelText := anArray at:4
|
|
177 |
].
|
|
178 |
resourceOwner := nil.
|
|
179 |
|
|
180 |
!
|
|
181 |
|
|
182 |
literalArrayEncoding
|
|
183 |
"encode myself as an array, from which a copy of the receiver can be
|
|
184 |
reconstructed with #decodeAsLiteralArray.
|
|
185 |
|
|
186 |
The encoding is:
|
|
187 |
(#ResourceRetriever className selector)
|
|
188 |
|
|
189 |
or if labelText not nil:
|
|
190 |
(#ResourceRetriever className selector labelText)
|
|
191 |
"
|
|
192 |
labelText isNil ifTrue:[
|
|
193 |
^ Array with:(self class name) with:className with:selector
|
|
194 |
] ifFalse:[
|
|
195 |
^ Array with:(self class name) with:className with:selector with:labelText
|
|
196 |
].
|
|
197 |
|
|
198 |
! !
|
|
199 |
|
|
200 |
!ResourceRetriever methodsFor:'testing'!
|
|
201 |
|
|
202 |
isDefined
|
|
203 |
"returns true if resource exists
|
|
204 |
"
|
|
205 |
selector notNil ifTrue:[
|
|
206 |
^ (resourceOwner notNil or:[className notNil])
|
|
207 |
].
|
|
208 |
^ false
|
|
209 |
!
|
|
210 |
|
|
211 |
notDefined
|
|
212 |
"returns false if resource is not defined
|
|
213 |
"
|
|
214 |
self isDefined ifTrue:[^ false ]
|
|
215 |
ifFalse:[^ true ]
|
|
216 |
! !
|
|
217 |
|
|
218 |
!ResourceRetriever class methodsFor:'documentation'!
|
|
219 |
|
|
220 |
version
|
|
221 |
^ '$Header$'
|
|
222 |
! !
|