author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:32:07 +0200 | |
changeset 221 | ea942fe5dc04 |
parent 219 | 106b86ca81da |
child 264 | 6c886ecb050d |
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 |
|
41 |
remember their names (they must have been remembered under that name |
|
42 |
before - of course). |
|
43 |
||
44 |
Icon was mostly added for ST-80 Compatibility: |
|
45 |
Images are returned via the #constantNamed: message which is used by |
|
46 |
some ST-80 PD classes and returns corresponding ST/X icons. |
|
47 |
Notice, that ST/X does not provide Icon instances - Icon only consists |
|
48 |
of class mimicri protocol, to make your life easier. |
|
111 | 49 |
|
193 | 50 |
If you like the original ST-80 icons, install the image files in the `bitmap' |
51 |
directory under a name foo.xbm, where `foo' corresponds to the icons |
|
52 |
name symbol |
|
53 |
(i.e. for the `Icon constantNamed:#foo', a 'foo.xbm' file is required). |
|
111 | 54 |
|
193 | 55 |
You can grab those icons from manchester or from the PrimeTime Freeware |
56 |
(PTF) CD. A copy of those bitmaps (from the PTF-CD) is found in |
|
57 |
goodies/bitmaps/st80bitmaps. |
|
58 |
||
59 |
CAVEAT: |
|
60 |
masks are not yet implemented |
|
61 |
||
62 |
[See also:] |
|
63 |
Image Form ImageReader |
|
219 | 64 |
|
65 |
[author:] |
|
66 |
Claus Gittinger |
|
77 | 67 |
" |
68 |
! ! |
|
69 |
||
70 |
!Icon class methodsFor:'initialization'! |
|
71 |
||
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
72 |
initialize |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
73 |
KnownIcons isNil ifTrue:[ |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
74 |
KnownIcons := IdentityDictionary new |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
75 |
] |
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 |
Icon initialize |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
79 |
" |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
80 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
81 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
82 |
replacementNameFor:aName |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
83 |
"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
|
84 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
85 |
self replacementNames do:[:aPair | |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
86 |
(aPair at:1) == aName ifTrue:[^ aPair at:2]. |
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 |
^ nil |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
89 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
90 |
|
77 | 91 |
replacementNames |
105 | 92 |
"return an ST-80 constant name to ST/X file name translation." |
77 | 93 |
|
94 |
^ #( |
|
95 |
#(file FBrowser) |
|
96 |
#(debugger Debugger) |
|
97 |
#(systembrowser SBrowser) |
|
98 |
#(classbrowser SBrowser) |
|
99 |
#(categoryBrowser SBrowser) |
|
100 |
#(hierarchyBrowser SBrowser) |
|
101 |
#(methodBrowser SBrowser) |
|
102 |
#(launcher SmalltalkX) |
|
103 |
#(workspace SmalltalkX) |
|
104 |
#(transcript SmalltalkX) |
|
105 |
#(inspector Inspector) |
|
106 |
#(default SmalltalkX) |
|
107 |
) |
|
108 |
! ! |
|
109 |
||
193 | 110 |
!Icon class methodsFor:'accessing'! |
77 | 111 |
|
112 |
constantNamed:aName |
|
193 | 113 |
"return the image registered under aName." |
114 |
||
77 | 115 |
|icon nm| |
116 |
||
117 |
icon := KnownIcons at:aName ifAbsent:[]. |
|
118 |
icon isNil ifTrue:[ |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
119 |
nm := self replacementNameFor:aName. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
120 |
nm notNil ifTrue:[ |
179 | 121 |
icon := Image fromFile:('bitmaps/' , nm). |
122 |
icon isNil ifTrue:[ |
|
123 |
icon := Image fromFile:('bitmaps/' , nm , '.xbm'). |
|
124 |
] |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
125 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
126 |
icon isNil ifTrue:[ |
179 | 127 |
icon := Image fromFile:('bitmaps/' , aName). |
128 |
icon isNil ifTrue:[ |
|
129 |
icon := Image fromFile:('bitmaps/' , aName , '.xbm'). |
|
130 |
]. |
|
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
131 |
icon isNil ifTrue:[ |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
132 |
('ICON: no icon named ' , aName) infoPrintNL. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
133 |
^ nil |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
134 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
135 |
icon := icon on:Screen default. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
136 |
]. |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
137 |
KnownIcons at:aName put:icon. |
77 | 138 |
]. |
139 |
^ icon |
|
140 |
||
141 |
" |
|
142 |
Icon constantNamed:#file |
|
143 |
Icon constantNamed:#debugger |
|
144 |
Icon constantNamed:#systembrowser |
|
84 | 145 |
Icon constantNamed:#SBrowser |
105 | 146 |
Icon constantNamed:#SBrowser |
77 | 147 |
" |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
148 |
|
193 | 149 |
"Modified: 23.4.1996 / 11:40:24 / cg" |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
150 |
! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
151 |
|
193 | 152 |
constantNamed:aName put:anImage |
153 |
"register anImage under aName." |
|
154 |
||
155 |
KnownIcons at:aName put:anImage |
|
156 |
||
157 |
"Modified: 23.4.1996 / 11:40:51 / cg" |
|
77 | 158 |
! ! |
159 |
||
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
160 |
!Icon class methodsFor:'documentation'! |
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
161 |
|
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
162 |
version |
219 | 163 |
^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.10 1996-04-25 16:21:10 cg Exp $' |
173
6bb37093ea47
nicer message / changed category
Claus Gittinger <cg@exept.de>
parents:
158
diff
changeset
|
164 |
! ! |
77 | 165 |
Icon initialize! |