Icon.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 18:32:07 +0200
changeset 221 ea942fe5dc04
parent 219 106b86ca81da
child 264 6c886ecb050d
permissions -rw-r--r--
documentation
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
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    41
    remember their names (they must have been remembered under that name
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:
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    45
    Images are returned via the #constantNamed: message which is used by 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    46
    some ST-80 PD classes and returns corresponding ST/X icons.
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    47
    Notice, that ST/X does not provide Icon instances - Icon only consists
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    48
    of class mimicri protocol, to make your life easier.
111
23f66f18a3cb doc comment
Claus Gittinger <cg@exept.de>
parents: 105
diff changeset
    49
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    50
    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
    51
    directory under a name foo.xbm, where `foo' corresponds to the icons
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    52
    name symbol 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    53
    (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
    54
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    55
    You can grab those icons from manchester or from the PrimeTime Freeware 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    56
    (PTF) CD. A copy of those bitmaps (from the PTF-CD) is found in 
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    57
    goodies/bitmaps/st80bitmaps.
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    58
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    59
    CAVEAT:
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    60
        masks are not yet implemented
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    61
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    62
    [See also:]
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
    63
        Image Form ImageReader
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    64
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    65
    [author:]
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    66
        Claus Gittinger
77
claus
parents:
diff changeset
    67
"
claus
parents:
diff changeset
    68
! !
claus
parents:
diff changeset
    69
claus
parents:
diff changeset
    70
!Icon class methodsFor:'initialization'!
claus
parents:
diff changeset
    71
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    72
initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    73
    KnownIcons isNil ifTrue:[
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    74
	KnownIcons := IdentityDictionary new
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    75
    ]
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
     Icon initialize
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    79
    "
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    80
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    81
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    82
replacementNameFor:aName
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    83
    "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
    84
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    85
    self replacementNames do:[:aPair |
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    86
	(aPair at:1) == aName ifTrue:[^ aPair at:2].
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
    ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    89
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    90
77
claus
parents:
diff changeset
    91
replacementNames
105
claus
parents: 84
diff changeset
    92
    "return an ST-80 constant name to ST/X file name translation."
77
claus
parents:
diff changeset
    93
claus
parents:
diff changeset
    94
    ^ #( 
claus
parents:
diff changeset
    95
	#(file             FBrowser)
claus
parents:
diff changeset
    96
	#(debugger         Debugger)
claus
parents:
diff changeset
    97
	#(systembrowser    SBrowser)
claus
parents:
diff changeset
    98
	#(classbrowser     SBrowser)
claus
parents:
diff changeset
    99
	#(categoryBrowser  SBrowser)
claus
parents:
diff changeset
   100
	#(hierarchyBrowser SBrowser)
claus
parents:
diff changeset
   101
	#(methodBrowser    SBrowser)
claus
parents:
diff changeset
   102
	#(launcher         SmalltalkX)
claus
parents:
diff changeset
   103
	#(workspace        SmalltalkX)
claus
parents:
diff changeset
   104
	#(transcript       SmalltalkX)
claus
parents:
diff changeset
   105
	#(inspector        Inspector)
claus
parents:
diff changeset
   106
	#(default          SmalltalkX)
claus
parents:
diff changeset
   107
       )
claus
parents:
diff changeset
   108
! !
claus
parents:
diff changeset
   109
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   110
!Icon class methodsFor:'accessing'!
77
claus
parents:
diff changeset
   111
claus
parents:
diff changeset
   112
constantNamed:aName
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   113
    "return the image registered under aName."
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   114
77
claus
parents:
diff changeset
   115
    |icon nm|
claus
parents:
diff changeset
   116
claus
parents:
diff changeset
   117
    icon := KnownIcons at:aName ifAbsent:[].
claus
parents:
diff changeset
   118
    icon isNil ifTrue:[
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   119
        nm := self replacementNameFor:aName.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   120
        nm notNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   121
            icon := Image fromFile:('bitmaps/' , nm).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   122
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   123
                icon := Image fromFile:('bitmaps/' , nm , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   124
            ]
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   125
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   126
        icon isNil ifTrue:[
179
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   127
            icon := Image fromFile:('bitmaps/' , aName).
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   128
            icon isNil ifTrue:[
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   129
                icon := Image fromFile:('bitmaps/' , aName , '.xbm').
14271a2e3625 check for imagefile without extension first
ca
parents: 173
diff changeset
   130
            ].
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   131
            icon isNil ifTrue:[
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   132
                ('ICON: no icon named ' , aName) infoPrintNL.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   133
                ^ nil
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   134
            ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   135
            icon := icon on:Screen default.
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   136
        ].
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   137
        KnownIcons at:aName put:icon.
77
claus
parents:
diff changeset
   138
    ].
claus
parents:
diff changeset
   139
    ^ icon
claus
parents:
diff changeset
   140
claus
parents:
diff changeset
   141
    "
claus
parents:
diff changeset
   142
     Icon constantNamed:#file     
claus
parents:
diff changeset
   143
     Icon constantNamed:#debugger     
claus
parents:
diff changeset
   144
     Icon constantNamed:#systembrowser     
84
claus
parents: 77
diff changeset
   145
     Icon constantNamed:#SBrowser     
105
claus
parents: 84
diff changeset
   146
     Icon constantNamed:#SBrowser     
77
claus
parents:
diff changeset
   147
    "
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   148
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   149
    "Modified: 23.4.1996 / 11:40:24 / cg"
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   150
!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   151
193
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   152
constantNamed:aName put:anImage
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   153
    "register anImage under aName."
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   154
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   155
    KnownIcons at:aName put:anImage
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   156
daaaf4594c9e commentary
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   157
    "Modified: 23.4.1996 / 11:40:51 / cg"
77
claus
parents:
diff changeset
   158
! !
claus
parents:
diff changeset
   159
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   160
!Icon class methodsFor:'documentation'!
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   161
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   162
version
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
   163
    ^ '$Header: /cvs/stx/stx/libview2/Icon.st,v 1.10 1996-04-25 16:21:10 cg Exp $'
173
6bb37093ea47 nicer message / changed category
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   164
! !
77
claus
parents:
diff changeset
   165
Icon initialize!