TransparentBox.st
author Stefan Vogel <sv@exept.de>
Tue, 18 Feb 2014 18:13:02 +0100
changeset 3289 3dff9f4efe99
parent 2377 4a5d442f4a2b
child 3621 63e942161951
permissions -rw-r--r--
class: TransparentBox changed: #computeShape get device via method call

"
 COPYRIGHT (c) 2004 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' }"

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

!TransparentBox class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2004 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.
"
!

examples
"
    | tv b1 b2 |

    b1 := Button label:'close'.
    b1 action:[ tv close ].
    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 |

    self graphicsDevice 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.5 2014-02-18 17:13:02 stefan Exp $'
! !