PopUpView.st
author claus
Wed, 13 Oct 1993 03:44:47 +0100
changeset 6 7ee0cfde237d
parent 5 e5942fea6925
child 12 9f0995fac1fa
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.4 1993-10-13 02:44:06 claus Exp $

written spring/summer 89 by claus
'!

Smalltalk at:#ActiveGrab put:nil!

!PopUpView class methodsFor:'documentation'!

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.
    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).
    self is3D ifTrue:[
        borderWidth := 0.
        self level:2
    ] ifFalse:[
        borderWidth := 1
    ].

    PopShadow ifTrue:[
        shadowView := (ShadowView on:device) for:self.
        device hasGreyscales ifTrue:[
            shadowView paint:(Color darkGrey)
        ]
    ].
    haveControl := false
!

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

create
    super create.
    PopShadow ifFalse:[
        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 "drawableId" 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.
    device grabPointerIn:drawableId.
    ActiveGrab := self.
!

realize
    shadowView notNil ifTrue:[shadowView realize].
    self raise.
    super realize.

    "get the pointer into my window"
"
    device grabPointerIn:drawableId.
    ActiveGrab := self.
"
    "and handle events for me"
    self takeControl
!

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

!PopUpView methodsFor:'accessing'!

heightIncludingBorder
    ^ height
!

widthIncludingBorder
    ^ width
!

createOnTop
    ^ true
! !