PopUpView.st
author claus
Mon, 10 Oct 1994 03:34:45 +0100
changeset 72 3e84121988c3
parent 54 29a6b2f8e042
child 81 4ba554473294
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1989 by Claus Gittinger
	      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.
"

View subclass:#PopUpView
       instanceVariableNames:'shadowView haveControl'
       classVariableNames:'PopShadow'
       poolDictionaries:''
       category:'Views-Basic'
!

PopUpView comment:'
COPYRIGHT (c) 1989 by Claus Gittinger
	      All Rights Reserved

$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.8 1994-10-10 02:32:53 claus Exp $
'!

Smalltalk at:#ActiveGrab put:nil!

!PopUpView class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1989 by Claus Gittinger
	      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.
"
!

version
"
$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.8 1994-10-10 02:32:53 claus Exp $
"
!

documentation
"
    this class implements an abstract superclass for all views which bypass the 
    window manager and pop up on top of the screen. 
    They are usually not decorated by window managers.

    class variables:

	PopShadow       <Boolean>       if true, popupviews show a shadow
"
! !

!PopUpView class methodsFor:'defaults'!

defaultExtent
    ^ (Display width // 2) @ (Display height // 2)
! !

!PopUpView class methodsFor:'initialization'!

initialize
    super initialize.
    Display notNil ifTrue:[
	PopShadow := self classResources name:'POPUP_SHADOW' default:false
    ]
! !

!PopUpView methodsFor:'initialization / release'!

initialize
    |c|

    super initialize.
    c := device center.
    left := c x - (width // 2).
    top := c y - (height // 2).
    ((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[
	borderWidth := 0.
	self level:2
    ] ifFalse:[
	borderWidth := 1
    ].

    (StyleSheet at:#popupShadow default:false) ifTrue:[
	shadowView := (ShadowView on:device) for:self.
    ].
    haveControl := false
!

destroy
    haveControl := false.
    super destroy.
    shadowView notNil ifTrue:[shadowView destroy. shadowView := nil]
!

create
    super create.
    shadowView isNil ifTrue:[
	self saveUnder:true
    ]
! !

!PopUpView methodsFor:'dispatching'!

modalLoop
    haveControl := true.

    "this is a kludge - we do not have multiple processes, therefore
     we start another dispatch loop, which exits when control is lost"

    device dispatchFor:nil while:[haveControl]
! !

!PopUpView methodsFor:'private'!

takeControl
^ self.
    haveControl := true.

    "this is a kludge - we do not have multiple processes, therefore
     we start another dispatch loop, which exits when control is lost"

    device dispatchFor:drawableId while:[haveControl]
!

leaveControl
    haveControl := false
! !

!PopUpView methodsFor:'realize / unrealize'!

mapped
    "wait till visible for grabbing"

    super mapped.
    ActiveGrab notNil ifTrue:[
	device ungrabPointer.
	ActiveGrab := nil
    ].
    device grabPointerIn:drawableId.
    ActiveGrab := self.
!

realize
    shadowView notNil ifTrue:[shadowView realize].
    self raise.
    super realize.
    haveControl := true.
!

unrealize
    haveControl := false.
    ActiveGrab == self ifTrue:[
	device ungrabPointer.
	ActiveGrab := nil.
    ].
    super unrealize.
    shadowView notNil ifTrue:[shadowView unrealize].
! !

!PopUpView methodsFor:'accessing'!

heightIncludingBorder
    ^ height
!

widthIncludingBorder
    ^ width
!

createOnTop
    ^ true
! !