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