Icon.st
author Claus Gittinger <cg@exept.de>
Thu, 07 Mar 1996 19:37:30 +0100
changeset 173 6bb37093ea47
parent 158 16f2237474fe
child 179 14271a2e3625
permissions -rw-r--r--
nicer message / changed category

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

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

!Icon class methodsFor:'initialization'!

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

    "
     Icon initialize
    "
!

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

    ^ #( 
	#(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 class methodsFor:'instance creation'!

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) infoPrintNL.
                ^ 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     
    "

    "Modified: 7.3.1996 / 19:17:15 / cg"
!

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

!Icon class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.7 1996-03-07 18:37:30 cg Exp $'
! !
Icon initialize!