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