0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1990-93 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
StandardSystemView subclass:#ModalBox
|
|
14 |
instanceVariableNames:'haveControl shadowView'
|
|
15 |
classVariableNames:'PopShadow'
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Basic'
|
|
18 |
!
|
|
19 |
|
|
20 |
ModalBox comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1990-93 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
2
|
25 |
%W% %E%
|
|
26 |
|
|
27 |
written Jan 90 by claus
|
|
28 |
'!
|
|
29 |
|
|
30 |
!ModalBox class methodsFor:'documentation'!
|
|
31 |
|
|
32 |
documentation
|
|
33 |
"
|
|
34 |
this class implements modal boxes; ModalBoxes are different from
|
|
35 |
others, in that they take complete control over the display, until
|
|
36 |
all processing is done (i.e. other views will not get any events
|
|
37 |
while the box is active).
|
0
|
38 |
|
|
39 |
class variables:
|
|
40 |
|
|
41 |
PopShadow <Boolean> if true, modalBoxes will show a shadow
|
|
42 |
|
2
|
43 |
"
|
|
44 |
! !
|
|
45 |
|
|
46 |
!ModalBox class methodsFor:'initialization'!
|
0
|
47 |
|
2
|
48 |
initialize
|
|
49 |
super initialize.
|
|
50 |
PopShadow := self classResources name:'POPUP_SHADOW' default:false
|
|
51 |
! !
|
0
|
52 |
|
|
53 |
!ModalBox class methodsFor:'instance creation'!
|
|
54 |
|
|
55 |
new
|
|
56 |
^ super on:ModalDisplay
|
|
57 |
! !
|
|
58 |
|
|
59 |
!ModalBox methodsFor:'initialize / release'!
|
|
60 |
|
|
61 |
initialize
|
|
62 |
super initialize.
|
|
63 |
|
|
64 |
haveControl := false.
|
|
65 |
self is3D ifTrue:[
|
|
66 |
borderWidth := 0.
|
|
67 |
self level:2
|
|
68 |
].
|
2
|
69 |
|
0
|
70 |
PopShadow ifTrue:[
|
|
71 |
shadowView := (ShadowView on:device) for:self
|
|
72 |
]
|
|
73 |
!
|
|
74 |
|
|
75 |
initEvents
|
|
76 |
super initEvents.
|
|
77 |
self enableKeyEvents
|
|
78 |
!
|
|
79 |
|
|
80 |
addToCurrentProject
|
|
81 |
"ignored here"
|
|
82 |
|
|
83 |
^ self
|
|
84 |
!
|
|
85 |
|
|
86 |
destroy
|
|
87 |
super destroy.
|
|
88 |
shadowView notNil ifTrue:[shadowView destroy]
|
|
89 |
!
|
|
90 |
|
|
91 |
create
|
|
92 |
super create.
|
2
|
93 |
PopShadow ifFalse:[
|
|
94 |
self saveUnder:true
|
|
95 |
]
|
0
|
96 |
!
|
|
97 |
|
|
98 |
createOnTop
|
|
99 |
^ true
|
|
100 |
! !
|
|
101 |
|
|
102 |
!ModalBox methodsFor:'show / hide'!
|
|
103 |
|
|
104 |
mapped
|
|
105 |
"wait till visible for grabbing"
|
|
106 |
|
|
107 |
super mapped.
|
|
108 |
device grabKeyboardIn:drawableId.
|
|
109 |
device setInputFocusTo:drawableId.
|
|
110 |
!
|
|
111 |
|
|
112 |
show
|
|
113 |
"make myself visible and take control"
|
|
114 |
|
|
115 |
self fixSize.
|
|
116 |
shadowView notNil ifTrue:[shadowView realize].
|
|
117 |
self raise.
|
|
118 |
self realize.
|
|
119 |
self takeControl
|
|
120 |
!
|
|
121 |
|
|
122 |
showAt:aPoint
|
|
123 |
self origin:aPoint.
|
|
124 |
((top + height) > (device height)) ifTrue:[
|
|
125 |
self top:(device height - height)
|
|
126 |
].
|
|
127 |
((left + width) > (device width)) ifTrue:[
|
|
128 |
self left:(device width - width)
|
|
129 |
].
|
|
130 |
(top < 0) ifTrue:[
|
|
131 |
self top:0
|
|
132 |
].
|
|
133 |
(left < 0) ifTrue:[
|
|
134 |
self left:0
|
|
135 |
].
|
|
136 |
self show
|
|
137 |
!
|
|
138 |
|
|
139 |
showAtPointer
|
|
140 |
self showAt:(device pointerPosition - ((width // 2) @ (height // 2)))
|
|
141 |
!
|
|
142 |
|
|
143 |
showAtPointerNotCovering:aView
|
|
144 |
|x y|
|
|
145 |
|
|
146 |
x := device pointerPosition x - (width // 2).
|
|
147 |
y := device pointerPosition y - (height // 2).
|
|
148 |
(((x @ y) corner:((x + width) @ (y + height))) intersects:
|
|
149 |
(aView origin corner: aView corner)) ifTrue:[
|
|
150 |
x := aView origin x + aView width
|
|
151 |
].
|
|
152 |
self showAt:(x @ y)
|
|
153 |
!
|
|
154 |
|
|
155 |
hide
|
|
156 |
"make myself invisible and leave control"
|
|
157 |
|
|
158 |
self unrealize.
|
|
159 |
device synchronizeOutput.
|
2
|
160 |
shadowView notNil ifTrue:[shadowView unrealize].
|
|
161 |
self leaveControl.
|
0
|
162 |
! !
|
|
163 |
|
|
164 |
!ModalBox methodsFor:'private'!
|
|
165 |
|
|
166 |
takeControl
|
|
167 |
haveControl := true.
|
|
168 |
|
|
169 |
"
|
|
170 |
device grabKeyboardIn:drawableId.
|
|
171 |
device setInputFocusTo:drawableId.
|
|
172 |
"
|
|
173 |
|
|
174 |
"this is a kludge - we do not have multiple processes, therefore
|
|
175 |
we start another dispatch loop, which exits when control is lost"
|
|
176 |
|
|
177 |
device dispatchWhile:[haveControl]
|
|
178 |
!
|
|
179 |
|
|
180 |
leaveControl
|
|
181 |
haveControl := false.
|
|
182 |
device ungrabKeyboard
|
|
183 |
! !
|