MultiImage.st
author convert-repo
Thu, 06 Dec 2018 04:35:51 +0000
changeset 4215 bc67d59fcf46
parent 4202 a0ae08f456ba
child 4332 7c7749ad2f63
permissions -rw-r--r--
update tags

"{ Encoding: utf8 }"

"
 COPYRIGHT (c) 2003 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libview2' }"

"{ NameSpace: Smalltalk }"

Object subclass:#MultiImage
	instanceVariableNames:'images'
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Images'
!

!MultiImage class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2003 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    A multiImage is an image which is drawn by drawing multiple images on top of each other.
    Typically, they are used to overlay additional information,
    for example a stop-icon or a link-arrow over a fileType icon.

    try: 
        MIMETypeIconLibrary iconForFile:'/foo/bar/baz.c' asFilename

    caveat:
        instances provide enough protocol to be shown as icon, label, etc.
        (i.e. provide a replacement for images and forms).
        However, not all tools are prepared for them not having mask, bits etc.
        Especially, the ImageEditor gets a bit confused and may fall into a debugger,
        if trying to edit one of my instances.
        
    [author:]
        Claus Gittinger
"
! !

!MultiImage class methodsFor:'instance creation'!

images:imageCollection
    ^ self new images:imageCollection
! !

!MultiImage methodsFor:'accessing'!

device
    images isNil ifTrue:[^ nil].
    ^ images first device
!

graphicsDevice
    images isNil ifTrue:[^ nil].
    ^ images first graphicsDevice

    "Created: / 25-10-2018 / 12:40:16 / Claus Gittinger"
!

images
    "return the value of the instance variable 'images' (automatically generated)"

    ^ images
!

images:something
    "set the value of the instance variable 'images' (automatically generated)"

    images := something.
!

mask
    ^ nil

    "Created: / 25-10-2018 / 12:35:09 / Claus Gittinger"
! !

!MultiImage methodsFor:'displaying'!

displayOn:aGC x:x y:y opaque:opaque
    |doOpaque|

    doOpaque := opaque.
    images do:[:eachImage |
        eachImage displayOn:aGC x:x y:y opaque:doOpaque.
        doOpaque := false.
    ].
! !

!MultiImage methodsFor:'misc'!

asFormOn:aDevice
    |form|

    form := Form extent:(images first extent) depth:aDevice depth onDevice:aDevice.
    images do:[:eachImage |
        eachImage displayOn:form x:0 y:0 opaque:false.
    ].
    ^ form

    "Created: / 25-10-2018 / 12:38:18 / Claus Gittinger"
!

clearMaskedPixels
    images := images do:[:eachImage | eachImage clearMaskedPixels].
    ^ self
!

onDevice:device
    images := images collect:[:eachImage | (eachImage onDevice:device) ? eachImage].
    ^ self
! !


!MultiImage methodsFor:'queries'!

ascentOn:aGC
    "I will not draw myself above the baseline"

    ^ 0
!

depth
    ^ images inject:0 into:[:maxSoFar :eachImage | maxSoFar max:eachImage depth].
!

extent
    ^ self width @ self height
!

height  
    ^ images inject:0 into:[:maxSoFar :eachImage | maxSoFar max:eachImage height].
!

isImageOrForm
    ^ true
!

width
    ^ images inject:0 into:[:maxSoFar :eachImage | maxSoFar max:eachImage width].
! !

!MultiImage class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !