ListEntry.st
author Claus Gittinger <cg@exept.de>
Tue, 22 Aug 2000 15:57:05 +0200
changeset 1820 9b17f0c15849
parent 1812 c9054636e3ea
child 2196 2d64b9c3bcea
permissions -rw-r--r--
category change
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
"
claus
parents:
diff changeset
    12
1812
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
    13
"{ Package: 'stx:libwidg2' }"
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
    14
58
claus
parents:
diff changeset
    15
Object subclass:#ListEntry
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    16
	instanceVariableNames:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    17
	classVariableNames:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    18
	poolDictionaries:''
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    19
	category:'Views-Support'
58
claus
parents:
diff changeset
    20
!
claus
parents:
diff changeset
    21
claus
parents:
diff changeset
    22
!ListEntry class methodsFor:'documentation'!
claus
parents:
diff changeset
    23
claus
parents:
diff changeset
    24
copyright
claus
parents:
diff changeset
    25
"
claus
parents:
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
86
4d7dbb5f1719 uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
    27
	      All Rights Reserved
58
claus
parents:
diff changeset
    28
claus
parents:
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    34
 hereby transferred.
claus
parents:
diff changeset
    35
"
claus
parents:
diff changeset
    36
!
claus
parents:
diff changeset
    37
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    ListEntry is an abstract superclass for objects which can be used
claus
parents:
diff changeset
    41
    in place of strings in ListViews or SelectionInListViews.
claus
parents:
diff changeset
    42
claus
parents:
diff changeset
    43
    If you want to create new subclasses, implement (at least) the methods
claus
parents:
diff changeset
    44
    found in the 'required protocol' category.
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    45
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    46
    [author:]
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    47
        Claus Gittinger
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    48
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    49
    [see also:]
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    50
        ListView
58
claus
parents:
diff changeset
    51
"
claus
parents:
diff changeset
    52
! !
claus
parents:
diff changeset
    53
669
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    54
!ListEntry methodsFor:'printing & storing'!
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    55
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    56
printOn:aStream
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    57
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    58
    aStream nextPutAll:self asString.
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    59
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    60
    "Created: / 20.1.1998 / 14:11:02 / stefan"
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    61
!
58
claus
parents:
diff changeset
    62
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    63
printString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    64
    ^ self asString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    65
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    66
    "Created: 8.2.1996 / 11:56:14 / cg"
669
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    67
! !
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    68
82c3b58df75e Define #printOn:
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    69
!ListEntry methodsFor:'queries'!
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    70
1820
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    71
size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    72
    "behave like a string when asked for the size"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    73
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    74
    ^ self string size
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    75
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    76
    "Created: / 8.2.1996 / 12:54:45 / cg"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    77
    "Modified: / 30.10.1997 / 15:42:19 / cg"
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    78
!
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
    79
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    80
species
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    81
    ^ String
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    82
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    83
    "Created: 8.2.1996 / 12:52:38 / cg"
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    84
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    85
58
claus
parents:
diff changeset
    86
string
claus
parents:
diff changeset
    87
    ^ self asString
claus
parents:
diff changeset
    88
! !
claus
parents:
diff changeset
    89
claus
parents:
diff changeset
    90
!ListEntry methodsFor:'required protocol'!
claus
parents:
diff changeset
    91
claus
parents:
diff changeset
    92
asString
claus
parents:
diff changeset
    93
    "return the receiver as a string (for example, to store it in a file)"
claus
parents:
diff changeset
    94
claus
parents:
diff changeset
    95
    ^ self subclassResponsibility
claus
parents:
diff changeset
    96
!
claus
parents:
diff changeset
    97
109
Claus Gittinger <cg@exept.de>
parents: 108
diff changeset
    98
displayOn:aGC x:x y:y opaque:opaque
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
    99
    "display the receiver on a GC"
58
claus
parents:
diff changeset
   100
claus
parents:
diff changeset
   101
    ^ self subclassResponsibility
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   102
!
58
claus
parents:
diff changeset
   103
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   104
heightOn:aGC
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   105
    "return the height of the receiver when displayed in aGC.
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   106
     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
   107
     particular subclass, this method is to be redefined there."
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   108
821
fb1c37408cd9 need device font for query
ca
parents: 734
diff changeset
   109
    ^ aGC font heightOn:(aGC device) 
94
169802ee9a6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   110
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   111
    "Created: 12.5.1996 / 20:37:06 / cg"
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   112
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   113
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   114
widthOn:aGC
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   115
    "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
   116
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 94
diff changeset
   117
    ^ self subclassResponsibility
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   118
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   119
    "Created: 12.5.1996 / 20:53:09 / cg"
58
claus
parents:
diff changeset
   120
! !
claus
parents:
diff changeset
   121
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   122
!ListEntry methodsFor:'string protocol'!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   124
< aString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   125
    "behave like a string when comparing"
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   126
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   127
    ^ self asString < aString asString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   128
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   129
    "Created: 8.2.1996 / 12:01:29 / cg"
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   130
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   131
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   132
= aString
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   133
    "behave like a string when comparing"
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   134
734
0fb26bdea415 fixed #=, if species are not alike (i.e. arg is nil)
ca
parents: 669
diff changeset
   135
    self == aString ifTrue:[^ true].
1812
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   136
    ^ self asString = aString asString
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   137
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   138
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   139
at:index
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   140
    "behave like a string when accessing characters"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   141
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   142
    ^ self string at:index
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   143
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   144
    "Created: / 8.2.1996 / 12:53:06 / cg"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   145
    "Modified: / 30.10.1997 / 15:41:47 / cg"
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   146
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   147
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   148
do:aBlock
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   149
    "behave like a string when enumerating characters"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   150
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   151
    ^ self string do:aBlock
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   152
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   153
    "Created: / 8.2.1996 / 12:56:06 / cg"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   154
    "Modified: / 30.10.1997 / 15:42:06 / cg"
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   155
!
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   156
1812
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   157
hash
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   158
    "return an integer useful for hashing"
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   159
c9054636e3ea added #hash
Claus Gittinger <cg@exept.de>
parents: 821
diff changeset
   160
    ^ self asString hash
600
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   161
! !
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   162
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   163
!ListEntry methodsFor:'testing'!
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   164
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   165
includes:aCharacter 
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   166
    "behave like a string when testing"
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   167
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   168
    ^ self string includes:aCharacter
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   169
ccedbbd1eac9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 555
diff changeset
   170
    "Modified: / 30.10.1997 / 15:42:32 / cg"
123
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   171
! !
5ac860f2e7b8 more String mimicri protocol
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
   172
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   173
!ListEntry class methodsFor:'documentation'!
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   174
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   175
version
1820
9b17f0c15849 category change
Claus Gittinger <cg@exept.de>
parents: 1812
diff changeset
   176
    ^ '$Header: /cvs/stx/stx/libwidg2/ListEntry.st,v 1.17 2000-08-22 13:56:59 cg Exp $'
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   177
! !