author | tz |
Wed, 04 Feb 1998 16:37:25 +0100 | |
changeset 582 | 3343d860b400 |
parent 476 | 05adf036c0ac |
child 815 | b2b9356a648c |
permissions | -rw-r--r-- |
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 |
||
399 | 23 |
ResourceRetriever class instanceVariableNames:'LabelResources' |
24 |
||
25 |
" |
|
26 |
The following class instance variables are inherited by this class: |
|
27 |
||
28 |
Object - |
|
29 |
" |
|
30 |
! |
|
31 |
||
120 | 32 |
!ResourceRetriever class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
||
47 |
||
48 |
||
49 |
! |
|
50 |
||
51 |
documentation |
|
52 |
" |
|
373 | 53 |
ST80 compatibility class. |
54 |
||
55 |
The class is not completed yet and certainly not bug free. |
|
56 |
Also, it is not guaranteed that all winSpecs are understood. |
|
120 | 57 |
|
373 | 58 |
Notice: |
59 |
this class was implemented using protocol information |
|
60 |
from alpha testers, literature and by reading public domain code |
|
61 |
- it may not be complete or compatible to |
|
62 |
the corresponding ST-80 class. |
|
63 |
If you encounter any incompatibilities, please forward a note |
|
64 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
120 | 65 |
|
66 |
[author:] |
|
67 |
Claus Atzkern |
|
68 |
||
69 |
[see also:] |
|
70 |
Application |
|
71 |
Menu |
|
72 |
MenuItem |
|
73 |
" |
|
74 |
||
75 |
||
76 |
||
77 |
! ! |
|
78 |
||
399 | 79 |
!ResourceRetriever class methodsFor:'accessing resource'! |
80 |
||
81 |
findResourceLabel: label in: aResourceOwner |
|
82 |
"look for a string |
|
83 |
in aResourceOwner, |
|
84 |
in class of aResourceOwner, |
|
85 |
in resources of class of aResourceOwner, |
|
86 |
and finally in my label resources |
|
87 |
" |
|
88 |
||
89 |
aResourceOwner isNil ifTrue: [^label]. |
|
90 |
||
91 |
label isSymbol |
|
92 |
ifTrue: |
|
93 |
[ |
|
94 |
(aResourceOwner respondsTo: label) |
|
95 |
ifTrue: |
|
96 |
[ |
|
97 |
^aResourceOwner perform: label |
|
98 |
]. |
|
99 |
||
100 |
(aResourceOwner isClass not and: [aResourceOwner class respondsTo: label]) |
|
101 |
ifTrue: |
|
102 |
[ |
|
103 |
^aResourceOwner perform: label |
|
104 |
]. |
|
105 |
]. |
|
106 |
||
107 |
((aResourceOwner isKindOf: ApplicationModel) or: |
|
108 |
[aResourceOwner isKindOf: SimpleView]) |
|
109 |
ifTrue: |
|
110 |
[ |
|
111 |
^aResourceOwner resources string: label |
|
112 |
]. |
|
113 |
||
114 |
^self labelResources string:label |
|
115 |
||
116 |
! |
|
117 |
||
118 |
labelResources |
|
119 |
"if not already loaded, get the common label resourcePack |
|
120 |
and return it" |
|
121 |
||
122 |
LabelResources isNil ifTrue:[ |
|
123 |
LabelResources := ResourcePack for:self. |
|
124 |
]. |
|
125 |
^ LabelResources |
|
126 |
! ! |
|
127 |
||
120 | 128 |
!ResourceRetriever methodsFor:'accessing'! |
129 |
||
130 |
className |
|
131 |
"return the value of the instance variable 'className' (automatically generated)" |
|
132 |
||
133 |
^ className! |
|
134 |
||
135 |
className:something |
|
136 |
"set the class which provides the resources |
|
137 |
" |
|
138 |
className := something. |
|
139 |
resourceOwner := nil. |
|
140 |
! |
|
141 |
||
198 | 142 |
labelText |
143 |
^ labelText |
|
144 |
! |
|
145 |
||
146 |
labelText:aText |
|
147 |
labelText := aText |
|
148 |
! |
|
149 |
||
120 | 150 |
selector |
151 |
"return the value of the instance variable 'selector' (automatically generated)" |
|
152 |
||
153 |
^ selector! |
|
154 |
||
155 |
selector:something |
|
156 |
"set the value of the instance variable 'selector' (automatically generated)" |
|
157 |
||
158 |
selector := something. |
|
159 |
! |
|
160 |
||
161 |
value |
|
373 | 162 |
"returns the value assigned to resource or nil |
120 | 163 |
" |
164 |
|resource| |
|
165 |
||
166 |
(resource := self resource) isNil ifTrue:[ |
|
167 |
^ labelText |
|
168 |
]. |
|
169 |
||
170 |
(labelText notNil and:[resource isImage]) ifTrue:[ |
|
378
9057ea063eca
use font derived from style sheet; no default Text object
ca
parents:
373
diff
changeset
|
171 |
^ LabelAndIcon icon:resource string:labelText |
120 | 172 |
]. |
173 |
^ resource |
|
373 | 174 |
|
175 |
"Modified: / 31.10.1997 / 12:10:05 / cg" |
|
120 | 176 |
! ! |
177 |
||
178 |
!ResourceRetriever methodsFor:'accessing resource'! |
|
179 |
||
180 |
findGuiResourcesIn:aResourceContainer |
|
181 |
"setup a resource owner |
|
182 |
" |
|
183 |
className isNil ifTrue:[ |
|
184 |
resourceOwner := aResourceContainer |
|
185 |
]. |
|
186 |
! |
|
187 |
||
188 |
resource |
|
373 | 189 |
"returns a form assigned to resource or nil |
120 | 190 |
" |
331 | 191 |
|img cls appl| |
226 | 192 |
|
120 | 193 |
selector isNil ifTrue:[ |
194 |
^nil |
|
195 |
]. |
|
196 |
||
197 |
resourceOwner isNil ifTrue:[ |
|
343 | 198 |
(resourceOwner := Smalltalk resolveName:className inClass:self class) isNil ifTrue:[ |
120 | 199 |
^ nil |
200 |
] |
|
201 |
]. |
|
320 | 202 |
|
226 | 203 |
(resourceOwner respondsTo:#visualFor:) ifTrue:[ |
204 |
(img := resourceOwner visualFor:selector) notNil ifTrue:[ |
|
205 |
^ img |
|
206 |
] |
|
207 |
]. |
|
320 | 208 |
|
209 |
(resourceOwner respondsTo:selector) ifTrue:[ |
|
210 |
^ resourceOwner perform:selector |
|
211 |
]. |
|
212 |
||
213 |
resourceOwner isClass ifFalse:[ |
|
214 |
cls := resourceOwner class. |
|
215 |
||
216 |
(cls respondsTo:selector) ifTrue:[ |
|
217 |
^ cls perform:selector |
|
218 |
] |
|
219 |
]. |
|
220 |
^ nil |
|
221 |
||
373 | 222 |
"Modified: / 31.10.1997 / 12:09:52 / cg" |
120 | 223 |
! ! |
224 |
||
225 |
!ResourceRetriever methodsFor:'converting'! |
|
226 |
||
227 |
fromLiteralArrayEncoding:anArray |
|
228 |
"read my values from an encoding. |
|
229 |
" |
|
230 |
className := anArray at: 2. |
|
231 |
selector := anArray at: 3. |
|
232 |
||
233 |
anArray size == 4 ifTrue:[ |
|
234 |
labelText := anArray at:4 |
|
235 |
]. |
|
236 |
resourceOwner := nil. |
|
237 |
||
238 |
! |
|
239 |
||
240 |
literalArrayEncoding |
|
241 |
"encode myself as an array, from which a copy of the receiver can be |
|
242 |
reconstructed with #decodeAsLiteralArray. |
|
243 |
||
244 |
The encoding is: |
|
245 |
(#ResourceRetriever className selector) |
|
246 |
||
247 |
or if labelText not nil: |
|
248 |
(#ResourceRetriever className selector labelText) |
|
249 |
" |
|
476 | 250 |
|myClassName| |
251 |
||
252 |
myClassName := self class name. |
|
120 | 253 |
labelText isNil ifTrue:[ |
476 | 254 |
^ Array with:myClassName with:className with:selector |
120 | 255 |
] ifFalse:[ |
476 | 256 |
^ Array with:myClassName with:className with:selector with:labelText |
120 | 257 |
]. |
258 |
||
476 | 259 |
"Modified: / 26.1.1998 / 13:52:43 / cg" |
120 | 260 |
! ! |
261 |
||
262 |
!ResourceRetriever methodsFor:'testing'! |
|
263 |
||
264 |
isDefined |
|
265 |
"returns true if resource exists |
|
266 |
" |
|
267 |
selector notNil ifTrue:[ |
|
268 |
^ (resourceOwner notNil or:[className notNil]) |
|
269 |
]. |
|
270 |
^ false |
|
271 |
! |
|
272 |
||
273 |
notDefined |
|
274 |
"returns false if resource is not defined |
|
275 |
" |
|
276 |
self isDefined ifTrue:[^ false ] |
|
277 |
ifFalse:[^ true ] |
|
278 |
! ! |
|
279 |
||
280 |
!ResourceRetriever class methodsFor:'documentation'! |
|
281 |
||
282 |
version |
|
283 |
^ '$Header$' |
|
284 |
! ! |