LabelAndIcon.st
changeset 4878 5928056755ab
parent 4678 450244b6639f
child 4928 ae564942af8d
child 5020 6dd1826b889c
equal deleted inserted replaced
4876:8edcf9875271 4878:5928056755ab
     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
   421 
   423 
   422     "Modified: / 21.6.1998 / 03:52:12 / cg"
   424     "Modified: / 21.6.1998 / 03:52:12 / cg"
   423 !
   425 !
   424 
   426 
   425 on:aDevice
   427 on:aDevice
       
   428     <resource: #obsolete>
   426     "return a new image on a device
   429     "return a new image on a device
   427     "
   430     "
   428     ^ self onDevice:aDevice
   431     ^ self onDevice:aDevice
   429 
   432 
   430 !
   433 !
   530 ! !
   533 ! !
   531 
   534 
   532 !LabelAndIcon class methodsFor:'documentation'!
   535 !LabelAndIcon class methodsFor:'documentation'!
   533 
   536 
   534 version
   537 version
   535     ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.43 2014-12-01 22:16:24 cg Exp $'
   538     ^ '$Header$'
   536 !
   539 !
   537 
   540 
   538 version_CVS
   541 version_CVS
   539     ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.43 2014-12-01 22:16:24 cg Exp $'
   542     ^ '$Header$'
   540 ! !
   543 ! !
   541 
   544