author | Claus Gittinger <cg@exept.de> |
Fri, 28 Feb 1997 22:35:19 +0100 | |
changeset 1397 | 932c517ad29c |
parent 1314 | 99e3347abb6c |
child 1400 | 4eda8ddb69eb |
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 |
fixPosition:aPoint |
|
495 |
"set origin to aPoint, but make sure, that the box is fully visible |
|
496 |
by shifting it into the visible screen area if nescessary. |
|
497 |
This prevents invisible modalBoxes (which you could never close)." |
|
54 | 498 |
|
296 | 499 |
self origin:aPoint. |
500 |
self makeFullyVisible |
|
501 |
! |
|
502 |
||
503 |
fixSize |
|
504 |
"this is sent right before the modalBox is made visible; |
|
505 |
If the size is not fixed, adjust my size." |
|
506 |
||
507 |
sizeFixed == true ifFalse:[ |
|
508 |
self resize. |
|
509 |
]. |
|
510 |
super fixSize. |
|
511 |
! |
|
512 |
||
513 |
hide |
|
514 |
"make the receiver invisible and leave control" |
|
515 |
||
516 |
|p| |
|
54 | 517 |
|
1314 | 518 |
realized ifFalse:[^ self]. |
519 |
||
644 | 520 |
shadowView notNil ifTrue:[shadowView unmap]. |
296 | 521 |
windowGroup notNil ifTrue:[windowGroup focusView:nil]. |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
522 |
exclusiveKeyboard ifTrue:[ |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
523 |
device ungrabKeyboard |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
524 |
]. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
525 |
|
644 | 526 |
self unmap. |
296 | 527 |
device flush. |
54 | 528 |
|
296 | 529 |
(windowGroup notNil and:[(p := windowGroup previousGroup) notNil]) ifTrue:[ |
644 | 530 |
" |
531 |
this is a kludge for IRIS which does not provide backingstore: |
|
532 |
when we hide a modalbox (such as a searchbox) which covered |
|
533 |
a scrollbar, the scrollbars bitblt-method will copy from the |
|
534 |
not-yet redrawn area - effectively clearing the scroller. |
|
535 |
We need a short delay here, since at this time, the expose event has |
|
536 |
not yet arrived. |
|
537 |
" |
|
538 |
Delay waitForSeconds:0.1. |
|
539 |
p processExposeEvents |
|
296 | 540 |
]. |
644 | 541 |
|
542 |
"Modified: 3.5.1996 / 23:47:57 / stefan" |
|
1314 | 543 |
"Modified: 8.2.1997 / 17:41:16 / cg" |
296 | 544 |
! |
0 | 545 |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
546 |
hideRequest |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
547 |
"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
|
548 |
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
|
549 |
|
1221
7ae7d7a901de
added escapeIsCancel flag (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
965
diff
changeset
|
550 |
escapeIsCancel ifTrue:[ |
7ae7d7a901de
added escapeIsCancel flag (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
965
diff
changeset
|
551 |
self hide |
7ae7d7a901de
added escapeIsCancel flag (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
965
diff
changeset
|
552 |
] |
393
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 |
|
0 | 555 |
mapped |
556 |
"wait till visible for grabbing" |
|
557 |
||
558 |
super mapped. |
|
12 | 559 |
|
560 |
"take it away from any popup menu possibly still active" |
|
561 |
||
81 | 562 |
device ungrabKeyboard. |
563 |
device ungrabPointer. |
|
12 | 564 |
|
54 | 565 |
" |
566 |
if I am a super-modal box, take the keyboard |
|
567 |
" |
|
12 | 568 |
exclusiveKeyboard ifTrue:[ |
81 | 569 |
device grabKeyboardInView:self. |
12 | 570 |
]. |
571 |
||
89 | 572 |
"/ UseTransientViews ifFalse:[ |
573 |
" |
|
574 |
get the focus |
|
575 |
" |
|
576 |
self getKeyboardFocus. |
|
577 |
self enableEnterLeaveEvents |
|
578 |
"/ ] |
|
0 | 579 |
! |
580 |
||
46 | 581 |
open |
72 | 582 |
"default for modalboxes is to come up modal at the pointer position" |
46 | 583 |
|
72 | 584 |
^ self showAtPointer |
46 | 585 |
! |
586 |
||
953 | 587 |
openAt:aPoint |
588 |
"default for modalboxes is to come up modal at the pointer position" |
|
589 |
||
590 |
^ self openModalAt:aPoint |
|
591 |
||
592 |
"Created: 17.7.1996 / 14:50:44 / cg" |
|
593 |
! |
|
594 |
||
595 |
openAtCenter |
|
596 |
"default for modalboxes is to come up modal at the pointer position" |
|
597 |
||
598 |
^ self openModalAtCenter |
|
599 |
||
600 |
"Created: 17.7.1996 / 14:50:35 / cg" |
|
601 |
! |
|
602 |
||
72 | 603 |
openModal:aBlock |
54 | 604 |
"open the box modal; |
605 |
In addition to the basic (inherited) modalloop, change |
|
72 | 606 |
the current active windowgroups cursors to the busy-stop cursor, show |
54 | 607 |
a shadow, and raise the box." |
608 |
||
1397
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
609 |
shadowView notNil ifTrue:[shadowView realize]. |
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
610 |
super openModal:aBlock. |
300
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
611 |
|
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
612 |
"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
|
613 |
"Modified: 28.2.1997 / 22:32:49 / cg" |
54 | 614 |
! |
615 |
||
296 | 616 |
positionOffset |
617 |
"return the delta, by which the box should be |
|
1232 | 618 |
displaced from the mouse pointer. |
619 |
Here, the boxes center is returned as a default. |
|
296 | 620 |
Usually redefined in subclasses to have the most convenient |
621 |
ok-button appear under the pointer." |
|
622 |
||
1232 | 623 |
^ self extent // 2 |
624 |
||
625 |
"Modified: 16.1.1997 / 20:42:07 / cg" |
|
296 | 626 |
! |
627 |
||
12 | 628 |
show |
514 | 629 |
"make myself visible (at the last or default position) and take control. |
630 |
If that position is out of the screen area, moves the receiver to make |
|
631 |
it fully visible." |
|
12 | 632 |
|
633 |
self fixSize. |
|
72 | 634 |
self makeFullyVisible. |
54 | 635 |
self openModal |
72 | 636 |
|
637 |
" |
|
638 |
|b| |
|
639 |
||
640 |
b := InfoBox title:'hello'. |
|
641 |
b show. |
|
642 |
" |
|
514 | 643 |
|
644 |
"Modified: 7.3.1996 / 17:57:49 / cg" |
|
12 | 645 |
! |
646 |
||
647 |
showAt:aPoint |
|
648 |
"make myself visible at aPoint. |
|
649 |
Fix position to make box fully visible" |
|
650 |
||
651 |
self fixSize. |
|
652 |
self fixPosition:aPoint. |
|
54 | 653 |
self openModal |
72 | 654 |
|
655 |
" |
|
656 |
|b| |
|
657 |
||
658 |
b := InfoBox title:'hello'. |
|
659 |
b showAt:(0 @ 0). |
|
660 |
b showAt:(400 @ 400). |
|
661 |
" |
|
662 |
! |
|
663 |
||
664 |
showAt:aPoint center:center |
|
665 |
"make myself visible at aPoint. center specifies |
|
666 |
if the view should show up centered around aPoint." |
|
667 |
||
668 |
self showAt:aPoint centerX:center centerY:center |
|
669 |
||
670 |
" |
|
671 |
|b| |
|
672 |
||
673 |
b := InfoBox title:'hello'. |
|
674 |
b showAt:(100 @ 100) center:true. |
|
675 |
b showAt:(100 @ 100) center:false. |
|
676 |
" |
|
677 |
! |
|
678 |
||
679 |
showAt:aPoint centerX:centerX centerY:centerY |
|
680 |
"make myself visible at aPoint. centerX/centerY specify |
|
681 |
if the view should show up centered around aPoint. |
|
682 |
Fix position to make box fully visible" |
|
683 |
||
684 |
|dx dy| |
|
685 |
||
686 |
self fixSize. |
|
687 |
centerX ifTrue:[ |
|
688 |
dx := self width // 2. |
|
689 |
] ifFalse:[ |
|
690 |
dx := 0 |
|
691 |
]. |
|
692 |
centerY ifTrue:[ |
|
693 |
dy := self height // 2. |
|
694 |
] ifFalse:[ |
|
695 |
dy := 0 |
|
696 |
]. |
|
697 |
self origin:(aPoint - (dx @ dy)). |
|
698 |
self makeFullyVisible. |
|
699 |
self openModal |
|
700 |
||
701 |
" |
|
702 |
|b| |
|
703 |
||
704 |
b := InfoBox title:'hello'. |
|
705 |
b showAt:(100 @ 100). |
|
706 |
b showAt:(100 @ 100) centerX:true centerY:false. |
|
707 |
" |
|
54 | 708 |
! |
709 |
||
710 |
showAtCenter |
|
711 |
"make myself visible at the screen center." |
|
712 |
||
72 | 713 |
self showAt:(device center) center:true |
714 |
||
715 |
" |
|
716 |
|b| |
|
717 |
||
718 |
b := InfoBox title:'hello'. |
|
719 |
b showAtCenter. |
|
720 |
" |
|
721 |
! |
|
722 |
||
0 | 723 |
showAtPointer |
12 | 724 |
"make myself visible at mouse pointer shifted to have |
66 | 725 |
convenient button under cursor. self positionOffset should |
726 |
return that offset (usually redefined, since we dont know here, |
|
727 |
which button should be under cursor)." |
|
12 | 728 |
|
729 |
self fixSize. |
|
66 | 730 |
self fixPosition:(device pointerPosition - self positionOffset). |
731 |
self openModal |
|
72 | 732 |
|
514 | 733 |
"/ cannot use: |
734 |
"/ self showAt:(device pointerPosition - self positionOffset). |
|
735 |
"/ because the resizing must be done before the |
|
736 |
"/ positionOffset is grabbed (it may change due to the resize) |
|
737 |
||
72 | 738 |
" |
739 |
|b| |
|
740 |
||
741 |
b := InfoBox title:'hello'. |
|
742 |
b showAtPointer. |
|
743 |
" |
|
514 | 744 |
|
745 |
"Modified: 7.3.1996 / 17:56:53 / cg" |
|
0 | 746 |
! |
747 |
||
748 |
showAtPointerNotCovering:aView |
|
12 | 749 |
"make myself visible at mouse pointer shifted to have |
750 |
convenient button under cursor. |
|
514 | 751 |
Fix position to make the box fully visible AND to make sure that |
12 | 752 |
aView is not covered." |
753 |
||
54 | 754 |
|pos newX| |
0 | 755 |
|
12 | 756 |
pos := device pointerPosition - self positionOffset. |
54 | 757 |
|
758 |
((Rectangle origin:pos extent:self extent) |
|
514 | 759 |
intersects: (aView origin corner: aView corner)) |
54 | 760 |
ifTrue:[ |
514 | 761 |
" |
762 |
try to the right of the untouchable view |
|
763 |
" |
|
764 |
newX := (aView origin x + aView width). |
|
765 |
newX + width > device width ifTrue:[ |
|
766 |
newX := device width - width |
|
767 |
]. |
|
768 |
pos x:newX. |
|
54 | 769 |
|
770 |
||
514 | 771 |
((Rectangle origin:pos extent:self extent) |
772 |
intersects: (aView origin corner: aView corner)) |
|
773 |
ifTrue:[ |
|
774 |
" |
|
775 |
try to the left of the untouchable view |
|
776 |
" |
|
777 |
newX := aView origin x - width. |
|
778 |
" |
|
779 |
should look for vertical possibilities too ... |
|
780 |
" |
|
781 |
pos x:newX. |
|
782 |
] |
|
270 | 783 |
|
784 |
]. |
|
785 |
self showAt:pos |
|
514 | 786 |
|
787 |
"Modified: 7.3.1996 / 17:58:10 / cg" |
|
270 | 788 |
! |
789 |
||
296 | 790 |
showCenteredIn:aView |
514 | 791 |
"make myself visible at the center if aView." |
270 | 792 |
|
296 | 793 |
|top| |
270 | 794 |
|
296 | 795 |
top := aView topView. |
796 |
top raise. |
|
797 |
self showAt:(top center + (aView originRelativeTo:top)) center:true |
|
270 | 798 |
|
799 |
" |
|
800 |
|b| |
|
801 |
||
296 | 802 |
b := InfoBox title:'hello'. |
803 |
b showCenteredIn:Transcript. |
|
270 | 804 |
" |
514 | 805 |
|
806 |
"Modified: 7.3.1996 / 17:58:53 / cg" |
|
270 | 807 |
! ! |
808 |
||
1232 | 809 |
!ModalBox class methodsFor:'documentation'! |
270 | 810 |
|
296 | 811 |
version |
1397
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
812 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.53 1997-02-28 21:34:26 cg Exp $' |
270 | 813 |
! ! |
296 | 814 |
ModalBox initialize! |