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