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