Icon.st
author ca
Tue, 26 Mar 1996 16:11:57 +0100
changeset 179 14271a2e3625
parent 173 6bb37093ea47
child 193 daaaf4594c9e
permissions -rw-r--r--
check for imagefile without extension first
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
     3
	      All Rights Reserved
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
claus
parents:
diff changeset
    12
claus
parents:
diff changeset
    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
claus
parents:
diff changeset
    18
!
claus
parents:
diff changeset
    19
claus
parents:
diff changeset
    20
!Icon class methodsFor:'documentation'!
claus
parents:
diff changeset
    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
claus
parents:
diff changeset
    34
!
claus
parents:
diff changeset
    35
claus
parents:
diff changeset
    36
documentation
claus
parents:
diff changeset
    37
"
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    38
    ST-80 Compatibility mimicri for Icon.
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    39
    Implements the #constantNamed: message which is used by some ST-80 PD
77
claus
parents:
diff changeset
    40
    classes and returns corresponding ST/X icons.
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    41
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    42
    If you like the original ST-80 icons, install the xbm files in the bitmap
77
claus
parents:
diff changeset
    43
    directory under a name foo.xbm, where foo corresponds to the icons
claus
parents:
diff changeset
    44
    name symbol (i.e. for Icon constantNamed:#foo, a 'foo.xbm' file is required).
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    45
    You can grab those icons from manchester or from the PrimeTime Freeware CD.
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    46
    A copy of the PTF-CD is also in goodies/bitmaps/st80bitmaps.
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    47
    Then, change the replacementName method to return an empty array.
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    48
105
claus
parents: 84
diff changeset
    49
    Caveat:
claus
parents: 84
diff changeset
    50
	masks are not yet implemented
77
claus
parents:
diff changeset
    51
"
claus
parents:
diff changeset
    52
! !
claus
parents:
diff changeset
    53
claus
parents:
diff changeset
    54
!Icon class methodsFor:'initialization'!
claus
parents:
diff changeset
    55
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    56
initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    57
    KnownIcons isNil ifTrue:[
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    58
	KnownIcons := IdentityDictionary new
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    59
    ]
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    60
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    61
    "
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    62
     Icon initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    63
    "
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    64
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    65
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    66
replacementNameFor:aName
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    67
    "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
    68
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    69
    self replacementNames do:[:aPair |
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    70
	(aPair at:1) == aName ifTrue:[^ aPair at:2].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    71
    ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    72
    ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    73
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    74
77
claus
parents:
diff changeset
    75
replacementNames
105
claus
parents: 84
diff changeset
    76
    "return an ST-80 constant name to ST/X file name translation."
77
claus
parents:
diff changeset
    77
claus
parents:
diff changeset
    78
    ^ #( 
claus
parents:
diff changeset
    79
	#(file             FBrowser)
claus
parents:
diff changeset
    80
	#(debugger         Debugger)
claus
parents:
diff changeset
    81
	#(systembrowser    SBrowser)
claus
parents:
diff changeset
    82
	#(classbrowser     SBrowser)
claus
parents:
diff changeset
    83
	#(categoryBrowser  SBrowser)
claus
parents:
diff changeset
    84
	#(hierarchyBrowser SBrowser)
claus
parents:
diff changeset
    85
	#(methodBrowser    SBrowser)
claus
parents:
diff changeset
    86
	#(launcher         SmalltalkX)
claus
parents:
diff changeset
    87
	#(workspace        SmalltalkX)
claus
parents:
diff changeset
    88
	#(transcript       SmalltalkX)
claus
parents:
diff changeset
    89
	#(inspector        Inspector)
claus
parents:
diff changeset
    90
	#(default          SmalltalkX)
claus
parents:
diff changeset
    91
       )
claus
parents:
diff changeset
    92
! !
claus
parents:
diff changeset
    93
claus
parents:
diff changeset
    94
!Icon class methodsFor:'instance creation'!
claus
parents:
diff changeset
    95
claus
parents:
diff changeset
    96
constantNamed:aName
claus
parents:
diff changeset
    97
    |icon nm|
claus
parents:
diff changeset
    98
claus
parents:
diff changeset
    99
    icon := KnownIcons at:aName ifAbsent:[].
claus
parents:
diff changeset
   100
    icon isNil ifTrue:[
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   101
        nm := self replacementNameFor:aName.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   102
        nm notNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   103
            icon := Image fromFile:('bitmaps/' , nm).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   104
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   105
                icon := Image fromFile:('bitmaps/' , nm , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   106
            ]
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   107
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   108
        icon isNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   109
            icon := Image fromFile:('bitmaps/' , aName).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   110
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   111
                icon := Image fromFile:('bitmaps/' , aName , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   112
            ].
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   113
            icon isNil ifTrue:[
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   114
                ('ICON: no icon named ' , aName) infoPrintNL.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   115
                ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   116
            ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   117
            icon := icon on:Screen default.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   118
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   119
        KnownIcons at:aName put:icon.
77
claus
parents:
diff changeset
   120
    ].
claus
parents:
diff changeset
   121
    ^ icon
claus
parents:
diff changeset
   122
claus
parents:
diff changeset
   123
    "
claus
parents:
diff changeset
   124
     Icon constantNamed:#file     
claus
parents:
diff changeset
   125
     Icon constantNamed:#debugger     
claus
parents:
diff changeset
   126
     Icon constantNamed:#systembrowser     
84
claus
parents: 77
diff changeset
   127
     Icon constantNamed:#SBrowser     
105
claus
parents: 84
diff changeset
   128
     Icon constantNamed:#SBrowser     
77
claus
parents:
diff changeset
   129
    "
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   130
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   131
    "Modified: 7.3.1996 / 19:17:15 / cg"
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   132
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   133
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   134
constantNamed:aName put:anIcon
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   135
    KnownIcons at:aName put:anIcon
77
claus
parents:
diff changeset
   136
! !
claus
parents:
diff changeset
   137
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   138
!Icon class methodsFor:'documentation'!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   139
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   140
version
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   141
    ^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.8 1996-03-26 15:11:57 ca Exp $'
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   142
! !
77
claus
parents:
diff changeset
   143
Icon initialize!