author | Claus Gittinger <cg@exept.de> |
Thu, 30 May 2019 09:43:18 +0200 | |
changeset 6061 | 6511c63804ef |
parent 5927 | f8763479f0c9 |
child 6119 | 68569809d6db |
permissions | -rw-r--r-- |
5913 | 1 |
"{ Encoding: utf8 }" |
2 |
||
58 | 3 |
" |
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
5 |
All Rights Reserved |
58 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1812 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
5391 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
58 | 18 |
Object subclass:#ListEntry |
123 | 19 |
instanceVariableNames:'' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Views-Support' |
|
58 | 23 |
! |
24 |
||
5913 | 25 |
ListEntry subclass:#SeparatingLineEntry |
26 |
instanceVariableNames:'width' |
|
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:ListEntry |
|
30 |
! |
|
31 |
||
58 | 32 |
!ListEntry class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
37 |
All Rights Reserved |
58 | 38 |
|
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
48 |
documentation |
|
49 |
" |
|
50 |
ListEntry is an abstract superclass for objects which can be used |
|
51 |
in place of strings in ListViews or SelectionInListViews. |
|
52 |
||
53 |
If you want to create new subclasses, implement (at least) the methods |
|
54 |
found in the 'required protocol' category. |
|
158 | 55 |
|
56 |
[author:] |
|
57 |
Claus Gittinger |
|
58 |
||
59 |
[see also:] |
|
60 |
ListView |
|
58 | 61 |
" |
62 |
! ! |
|
63 |
||
5913 | 64 |
!ListEntry class methodsFor:'instance creation'! |
65 |
||
66 |
separatingLineEntry |
|
67 |
^ SeparatingLineEntry new |
|
68 |
||
69 |
"Created: / 01-10-2018 / 11:22:03 / Claus Gittinger" |
|
70 |
! ! |
|
71 |
||
5391 | 72 |
!ListEntry methodsFor:'comparing'! |
73 |
||
74 |
< aString |
|
75 |
"behave like a string when comparing" |
|
76 |
||
77 |
^ self asString < aString asString |
|
78 |
||
79 |
"Created: 8.2.1996 / 12:01:29 / cg" |
|
80 |
! |
|
81 |
||
82 |
= aString |
|
83 |
"behave like a string when comparing" |
|
84 |
||
85 |
self == aString ifTrue:[^ true]. |
|
86 |
^ self asString = aString asString |
|
87 |
! |
|
88 |
||
89 |
hash |
|
90 |
"return an integer useful for hashing" |
|
91 |
||
92 |
^ self asString hash |
|
93 |
! ! |
|
94 |
||
669 | 95 |
!ListEntry methodsFor:'printing & storing'! |
96 |
||
97 |
printOn:aStream |
|
98 |
||
99 |
aStream nextPutAll:self asString. |
|
100 |
||
101 |
"Created: / 20.1.1998 / 14:11:02 / stefan" |
|
102 |
! |
|
58 | 103 |
|
123 | 104 |
printString |
105 |
^ self asString |
|
106 |
||
107 |
"Created: 8.2.1996 / 11:56:14 / cg" |
|
669 | 108 |
! ! |
109 |
||
110 |
!ListEntry methodsFor:'queries'! |
|
123 | 111 |
|
5927 | 112 |
hasChangeOfEmphasis |
113 |
"return true, if the receiver contains non-empty emphasis information |
|
114 |
i.e. any non-normal (=emphasized) characters" |
|
115 |
||
116 |
^ false |
|
117 |
||
118 |
"Created: / 27-10-2018 / 09:51:45 / Claus Gittinger" |
|
119 |
! |
|
120 |
||
2655
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
121 |
hasIcon |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
122 |
^ false |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
123 |
! |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
124 |
|
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
125 |
hasImage |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
126 |
^ false |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
127 |
! |
4b72f593d5ba
hasImage, hasIcon queries added
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
128 |
|
3764 | 129 |
includes:aCharacter |
130 |
"behave like a string when testing" |
|
131 |
||
132 |
^ self string includes:aCharacter |
|
133 |
||
134 |
"Modified: / 30.10.1997 / 15:42:32 / cg" |
|
135 |
! |
|
136 |
||
1820 | 137 |
size |
138 |
"behave like a string when asked for the size" |
|
139 |
||
140 |
^ self string size |
|
141 |
||
142 |
"Created: / 8.2.1996 / 12:54:45 / cg" |
|
143 |
"Modified: / 30.10.1997 / 15:42:19 / cg" |
|
144 |
! |
|
145 |
||
123 | 146 |
species |
147 |
^ String |
|
148 |
||
149 |
"Created: 8.2.1996 / 12:52:38 / cg" |
|
150 |
! |
|
151 |
||
58 | 152 |
string |
153 |
^ self asString |
|
154 |
! ! |
|
155 |
||
156 |
!ListEntry methodsFor:'required protocol'! |
|
157 |
||
158 |
asString |
|
159 |
"return the receiver as a string (for example, to store it in a file)" |
|
160 |
||
161 |
^ self subclassResponsibility |
|
162 |
! |
|
163 |
||
109 | 164 |
displayOn:aGC x:x y:y opaque:opaque |
97 | 165 |
"display the receiver on a GC" |
58 | 166 |
|
167 |
^ self subclassResponsibility |
|
94 | 168 |
! |
58 | 169 |
|
173 | 170 |
heightOn:aGC |
94 | 171 |
"return the height of the receiver when displayed in aGC. |
172 |
Assume the GC's font is taken. If that is not the case in a |
|
173 |
particular subclass, this method is to be redefined there." |
|
174 |
||
821 | 175 |
^ aGC font heightOn:(aGC device) |
94 | 176 |
|
173 | 177 |
"Created: 12.5.1996 / 20:37:06 / cg" |
97 | 178 |
! |
179 |
||
2196 | 180 |
sameStringAndEmphasisAs:aStringOrText |
181 |
||
182 |
^ self subclassResponsibility |
|
183 |
! |
|
184 |
||
173 | 185 |
widthOn:aGC |
97 | 186 |
"return the width (in device units) of the receiver when displayed in aGC" |
187 |
||
188 |
^ self subclassResponsibility |
|
173 | 189 |
|
190 |
"Created: 12.5.1996 / 20:53:09 / cg" |
|
58 | 191 |
! ! |
192 |
||
123 | 193 |
!ListEntry methodsFor:'string protocol'! |
194 |
||
195 |
at:index |
|
600 | 196 |
"behave like a string when accessing characters" |
197 |
||
123 | 198 |
^ self string at:index |
199 |
||
600 | 200 |
"Created: / 8.2.1996 / 12:53:06 / cg" |
201 |
"Modified: / 30.10.1997 / 15:41:47 / cg" |
|
123 | 202 |
! |
203 |
||
204 |
do:aBlock |
|
600 | 205 |
"behave like a string when enumerating characters" |
206 |
||
123 | 207 |
^ self string do:aBlock |
208 |
||
600 | 209 |
"Created: / 8.2.1996 / 12:56:06 / cg" |
210 |
"Modified: / 30.10.1997 / 15:42:06 / cg" |
|
5927 | 211 |
! |
212 |
||
213 |
withoutAnyColorEmphasis |
|
214 |
"/ to be redefined in subclasses |
|
215 |
^ self. |
|
216 |
||
217 |
"Created: / 27-10-2018 / 10:09:14 / Claus Gittinger" |
|
600 | 218 |
! ! |
219 |
||
5913 | 220 |
!ListEntry::SeparatingLineEntry class methodsFor:'documentation'! |
221 |
||
222 |
documentation |
|
223 |
" |
|
224 |
an experiment (unfinished) |
|
225 |
||
226 |
in a listView: |
|
227 |
[exBegin] |
|
228 |
|top slv wrapper l| |
|
229 |
||
230 |
l := OrderedCollection new. |
|
231 |
l add:'one'. |
|
232 |
l add:'two'. |
|
233 |
l add:(ListEntry separatingLineEntry). |
|
234 |
l add:'three'. |
|
235 |
||
236 |
slv := SelectionInListView new. |
|
237 |
slv list:l. |
|
238 |
wrapper := HVScrollableView forView:slv miniScrollerH:true. |
|
239 |
||
240 |
top := StandardSystemView extent:150@200. |
|
241 |
top add:wrapper in:(0.0@0.0 corner:1.0@1.0). |
|
242 |
top open. |
|
243 |
[exEnd] |
|
244 |
" |
|
245 |
! ! |
|
246 |
||
247 |
!ListEntry::SeparatingLineEntry methodsFor:'required protocol'! |
|
248 |
||
249 |
displayOn:aGC x:x y:y opaque:opaque |
|
250 |
|hFont aFont yMiddle| |
|
251 |
||
252 |
"/ hFont := aGC font height. |
|
253 |
aFont := aGC font ascent. |
|
254 |
yMiddle := y - (aFont // 2). |
|
255 |
^ aGC displayLineFromX:0 y:yMiddle toX:(width-1) y:yMiddle |
|
256 |
||
257 |
"Created: / 01-10-2018 / 11:26:20 / Claus Gittinger" |
|
258 |
! |
|
259 |
||
260 |
widthOn:aGC |
|
261 |
width := aGC width. |
|
262 |
^ width |
|
263 |
||
264 |
"Created: / 01-10-2018 / 11:25:33 / Claus Gittinger" |
|
265 |
! ! |
|
266 |
||
98 | 267 |
!ListEntry class methodsFor:'documentation'! |
268 |
||
269 |
version |
|
5391 | 270 |
^ '$Header$' |
3764 | 271 |
! |
272 |
||
273 |
version_CVS |
|
5391 | 274 |
^ '$Header$' |
98 | 275 |
! ! |
5391 | 276 |