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