Icon.st
author Claus Gittinger <cg@exept.de>
Sat, 27 Jan 1996 19:36:37 +0100
changeset 158 16f2237474fe
parent 114 e577a2f332d0
child 173 6bb37093ea47
permissions -rw-r--r--
only init once

"
 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.
"

'From Smalltalk/X, Version:2.10.5 on 14-apr-1995 at 11:13:06 am'!

Object subclass:#Icon
	 instanceVariableNames:'image mask'
	 classVariableNames:'KnownIcons'
	 poolDictionaries:''
	 category:'Graphics-Support'
!

!Icon class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.6 1996-01-27 18:36:37 cg Exp $'
!

documentation
"
    ST-80 Compatibility mimicri for Icon.
    Implements the #constantNamed: message which is used by some ST-80 PD
    classes and returns corresponding ST/X icons.

    If you like the original ST-80 icons, install the xbm files in the bitmap
    directory under a name foo.xbm, where foo corresponds to the icons
    name symbol (i.e. for Icon constantNamed:#foo, a 'foo.xbm' file is required).
    You can grab those icons from manchester or from the PrimeTime Freeware CD.
    A copy of the PTF-CD is also in goodies/bitmaps/st80bitmaps.
    Then, change the replacementName method to return an empty array.

    Caveat:
	masks are not yet implemented
"
!

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.
"
! !

!Icon class methodsFor:'initialization'!

replacementNames
    "return an ST-80 constant name to ST/X file name translation."

    ^ #( 
	#(file             FBrowser)
	#(debugger         Debugger)
	#(systembrowser    SBrowser)
	#(classbrowser     SBrowser)
	#(categoryBrowser  SBrowser)
	#(hierarchyBrowser SBrowser)
	#(methodBrowser    SBrowser)
	#(launcher         SmalltalkX)
	#(workspace        SmalltalkX)
	#(transcript       SmalltalkX)
	#(inspector        Inspector)
	#(default          SmalltalkX)
       )
!

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
!

initialize
    KnownIcons isNil ifTrue:[
	KnownIcons := IdentityDictionary new
    ]

    "
     Icon initialize
    "
! !

!Icon class methodsFor:'instance creation'!

constantNamed:aName put:anIcon
    KnownIcons at:aName put:anIcon
!

constantNamed:aName
    |icon nm|

    icon := KnownIcons at:aName ifAbsent:[].
    icon isNil ifTrue:[
	nm := self replacementNameFor:aName.
	nm notNil ifTrue:[
	    icon := Image fromFile:('bitmaps/' , nm , '.xbm').
	].
	icon isNil ifTrue:[
	    icon := Image fromFile:('bitmaps/' , aName , '.xbm').
	    icon isNil ifTrue:[
		('ICON: no icon named ' , aName) errorPrintNL.
		^ nil
	    ].
	    icon := icon on:Screen default.
	].
	KnownIcons at:aName put:icon.
    ].
    ^ icon

    "
     Icon constantNamed:#file     
     Icon constantNamed:#debugger     
     Icon constantNamed:#systembrowser     
     Icon constantNamed:#SBrowser     
     Icon constantNamed:#SBrowser     
    "
! !

Icon initialize!