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