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