ListEntry.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 02 Sep 2022 11:25:39 +0100
branchjv
changeset 6261 9b7eb7159d29
parent 5391 4392c1cf3c16
child 5913 b8dd70aeb192
permissions -rw-r--r--
Fix loong standing bug with some menus not being translated / resolved This has happened with browser "View" menu when sometimes it had the slice resolved and sometimes not. It turned out that it was because the code disabled resources (and therefore slices) resolution when processing shortcuts, so the menu was created and cached unresolved. This fixes the issue. eXept apparently run into the same problem.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
86
4d7dbb5f1719 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
     3
	      All Rights Reserved
58
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
"
1812
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
    13
5391
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    14
"{ NameSpace: Smalltalk }"
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    15
58
claus
parents:
diff changeset
    16
Object subclass:#ListEntry
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    17
	instanceVariableNames:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    18
	classVariableNames:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    19
	poolDictionaries:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    20
	category:'Views-Support'
58
claus
parents:
diff changeset
    21
!
claus
parents:
diff changeset
    22
claus
parents:
diff changeset
    23
!ListEntry class methodsFor:'documentation'!
claus
parents:
diff changeset
    24
claus
parents:
diff changeset
    25
copyright
claus
parents:
diff changeset
    26
"
claus
parents:
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
86
4d7dbb5f1719 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
    28
	      All Rights Reserved
58
claus
parents:
diff changeset
    29
claus
parents:
diff changeset
    30
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    35
 hereby transferred.
claus
parents:
diff changeset
    36
"
claus
parents:
diff changeset
    37
!
claus
parents:
diff changeset
    38
claus
parents:
diff changeset
    39
documentation
claus
parents:
diff changeset
    40
"
claus
parents:
diff changeset
    41
    ListEntry is an abstract superclass for objects which can be used
claus
parents:
diff changeset
    42
    in place of strings in ListViews or SelectionInListViews.
claus
parents:
diff changeset
    43
claus
parents:
diff changeset
    44
    If you want to create new subclasses, implement (at least) the methods
claus
parents:
diff changeset
    45
    found in the 'required protocol' category.
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    46
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    47
    [author:]
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    48
        Claus Gittinger
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    49
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    50
    [see also:]
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    51
        ListView
58
claus
parents:
diff changeset
    52
"
claus
parents:
diff changeset
    53
! !
claus
parents:
diff changeset
    54
5391
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    55
!ListEntry methodsFor:'comparing'!
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    56
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    57
< aString
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    58
    "behave like a string when comparing"
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    59
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    60
    ^ self asString < aString asString
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    61
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    62
    "Created: 8.2.1996 / 12:01:29 / cg"
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    63
!
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    64
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    65
= aString
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    66
    "behave like a string when comparing"
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    67
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    68
    self == aString ifTrue:[^ true].
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    69
    ^ self asString = aString asString
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    70
!
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    71
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    72
hash
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    73
    "return an integer useful for hashing"
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    74
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    75
    ^ self asString hash
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    76
! !
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
    77
669
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    78
!ListEntry methodsFor:'printing & storing'!
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    79
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    80
printOn:aStream
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    81
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    82
    aStream nextPutAll:self asString.
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    83
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    84
    "Created: / 20.1.1998 / 14:11:02 / stefan"
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    85
!
58
claus
parents:
diff changeset
    86
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    87
printString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    88
    ^ self asString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    89
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    90
    "Created: 8.2.1996 / 11:56:14 / cg"
669
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    91
! !
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    92
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    93
!ListEntry methodsFor:'queries'!
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    94
2655
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
    95
hasIcon
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
    96
    ^ false
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
    97
!
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
    98
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
    99
hasImage
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
   100
    ^ false
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
   101
!
4b72f593d5ba hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
   102
3764
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   103
includes:aCharacter 
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   104
    "behave like a string when testing"
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   105
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   106
    ^ self string includes:aCharacter
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   107
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   108
    "Modified: / 30.10.1997 / 15:42:32 / cg"
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   109
!
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   110
1820
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   111
size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   112
    "behave like a string when asked for the size"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   113
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   114
    ^ self string size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   115
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   116
    "Created: / 8.2.1996 / 12:54:45 / cg"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   117
    "Modified: / 30.10.1997 / 15:42:19 / cg"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   118
