author | Claus Gittinger <cg@exept.de> |
Fri, 19 Jul 1996 20:50:23 +0200 | |
changeset 965 | c95ecf109867 |
parent 959 | a47e44337899 |
child 1221 | 7ae7d7a901de |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
72 | 3 |
All Rights Reserved |
0 | 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 |
|
514 | 14 |
instanceVariableNames:'shadowView exclusiveKeyboard' |
15 |
classVariableNames:'UseTransientViews' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Basic' |
|
0 | 18 |
! |
19 |
||
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
20 |
!ModalBox class methodsFor:'documentation'! |
2 | 21 |
|
46 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
72 | 25 |
All Rights Reserved |
46 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
2 | 36 |
documentation |
37 |
" |
|
46 | 38 |
this class implements modal boxes; ModalBoxes are different from |
81 | 39 |
others, in that they take control over the current topview, until |
40 |
all processing is done (i.e. the currently active topview and all of |
|
41 |
its subviews will not handle user events while the box is active). |
|
89 | 42 |
|
43 |
ModalBoxes are either implemented as transient windows |
|
44 |
(if UseTransientViews := true) or as override redirect views. |
|
45 |
Some window managers have problems with either; so you may want to |
|
46 |
change the default setting from your display.rc file. |
|
616 | 47 |
|
48 |
[see also:] |
|
49 |
StandardSystemView |
|
50 |
DialogBox |
|
51 |
( introduction to view programming :html: programming/viewintro.html ) |
|
52 |
||
53 |
[author:] |
|
54 |
Claus Gittinger |
|
2 | 55 |
" |
56 |
! ! |
|
57 |
||
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
58 |
!ModalBox class methodsFor:'initialization'! |
0 | 59 |
|
2 | 60 |
initialize |
89 | 61 |
UseTransientViews := true. |
62 |
! ! |
|
63 |
||
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
64 |
!ModalBox class methodsFor:'defaults'! |
89 | 65 |
|
66 |
defaultExtent |
|
67 |
"this defines the defaultExtent for instances of me; |
|
68 |
the value returned here is usually not correct for concrete subclasses, |
|
587 | 69 |
so you better redefine this method. |
70 |
The value returned here is usually ignored, and |
|
71 |
the value from preferredExtent taken instead." |
|
72 |
||
89 | 73 |
|
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
74 |
^ (Screen current pixelPerMillimeter * (60 @ 30)) rounded |
587 | 75 |
|
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
76 |
"Modified: 5.7.1996 / 13:54:18 / cg" |
89 | 77 |
! |
78 |
||
596 | 79 |
defaultLabel |
80 |
"return the boxes default window title." |
|
81 |
||
82 |
^ 'PopUp' |
|
83 |
||
84 |
"Created: 23.4.1996 / 17:14:21 / cg" |
|
85 |
! |
|
86 |
||
89 | 87 |
useTransientViews:aBoolean |
88 |
"change the way modalBoxes are created on the Display. |
|
89 |
If the argument is true, transient views are used; otherwise |
|
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
90 |
override redirect views are used. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
91 |
Depending on your windowmanager, either one may have problems. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
92 |
You may want to change the setting |
89 | 93 |
from your display.rc or d_xxx.rc file." |
94 |
||
95 |
UseTransientViews := aBoolean. |
|
96 |
||
97 |
" |
|
144 | 98 |
ModalBox useTransientViews:false |
99 |
ModalBox useTransientViews:true |
|
89 | 100 |
" |
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
101 |
|
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
102 |
"Modified: 18.7.1996 / 19:18:46 / cg" |
2 | 103 |
! ! |
0 | 104 |
|
296 | 105 |
!ModalBox methodsFor:'accessing'! |
106 |
||
107 |
exclusiveKeyboard:aBoolean |
|
108 |
"set/clear exclusive locking of the keyboard; |
|
109 |
If set, the box will take total control over the |
|
110 |
keyboard, not allowing input to other views/boxes |
|
111 |
while active. |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
112 |
DANGER: |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
113 |
only use this for very very urgent boxes, since |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
114 |
no interaction with ANY view on the screen is possible then." |
296 | 115 |
|
116 |
exclusiveKeyboard := aBoolean |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
117 |
|
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
118 |
"Modified: 12.5.1996 / 21:55:09 / cg" |
296 | 119 |
! ! |
120 |
||
121 |
!ModalBox methodsFor:'event handling'! |
|
122 |
||
123 |
coveredBy:aView |
|
124 |
"the receiver has been covered by another view. |
|
125 |
If the other view is a non-modal one, raise" |
|
126 |
||
127 |
|mainGroup topViews| |
|
128 |
||
129 |
" |
|
130 |
if the other view is not a modal- (or shadow-, or popup-) -view, |
|
131 |
bring myself to the front again. |
|
132 |
" |
|
133 |
aView isPopUpView ifFalse:[ |
|
134 |
" |
|
135 |
if I have a mainGroup, |
|
136 |
only raise if its one of my maingroup-views |
|
137 |
" |
|
138 |
windowGroup notNil ifTrue:[ |
|
139 |
mainGroup := windowGroup mainGroup. |
|
140 |
mainGroup notNil ifTrue:[ |
|
141 |
topViews := mainGroup topViews. |
|
142 |
topViews notNil ifTrue:[ |
|
143 |
topViews do:[:aTopView | |
|
144 |
aView == aTopView ifTrue:[ |
|
145 |
self raise. |
|
146 |
^ self |
|
147 |
] |
|
148 |
] |
|
149 |
]. |
|
150 |
^ self |
|
151 |
] |
|
152 |
]. |
|
153 |
self raise |
|
154 |
] |
|
155 |
! |
|
156 |
||
157 |
pointerEnter:state x:x y:y |
|
158 |
"mhmh: this seems to be a special X kludge; |
|
159 |
without the following, we will not regain input focus after |
|
160 |
pointer is reentered." |
|
161 |
||
162 |
self getKeyboardFocus. |
|
163 |
super pointerEnter:state x:x y:y |
|
164 |
! |
|
165 |
||
166 |
terminate |
|
167 |
"this is the close from a windowmanager |
|
168 |
(only if UseTransientViews == true)" |
|
169 |
||
170 |
" |
|
171 |
if I am a dialog, make the receiver invisible and leave control. |
|
172 |
But, do not destroy the underlying view resources, to allow for |
|
173 |
another open/show to occur later. |
|
174 |
if I have been opened modeLess, perform the normal destroy operation. |
|
175 |
" |
|
176 |
(windowGroup isNil or:[windowGroup isModal]) ifTrue:[ |
|
177 |
self hide |
|
178 |
] ifFalse:[ |
|
179 |
super terminate |
|
180 |
] |
|
181 |
! |
|
182 |
||
183 |
visibilityChange:how |
|
184 |
"raise when covered - this should not be needed, since we |
|
185 |
have been created as override-redirect window (which should |
|
186 |
stay on top - but some window managers (fvwm) seem to ignore |
|
187 |
this ..." |
|
188 |
||
189 |
"the code below is not good, since it will lead to |
|
190 |
oscillating raises when two modalBoxes are going to cover |
|
191 |
each other - see coveredBy:-handling ..." |
|
192 |
||
193 |
"/ how ~~ #fullyVisible ifTrue:[ |
|
194 |
"/ self raise |
|
195 |
"/ ] |
|
196 |
! ! |
|
197 |
||
0 | 198 |
!ModalBox methodsFor:'initialize / release'! |
199 |
||
296 | 200 |
addToCurrentProject |
201 |
"ignored here" |
|
202 |
||
203 |
^ self |
|
204 |
! |
|
205 |
||
206 |
create |
|
207 |
super create. |
|
208 |
shadowView notNil ifTrue:[ |
|
209 |
self saveUnder:true |
|
210 |
] |
|
211 |
! |
|
212 |
||
213 |
destroy |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
214 |
"destroy the view. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
215 |
redefined to also destroy my shadow, if there is one, |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
216 |
and to release the global keyboard grab (if there is one)" |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
217 |
|
296 | 218 |
shadowView notNil ifTrue:[ |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
219 |
shadowView destroy. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
220 |
shadowView := nil |
296 | 221 |
]. |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
222 |
exclusiveKeyboard ifTrue:[ |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
223 |
device ungrabKeyboard |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
224 |
]. |
296 | 225 |
super destroy. |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
226 |
|
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
227 |
"Modified: 12.5.1996 / 21:56:10 / cg" |
296 | 228 |
! |
229 |
||
230 |
initEvents |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
231 |
"initialize event handling; redefined to enable visibility changes" |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
232 |
|
296 | 233 |
super initEvents. |
234 |
self enableEvent:#visibilityChange |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
235 |
|
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
236 |
"Modified: 12.5.1996 / 21:56:31 / cg" |
296 | 237 |
! |
238 |
||
239 |
initStyle |
|
240 |
|style| |
|
241 |
||
242 |
super initStyle. |
|
243 |
style := styleSheet name. |
|
244 |
((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[ |
|
245 |
borderWidth := 0. |
|
246 |
UseTransientViews ifFalse:[ |
|
247 |
self level:2 |
|
248 |
] |
|
249 |
] |
|
250 |
! |
|
251 |
||
0 | 252 |
initialize |
89 | 253 |
|form resizeButton moveButton| |
81 | 254 |
|
0 | 255 |
super initialize. |
256 |
||
141 | 257 |
type := #dialog. |
12 | 258 |
exclusiveKeyboard := false. |
596 | 259 |
"/ label := ' '. |
12 | 260 |
|
596 | 261 |
"/ label := 'Popup'. |
89 | 262 |
|
81 | 263 |
UseTransientViews ifFalse:[ |
596 | 264 |
PopUpView shadows ifTrue:[ |
265 |
shadowView := (ShadowView onDevice:device) for:self |
|
266 |
]. |
|
89 | 267 |
|
596 | 268 |
form := Form width:8 height:8 |
269 |
fromArray:#[2r00000000 |
|
270 |
2r00000000 |
|
271 |
2r00000000 |
|
272 |
2r00000001 |
|
273 |
2r00000011 |
|
274 |
2r00000111 |
|
275 |
2r00001111 |
|
276 |
2r00011111 |
|
277 |
] |
|
278 |
on:device. |
|
279 |
resizeButton := Button form:form in:self. |
|
280 |
resizeButton origin:1.0 @ 1.0 corner:1.0@1.0. |
|
281 |
resizeButton activeForegroundColor:(resizeButton foregroundColor). |
|
282 |
resizeButton activeBackgroundColor:(resizeButton backgroundColor). |
|
283 |
resizeButton enteredBackgroundColor:(resizeButton backgroundColor). |
|
284 |
resizeButton leftInset:-8; topInset:-8. |
|
285 |
resizeButton releaseAction:[]. |
|
286 |
resizeButton pressAction:[resizeButton turnOff; redraw. self doResize]. |
|
287 |
resizeButton borderWidth:0. |
|
752 | 288 |
resizeButton activeLevel:0; passiveLevel:0. |
596 | 289 |
resizeButton cursor:(Cursor corner). |
89 | 290 |
|
596 | 291 |
form := Form width:8 height:8 |
292 |
fromArray:#[2r11111000 |
|
293 |
2r11110000 |
|
294 |
2r11100000 |
|
295 |
2r11000000 |
|
296 |
2r10000000 |
|
297 |
2r00000000 |
|
298 |
2r00000000 |
|
299 |
2r00000000 |
|
300 |
] |
|
301 |
on:device. |
|
302 |
moveButton := Button form:form in:self. |
|
303 |
moveButton origin:0.0 @ 0.0 corner:0.0@0.0. |
|
304 |
moveButton activeForegroundColor:(moveButton foregroundColor). |
|
305 |
moveButton activeBackgroundColor:(moveButton backgroundColor). |
|
306 |
moveButton enteredBackgroundColor:(moveButton backgroundColor). |
|
307 |
moveButton rightInset:-8; bottomInset:-8. |
|
308 |
moveButton releaseAction:[]. |
|
309 |
moveButton pressAction:[moveButton turnOff; redraw. self doMove]. |
|
310 |
moveButton borderWidth:0. |
|
752 | 311 |
moveButton activeLevel:0; passiveLevel:0. |
596 | 312 |
moveButton cursor:(Cursor origin) |
81 | 313 |
]. |
314 |
||
752 | 315 |
"Modified: 28.5.1996 / 22:04:38 / cg" |
12 | 316 |
! |
317 |
||
296 | 318 |
isPopUpView |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
319 |
"return true, if I want to come up without decoration |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
320 |
and popUp to top immediately." |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
321 |
|
296 | 322 |
^ UseTransientViews not |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
323 |
|
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
324 |
"Modified: 12.5.1996 / 21:57:58 / cg" |
0 | 325 |
! |
326 |
||
72 | 327 |
reinitialize |
328 |
super reinitialize. |
|
644 | 329 |
self unmap. |
330 |
||
331 |
"Modified: 3.5.1996 / 23:48:04 / stefan" |
|
72 | 332 |
! |
333 |
||
81 | 334 |
resize |
335 |
"resize myself to make everything visible" |
|
336 |
||
337 |
|newExtent| |
|
338 |
||
151 | 339 |
newExtent := self preferredExtent. |
81 | 340 |
newExtent = self extent ifTrue:[^ self]. |
341 |
||
342 |
(shown and:[shadowView notNil]) ifTrue:[ |
|
644 | 343 |
shadowView unmap. |
344 |
self extent:newExtent. |
|
345 |
shadowView realize. |
|
346 |
self raise |
|
81 | 347 |
] ifFalse:[ |
644 | 348 |
self extent:newExtent. |
81 | 349 |
]. |
644 | 350 |
|
351 |
"Modified: 3.5.1996 / 23:48:12 / stefan" |
|
180 | 352 |
! |
353 |
||
354 |
resizeUnderPointer |
|
355 |
"resize myself to make everything visible, AND possibly change the origin |
|
356 |
to have the mouse pointer stay within my bounds. |
|
357 |
This is used for self-resizing enterBoxes, to avoid moving |
|
358 |
the box away from the cursor." |
|
359 |
||
360 |
|newExtent newLeft delta| |
|
361 |
||
362 |
newExtent := self preferredExtent. |
|
363 |
newExtent = self extent ifTrue:[^ self]. |
|
364 |
||
365 |
shown ifTrue:[ |
|
644 | 366 |
delta := width - newExtent x. |
367 |
newLeft := left + delta. |
|
368 |
(((newLeft @ top) extent:newExtent) |
|
369 |
containsPoint:device pointerPosition) |
|
370 |
ifFalse:[newLeft := left]. |
|
371 |
newLeft < 0 ifTrue:[newLeft := 0]. |
|
372 |
newLeft + newExtent x > device width ifTrue:[ |
|
373 |
newLeft := device width - newExtent x |
|
374 |
]. |
|
375 |
shadowView notNil ifTrue:[ |
|
376 |
shadowView unmap. |
|
377 |
]. |
|
378 |
self origin:(newLeft @ top) extent:newExtent. |
|
379 |
shadowView notNil ifTrue:[ |
|
380 |
shadowView realize. |
|
381 |
self raise. |
|
382 |
]. |
|
180 | 383 |
] ifFalse:[ |
644 | 384 |
self extent:newExtent. |
180 | 385 |
]. |
386 |
||
387 |
"Modified: 6.9.1995 / 15:31:21 / claus" |
|
644 | 388 |
"Modified: 3.5.1996 / 23:48:17 / stefan" |
81 | 389 |
! ! |
390 |
||
296 | 391 |
!ModalBox methodsFor:'move & resize'! |
392 |
||
393 |
doMove |
|
394 |
"the move button was pressed" |
|
395 |
||
396 |
|r| |
|
397 |
||
398 |
r := device rectangleFromUser:(self origin corner:self corner). |
|
399 |
shadowView notNil ifTrue:[ |
|
644 | 400 |
shadowView unmap |
296 | 401 |
]. |
402 |
self origin:r origin extent:(r extent max:(100@100)). |
|
403 |
shadowView notNil ifTrue:[ |
|
644 | 404 |
shadowView realize. |
405 |
self raise |
|
296 | 406 |
]. |
644 | 407 |
|
408 |
"Modified: 3.5.1996 / 23:47:38 / stefan" |
|
296 | 409 |
! |
410 |
||
411 |
doResize |
|
412 |
"the resize button was pressed" |
|
413 |
||
414 |
|r| |
|
415 |
||
416 |
r := device rectangleFromUser:(self origin corner:self corner). |
|
417 |
shadowView notNil ifTrue:[ |
|
644 | 418 |
shadowView unmap |
296 | 419 |
]. |
420 |
self origin:r origin extent:(r extent max:(100@100)). |
|
421 |
shadowView notNil ifTrue:[ |
|
644 | 422 |
shadowView realize. |
423 |
self raise |
|
296 | 424 |
]. |
644 | 425 |
|
426 |
"Modified: 3.5.1996 / 23:47:47 / stefan" |
|
296 | 427 |
! ! |
428 |
||
81 | 429 |
!ModalBox methodsFor:'queries'! |
430 |
||
151 | 431 |
preferredExtent |
81 | 432 |
"return the extent required to make all components |
433 |
visible in myself. This should be redefined in |
|
434 |
subclasses." |
|
435 |
||
965 | 436 |
"/ If I have an explicit preferredExtent .. |
437 |
||
761
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
438 |
preferredExtent notNil ifTrue:[ |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
439 |
^ preferredExtent |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
440 |
]. |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
441 |
|
81 | 442 |
^ self class defaultExtent |
761
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
443 |
|
965 | 444 |
"Modified: 19.7.1996 / 20:45:07 / cg" |
0 | 445 |
! ! |
446 |
||
296 | 447 |
!ModalBox methodsFor:'show / hide'! |
448 |
||
449 |
autoHideAfter:seconds with:anAction |
|
450 |
"install a background process, which hides the box |
|
451 |
after some time. Also, if non-nil, anAction will be |
|
452 |
evaluated then. The action will not be evaluated if |
|
453 |
the box is closed by the user pressing a button." |
|
454 |
||
455 |
"the implementation is simple: just fork of a process |
|
456 |
to hide me." |
|
457 |
[ |
|
371 | 458 |
Delay waitForSeconds:seconds. |
296 | 459 |
self shown ifTrue:[ |
460 |
self hide. |
|
461 |
anAction notNil ifTrue:[anAction value] |
|
462 |
] |
|
463 |
] forkAt:4. |
|
464 |
||
465 |
" |
|
466 |
|b| |
|
467 |
||
468 |
b := InfoBox title:'hello there'. |
|
469 |
b autoHideAfter:5 with:[]. |
|
470 |
b showAtCenter. |
|
471 |
" |
|
472 |
! |
|
473 |
||
474 |
fixPosition:aPoint |
|
475 |
"set origin to aPoint, but make sure, that the box is fully visible |
|
476 |
by shifting it into the visible screen area if nescessary. |
|
477 |
This prevents invisible modalBoxes (which you could never close)." |
|
54 | 478 |
|
296 | 479 |
self origin:aPoint. |
480 |
self makeFullyVisible |
|
481 |
! |
|
482 |
||
483 |
fixSize |
|
484 |
"this is sent right before the modalBox is made visible; |
|
485 |
If the size is not fixed, adjust my size." |
|
486 |
||
487 |
sizeFixed == true ifFalse:[ |
|
488 |
self resize. |
|
489 |
]. |
|
490 |
super fixSize. |
|
491 |
! |
|
492 |
||
493 |
hide |
|
494 |
"make the receiver invisible and leave control" |
|
495 |
||
496 |
|p| |
|
54 | 497 |
|
644 | 498 |
shadowView notNil ifTrue:[shadowView unmap]. |
296 | 499 |
windowGroup notNil ifTrue:[windowGroup focusView:nil]. |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
500 |
exclusiveKeyboard ifTrue:[ |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
501 |
device ungrabKeyboard |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
502 |
]. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
503 |
|
644 | 504 |
self unmap. |
296 | 505 |
device flush. |
54 | 506 |
|
296 | 507 |
(windowGroup notNil and:[(p := windowGroup previousGroup) notNil]) ifTrue:[ |
644 | 508 |
" |
509 |
this is a kludge for IRIS which does not provide backingstore: |
|
510 |
when we hide a modalbox (such as a searchbox) which covered |
|
511 |
a scrollbar, the scrollbars bitblt-method will copy from the |
|
512 |
not-yet redrawn area - effectively clearing the scroller. |
|
513 |
We need a short delay here, since at this time, the expose event has |
|
514 |
not yet arrived. |
|
515 |
" |
|
516 |
Delay waitForSeconds:0.1. |
|
517 |
p processExposeEvents |
|
296 | 518 |
]. |
644 | 519 |
|
520 |
"Modified: 3.5.1996 / 23:47:57 / stefan" |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
521 |
"Modified: 12.5.1996 / 21:54:22 / cg" |
296 | 522 |
! |
0 | 523 |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
524 |
hideRequest |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
525 |
"hide request from windowGroup (i.e. via Escape key). |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
526 |
Can be redefined in subclasses which dont like this" |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
527 |
|
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
528 |
self hide |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
529 |
! |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
530 |
|
0 | 531 |
mapped |
532 |
"wait till visible for grabbing" |
|
533 |
||
534 |
super mapped. |
|
12 | 535 |
|
536 |
"take it away from any popup menu possibly still active" |
|
537 |
||
81 | 538 |
device ungrabKeyboard. |
539 |
device ungrabPointer. |
|
12 | 540 |
|
54 | 541 |
" |
542 |
if I am a super-modal box, take the keyboard |
|
543 |
" |
|
12 | 544 |
exclusiveKeyboard ifTrue:[ |
81 | 545 |
device grabKeyboardInView:self. |
12 | 546 |
]. |
547 |
||
89 | 548 |
"/ UseTransientViews ifFalse:[ |
549 |
" |
|
550 |
get the focus |
|
551 |
" |
|
552 |
self getKeyboardFocus. |
|
553 |
self enableEnterLeaveEvents |
|
554 |
"/ ] |
|
0 | 555 |
! |
556 |
||
46 | 557 |
open |
72 | 558 |
"default for modalboxes is to come up modal at the pointer position" |
46 | 559 |
|
72 | 560 |
^ self showAtPointer |
46 | 561 |
! |
562 |
||
953 | 563 |
openAt:aPoint |
564 |
"default for modalboxes is to come up modal at the pointer position" |
|
565 |
||
566 |
^ self openModalAt:aPoint |
|
567 |
||
568 |
"Created: 17.7.1996 / 14:50:44 / cg" |
|
569 |
! |
|
570 |
||
571 |
openAtCenter |
|
572 |
"default for modalboxes is to come up modal at the pointer position" |
|
573 |
||
574 |
^ self openModalAtCenter |
|
575 |
||
576 |
"Created: 17.7.1996 / 14:50:35 / cg" |
|
577 |
! |
|
578 |
||
72 | 579 |
openModal:aBlock |
54 | 580 |
"open the box modal; |
581 |
In addition to the basic (inherited) modalloop, change |
|
72 | 582 |
the current active windowgroups cursors to the busy-stop cursor, show |
54 | 583 |
a shadow, and raise the box." |
584 |
||
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
585 |
|mainGroup mainView mainViewID useTransient| |
72 | 586 |
|
81 | 587 |
useTransient := UseTransientViews. |
72 | 588 |
|
589 |
" |
|
590 |
show a stop-cursor in the current group |
|
591 |
" |
|
592 |
mainGroup := WindowGroup activeGroup. |
|
593 |
mainGroup notNil ifTrue:[ |
|
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
594 |
mainGroup := mainGroup mainGroup. |
72 | 595 |
]. |
596 |
||
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
597 |
"/ mainGroup isNil ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
598 |
"/ useTransient := false |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
599 |
"/ ]. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
600 |
|
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
601 |
useTransient ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
602 |
mainGroup notNil ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
603 |
mainGroup topViews notNil ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
604 |
mainView := mainGroup topViews first. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
605 |
]. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
606 |
mainView notNil ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
607 |
mainViewID := mainView id. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
608 |
] |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
609 |
] |
72 | 610 |
]. |
611 |
||
612 |
useTransient ifTrue:[ |
|
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
613 |
mainViewID isNil ifTrue:[ |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
614 |
self origin:(device center - (self extent//2)) |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
615 |
]. |
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
616 |
shadowView := nil. |
72 | 617 |
] ifFalse:[ |
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
618 |
shadowView notNil ifTrue:[shadowView realize]. |
54 | 619 |
]. |
620 |
self raise. |
|
72 | 621 |
|
622 |
useTransient ifTrue:[ |
|
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
623 |
device setTransient:drawableId for:mainViewID. |
72 | 624 |
]. |
129 | 625 |
|
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
626 |
super openModal:aBlock inGroup:mainGroup. |
300
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
627 |
|
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
628 |
"Created: 10.12.1995 / 14:07:01 / cg" |
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
629 |
"Modified: 18.7.1996 / 19:22:53 / cg" |
54 | 630 |
! |
631 |
||
296 | 632 |
positionOffset |
633 |
"return the delta, by which the box should be |
|
634 |
displaced from the mouse pointer. |
|
635 |
Usually redefined in subclasses to have the most convenient |
|
636 |
ok-button appear under the pointer." |
|
637 |
||
638 |
^ (width // 2) @ (height // 2) |
|
639 |
! |
|
640 |
||
12 | 641 |
show |
514 | 642 |
"make myself visible (at the last or default position) and take control. |
643 |
If that position is out of the screen area, moves the receiver to make |
|
644 |
it fully visible." |
|
12 | 645 |
|
646 |
self fixSize. |
|
72 | 647 |
self makeFullyVisible. |
54 | 648 |
self openModal |
72 | 649 |
|
650 |
" |
|
651 |
|b| |
|
652 |
||
653 |
b := InfoBox title:'hello'. |
|
654 |
b show. |
|
655 |
" |
|
514 | 656 |
|
657 |
"Modified: 7.3.1996 / 17:57:49 / cg" |
|
12 | 658 |
! |
659 |
||
660 |
showAt:aPoint |
|
661 |
"make myself visible at aPoint. |
|
662 |
Fix position to make box fully visible" |
|
663 |
||
664 |
self fixSize. |
|
665 |
self fixPosition:aPoint. |
|
54 | 666 |
self openModal |
72 | 667 |
|
668 |
" |
|
669 |
|b| |
|
670 |
||
671 |
b := InfoBox title:'hello'. |
|
672 |
b showAt:(0 @ 0). |
|
673 |
b showAt:(400 @ 400). |
|
674 |
" |
|
675 |
! |
|
676 |
||
677 |
showAt:aPoint center:center |
|
678 |
"make myself visible at aPoint. center specifies |
|
679 |
if the view should show up centered around aPoint." |
|
680 |
||
681 |
self showAt:aPoint centerX:center centerY:center |
|
682 |
||
683 |
" |
|
684 |
|b| |
|
685 |
||
686 |
b := InfoBox title:'hello'. |
|
687 |
b showAt:(100 @ 100) center:true. |
|
688 |
b showAt:(100 @ 100) center:false. |
|
689 |
" |
|
690 |
! |
|
691 |
||
692 |
showAt:aPoint centerX:centerX centerY:centerY |
|
693 |
"make myself visible at aPoint. centerX/centerY specify |
|
694 |
if the view should show up centered around aPoint. |
|
695 |
Fix position to make box fully visible" |
|
696 |
||
697 |
|dx dy| |
|
698 |
||
699 |
self fixSize. |
|
700 |
centerX ifTrue:[ |
|
701 |
dx := self width // 2. |
|
702 |
] ifFalse:[ |
|
703 |
dx := 0 |
|
704 |
]. |
|
705 |
centerY ifTrue:[ |
|
706 |
dy := self height // 2. |
|
707 |
] ifFalse:[ |
|
708 |
dy := 0 |
|
709 |
]. |
|
710 |
self origin:(aPoint - (dx @ dy)). |
|
711 |
self makeFullyVisible. |
|
712 |
self openModal |
|
713 |
||
714 |
" |
|
715 |
|b| |
|
716 |
||
717 |
b := InfoBox title:'hello'. |
|
718 |
b showAt:(100 @ 100). |
|
719 |
b showAt:(100 @ 100) centerX:true centerY:false. |
|
720 |
" |
|
54 | 721 |
! |
722 |
||
723 |
showAtCenter |
|
724 |
"make myself visible at the screen center." |
|
725 |
||
72 | 726 |
self showAt:(device center) center:true |
727 |
||
728 |
" |
|
729 |
|b| |
|
730 |
||
731 |
b := InfoBox title:'hello'. |
|
732 |
b showAtCenter. |
|
733 |
" |
|
734 |
! |
|
735 |
||
0 | 736 |
showAtPointer |
12 | 737 |
"make myself visible at mouse pointer shifted to have |
66 | 738 |
convenient button under cursor. self positionOffset should |
739 |
return that offset (usually redefined, since we dont know here, |
|
740 |
which button should be under cursor)." |
|
12 | 741 |
|
742 |
self fixSize. |
|
66 | 743 |
self fixPosition:(device pointerPosition - self positionOffset). |
744 |
self openModal |
|
72 | 745 |
|
514 | 746 |
"/ cannot use: |
747 |
"/ self showAt:(device pointerPosition - self positionOffset). |
|
748 |
"/ because the resizing must be done before the |
|
749 |
"/ positionOffset is grabbed (it may change due to the resize) |
|
750 |
||
72 | 751 |
" |
752 |
|b| |
|
753 |
||
754 |
b := InfoBox title:'hello'. |
|
755 |
b showAtPointer. |
|
756 |
" |
|
514 | 757 |
|
758 |
"Modified: 7.3.1996 / 17:56:53 / cg" |
|
0 | 759 |
! |
760 |
||
761 |
showAtPointerNotCovering:aView |
|
12 | 762 |
"make myself visible at mouse pointer shifted to have |
763 |
convenient button under cursor. |
|
514 | 764 |
Fix position to make the box fully visible AND to make sure that |
12 | 765 |
aView is not covered." |
766 |
||
54 | 767 |
|pos newX| |
0 | 768 |
|
12 | 769 |
pos := device pointerPosition - self positionOffset. |
54 | 770 |
|
771 |
((Rectangle origin:pos extent:self extent) |
|
514 | 772 |
intersects: (aView origin corner: aView corner)) |
54 | 773 |
ifTrue:[ |
514 | 774 |
" |
775 |
try to the right of the untouchable view |
|
776 |
" |
|
777 |
newX := (aView origin x + aView width). |
|
778 |
newX + width > device width ifTrue:[ |
|
779 |
newX := device width - width |
|
780 |
]. |
|
781 |
pos x:newX. |
|
54 | 782 |
|
783 |
||
514 | 784 |
((Rectangle origin:pos extent:self extent) |
785 |
intersects: (aView origin corner: aView corner)) |
|
786 |
ifTrue:[ |
|
787 |
" |
|
788 |
try to the left of the untouchable view |
|
789 |
" |
|
790 |
newX := aView origin x - width. |
|
791 |
" |
|
792 |
should look for vertical possibilities too ... |
|
793 |
" |
|
794 |
pos x:newX. |
|
795 |
] |
|
270 | 796 |
|
797 |
]. |
|
798 |
self showAt:pos |
|
514 | 799 |
|
800 |
"Modified: 7.3.1996 / 17:58:10 / cg" |
|
270 | 801 |
! |
802 |
||
296 | 803 |
showCenteredIn:aView |
514 | 804 |
"make myself visible at the center if aView." |
270 | 805 |
|
296 | 806 |
|top| |
270 | 807 |
|
296 | 808 |
top := aView topView. |
809 |
top raise. |
|
810 |
self showAt:(top center + (aView originRelativeTo:top)) center:true |
|
270 | 811 |
|
812 |
" |
|
813 |
|b| |
|
814 |
||
296 | 815 |
b := InfoBox title:'hello'. |
816 |
b showCenteredIn:Transcript. |
|
270 | 817 |
" |
514 | 818 |
|
819 |
"Modified: 7.3.1996 / 17:58:53 / cg" |
|
270 | 820 |
! ! |
821 |
||
922
52c1d0d22c0e
dont ask Display for defaultExtent - ask current screen
Claus Gittinger <cg@exept.de>
parents:
761
diff
changeset
|
822 |
!ModalBox class methodsFor:'documentation'! |
270 | 823 |
|
296 | 824 |
version |
965 | 825 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.48 1996-07-19 18:50:23 cg Exp $' |
270 | 826 |
! ! |
296 | 827 |
ModalBox initialize! |