Icon.st
author Claus Gittinger <cg@exept.de>
Thu, 06 Mar 1997 15:16:03 +0100
changeset 494 ce8c074d5e6b
parent 358 6b9671f01908
child 777 03e6a1108f80
permissions -rw-r--r--
checkin from browser
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
"
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    38
    The Icon class keeps track of already loaded Images and caches
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    39
    them for later reuse.
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    40
    Icons are accessed by a symbolic name, so there is no need to
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    41
    remember their names (they must have been registered under that name
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    42
    before - of course).
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    43
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    44
    Icon was mostly added for ST-80 Compatibility:
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    45
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    46
    Images are returned via the #constantNamed: message which is used by 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    47
    some ST-80 PD classes and returns corresponding ST/X icons.
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    48
    Notice, that ST/X does not provide Icon instances - Icon only consists
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    49
    of class mimicri protocol, to make your life easier.
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    50
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    51
    If you like the original ST-80 icons, install the image files in the `bitmap'
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    52
    directory under a name foo.xbm, where `foo' corresponds to the icons
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    53
    name symbol 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    54
    (i.e. for the `Icon constantNamed:#foo', a 'foo.xbm' file is required).
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    55
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    56
    You can grab those icons from manchester or from the PrimeTime Freeware 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    57
    (PTF) CD. A copy of those bitmaps (from the PTF-CD) is found in 
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    58
    'goodies/bitmaps/st80bitmaps'.
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    59
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    60
    CAVEAT:
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    61
        masks are not yet implemented
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    62
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    63
    [See also:]
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    64
        Image Form ImageReader
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    65
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    66
    [author:]
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    67
        Claus Gittinger
77
claus
parents:
diff changeset
    68
"
claus
parents:
diff changeset
    69
! !
claus
parents:
diff changeset
    70
claus
parents:
diff changeset
    71
!Icon class methodsFor:'initialization'!
claus
parents:
diff changeset
    72
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    73
initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    74
    KnownIcons isNil ifTrue:[
269
6c70d392634b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    75
        KnownIcons := Dictionary new
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    76
    ]
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    77
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    78
    "
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    79
     Icon initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    80
    "
269
6c70d392634b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    81
6c70d392634b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 264
diff changeset
    82
    "Modified: 20.5.1996 / 09:24:10 / cg"
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    83
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    84
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    85
replacementNameFor:aName
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    86
    "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
    87
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    88
    self replacementNames do:[:aPair |
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    89
	(aPair at:1) == aName ifTrue:[^ aPair at:2].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    90
    ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    91
    ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    92
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    93
77
claus
parents:
diff changeset
    94
replacementNames
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
    "return an ST-80 constant name to ST/X file name translation.
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    96
     This was added for ST-80 compatibility, to support code which uses
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    97
     things like 'Icon constantNamed:#categoryBrowser'."
77
claus
parents:
diff changeset
    98
claus
parents:
diff changeset
    99
    ^ #( 
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
        #(file             FBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   101
        #(debugger         Debugger)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   102
        #(systembrowser    SBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   103
        #(classbrowser     SBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
        #(categoryBrowser  SBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   105
        #(hierarchyBrowser SBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   106
        #(methodBrowser    SBrowser)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   107
        #(launcher         SmalltalkX)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   108
        #(workspace        SmalltalkX)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   109
        #(transcript       SmalltalkX)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   110
        #(inspector        Inspector)
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   111
        #(default          SmalltalkX)
77
claus
parents:
diff changeset
   112
       )
264
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   113
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   114
    "
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   115
     Icon constantNamed:#categoryBrowser
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   116
     Icon constantNamed:#default
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   117
    "
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   118
6c886ecb050d comments
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   119
    "Modified: 13.5.1996 / 10:29:43 / cg"
77
claus
parents:
diff changeset
   120
! !
claus
parents:
diff changeset
   121
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   122
!Icon class methodsFor:'accessing'!
77
claus
parents:
diff changeset
   123
claus
parents:
diff changeset
   124
constantNamed:aName
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   125
    "return the image registered under aName."
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   126
77
claus
parents:
diff changeset
   127
    |icon nm|
claus
parents:
diff changeset
   128
claus
parents:
diff changeset
   129
    icon := KnownIcons at:aName ifAbsent:[].
claus
parents:
diff changeset
   130
    icon isNil ifTrue:[
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   131
        nm := self replacementNameFor:aName.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   132
        nm notNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   133
            icon := Image fromFile:('bitmaps/' , nm).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   134
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   135
                icon := Image fromFile:('bitmaps/' , nm , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   136
            ]
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   137
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   138
        icon isNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   139
            icon := Image fromFile:('bitmaps/' , aName).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   140
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   141
                icon := Image fromFile:('bitmaps/' , aName , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   142
            ].
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   143
            icon isNil ifTrue:[
358
6b9671f01908 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   144
                ('Icon [info]: no icon named ' , aName) infoPrintCR.
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   145
                ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   146
            ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   147
            icon := icon on:Screen default.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   148
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   149
        KnownIcons at:aName put:icon.
77
claus
parents:
diff changeset
   150
    ].
claus
parents:
diff changeset
   151
    ^ icon
claus
parents:
diff changeset
   152
claus
parents:
diff changeset
   153
    "
claus
parents:
diff changeset
   154
     Icon constantNamed:#file     
claus
parents:
diff changeset
   155
     Icon constantNamed:#debugger     
claus
parents:
diff changeset
   156
     Icon constantNamed:#systembrowser     
84
claus
parents: 77
diff changeset
   157
     Icon constantNamed:#SBrowser     
105
claus
parents: 84
diff changeset
   158
     Icon constantNamed:#SBrowser     
77
claus
parents:
diff changeset
   159
    "
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   160
358
6b9671f01908 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   161
    "Modified: 10.1.1997 / 17:52:06 / cg"
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   162
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   163
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   164
constantNamed:aName put:anImage
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   165
    "register anImage under aName."
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   166
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   167
    KnownIcons at:aName put:anImage
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   168
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   169
    "Modified: 23.4.1996 / 11:40:51 / cg"
77
claus
parents:
diff changeset
   170
! !
claus
parents:
diff changeset
   171
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   172
!Icon class methodsFor:'documentation'!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   174
version
358
6b9671f01908 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   175
    ^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.14 1997-01-10 17:59:45 cg Exp $'
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   176
! !
77
claus
parents:
diff changeset
   177
Icon initialize!