Icon.st
author claus
Mon, 03 Jul 1995 04:47:44 +0200
changeset 84 31752ae049fa
parent 77 e846c6f3ac50
child 105 2e1c39cafe2e
permissions -rw-r--r--
.

"
 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.2 1995-07-03 02:47:44 claus Exp $
"
!

documentation
"
    Compatibility mimicri for Icon.
    Implements the #constantNamed: message which is used by some PD
    classes and returns corresponding ST/X icons.
    If you like the original 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).
"
!

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 a constant name to ST/X 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 := IdentityDictionary new

    "
     Icon initialize
    "
! !

!Icon class methodsFor:'instance creation'!

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

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
	    ].
	].
	KnownIcons at:aName put:icon.
    ].
    ^ icon

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

Icon initialize!