author | Claus Gittinger <cg@exept.de> |
Mon, 20 May 1996 09:26:04 +0200 | |
changeset 269 | 6c70d392634b |
parent 264 | 6c886ecb050d |
child 356 | 0f90fb1e9db9 |
permissions | -rw-r--r-- |
77 | 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 |
||
13 |
Object subclass:#Icon |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
14 |
instanceVariableNames:'image mask' |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
15 |
classVariableNames:'KnownIcons' |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
16 |
poolDictionaries:'' |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
17 |
category:'Graphics-Images' |
77 | 18 |
! |
19 |
||
20 |
!Icon class methodsFor:'documentation'! |
|
21 |
||
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
22 |
copyright |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
23 |
" |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
25 |
All Rights Reserved |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
26 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
27 |
This software is furnished under a license and may be used |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
28 |
only in accordance with the terms of that license and with the |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
29 |
inclusion of the above copyright notice. This software may not |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
30 |
be provided or otherwise made available to, or used by, any |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
31 |
other person. No title to or ownership of the software is |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
32 |
hereby transferred. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
33 |
" |
77 | 34 |
! |
35 |
||
36 |
documentation |
|
37 |
" |
|
193 | 38 |
The Icon class keeps track of already loaded Images and caches |
39 |
them for later reuse. |
|
40 |
Icons are accessed by a symbolic name, so there is no need to |
|
264 | 41 |
remember their names (they must have been registered under that name |
193 | 42 |
before - of course). |
43 |
||
44 |
Icon was mostly added for ST-80 Compatibility: |
|
264 | 45 |
|
193 | 46 |
Images are returned via the #constantNamed: message which is used by |
47 |
some ST-80 PD classes and returns corresponding ST/X icons. |
|
48 |
Notice, that ST/X does not provide Icon instances - Icon only consists |
|
49 |
of class mimicri protocol, to make your life easier. |
|
111 | 50 |
|
193 | 51 |
If you like the original ST-80 icons, install the image files in the `bitmap' |
52 |
directory under a name foo.xbm, where `foo' corresponds to the icons |
|
53 |
name symbol |
|
54 |
(i.e. for the `Icon constantNamed:#foo', a 'foo.xbm' file is required). |
|
111 | 55 |
|
193 | 56 |
You can grab those icons from manchester or from the PrimeTime Freeware |
57 |
(PTF) CD. A copy of those bitmaps (from the PTF-CD) is found in |
|
264 | 58 |
'goodies/bitmaps/st80bitmaps'. |
193 | 59 |
|
60 |
CAVEAT: |
|
61 |
masks are not yet implemented |
|
62 |
||
63 |
[See also:] |
|
64 |
Image Form ImageReader |
|
219 | 65 |
|
66 |
[author:] |
|
67 |
Claus Gittinger |
|
77 | 68 |
" |
69 |
! ! |
|
70 |
||
71 |
!Icon class methodsFor:'initialization'! |
|
72 |
||
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
73 |
initialize |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
74 |
KnownIcons isNil ifTrue:[ |
269 | 75 |
KnownIcons := Dictionary new |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
76 |
] |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
77 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
78 |
" |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
79 |
Icon initialize |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
80 |
" |
269 | 81 |
|
82 |
"Modified: 20.5.1996 / 09:24:10 / cg" |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
83 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
84 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
85 |
replacementNameFor:aName |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
86 |
"return a replacement ST/X name for an ST80 icon name." |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
87 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
88 |
self replacementNames do:[:aPair | |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
89 |
(aPair at:1) == aName ifTrue:[^ aPair at:2]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
90 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
91 |
^ nil |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
92 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
93 |
|
77 | 94 |
replacementNames |
264 | 95 |
"return an ST-80 constant name to ST/X file name translation. |
96 |
This was added for ST-80 compatibility, to support code which uses |
|
97 |
things like 'Icon constantNamed:#categoryBrowser'." |
|
77 | 98 |
|
99 |
^ #( |
|
264 | 100 |
#(file FBrowser) |
101 |
#(debugger Debugger) |
|
102 |
#(systembrowser SBrowser) |
|
103 |
#(classbrowser SBrowser) |
|
104 |
#(categoryBrowser SBrowser) |
|
105 |
#(hierarchyBrowser SBrowser) |
|
106 |
#(methodBrowser SBrowser) |
|
107 |
#(launcher SmalltalkX) |
|
108 |
#(workspace SmalltalkX) |
|
109 |
#(transcript SmalltalkX) |
|
110 |
#(inspector Inspector) |
|
111 |
#(default SmalltalkX) |
|
77 | 112 |
) |
264 | 113 |
|
114 |
" |
|
115 |
Icon constantNamed:#categoryBrowser |
|
116 |
Icon constantNamed:#default |
|
117 |
" |
|
118 |
||
119 |
"Modified: 13.5.1996 / 10:29:43 / cg" |
|
77 | 120 |
! ! |
121 |
||
193 | 122 |
!Icon class methodsFor:'accessing'! |
77 | 123 |
|
124 |
constantNamed:aName |
|
193 | 125 |
"return the image registered under aName." |
126 |
||
77 | 127 |
|icon nm| |
128 |
||
129 |
icon := KnownIcons at:aName ifAbsent:[]. |
|
130 |
icon isNil ifTrue:[ |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
131 |
nm := self replacementNameFor:aName. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
132 |
nm notNil ifTrue:[ |
179 | 133 |
icon := Image fromFile:('bitmaps/' , nm). |
134 |
icon isNil ifTrue:[ |
|
135 |
icon := Image fromFile:('bitmaps/' , nm , '.xbm'). |
|
136 |
] |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
137 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
138 |
icon isNil ifTrue:[ |
179 | 139 |
icon := Image fromFile:('bitmaps/' , aName). |
140 |
icon isNil ifTrue:[ |
|
141 |
icon := Image fromFile:('bitmaps/' , aName , '.xbm'). |
|
142 |
]. |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
143 |
icon isNil ifTrue:[ |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
144 |
('ICON: no icon named ' , aName) infoPrintNL. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
145 |
^ nil |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
146 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
147 |
icon := icon on:Screen default. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
148 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
149 |
KnownIcons at:aName put:icon. |
77 | 150 |
]. |
151 |
^ icon |
|
152 |
||
153 |
" |
|
154 |
Icon constantNamed:#file |
|
155 |
Icon constantNamed:#debugger |
|
156 |
Icon constantNamed:#systembrowser |
|
84 | 157 |
Icon constantNamed:#SBrowser |
105 | 158 |
Icon constantNamed:#SBrowser |
77 | 159 |
" |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
160 |
|
193 | 161 |
"Modified: 23.4.1996 / 11:40:24 / cg" |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
162 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
163 |
|
193 | 164 |
constantNamed:aName put:anImage |
165 |
"register anImage under aName." |
|
166 |
||
167 |
KnownIcons at:aName put:anImage |
|
168 |
||
169 |
"Modified: 23.4.1996 / 11:40:51 / cg" |
|
77 | 170 |
! ! |
171 |
||
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
172 |
!Icon class methodsFor:'documentation'! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
173 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
174 |
version |
269 | 175 |
^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.12 1996-05-20 07:26:04 cg Exp $' |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
176 |
! ! |
77 | 177 |
Icon initialize! |