"
COPYRIGHT (c) 1990-93 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.
"
StandardSystemView subclass:#ModalBox
instanceVariableNames:'haveControl shadowView'
classVariableNames:'PopShadow'
poolDictionaries:''
category:'Views-Basic'
!
ModalBox comment:'
COPYRIGHT (c) 1990-93 by Claus Gittinger
All Rights Reserved
this class implements modal boxes; those that take control until all
processing is done.
class variables:
PopShadow <Boolean> if true, modalBoxes will show a shadow
%W% %E%
written Jan 90 by claus
'!
!ModalBox class methodsFor:'instance creation'!
new
^ super on:ModalDisplay
! !
!ModalBox class methodsFor:'initialization'!
initialize
super initialize.
PopShadow := Resource name:'POPUP_SHADOW'
default:View3D
fromFile:'Smalltalk.rs'
! !
!ModalBox methodsFor:'initialize / release'!
initialize
super initialize.
resources := ResourcePack fromFile:'Boxes.rs'.
haveControl := false.
self is3D ifTrue:[
borderWidth := 0.
self level:2
].
PopShadow ifTrue:[
shadowView := (ShadowView on:device) for:self
]
!
initEvents
super initEvents.
self enableKeyEvents
!
addToCurrentProject
"ignored here"
^ self
!
destroy
super destroy.
shadowView notNil ifTrue:[shadowView destroy]
!
create
super create.
self saveUnder:true
!
createOnTop
^ true
! !
!ModalBox methodsFor:'show / hide'!
mapped
"wait till visible for grabbing"
super mapped.
device grabKeyboardIn:drawableId.
device setInputFocusTo:drawableId.
!
show
"make myself visible and take control"
self fixSize.
shadowView notNil ifTrue:[shadowView realize].
self raise.
self realize.
self takeControl
!
showAt:aPoint
self origin:aPoint.
((top + height) > (device height)) ifTrue:[
self top:(device height - height)
].
((left + width) > (device width)) ifTrue:[
self left:(device width - width)
].
(top < 0) ifTrue:[
self top:0
].
(left < 0) ifTrue:[
self left:0
].
self show
!
showAtPointer
self showAt:(device pointerPosition - ((width // 2) @ (height // 2)))
!
showAtPointerNotCovering:aView
|x y|
x := device pointerPosition x - (width // 2).
y := device pointerPosition y - (height // 2).
(((x @ y) corner:((x + width) @ (y + height))) intersects:
(aView origin corner: aView corner)) ifTrue:[
x := aView origin x + aView width
].
self showAt:(x @ y)
!
hide
"make myself invisible and leave control"
shadowView notNil ifTrue:[shadowView unrealize].
self unrealize.
device synchronizeOutput.
self leaveControl
! !
!ModalBox methodsFor:'private'!
takeControl
haveControl := true.
"
device grabKeyboardIn:drawableId.
device setInputFocusTo:drawableId.
"
"this is a kludge - we do not have multiple processes, therefore
we start another dispatch loop, which exits when control is lost"
device dispatchWhile:[haveControl]
!
leaveControl
haveControl := false.
device ungrabKeyboard
! !