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