TransparentBox.st
author Claus Gittinger <cg@exept.de>
Fri, 16 Jul 2004 16:40:32 +0200
changeset 2003 196bdcaf1859
parent 1975 3901166c295e
child 2004 a0245a3e8cdc
permissions -rw-r--r--
*** empty log message ***

"{ Package: 'stx:libview2' }"

View subclass:#TransparentBox
	instanceVariableNames:'shapeForm'
	classVariableNames:''
	poolDictionaries:''
	category:'Views-Basic'
!

!TransparentBox class methodsFor:'documentation'!

examples
"
    | tv b1 b2 |

    b1 := Button label:'hello'.
    b1 origin:10@10.

    b2 := Button label:'hello'.
    b2 origin:100@100.

    tv := self new.
    tv extent:200@200.

    tv addSubView:b1.
    tv addSubView:b2.
    tv open
"
! !

!TransparentBox methodsFor:'events'!

sizeChanged:how
    shapeForm notNil ifTrue:[
        self computeShape.
    ].
    ^ super sizeChanged: how.
! !

!TransparentBox methodsFor:'initialization'!

realize
    self computeShape.
    super realize.
! !

!TransparentBox methodsFor:'queries'!

isTransparentBox

    ^true
!

specClass
    ^ TransparentBoxSpec
!

windowStyle
    ^ #undecorated
! !

!TransparentBox methodsFor:'shape computation'!

addSubView:aView
    super addSubView:aView.
    shapeForm notNil ifTrue:[
        self computeShape
    ].
!

computeShape
    | subViews w h |

    device supportsArbitraryShapedViews ifFalse:[^self].

    w := self extent x.
    h := self extent y.
    shapeForm := Form width:w height:h.
    shapeForm fill:(Color colorId:0).

    shapeForm foreground:(Color colorId:1).

    subViews := self subViews.
    subViews isEmptyOrNil ifTrue:[
       self fillFormWithBorderShape:shapeForm.
    ] ifFalse:[
        subViews do:[:aSubView|
            aSubView fillFormWithBorderShape:shapeForm.
        ]
    ].
    "/ self viewShape:shapeForm.
    self borderShape:shapeForm.
! !

!TransparentBox class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/TransparentBox.st,v 1.2 2004-07-16 14:40:32 cg Exp $'
! !