equal
deleted
inserted
replaced
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 |
13 |
14 ListEntry subclass:#LabelAndIcon |
14 ListEntry subclass:#LabelAndIcon |
15 instanceVariableNames:'icon gap string image' |
15 instanceVariableNames:'icon gap string image offset' |
16 classVariableNames:'' |
16 classVariableNames:'' |
17 poolDictionaries:'' |
17 poolDictionaries:'' |
18 category:'Views-Support' |
18 category:'Views-Support' |
19 ! |
19 ! |
20 |
20 |
257 "set the image" |
257 "set the image" |
258 |
258 |
259 image := anImage |
259 image := anImage |
260 ! |
260 ! |
261 |
261 |
|
262 offset:pixels |
|
263 "set the left offset (i.e. spacing to the left of the icon). |
|
264 The default is 0." |
|
265 |
|
266 offset := pixels. |
|
267 |
|
268 "Created: / 21.6.1998 / 03:11:03 / cg" |
|
269 ! |
|
270 |
262 string |
271 string |
263 "return my string part" |
272 "return my string part" |
264 |
273 |
265 ^ string |
274 ^ string |
266 ! |
275 ! |
296 iconHeight := icon notNil ifTrue:[icon height] ifFalse:[0]. |
305 iconHeight := icon notNil ifTrue:[icon height] ifFalse:[0]. |
297 imageHeight := image notNil ifTrue:[image height] ifFalse:[0]. |
306 imageHeight := image notNil ifTrue:[image height] ifFalse:[0]. |
298 stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
307 stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
299 |
308 |
300 maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
309 maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
301 x1 := x. |
310 x1 := x + offset. |
302 |
311 |
303 icon notNil ifTrue:[ |
312 icon notNil ifTrue:[ |
304 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
313 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
305 icon := icon onDevice:aGC device. |
314 icon := icon onDevice:aGC device. |
306 |
315 |
320 x1 := x1 + image width + gap |
329 x1 := x1 + image width + gap |
321 ]. |
330 ]. |
322 |
331 |
323 stringHeight ~~ 0 ifTrue:[ |
332 stringHeight ~~ 0 ifTrue:[ |
324 y1 := y + (maxHeight - stringHeight + 1 // 2). |
333 y1 := y + (maxHeight - stringHeight + 1 // 2). |
325 string displayOn:aGC x:x1 y:y1 |
334 string displayOn:aGC x:x1 y:y1 opaque:opaque |
326 ] |
335 ] |
|
336 |
|
337 "Modified: / 21.6.1998 / 03:52:12 / cg" |
327 ! |
338 ! |
328 |
339 |
329 on:aDevice |
340 on:aDevice |
330 "return a new image on a device |
341 "return a new image on a device |
331 " |
342 " |
345 ! ! |
356 ! ! |
346 |
357 |
347 !LabelAndIcon methodsFor:'initialization'! |
358 !LabelAndIcon methodsFor:'initialization'! |
348 |
359 |
349 initialize |
360 initialize |
350 gap := 4 |
361 gap := 4. |
|
362 offset := 0. |
|
363 |
|
364 "Modified: / 21.6.1998 / 03:10:19 / cg" |
351 ! ! |
365 ! ! |
352 |
366 |
353 !LabelAndIcon methodsFor:'queries'! |
367 !LabelAndIcon methodsFor:'queries'! |
354 |
368 |
355 heightOn:aGC |
369 heightOn:aGC |
380 widthOn:aGC |
394 widthOn:aGC |
381 "return the width of the receiver, if it is to be displayed on aGC" |
395 "return the width of the receiver, if it is to be displayed on aGC" |
382 |
396 |
383 |width| |
397 |width| |
384 |
398 |
385 width := 0. |
399 width := offset. |
386 icon notNil ifTrue:[ |
400 icon notNil ifTrue:[ |
387 width := width + icon width |
401 width := width + icon width |
388 ]. |
402 ]. |
389 image notNil ifTrue:[ |
403 image notNil ifTrue:[ |
390 width := width + gap + image width |
404 width := width + gap + image width |
391 ]. |
405 ]. |
392 string size > 0 ifTrue:[ |
406 string size > 0 ifTrue:[ |
393 width := width + gap + (string widthOn:aGC) |
407 width := width + gap + (string widthOn:aGC) |
394 ]. |
408 ]. |
395 ^width |
409 ^width |
396 |
410 |
|
411 "Modified: / 21.6.1998 / 03:11:14 / cg" |
397 ! ! |
412 ! ! |
398 |
413 |
399 !LabelAndIcon class methodsFor:'documentation'! |
414 !LabelAndIcon class methodsFor:'documentation'! |
400 |
415 |
401 version |
416 version |
402 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.21 1998-03-09 16:07:25 ca Exp $' |
417 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.22 1998-06-21 02:48:23 cg Exp $' |
403 ! ! |
418 ! ! |