!
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   119
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   120
species
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   121
    ^ String
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   122
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   123
    "Created: 8.2.1996 / 12:52:38 / cg"
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   124
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   125
58
claus
parents:
diff changeset
   126
string
claus
parents:
diff changeset
   127
    ^ self asString
claus
parents:
diff changeset
   128
! !
claus
parents:
diff changeset
   129
claus
parents:
diff changeset
   130
!ListEntry methodsFor:'required protocol'!
claus
parents:
diff changeset
   131
claus
parents:
diff changeset
   132
asString
claus
parents:
diff changeset
   133
    "return the receiver as a string (for example, to store it in a file)"
claus
parents:
diff changeset
   134
claus
parents:
diff changeset
   135
    ^ self subclassResponsibility
claus
parents:
diff changeset
   136
!
claus
parents:
diff changeset
   137
109
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
   138
displayOn:aGC x:x y:y opaque:opaque
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   139
    "display the receiver on a GC"
58
claus
parents:
diff changeset
   140
claus
parents:
diff changeset
   141
    ^ self subclassResponsibility
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   142
!
58
claus
parents:
diff changeset
   143
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   144
heightOn:aGC
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   145
    "return the height of the receiver when displayed in aGC.
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   146
     Assume the GC's font is taken. If that is not the case in a
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   147
     particular subclass, this method is to be redefined there."
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   148
821
fb1c37408cd9 need device font for query
ca
parents: 734
diff changeset
   149
    ^ aGC font heightOn:(aGC device) 
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   150
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   151
    "Created: 12.5.1996 / 20:37:06 / cg"
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   152
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   153
2196
2d64b9c3bcea add subclassresponsibility
Stefan Vogel <sv@exept.de>
parents: 1820
diff changeset
   154
sameStringAndEmphasisAs:aStringOrText
2d64b9c3bcea add subclassresponsibility
Stefan Vogel <sv@exept.de>
parents: 1820
diff changeset
   155
2d64b9c3bcea add subclassresponsibility
Stefan Vogel <sv@exept.de>
parents: 1820
diff changeset
   156
    ^ self subclassResponsibility
2d64b9c3bcea add subclassresponsibility
Stefan Vogel <sv@exept.de>
parents: 1820
diff changeset
   157
!
2d64b9c3bcea add subclassresponsibility
Stefan Vogel <sv@exept.de>
parents: 1820
diff changeset
   158
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   159
widthOn:aGC
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   160
    "return the width (in device units) of the receiver when displayed in aGC"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   161
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   162
    ^ self subclassResponsibility
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   163
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   164
    "Created: 12.5.1996 / 20:53:09 / cg"
58
claus
parents:
diff changeset
   165
! !
claus
parents:
diff changeset
   166
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   167
!ListEntry methodsFor:'string protocol'!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   168
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   169
at:index
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   170
    "behave like a string when accessing characters"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   171
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   172
    ^ self string at:index
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   173
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   174
    "Created: / 8.2.1996 / 12:53:06 / cg"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   175
    "Modified: / 30.10.1997 / 15:41:47 / cg"
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   176
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   177
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   178
do:aBlock
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   179
    "behave like a string when enumerating characters"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   180
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   181
    ^ self string do:aBlock
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   182
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   183
    "Created: / 8.2.1996 / 12:56:06 / cg"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   184
    "Modified: / 30.10.1997 / 15:42:06 / cg"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   185
! !
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   186
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   187
!ListEntry class methodsFor:'documentation'!
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   188
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   189
version
5391
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
   190
    ^ '$Header$'
3764
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   191
!
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   192
1414561b990a category of: #includes:
Claus Gittinger <cg@exept.de>
parents: 2655
diff changeset
   193
version_CVS
5391
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
   194
    ^ '$Header$'
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   195
! !
5391
4392c1cf3c16 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3764
diff changeset
   196