author | Stefan Vogel <sv@exept.de> |
Wed, 18 Sep 2002 21:33:10 +0200 | |
changeset 2197 | 7ad026a1ae93 |
parent 1977 | e658f77f88b2 |
child 2453 | 3dad4e5c2fbe |
permissions | -rw-r--r-- |
172 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
14 |
"{ Package: 'stx:libwidg2' }" |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
15 |
|
2197
7ad026a1ae93
Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents:
1977
diff
changeset
|
16 |
ModelListEntry subclass:#LabelAndIcon |
7ad026a1ae93
Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents:
1977
diff
changeset
|
17 |
instanceVariableNames:'icon gap image offset' |
172 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Support' |
|
21 |
! |
|
22 |
||
23 |
!LabelAndIcon class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
an icon and a string, side by side. |
|
178 | 43 |
Usable as list entries in a listView (a fileList), as |
179 | 44 |
popUpMenuItems or as Label/Button image. |
172 | 45 |
|
46 |
This is an example class - currently not used by the system. |
|
47 |
||
179 | 48 |
Notice: |
49 |
This is different from ST-80's LabelAndIcon class, which |
|
50 |
inherits from Label. Therefore, things may change in the future. |
|
51 |
||
172 | 52 |
[author:] |
53 |
Claus Gittinger |
|
54 |
||
55 |
[see also:] |
|
56 |
ListEntry Text String Icon |
|
57 |
ListView SelectionInListView |
|
58 |
" |
|
59 |
! |
|
60 |
||
61 |
examples |
|
62 |
" |
|
175 | 63 |
in a listView: |
172 | 64 |
[exBegin] |
65 |
|top slv wrapper l fileImage dirImage| |
|
66 |
||
67 |
fileImage := Image |
|
68 |
width:16 |
|
69 |
height:16 |
|
70 |
depth:1 |
|
71 |
fromArray:#[2r00000000 2r00000000 |
|
72 |
2r00000000 2r00000000 |
|
73 |
2r00011111 2r11100000 |
|
74 |
2r00010000 2r00100000 |
|
75 |
2r00010000 2r00011000 |
|
76 |
2r00010000 2r00001000 |
|
77 |
2r00010000 2r00001000 |
|
78 |
2r00010000 2r00001000 |
|
79 |
2r00010000 2r00001000 |
|
80 |
2r00010000 2r00001000 |
|
81 |
2r00010000 2r00001000 |
|
82 |
2r00010000 2r00001000 |
|
83 |
2r00010000 2r00001000 |
|
84 |
2r00011111 2r11111000 |
|
85 |
2r00000000 2r00000000 |
|
86 |
2r00000000 2r00000000]. |
|
87 |
fileImage photometric:#whiteIs0. |
|
88 |
||
89 |
dirImage := Image |
|
90 |
width:16 |
|
91 |
height:16 |
|
92 |
depth:1 |
|
93 |
fromArray:#[2r00000000 2r00000000 |
|
94 |
2r00000000 2r00000000 |
|
95 |
2r00000000 2r00000000 |
|
96 |
2r01111111 2r11110000 |
|
97 |
2r01000000 2r00001000 |
|
98 |
2r01000000 2r00000100 |
|
99 |
2r01000000 2r00000010 |
|
100 |
2r01000000 2r00000010 |
|
101 |
2r01000000 2r00000010 |
|
102 |
2r01000000 2r00000010 |
|
103 |
2r01000000 2r00000010 |
|
104 |
2r01000000 2r00000010 |
|
105 |
2r01111111 2r11111110 |
|
106 |
2r00000000 2r00000000 |
|
107 |
2r00000000 2r00000000 |
|
108 |
2r00000000 2r00000000]. |
|
109 |
dirImage photometric:#whiteIs0. |
|
110 |
||
111 |
||
112 |
l := OrderedCollection new. |
|
113 |
Filename currentDirectory directoryContents do:[:s | |
|
114 |
s asFilename isDirectory ifTrue:[ |
|
115 |
l add:(LabelAndIcon icon:dirImage string:s) |
|
116 |
] ifFalse:[ |
|
117 |
l add:(LabelAndIcon icon:fileImage string:s) |
|
118 |
] |
|
119 |
]. |
|
120 |
||
121 |
slv := SelectionInListView new. |
|
122 |
slv list:l. |
|
123 |
wrapper := HVScrollableView forView:slv miniScrollerH:true. |
|
124 |
||
125 |
top := StandardSystemView extent:150@200. |
|
126 |
top add:wrapper in:(0.0@0.0 corner:1.0@1.0). |
|
127 |
top open. |
|
128 |
[exEnd] |
|
175 | 129 |
in a selectionInListView: |
172 | 130 |
[exBegin] |
131 |
|top slv wrapper l fileImage dirImage| |
|
132 |
||
133 |
dirImage := Image fromFile:'DirObj.xbm'. |
|
134 |
fileImage := Image fromFile:'FileObj.xbm'. |
|
135 |
||
136 |
||
137 |
l := OrderedCollection new. |
|
138 |
Filename currentDirectory directoryContents do:[:s | |
|
139 |
s asFilename isDirectory ifTrue:[ |
|
140 |
l add:(LabelAndIcon icon:dirImage string:s) |
|
141 |
] ifFalse:[ |
|
142 |
l add:(LabelAndIcon icon:fileImage string:s) |
|
143 |
] |
|
144 |
]. |
|
145 |
||
146 |
slv := SelectionInListView new. |
|
147 |
slv list:l. |
|
148 |
wrapper := HVScrollableView forView:slv miniScrollerH:true. |
|
149 |
||
150 |
top := StandardSystemView extent:150@200. |
|
151 |
top add:wrapper in:(0.0@0.0 corner:1.0@1.0). |
|
152 |
top open. |
|
153 |
[exEnd] |
|
175 | 154 |
in a menu: |
155 |
[exBegin] |
|
156 |
|top l fileImage dirImage| |
|
157 |
||
158 |
dirImage := Image fromFile:'DirObj.xbm'. |
|
159 |
fileImage := Image fromFile:'FileObj.xbm'. |
|
160 |
||
161 |
||
162 |
l := OrderedCollection new. |
|
163 |
l add:(LabelAndIcon icon:dirImage string:'create directory'). |
|
164 |
l add:(LabelAndIcon icon:fileImage string:'create file'). |
|
165 |
||
166 |
top := View new. |
|
167 |
||
168 |
top middleButtonMenu:(PopUpMenu labels:l |
|
169 |
selectors:#(foo bar)). |
|
170 |
||
171 |
top open. |
|
172 |
[exEnd] |
|
178 | 173 |
in a button/label: |
174 |
[exBegin] |
|
175 |
|top l image| |
|
176 |
||
177 |
image := Image fromFile:'DirObj.xbm'. |
|
178 |
l := (LabelAndIcon icon:image string:'directory'). |
|
179 |
||
180 |
top := Button label:l. |
|
181 |
top open. |
|
182 |
[exEnd] |
|
172 | 183 |
" |
184 |
! ! |
|
185 |
||
186 |
!LabelAndIcon class methodsFor:'instance creation'! |
|
187 |
||
629 | 188 |
form:aForm image:anImage |
726 | 189 |
|
629 | 190 |
^self new form:aForm image:anImage string:'' |
191 |
! |
|
192 |
||
193 |
form:aForm image:anImage string:aString |
|
726 | 194 |
|
629 | 195 |
^self new form:aForm image:anImage string:aString |
196 |
! |
|
197 |
||
172 | 198 |
icon:anIcon string:aString |
726 | 199 |
|
172 | 200 |
^ self new icon:anIcon string:aString |
201 |
||
202 |
"Created: 12.5.1996 / 20:00:58 / cg" |
|
203 |
! |
|
204 |
||
1977 | 205 |
label:aString icon:anIcon |
206 |
^ self new icon:anIcon string:aString |
|
207 |
! |
|
208 |
||
172 | 209 |
new |
210 |
^ self basicNew initialize |
|
211 |
||
212 |
"Created: 12.5.1996 / 20:00:58 / cg" |
|
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
213 |
! |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
214 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
215 |
string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
216 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
217 |
^ self new icon:nil string:aString |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
218 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
219 |
"Created: / 21.6.1998 / 04:57:28 / cg" |
172 | 220 |
! ! |
221 |
||
222 |
!LabelAndIcon methodsFor:'accessing'! |
|
223 |
||
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
224 |
beCheckMark |
1860 | 225 |
"/ self icon:(CheckToggle checkFormOn:Screen current) |
226 |
self icon:((CheckToggle smallCheckImageForStyle:#borderedFatcross) onDevice:Screen current) |
|
986
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
227 |
|
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
228 |
"Created: / 21.6.1998 / 05:01:01 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
229 |
"Modified: / 21.6.1998 / 05:03:23 / cg" |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
230 |
! |
ed6b89c43416
added #beCheckMark for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
981
diff
changeset
|
231 |
|
629 | 232 |
form:aForm image:anImage string:aString |
233 |
||
234 |
icon := aForm. |
|
235 |
image:= anImage. |
|
236 |
string := aString. |
|
237 |
! |
|
238 |
||
1975 | 239 |
gap |
240 |
"return the spacing between the icon and the labelString. |
|
241 |
The default is 4" |
|
242 |
||
243 |
^ gap |
|
244 |
! |
|
245 |
||
172 | 246 |
gap:pixels |
247 |
"set the spacing between the icon and the labelString. |
|
248 |
The default is 4." |
|
249 |
||
250 |
gap := pixels. |
|
251 |
||
252 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
253 |
! |
|
254 |
||
286 | 255 |
icon |
256 |
"return my icon part" |
|
257 |
||
258 |
^ icon |
|
259 |
! |
|
260 |
||
172 | 261 |
icon:anIcon |
262 |
"set the icon image" |
|
263 |
||
264 |
icon := anIcon. |
|
265 |
||
266 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
267 |
! |
|
268 |
||
269 |
icon:anIcon string:aString |
|
270 |
"set both iconImage and the labelString" |
|
271 |
||
272 |
icon := anIcon. |
|
273 |
string := aString |
|
274 |
||
275 |
"Created: 12.5.1996 / 20:00:52 / cg" |
|
175 | 276 |
! |
277 |
||
719 | 278 |
image |
279 |
"return my image" |
|
280 |
||
281 |
^ image |
|
282 |
! |
|
283 |
||
284 |
image:anImage |
|
285 |
"set the image" |
|
286 |
||
287 |
image := anImage |
|
288 |
! |
|
289 |
||
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
290 |
offset:pixels |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
291 |
"set the left offset (i.e. spacing to the left of the icon). |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
292 |
The default is 0." |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
293 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
294 |
offset := pixels. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
295 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
296 |
"Created: / 21.6.1998 / 03:11:03 / cg" |
172 | 297 |
! ! |
298 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
299 |
!LabelAndIcon methodsFor:'comparing'! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
300 |
|
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
301 |
sameStringAndEmphasisAs:someStringOrLabelAndIcon |
1817 | 302 |
someStringOrLabelAndIcon class == self class ifTrue:[ |
303 |
icon = someStringOrLabelAndIcon icon ifFalse:[^ false]. |
|
304 |
image = someStringOrLabelAndIcon image ifFalse:[^ false]. |
|
305 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon string) ifFalse:[ ^ false]. |
|
306 |
^ true. |
|
307 |
]. |
|
308 |
||
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
309 |
(string sameStringAndEmphasisAs:someStringOrLabelAndIcon) ifFalse:[ ^ false]. |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
310 |
(icon isNil and:[image isNil]) ifTrue:[^ true]. |
1817 | 311 |
^ false |
1814
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
312 |
! ! |
a7697ca7f34f
added sameStringAndEmphasisAs
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
313 |
|
172 | 314 |
!LabelAndIcon methodsFor:'displaying'! |
315 |
||
316 |
displayOn:aGC x:x y:y opaque:opaque |
|
317 |
"display the receiver on a GC" |
|
318 |
||
726 | 319 |
|y1 x1 iconHeight imageHeight stringHeight maxHeight gapY asc| |
320 |
||
321 |
gapY := (aGC device pixelPerMillimeter x) rounded. |
|
1860 | 322 |
"/ gapY := 0. |
1479 | 323 |
asc := (aGC font onDevice:aGC device) ascent. |
180 | 324 |
|
726 | 325 |
iconHeight := icon notNil ifTrue:[icon height] ifFalse:[0]. |
326 |
imageHeight := image notNil ifTrue:[image height] ifFalse:[0]. |
|
327 |
stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
|
172 | 328 |
|
726 | 329 |
maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
330 |
x1 := x + offset. |
258 | 331 |
|
306 | 332 |
icon notNil ifTrue:[ |
726 | 333 |
y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
1860 | 334 |
|
726 | 335 |
icon := icon onDevice:aGC device. |
578
72916ad0a5f3
fixed centering of the image w.r.t. the fontHeight
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
336 |
|
726 | 337 |
(opaque and:[icon mask isNil]) ifTrue:[aGC displayOpaqueForm:icon x:x1 y:y1] |
338 |
ifFalse:[aGC displayForm:icon x:x1 y:y1]. |
|
578
72916ad0a5f3
fixed centering of the image w.r.t. the fontHeight
Claus Gittinger <cg@exept.de>
parents:
423
diff
changeset
|
339 |
|
726 | 340 |
x1 := x1 + icon width + gap |
258 | 341 |
]. |
342 |
||
629 | 343 |
image notNil ifTrue:[ |
726 | 344 |
y1 := y - asc + (maxHeight - imageHeight + 1 // 2). |
345 |
image := image onDevice:aGC device. |
|
346 |
||
347 |
(opaque and:[image mask isNil]) ifTrue:[aGC displayOpaqueForm:image x:x1 y:y1] |
|
348 |
ifFalse:[aGC displayForm:image x:x1 y:y1]. |
|
629 | 349 |
|
726 | 350 |
x1 := x1 + image width + gap |
629 | 351 |
]. |
172 | 352 |
|
726 | 353 |
stringHeight ~~ 0 ifTrue:[ |
354 |
y1 := y + (maxHeight - stringHeight + 1 // 2). |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
355 |
string displayOn:aGC x:x1 y:y1 opaque:opaque |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
356 |
] |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
357 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
358 |
"Modified: / 21.6.1998 / 03:52:12 / cg" |
810 | 359 |
! |
360 |
||
361 |
on:aDevice |
|
362 |
"return a new image on a device |
|
363 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
364 |
^ self onDevice:aDevice |
810 | 365 |
|
366 |
! |
|
367 |
||
368 |
onDevice:aDevice |
|
369 |
"return a new image on a device |
|
370 |
" |
|
1604
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
371 |
|form img| |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
372 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
373 |
aDevice isNil ifTrue:[^ self]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
374 |
icon notNil ifTrue:[form := icon onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
375 |
image notNil ifTrue:[img := image onDevice:aDevice]. |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
376 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
377 |
^ LabelAndIcon form:form image:img string:string |
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
378 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
379 |
|
2c15dd8fb3cf
ignore nil device in #onDevice:
Claus Gittinger <cg@exept.de>
parents:
1479
diff
changeset
|
380 |
|
172 | 381 |
! ! |
382 |
||
383 |
!LabelAndIcon methodsFor:'initialization'! |
|
384 |
||
385 |
initialize |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
386 |
gap := 4. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
387 |
offset := 0. |
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
388 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
389 |
"Modified: / 21.6.1998 / 03:10:19 / cg" |
172 | 390 |
! ! |
391 |
||
392 |
!LabelAndIcon methodsFor:'queries'! |
|
393 |
||
394 |
heightOn:aGC |
|
395 |
"return the height of the receiver, if it is to be displayed on aGC" |
|
396 |
||
719 | 397 |
|iconHeight imageHeight stringHeight oneMillimeter| |
682 | 398 |
|
399 |
oneMillimeter := aGC device pixelPerMillimeter x rounded. |
|
1860 | 400 |
"/ oneMillimeter := 0. |
306 | 401 |
|
402 |
icon notNil ifTrue:[ |
|
682 | 403 |
iconHeight := icon height + oneMillimeter |
306 | 404 |
] ifFalse:[ |
405 |
iconHeight := 0 |
|
406 |
]. |
|
629 | 407 |
image notNil ifTrue:[ |
682 | 408 |
imageHeight := image height + oneMillimeter |
629 | 409 |
] ifFalse:[ |
410 |
imageHeight := 0 |
|
411 |
]. |
|
719 | 412 |
string size > 0 ifTrue:[ |
413 |
stringHeight := string heightOn:aGC |
|
414 |
] ifFalse:[ |
|
415 |
stringHeight := 0 |
|
416 |
]. |
|
726 | 417 |
^ ((iconHeight max: imageHeight) max: stringHeight) |
172 | 418 |
! |
419 |
||
420 |
widthOn:aGC |
|
421 |
"return the width of the receiver, if it is to be displayed on aGC" |
|
422 |
||
719 | 423 |
|width| |
306 | 424 |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
425 |
width := offset. |
306 | 426 |
icon notNil ifTrue:[ |
719 | 427 |
width := width + icon width |
306 | 428 |
]. |
629 | 429 |
image notNil ifTrue:[ |
719 | 430 |
width := width + gap + image width |
629 | 431 |
]. |
719 | 432 |
string size > 0 ifTrue:[ |
433 |
width := width + gap + (string widthOn:aGC) |
|
434 |
]. |
|
435 |
^width |
|
981
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
436 |
|
b7558ca52e20
added an optional left-offset
Claus Gittinger <cg@exept.de>
parents:
810
diff
changeset
|
437 |
"Modified: / 21.6.1998 / 03:11:14 / cg" |
172 | 438 |
! ! |
439 |
||
440 |
!LabelAndIcon class methodsFor:'documentation'! |
|
441 |
||
442 |
version |
|
2197
7ad026a1ae93
Make subclass of ModelListEntry
Stefan Vogel <sv@exept.de>
parents:
1977
diff
changeset
|
443 |
^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.31 2002-09-18 19:33:10 stefan Exp $' |
172 | 444 |
! ! |