"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libview2' }"
Object subclass:#Icon
instanceVariableNames:'image mask'
classVariableNames:'KnownIcons'
poolDictionaries:''
category:'Graphics-Images'
!
!Icon class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
The Icon class keeps track of already loaded Images and caches
them for later reuse.
Icons are accessed by a symbolic name, so there is no need to
remember their names (they must have been registered under that name
before - of course).
Icon was mostly added for ST-80 Compatibility:
Images are returned via the #constantNamed: message which is used by
some ST-80 PD classes and returns corresponding ST/X icons.
Notice, that ST/X does not provide Icon instances - Icon only consists
of class mimicri protocol, to make your life easier.
If you like the original ST-80 icons, install the image files in the `bitmap'
directory under a name foo.xbm, where `foo' corresponds to the icons
name symbol
(i.e. for the `Icon constantNamed:#foo', a 'foo.xbm' file is required).
You can grab those icons from manchester or from the PrimeTime Freeware
(PTF) CD. A copy of those bitmaps (from the PTF-CD) is found in
'goodies/bitmaps/st80bitmaps'.
CAVEAT:
masks are not yet implemented
[See also:]
Image Form ImageReader
[author:]
Claus Gittinger
"
! !
!Icon class methodsFor:'initialization'!
initialize
KnownIcons isNil ifTrue:[
KnownIcons := Dictionary new.
Color initialize.
]
"
Icon initialize
"
"Modified: 20.5.1996 / 09:24:10 / cg"
!
replacementNameFor:aName
"return a replacement ST/X name for an ST80 icon name."
self replacementNames do:[:aPair |
(aPair at:1) == aName ifTrue:[^ aPair at:2].
].
^ nil
!
replacementNames
"return an ST-80 constant name to ST/X file name translation.
This was added for ST-80 compatibility, to support code which uses
things like 'Icon constantNamed:#categoryBrowser'."
^ #(
#(file FBrowser)
#(debugger Debugger)
#(systembrowser SBrowser)
#(classbrowser SBrowser)
#(categoryBrowser SBrowser)
#(hierarchyBrowser SBrowser)
#(methodBrowser SBrowser)
#(launcher SmalltalkX)
#(workspace SmalltalkX)
#(transcript SmalltalkX)
#(inspector Inspector)
#(default SmalltalkX)
)
"
Icon constantNamed:#categoryBrowser
Icon constantNamed:#default
"
"Modified: 13.5.1996 / 10:29:43 / cg"
! !
!Icon class methodsFor:'accessing'!
constantNamed:aName
"return the image registered under aName."
^ self constantNamed:aName searchForFile:true
"
Icon constantNamed:#file
Icon constantNamed:#debugger
Icon constantNamed:#systembrowser
Icon constantNamed:#SBrowser
Icon constantNamed:#SBrowser
"
"Modified: 10.1.1997 / 17:52:06 / cg"
!
constantNamed:aName ifAbsentPut:aBlock
"if an image for aName is registered, return it;
otherwise, register the result from evaluating aBlock
(which also could be a value holder) and return it."
|image|
(image := self constantNamed:aName searchForFile:false) isNil
ifTrue:[
self constantNamed:aName put:(image := aBlock value)
].
^image
!
constantNamed:aName ifAbsentPutImageFromFile:aFileName
"if an image for aName is registered, return it;
otherwise, load the image from aFileName (searched in bitmaps directories),
register the result and return it."
^ self
constantNamed:aName
ifAbsentPut:[Smalltalk imageFromFileNamed:aFileName forClass:self]
!
constantNamed:aName put:anImage
"register anImage under aName."
KnownIcons isNil ifTrue:[
self initialize
].
KnownIcons at:aName put:anImage
"Modified: 23.4.1996 / 11:40:51 / cg"
!
constantNamed:aName searchForFile:doSearchForFile
"return the image registered under aName."
|icon nm|
KnownIcons isNil ifTrue:[
self initialize
].
icon := KnownIcons at:aName ifAbsent:[].
(icon isNil and:[doSearchForFile]) ifTrue:[
nm := self replacementNameFor:aName.
nm notNil ifTrue:[
icon := Smalltalk imageFromFileNamed:nm forClass:self.
icon isNil ifTrue:[
icon := Smalltalk imageFromFileNamed:(nm , '.xbm') forClass:self.
]
].
icon isNil ifTrue:[
icon := Smalltalk imageFromFileNamed:aName forClass:self.
icon isNil ifTrue:[
icon := Smalltalk imageFromFileNamed:(aName , '.xbm') forClass:self.
].
icon isNil ifTrue:[
^ nil
].
icon := icon onDevice:Screen default.
].
KnownIcons at:aName put:icon.
].
^ icon
"
Icon constantNamed:#file
Icon constantNamed:#debugger
Icon constantNamed:#systembrowser
Icon constantNamed:#SBrowser
Icon constantNamed:#SBrowser
"
"Modified: 10.1.1997 / 17:52:06 / cg"
! !
!Icon class methodsFor:'image specs'!
backwardIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary backward22x22_3DIcon
!
copyIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary copy22x22Icon
!
cutIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary cut22x22Icon
!
deleteIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary delete22x22Icon
!
downIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary down22x22Icon
!
downRightIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary downRight22x22Icon
!
forwardIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary forward22x22_3DIcon
!
helpIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary help22x22Icon
!
leftDownIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary leftDown22x22Icon
!
leftIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary left22x22Icon
!
loadIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary load22x22Icon
!
newIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary new22x22Icon
!
pasteIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary paste22x22Icon
!
rightIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary right22x22Icon
!
saveIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary save22x22Icon
!
startIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary start22x22Icon
!
stxIcon
|icn|
(icn := self constantNamed:'stxIcon') isNil ifTrue:[
OperatingSystem platformName == #win32 ifTrue:[
icn := Smalltalk imageFromFileNamed:'stx_32x32.xpm' forClass:self.
].
icn isNil ifTrue:[
icn := self stxIconOld.
].
icn notNil ifTrue:[
self constantNamed:'stxIcon' put:icn.
]
].
^ icn
"
Icon stxIcon
"
"Modified: / 25.5.1999 / 15:42:55 / cg"
!
stxIcon16x16
"This resource specification was automatically generated
by the ImageEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the ImageEditor may not be able to read the specification."
"
self stxIcon16x16 inspect
ImageEditor openOnClass:self andSelector:#stxIcon16x16
Icon flushCachedIcons
"
<resource: #image>
^Icon
constantNamed:#'Icon class stxIcon16x16'
ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[4]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@@@@@@@@@T@@@@@@@@@AD@@@@P@@@@DP@@@P@@@@@AP@@P@@@@@@@P@P@@@@@@@APP@@@@@@@@@P@@@@@@@@@Q@@@@@@@@@P@P@@@@@@
PP@@P@@@@@PP@@A@@@@@DP@@@@D@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[25 25 25 0 204 51 0 0 0 255 255 255 0 168 39]; yourself]
!
stxIconOld
"This resource specification was automatically generated
by the ImageEditor of ST/X."
"Do not manually edit this!! If it is corrupted,
the ImageEditor may not be able to read the specification."
"
self stxIconOld inspect
ImageEditor openOnClass:self andSelector:#stxIconOld
Icon flushCachedIcons
"
<resource: #image>
^Icon
constantNamed:#'Icon class stxIconOld'
ifAbsentPut:[(Depth2Image new) width: 48; height: 48; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU@UUUUUUUTEUUUUUT@EUUUUUUPUUUUUUT@EU
UUUUUAUUUUUUT@EUUUUUXEUUUUUUT@EUUUUU %UUUUUUT@IUUUUVBUUUUUUUU@AUUUUXIUUUUUUUU@AUUUU EUUUUUUUUP@UUUV@UUUUUUUUUX@UUUTAUUUU
UUUUUT@EUUPEUUUUUUUUUV@EUU@UUUUUUUUUUU@AUTBUUUUUUUUUUUPBUPIUUUUUUUUUUUP@U@EUUUUUUUUUUUT@$@UUUUUUUUUUUUV@@AUUUUUUUUUUUUU@
@EUUUUUUUUUUUUU @%UUUUUUUUUUUUUPBUUUUUUUUUUUUUU@@UUUUUUUUUUUUUT@@EUUUUUUUUUUUUP@@EUUUUUUUUUUUU@I AUUUUUUUUUUUT@EPAUUUUUU
UUUUUP@UT@UUUUUUUUUUV@AUV@UUUUUUUUUUT@EUU EUUUUUUUUU@@UUUXIUUUUUUUUT@IUUUTAUUUUUUUUP@EUUUUBUUUUUUUT@@UUUUU %UUUUUUP@AUUU
UUPEUUUUUU@@EUUUUUTIUUUUUU@@EUUUUUUAUUUUUU@@UUUUUUUPUUUUUUPAUUUUUUUTUUUUUUUUUUUUUUUUEUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU') ; colorMapFromArray:#[0 204 51 25 25 25 0 112 21]; yourself]
!
upIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary up22x22Icon
!
upRightIcon
"Obsolete - please goto ToolbarIconLibrary directly"
^ ToolbarIconLibrary upRight22x22Icon
! !
!Icon class methodsFor:'startup & release'!
flushCachedIcons
KnownIcons removeAll
"
Icon flushCachedIcons
"
!
preSnapshot
self flushCachedIcons
! !
!Icon class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.35 2008-09-03 09:52:08 cg Exp $'
! !
Icon initialize!