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