author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 19:17:58 +0200 | |
changeset 616 | 56cf67c82664 |
parent 596 | e196ea43d242 |
child 644 | 85ce9499c925 |
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. |
|
306 |
self unrealize. |
|
307 |
! |
|
308 |
||
81 | 309 |
resize |
310 |
"resize myself to make everything visible" |
|
311 |
||
312 |
|newExtent| |
|
313 |
||
151 | 314 |
newExtent := self preferredExtent. |
81 | 315 |
newExtent = self extent ifTrue:[^ self]. |
316 |
||
317 |
(shown and:[shadowView notNil]) ifTrue:[ |
|
318 |
shadowView unrealize. |
|
319 |
self extent:newExtent. |
|
320 |
shadowView realize. |
|
321 |
self raise |
|
322 |
] ifFalse:[ |
|
323 |
self extent:newExtent. |
|
324 |
]. |
|
180 | 325 |
! |
326 |
||
327 |
resizeUnderPointer |
|
328 |
"resize myself to make everything visible, AND possibly change the origin |
|
329 |
to have the mouse pointer stay within my bounds. |
|
330 |
This is used for self-resizing enterBoxes, to avoid moving |
|
331 |
the box away from the cursor." |
|
332 |
||
333 |
|newExtent newLeft delta| |
|
334 |
||
335 |
newExtent := self preferredExtent. |
|
336 |
newExtent = self extent ifTrue:[^ self]. |
|
337 |
||
338 |
shown ifTrue:[ |
|
339 |
delta := width - newExtent x. |
|
340 |
newLeft := left + delta. |
|
341 |
(((newLeft @ top) extent:newExtent) |
|
342 |
containsPoint:device pointerPosition) |
|
343 |
ifFalse:[newLeft := left]. |
|
344 |
newLeft < 0 ifTrue:[newLeft := 0]. |
|
345 |
newLeft + newExtent x > device width ifTrue:[ |
|
346 |
newLeft := device width - newExtent x |
|
347 |
]. |
|
348 |
shadowView notNil ifTrue:[ |
|
349 |
shadowView unrealize. |
|
350 |
]. |
|
351 |
self origin:(newLeft @ top) extent:newExtent. |
|
352 |
shadowView notNil ifTrue:[ |
|
353 |
shadowView realize. |
|
354 |
self raise. |
|
355 |
]. |
|
356 |
] ifFalse:[ |
|
357 |
self extent:newExtent. |
|
358 |
]. |
|
359 |
||
360 |
"Modified: 6.9.1995 / 15:31:21 / claus" |
|
81 | 361 |
! ! |
362 |
||
296 | 363 |
!ModalBox methodsFor:'move & resize'! |
364 |
||
365 |
doMove |
|
366 |
"the move button was pressed" |
|
367 |
||
368 |
|r| |
|
369 |
||
370 |
r := device rectangleFromUser:(self origin corner:self corner). |
|
371 |
shadowView notNil ifTrue:[ |
|
372 |
shadowView unrealize |
|
373 |
]. |
|
374 |
self origin:r origin extent:(r extent max:(100@100)). |
|
375 |
shadowView notNil ifTrue:[ |
|
376 |
shadowView realize. |
|
377 |
self raise |
|
378 |
]. |
|
379 |
! |
|
380 |
||
381 |
doResize |
|
382 |
"the resize button was pressed" |
|
383 |
||
384 |
|r| |
|
385 |
||
386 |
r := device rectangleFromUser:(self origin corner:self corner). |
|
387 |
shadowView notNil ifTrue:[ |
|
388 |
shadowView unrealize |
|
389 |
]. |
|
390 |
self origin:r origin extent:(r extent max:(100@100)). |
|
391 |
shadowView notNil ifTrue:[ |
|
392 |
shadowView realize. |
|
393 |
self raise |
|
394 |
]. |
|
395 |
! ! |
|
396 |
||
397 |
!ModalBox methodsFor:'private'! |
|
398 |
||
399 |
leaveControl |
|
400 |
exclusiveKeyboard ifTrue:[ |
|
401 |
device ungrabKeyboard |
|
402 |
] |
|
403 |
! ! |
|
404 |
||
81 | 405 |
!ModalBox methodsFor:'queries'! |
406 |
||
151 | 407 |
preferredExtent |
81 | 408 |
"return the extent required to make all components |
409 |
visible in myself. This should be redefined in |
|
410 |
subclasses." |
|
411 |
||
412 |
^ self class defaultExtent |
|
0 | 413 |
! ! |
414 |
||
296 | 415 |
!ModalBox methodsFor:'show / hide'! |
416 |
||
417 |
autoHideAfter:seconds with:anAction |
|
418 |
"install a background process, which hides the box |
|
419 |
after some time. Also, if non-nil, anAction will be |
|
420 |
evaluated then. The action will not be evaluated if |
|
421 |
the box is closed by the user pressing a button." |
|
422 |
||
423 |
"the implementation is simple: just fork of a process |
|
424 |
to hide me." |
|
425 |
[ |
|
371 | 426 |
Delay waitForSeconds:seconds. |
296 | 427 |
self shown ifTrue:[ |
428 |
self hide. |
|
429 |
anAction notNil ifTrue:[anAction value] |
|
430 |
] |
|
431 |
] forkAt:4. |
|
432 |
||
433 |
" |
|
434 |
|b| |
|
435 |
||
436 |
b := InfoBox title:'hello there'. |
|
437 |
b autoHideAfter:5 with:[]. |
|
438 |
b showAtCenter. |
|
439 |
" |
|
440 |
! |
|
441 |
||
442 |
fixPosition:aPoint |
|
443 |
"set origin to aPoint, but make sure, that the box is fully visible |
|
444 |
by shifting it into the visible screen area if nescessary. |
|
445 |
This prevents invisible modalBoxes (which you could never close)." |
|
54 | 446 |
|
296 | 447 |
self origin:aPoint. |
448 |
self makeFullyVisible |
|
449 |
! |
|
450 |
||
451 |
fixSize |
|
452 |
"this is sent right before the modalBox is made visible; |
|
453 |
If the size is not fixed, adjust my size." |
|
454 |
||
455 |
sizeFixed == true ifFalse:[ |
|
456 |
self resize. |
|
457 |
]. |
|
458 |
super fixSize. |
|
459 |
! |
|
460 |
||
461 |
hide |
|
462 |
"make the receiver invisible and leave control" |
|
463 |
||
464 |
|p| |
|
54 | 465 |
|
296 | 466 |
shadowView notNil ifTrue:[shadowView unrealize]. |
467 |
windowGroup notNil ifTrue:[windowGroup focusView:nil]. |
|
468 |
self leaveControl. |
|
469 |
self unrealize. |
|
470 |
device flush. |
|
54 | 471 |
|
296 | 472 |
(windowGroup notNil and:[(p := windowGroup previousGroup) notNil]) ifTrue:[ |
473 |
" |
|
474 |
this is a kludge for IRIS which does not provide backingstore: |
|
475 |
when we hide a modalbox (such as a searchbox) which covered |
|
476 |
a scrollbar, the scrollbars bitblt-method will copy from the |
|
477 |
not-yet redrawn area - effectively clearing the scroller. |
|
478 |
We need a short delay here, since at this time, the expose event has |
|
479 |
not yet arrived. |
|
480 |
" |
|
371 | 481 |
Delay waitForSeconds:0.1. |
296 | 482 |
p processExposeEvents |
483 |
]. |
|
484 |
! |
|
0 | 485 |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
486 |
hideRequest |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
487 |
"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
|
488 |
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
|
489 |
|
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
490 |
self hide |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
491 |
! |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
492 |
|
0 | 493 |
mapped |
494 |
"wait till visible for grabbing" |
|
495 |
||
496 |
super mapped. |
|
12 | 497 |
|
498 |
"take it away from any popup menu possibly still active" |
|
499 |
||
81 | 500 |
device ungrabKeyboard. |
501 |
device ungrabPointer. |
|
12 | 502 |
|
54 | 503 |
" |
504 |
if I am a super-modal box, take the keyboard |
|
505 |
" |
|
12 | 506 |
exclusiveKeyboard ifTrue:[ |
81 | 507 |
device grabKeyboardInView:self. |
12 | 508 |
]. |
509 |
||
89 | 510 |
"/ UseTransientViews ifFalse:[ |
511 |
" |
|
512 |
get the focus |
|
513 |
" |
|
514 |
self getKeyboardFocus. |
|
515 |
self enableEnterLeaveEvents |
|
516 |
"/ ] |
|
0 | 517 |
! |
518 |
||
46 | 519 |
open |
72 | 520 |
"default for modalboxes is to come up modal at the pointer position" |
46 | 521 |
|
72 | 522 |
^ self showAtPointer |
46 | 523 |
! |
524 |
||
72 | 525 |
openModal:aBlock |
54 | 526 |
"open the box modal; |
527 |
In addition to the basic (inherited) modalloop, change |
|
72 | 528 |
the current active windowgroups cursors to the busy-stop cursor, show |
54 | 529 |
a shadow, and raise the box." |
530 |
||
72 | 531 |
|mainGroup mainView useTransient| |
532 |
||
81 | 533 |
useTransient := UseTransientViews. |
72 | 534 |
|
535 |
" |
|
536 |
show a stop-cursor in the current group |
|
537 |
" |
|
538 |
mainGroup := WindowGroup activeGroup. |
|
539 |
mainGroup notNil ifTrue:[ |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
540 |
mainGroup := mainGroup mainGroup. |
421
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
541 |
"/ mainGroup notNil ifTrue:[ |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
542 |
"/ mainGroup showCursor:(Cursor stop). |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
543 |
"/ ] |
72 | 544 |
]. |
545 |
||
546 |
mainGroup isNil ifTrue:[ |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
547 |
useTransient := false |
72 | 548 |
]. |
549 |
||
550 |
useTransient ifTrue:[ |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
551 |
mainGroup topViews notNil ifTrue:[ |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
552 |
mainView := mainGroup topViews first. |
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 |
mainView isNil ifTrue:[ |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
555 |
useTransient := false. |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
556 |
] |
72 | 557 |
]. |
54 | 558 |
|
72 | 559 |
useTransient ifTrue:[ |
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
560 |
shadowView := nil. |
72 | 561 |
] ifFalse:[ |
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
562 |
shadowView notNil ifTrue:[shadowView realize]. |
54 | 563 |
]. |
564 |
self raise. |
|
72 | 565 |
|
566 |
useTransient ifTrue:[ |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
567 |
device setTransient:drawableId for:(mainView id). |
72 | 568 |
]. |
129 | 569 |
|
421
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
570 |
"/ [ |
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
571 |
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
|
572 |
"/ ] valueNowOrOnUnwindDo:[ |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
573 |
"/ " |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
574 |
"/ restore cursors in the main group |
138 | 575 |
"/ " |
421
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
576 |
"/ mainGroup notNil ifTrue:[ |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
577 |
"/ mainGroup restoreCursors. |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
578 |
"/ mainGroup sensor flushUserEvents. |
7f437da61df1
cursor restoring and event-flushing done in supers openModal
Claus Gittinger <cg@exept.de>
parents:
393
diff
changeset
|
579 |
"/ ] |
138 | 580 |
"/ ]. |
300
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
581 |
|
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
582 |
"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
|
583 |
"Modified: 10.12.1995 / 14:08:41 / cg" |
54 | 584 |
! |
585 |
||
296 | 586 |
positionOffset |
587 |
"return the delta, by which the box should be |
|
588 |
displaced from the mouse pointer. |
|
589 |
Usually redefined in subclasses to have the most convenient |
|
590 |
ok-button appear under the pointer." |
|
591 |
||
592 |
^ (width // 2) @ (height // 2) |
|
593 |
! |
|
594 |
||
12 | 595 |
show |
514 | 596 |
"make myself visible (at the last or default position) and take control. |
597 |
If that position is out of the screen area, moves the receiver to make |
|
598 |
it fully visible." |
|
12 | 599 |
|
600 |
self fixSize. |
|
72 | 601 |
self makeFullyVisible. |
54 | 602 |
self openModal |
72 | 603 |
|
604 |
" |
|
605 |
|b| |
|
606 |
||
607 |
b := InfoBox title:'hello'. |
|
608 |
b show. |
|
609 |
" |
|
514 | 610 |
|
611 |
"Modified: 7.3.1996 / 17:57:49 / cg" |
|
12 | 612 |
! |
613 |
||
614 |
showAt:aPoint |
|
615 |
"make myself visible at aPoint. |
|
616 |
Fix position to make box fully visible" |
|
617 |
||
618 |
self fixSize. |
|
619 |
self fixPosition:aPoint. |
|
54 | 620 |
self openModal |
72 | 621 |
|
622 |
" |
|
623 |
|b| |
|
624 |
||
625 |
b := InfoBox title:'hello'. |
|
626 |
b showAt:(0 @ 0). |
|
627 |
b showAt:(400 @ 400). |
|
628 |
" |
|
629 |
! |
|
630 |
||
631 |
showAt:aPoint center:center |
|
632 |
"make myself visible at aPoint. center specifies |
|
633 |
if the view should show up centered around aPoint." |
|
634 |
||
635 |
self showAt:aPoint centerX:center centerY:center |
|
636 |
||
637 |
" |
|
638 |
|b| |
|
639 |
||
640 |
b := InfoBox title:'hello'. |
|
641 |
b showAt:(100 @ 100) center:true. |
|
642 |
b showAt:(100 @ 100) center:false. |
|
643 |
" |
|
644 |
! |
|
645 |
||
646 |
showAt:aPoint centerX:centerX centerY:centerY |
|
647 |
"make myself visible at aPoint. centerX/centerY specify |
|
648 |
if the view should show up centered around aPoint. |
|
649 |
Fix position to make box fully visible" |
|
650 |
||
651 |
|dx dy| |
|
652 |
||
653 |
self fixSize. |
|
654 |
centerX ifTrue:[ |
|
655 |
dx := self width // 2. |
|
656 |
] ifFalse:[ |
|
657 |
dx := 0 |
|
658 |
]. |
|
659 |
centerY ifTrue:[ |
|
660 |
dy := self height // 2. |
|
661 |
] ifFalse:[ |
|
662 |
dy := 0 |
|
663 |
]. |
|
664 |
self origin:(aPoint - (dx @ dy)). |
|
665 |
self makeFullyVisible. |
|
666 |
self openModal |
|
667 |
||
668 |
" |
|
669 |
|b| |
|
670 |
||
671 |
b := InfoBox title:'hello'. |
|
672 |
b showAt:(100 @ 100). |
|
673 |
b showAt:(100 @ 100) centerX:true centerY:false. |
|
674 |
" |
|
54 | 675 |
! |
676 |
||
677 |
showAtCenter |
|
678 |
"make myself visible at the screen center." |
|
679 |
||
72 | 680 |
self showAt:(device center) center:true |
681 |
||
682 |
" |
|
683 |
|b| |
|
684 |
||
685 |
b := InfoBox title:'hello'. |
|
686 |
b showAtCenter. |
|
687 |
" |
|
688 |
! |
|
689 |
||
0 | 690 |
showAtPointer |
12 | 691 |
"make myself visible at mouse pointer shifted to have |
66 | 692 |
convenient button under cursor. self positionOffset should |
693 |
return that offset (usually redefined, since we dont know here, |
|
694 |
which button should be under cursor)." |
|
12 | 695 |
|
696 |
self fixSize. |
|
66 | 697 |
self fixPosition:(device pointerPosition - self positionOffset). |
698 |
self openModal |
|
72 | 699 |
|
514 | 700 |
"/ cannot use: |
701 |
"/ self showAt:(device pointerPosition - self positionOffset). |
|
702 |
"/ because the resizing must be done before the |
|
703 |
"/ positionOffset is grabbed (it may change due to the resize) |
|
704 |
||
72 | 705 |
" |
706 |
|b| |
|
707 |
||
708 |
b := InfoBox title:'hello'. |
|
709 |
b showAtPointer. |
|
710 |
" |
|
514 | 711 |
|
712 |
"Modified: 7.3.1996 / 17:56:53 / cg" |
|
0 | 713 |
! |
714 |
||
715 |
showAtPointerNotCovering:aView |
|
12 | 716 |
"make myself visible at mouse pointer shifted to have |
717 |
convenient button under cursor. |
|
514 | 718 |
Fix position to make the box fully visible AND to make sure that |
12 | 719 |
aView is not covered." |
720 |
||
54 | 721 |
|pos newX| |
0 | 722 |
|
12 | 723 |
pos := device pointerPosition - self positionOffset. |
54 | 724 |
|
725 |
((Rectangle origin:pos extent:self extent) |
|
514 | 726 |
intersects: (aView origin corner: aView corner)) |
54 | 727 |
ifTrue:[ |
514 | 728 |
" |
729 |
try to the right of the untouchable view |
|
730 |
" |
|
731 |
newX := (aView origin x + aView width). |
|
732 |
newX + width > device width ifTrue:[ |
|
733 |
newX := device width - width |
|
734 |
]. |
|
735 |
pos x:newX. |
|
54 | 736 |
|
737 |
||
514 | 738 |
((Rectangle origin:pos extent:self extent) |
739 |
intersects: (aView origin corner: aView corner)) |
|
740 |
ifTrue:[ |
|
741 |
" |
|
742 |
try to the left of the untouchable view |
|
743 |
" |
|
744 |
newX := aView origin x - width. |
|
745 |
" |
|
746 |
should look for vertical possibilities too ... |
|
747 |
" |
|
748 |
pos x:newX. |
|
749 |
] |
|
270 | 750 |
|
751 |
]. |
|
752 |
self showAt:pos |
|
514 | 753 |
|
754 |
"Modified: 7.3.1996 / 17:58:10 / cg" |
|
270 | 755 |
! |
756 |
||
296 | 757 |
showCenteredIn:aView |
514 | 758 |
"make myself visible at the center if aView." |
270 | 759 |
|
296 | 760 |
|top| |
270 | 761 |
|
296 | 762 |
top := aView topView. |
763 |
top raise. |
|
764 |
self showAt:(top center + (aView originRelativeTo:top)) center:true |
|
270 | 765 |
|
766 |
" |
|
767 |
|b| |
|
768 |
||
296 | 769 |
b := InfoBox title:'hello'. |
770 |
b showCenteredIn:Transcript. |
|
270 | 771 |
" |
514 | 772 |
|
773 |
"Modified: 7.3.1996 / 17:58:53 / cg" |
|
270 | 774 |
! ! |
775 |
||
296 | 776 |
!ModalBox class methodsFor:'documentation'! |
270 | 777 |
|
296 | 778 |
version |
616 | 779 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.40 1996-04-25 17:16:06 cg Exp $' |
270 | 780 |
! ! |
296 | 781 |
ModalBox initialize! |