8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libwidg2' }" |
12 "{ Package: 'stx:libwidg2' }" |
|
13 |
|
14 "{ NameSpace: Smalltalk }" |
13 |
15 |
14 ModelListEntry subclass:#LabelAndIcon |
16 ModelListEntry subclass:#LabelAndIcon |
15 instanceVariableNames:'icon gap image offset' |
17 instanceVariableNames:'icon gap image offset' |
16 classVariableNames:'' |
18 classVariableNames:'' |
17 poolDictionaries:'' |
19 poolDictionaries:'' |
373 !LabelAndIcon methodsFor:'displaying'! |
375 !LabelAndIcon methodsFor:'displaying'! |
374 |
376 |
375 displayOn:aGC x:x y:y opaque:opaque |
377 displayOn:aGC x:x y:y opaque:opaque |
376 "display the receiver on a GC" |
378 "display the receiver on a GC" |
377 |
379 |
378 |y1 x1 iconValue imageValue iconHeight imageHeight stringHeight maxHeight gapY asc| |
380 |y1 x1 iconValue imageValue iconHeight imageHeight stringHeight maxHeight gapY asc device| |
379 |
381 |
380 gapY := (aGC device pixelPerMillimeter x) rounded. |
382 device := aGC device. |
381 "/ gapY := 0. |
383 gapY := (device pixelPerMillimeter x) rounded. |
382 asc := (aGC font onDevice:aGC device) ascent. |
384 asc := (aGC font onDevice:device) ascent. |
383 |
385 |
384 iconValue := icon value. |
386 iconValue := icon value. |
385 imageValue := image value. |
387 imageValue := image value. |
386 |
388 |
387 iconHeight := iconValue notNil ifTrue:[iconValue height] ifFalse:[0]. |
389 iconHeight := iconValue notNil ifTrue:[iconValue height] ifFalse:[0]. |
388 imageHeight := imageValue notNil ifTrue:[imageValue height] ifFalse:[0]. |
390 imageHeight := imageValue notNil ifTrue:[imageValue height] ifFalse:[0]. |
389 stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
391 stringHeight := string size ~~ 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
390 |
392 |
391 "/ maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
393 "/ maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
392 maxHeight := self heightOn:aGC. |
394 maxHeight := self heightOn:aGC. |
393 |
395 |
394 x1 := x + offset. |
396 x1 := x + offset. |
395 |
397 |
396 iconValue notNil ifTrue:[ |
398 iconValue notNil ifTrue:[ |
397 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
399 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
398 |
400 |
399 icon := iconValue onDevice:aGC device. |
401 icon := iconValue onDevice:device. |
400 |
402 |
401 (opaque and:[iconValue mask isNil]) ifTrue:[aGC displayOpaqueForm:iconValue x:x1 y:y1] |
403 (opaque and:[iconValue mask isNil]) ifTrue:[aGC displayOpaqueForm:iconValue x:x1 y:y1] |
402 ifFalse:[aGC displayForm:iconValue x:x1 y:y1]. |
404 ifFalse:[aGC displayForm:iconValue x:x1 y:y1]. |
403 |
405 |
404 x1 := x1 + iconValue width + gap |
406 x1 := x1 + iconValue width + gap |
405 ]. |
407 ]. |
406 |
408 |
407 imageValue notNil ifTrue:[ |
409 imageValue notNil ifTrue:[ |
408 y1 := y - asc + (maxHeight - imageHeight + 1 // 2). |
410 y1 := y - asc + (maxHeight - imageHeight + 1 // 2). |
409 image := imageValue onDevice:aGC device. |
411 image := imageValue onDevice:device. |
410 |
412 |
411 (opaque and:[imageValue mask isNil]) ifTrue:[aGC displayOpaqueForm:imageValue x:x1 y:y1] |
413 (opaque and:[imageValue mask isNil]) ifTrue:[aGC displayOpaqueForm:imageValue x:x1 y:y1] |
412 ifFalse:[aGC displayForm:imageValue x:x1 y:y1]. |
414 ifFalse:[aGC displayForm:imageValue x:x1 y:y1]. |
413 |
415 |
414 x1 := x1 + imageValue width + gap |
416 x1 := x1 + imageValue width + gap |