MultiImage.st
author Claus Gittinger <cg@exept.de>
Sat, 12 May 2018 14:23:45 +0200
changeset 4088 bbf9b58f99c8
parent 4053 f2c550e0c24e
child 4202 a0ae08f456ba
permissions -rw-r--r--
#FEATURE by cg class: MIMETypes class changed: #initializeFileInfoMappings class: MIMETypes::MIMEType added: #asMimeType #isCHeaderType #isCPPSourceType #isCSourceType

"
 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
!

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.
! !

!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'!

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$'
! !