author | Claus Gittinger <cg@exept.de> |
Fri, 11 Apr 2008 15:16:49 +0200 | |
changeset 4936 | 9ac25d62f361 |
parent 4935 | 57354733f7d4 |
child 5058 | 60bb10ed290b |
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 |
81 | 40 |
others, in that they take control over the current topview, until |
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:] |
|
50 |
StandardSystemView |
|
51 |
DialogBox |
|
52 |
( introduction to view programming :html: programming/viewintro.html ) |
|
53 |
||
54 |
[author:] |
|
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 |
|
89 | 112 |
useTransientViews:aBoolean |
113 |
"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
|
114 |
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
|
115 |
otherwise override redirect views are used. |
959
a47e44337899
modalBoxes from non-windowGroup processes (background process)
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
116 |
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
|
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 |
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 |
|
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
131 |
usingTransientViews |
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
132 |
"return true, if transient views are used |
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
133 |
for modalBoxes. This is somewhat oboslete." |
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. |
|
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
158 |
DANGER: |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
159 |
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
|
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:[ |
|
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:[:aTopView | |
|
190 |
aView == aTopView ifTrue:[ |
|
191 |
self raise. |
|
192 |
^ self |
|
193 |
] |
|
194 |
] |
|
195 |
]. |
|
196 |
^ self |
|
197 |
] |
|
198 |
]. |
|
199 |
self raise |
|
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:[ |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
272 |
shadowView destroy. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
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:[ |
3093 | 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:[ |
|
1263 | 301 |
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 |
||
4272 | 315 |
"/ self beDialogView. |
316 |
self beToolDialog. |
|
317 |
||
12 | 318 |
exclusiveKeyboard := false. |
596 | 319 |
"/ label := ' '. |
12 | 320 |
|
596 | 321 |
"/ label := 'Popup'. |
89 | 322 |
|
81 | 323 |
UseTransientViews ifFalse:[ |
2876
dbe1454f8539
allow for a device to suppress shadowViews.
Claus Gittinger <cg@exept.de>
parents:
2690
diff
changeset
|
324 |
(PopUpView shadowsOnDevice:device) ifTrue:[ |
596 | 325 |
shadowView := (ShadowView onDevice:device) for:self |
326 |
]. |
|
89 | 327 |
|
596 | 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 |
] |
|
4771
7ffe69dd0a1a
Use Form class>>#width:height:fromArray:onDevice: instead of obsolete
Stefan Vogel <sv@exept.de>
parents:
4413
diff
changeset
|
338 |
onDevice:device. |
1826 | 339 |
resizeButton := Button label:form in:self. |
596 | 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. |
|
752 | 348 |
resizeButton activeLevel:0; passiveLevel:0. |
596 | 349 |
resizeButton cursor:(Cursor corner). |
89 | 350 |
|
596 | 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 |
] |
|
4771
7ffe69dd0a1a
Use Form class>>#width:height:fromArray:onDevice: instead of obsolete
Stefan Vogel <sv@exept.de>
parents:
4413
diff
changeset
|
361 |
onDevice:device. |
1826 | 362 |
moveButton := Button label:form in:self. |
596 | 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. |
|
752 | 371 |
moveButton activeLevel:0; passiveLevel:0. |
596 | 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:[ |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
398 |
^ self |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
399 |
]. |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
400 |
"physically create the view & subviews" |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
401 |
self recreate. |
644 | 402 |
|
2644
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
403 |
"/ super reinitialize. |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
404 |
"/ self unmap. |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
405 |
|
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
406 |
"Modified: / 3.5.1996 / 23:48:04 / stefan" |
bb15778539af
oops - restart with iconified views recreated them
Claus Gittinger <cg@exept.de>
parents:
2589
diff
changeset
|
407 |
"Modified: / 6.5.1999 / 09:38:06 / cg" |
72 | 408 |
! |
409 |
||
81 | 410 |
resize |
411 |
"resize myself to make everything visible" |
|
412 |
||
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. |
4197
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
416 |
maxExtent := self maxExtent. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
417 |
maxExtent notNil ifTrue:[ |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
418 |
newExtent := newExtent min:maxExtent. |
81 | 419 |
]. |
4197
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
420 |
newExtent ~= self extent ifTrue:[ |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
421 |
(shown and:[shadowView notNil]) ifTrue:[ |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
422 |
shadowView unmap. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
423 |
self extent:newExtent. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
424 |
shadowView realize. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
425 |
self raise |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
426 |
] ifFalse:[ |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
427 |
self extent:newExtent. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
428 |
]. |
1984b2ba83de
Do not set maxExtent (to the Screen size) in StandartSystemView.
Stefan Vogel <sv@exept.de>
parents:
4179
diff
changeset
|
429 |
]. |
180 | 430 |
! |
431 |
||
432 |
resizeUnderPointer |
|
433 |
"resize myself to make everything visible, AND possibly change the origin |
|
434 |
to have the mouse pointer stay within my bounds. |
|
435 |
This is used for self-resizing enterBoxes, to avoid moving |
|
436 |
the box away from the cursor." |
|
437 |
||
4935
57354733f7d4
use usableExtent in resizeUnderPointer (multi-screen configurations)
Claus Gittinger <cg@exept.de>
parents:
4771
diff
changeset
|
438 |
|newExtent newLeft delta screenWidth| |
180 | 439 |
|
440 |
newExtent := self preferredExtent. |
|
441 |
newExtent = self extent ifTrue:[^ self]. |
|
442 |
||
443 |
shown ifTrue:[ |
|
644 | 444 |
delta := width - newExtent x. |
445 |
newLeft := left + delta. |
|
446 |
(((newLeft @ top) extent:newExtent) |
|
447 |
containsPoint:device pointerPosition) |
|
448 |
ifFalse:[newLeft := left]. |
|
449 |
newLeft < 0 ifTrue:[newLeft := 0]. |
|
4935
57354733f7d4
use usableExtent in resizeUnderPointer (multi-screen configurations)
Claus Gittinger <cg@exept.de>
parents:
4771
diff
changeset
|
450 |
screenWidth := device usableExtent x. |
57354733f7d4
use usableExtent in resizeUnderPointer (multi-screen configurations)
Claus Gittinger <cg@exept.de>
parents:
4771
diff
changeset
|
451 |
newLeft + newExtent x > screenWidth ifTrue:[ |
57354733f7d4
use usableExtent in resizeUnderPointer (multi-screen configurations)
Claus Gittinger <cg@exept.de>
parents:
4771
diff
changeset
|
452 |
newLeft := screenWidth - newExtent x |
644 | 453 |
]. |
454 |
shadowView notNil ifTrue:[ |
|
455 |
shadowView unmap. |
|
456 |
]. |
|
457 |
self origin:(newLeft @ top) extent:newExtent. |
|
458 |
shadowView notNil ifTrue:[ |
|
459 |
shadowView realize. |
|
460 |
self raise. |
|
461 |
]. |
|
180 | 462 |
] ifFalse:[ |
644 | 463 |
self extent:newExtent. |
180 | 464 |
]. |
465 |
||
466 |
"Modified: 6.9.1995 / 15:31:21 / claus" |
|
644 | 467 |
"Modified: 3.5.1996 / 23:48:17 / stefan" |
81 | 468 |
! ! |
469 |
||
296 | 470 |
!ModalBox methodsFor:'move & resize'! |
471 |
||
472 |
doMove |
|
1825 | 473 |
"the move button was pressed. |
474 |
This method is only used with non-transient views |
|
475 |
(UseTransientViews == false)." |
|
296 | 476 |
|
477 |
|r| |
|
478 |
||
1825 | 479 |
r := device rectangleFromUser:(self origin corner:self corner) keepExtent:true. |
296 | 480 |
shadowView notNil ifTrue:[ |
644 | 481 |
shadowView unmap |
296 | 482 |
]. |
1825 | 483 |
self origin:r origin extent:(self extent). |
296 | 484 |
shadowView notNil ifTrue:[ |
644 | 485 |
shadowView realize. |
1825 | 486 |
self raise. |
296 | 487 |
]. |
644 | 488 |
|
489 |
"Modified: 3.5.1996 / 23:47:38 / stefan" |
|
1825 | 490 |
"Modified: 24.7.1997 / 16:07:18 / cg" |
296 | 491 |
! |
492 |
||
493 |
doResize |
|
1825 | 494 |
"the resize button was pressed. |
495 |
This method is only used with non-transient views |
|
496 |
(UseTransientViews == false)." |
|
296 | 497 |
|
498 |
|r| |
|
499 |
||
500 |
r := device rectangleFromUser:(self origin corner:self corner). |
|
501 |
shadowView notNil ifTrue:[ |
|
644 | 502 |
shadowView unmap |
296 | 503 |
]. |
504 |
self origin:r origin extent:(r extent max:(100@100)). |
|
505 |
shadowView notNil ifTrue:[ |
|
644 | 506 |
shadowView realize. |
507 |
self raise |
|
296 | 508 |
]. |
644 | 509 |
|
510 |
"Modified: 3.5.1996 / 23:47:47 / stefan" |
|
1825 | 511 |
"Modified: 24.7.1997 / 15:18:46 / cg" |
296 | 512 |
! ! |
513 |
||
81 | 514 |
!ModalBox methodsFor:'queries'! |
515 |
||
151 | 516 |
preferredExtent |
81 | 517 |
"return the extent required to make all components |
518 |
visible in myself. This should be redefined in |
|
519 |
subclasses." |
|
520 |
||
965 | 521 |
"/ If I have an explicit preferredExtent .. |
522 |
||
761
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
523 |
preferredExtent notNil ifTrue:[ |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
524 |
^ preferredExtent |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
525 |
]. |
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
526 |
|
81 | 527 |
^ self class defaultExtent |
761
34d17118452a
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
752
diff
changeset
|
528 |
|
965 | 529 |
"Modified: 19.7.1996 / 20:45:07 / cg" |
0 | 530 |
! ! |
531 |
||
3266 | 532 |
!ModalBox methodsFor:'queries-internal'! |
1700
ea1abaa7901d
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
533 |
|
1915
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
534 |
windowLabelFor:labelString |
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
535 |
"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
|
536 |
|
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
537 |
^ labelString |
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
538 |
|
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
539 |
"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
|
540 |
! |
f86162de1a2f
extracted windowLabel generation into a separate method
Claus Gittinger <cg@exept.de>
parents:
1865
diff
changeset
|
541 |
|
1700
ea1abaa7901d
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
542 |
windowStyle |
3715 | 543 |
"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
|
544 |
(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
|
545 |
|
4272 | 546 |
UseTransientViews ifFalse:[ |
547 |
^ #popUp |
|
1825 | 548 |
]. |
4272 | 549 |
^ super windowStyle |
1700
ea1abaa7901d
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
550 |
|
ea1abaa7901d
preps for native window support
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
551 |
"Created: 2.5.1997 / 14:34:17 / cg" |
1825 | 552 |
"Modified: 24.7.1997 / 15:22:39 / cg" |
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 |
|
3881 | 555 |
!ModalBox methodsFor:'show & hide'! |
296 | 556 |
|
557 |
autoHideAfter:seconds with:anAction |
|
558 |
"install a background process, which hides the box |
|
559 |
after some time. Also, if non-nil, anAction will be |
|
560 |
evaluated then. The action will not be evaluated if |
|
561 |
the box is closed by the user pressing a button." |
|
562 |
||
563 |
"the implementation is simple: just fork of a process |
|
564 |
to hide me." |
|
565 |
[ |
|
4413 | 566 |
Delay waitForSeconds:seconds. |
567 |
self shown ifTrue:[ |
|
568 |
self hide. |
|
569 |
anAction value |
|
570 |
] |
|
296 | 571 |
] forkAt:4. |
572 |
||
573 |
" |
|
574 |
|b| |
|
575 |
||
576 |
b := InfoBox title:'hello there'. |
|
577 |
b autoHideAfter:5 with:[]. |
|
578 |
b showAtCenter. |
|
579 |
" |
|
580 |
! |
|
581 |
||
582 |
fixSize |
|
583 |
"this is sent right before the modalBox is made visible; |
|
584 |
If the size is not fixed, adjust my size." |
|
585 |
||
586 |
sizeFixed == true ifFalse:[ |
|
587 |
self resize. |
|
588 |
]. |
|
589 |
super fixSize. |
|
590 |
! |
|
591 |
||
592 |
hide |
|
593 |
"make the receiver invisible and leave control" |
|
594 |
||
2579 | 595 |
|masterGroup| |
54 | 596 |
|
1314 | 597 |
realized ifFalse:[^ self]. |
598 |
||
644 | 599 |
shadowView notNil ifTrue:[shadowView unmap]. |
3313 | 600 |
windowGroup notNil ifTrue:[ |
601 |
windowGroup focusView:nil. |
|
602 |
masterGroup := windowGroup previousGroup. |
|
603 |
]. |
|
604 |
||
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
605 |
exclusiveKeyboard ifTrue:[ |
3093 | 606 |
self forceUngrabKeyboard |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
607 |
]. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
608 |
|
644 | 609 |
self unmap. |
54 | 610 |
|
2579 | 611 |
masterGroup notNil ifTrue:[ |
644 | 612 |
" |
2579 | 613 |
this is a kludge for IRIS and others which do not provide backingstore: |
644 | 614 |
when we hide a modalbox (such as a searchbox) which covered |
615 |
a scrollbar, the scrollbars bitblt-method will copy from the |
|
616 |
not-yet redrawn area - effectively clearing the scroller. |
|
617 |
We need a short delay here, since at this time, the expose event has |
|
618 |
not yet arrived. |
|
619 |
" |
|
3649 | 620 |
device sync. "/ thats a round trip, to ensure that all expose events are present..." |
2579 | 621 |
Delay waitForSeconds:0.05. |
622 |
masterGroup processExposeEvents |
|
296 | 623 |
]. |
644 | 624 |
|
625 |
"Modified: 3.5.1996 / 23:47:57 / stefan" |
|
1314 | 626 |
"Modified: 8.2.1997 / 17:41:16 / cg" |
296 | 627 |
! |
0 | 628 |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
629 |
hideRequest |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
630 |
"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
|
631 |
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
|
632 |
|
3440 | 633 |
self hide |
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
634 |
! |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
635 |
|
0 | 636 |
mapped |
637 |
"wait till visible for grabbing" |
|
638 |
||
639 |
super mapped. |
|
12 | 640 |
|
3344
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
641 |
"/ "take it away from any popup menu possibly still active" |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
642 |
"/ |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
643 |
"/ self forceUngrabKeyboard. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
644 |
"/ self forceUngrabPointer. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
645 |
"/ |
54 | 646 |
" |
647 |
if I am a super-modal box, take the keyboard |
|
648 |
" |
|
12 | 649 |
exclusiveKeyboard ifTrue:[ |
3344
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
650 |
self forceUngrabKeyboard. |
3093 | 651 |
self grabKeyboard. |
12 | 652 |
]. |
3344
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
653 |
"/ |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
654 |
"/"/ UseTransientViews ifFalse:[ |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
655 |
"/ " |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
656 |
"/ get the focus |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
657 |
"/ " |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
658 |
"/ self getKeyboardFocus. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
659 |
"/ self enableEnterLeaveEvents |
3351 | 660 |
"/"/ ] |
3440 | 661 |
! |
0 | 662 |
|
46 | 663 |
open |
72 | 664 |
"default for modalboxes is to come up modal at the pointer position" |
46 | 665 |
|
3520 | 666 |
ForceModalBoxesToOpenAtCenter == true ifTrue:[ |
667 |
^ self showAtCenter |
|
668 |
]. |
|
72 | 669 |
^ self showAtPointer |
46 | 670 |
! |
671 |
||
953 | 672 |
openAt:aPoint |
673 |
"default for modalboxes is to come up modal at the pointer position" |
|
674 |
||
675 |
^ self openModalAt:aPoint |
|
676 |
||
677 |
"Created: 17.7.1996 / 14:50:44 / cg" |
|
678 |
! |
|
679 |
||
680 |
openAtCenter |
|
681 |
"default for modalboxes is to come up modal at the pointer position" |
|
682 |
||
683 |
^ self openModalAtCenter |
|
684 |
||
685 |
"Created: 17.7.1996 / 14:50:35 / cg" |
|
686 |
! |
|
687 |
||
72 | 688 |
openModal:aBlock |
54 | 689 |
"open the box modal; |
690 |
In addition to the basic (inherited) modalloop, change |
|
72 | 691 |
the current active windowgroups cursors to the busy-stop cursor, show |
54 | 692 |
a shadow, and raise the box." |
693 |
||
1397
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
694 |
shadowView notNil ifTrue:[shadowView realize]. |
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
695 |
super openModal:aBlock. |
300
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
696 |
|
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
697 |
"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
|
698 |
"Modified: 28.2.1997 / 22:32:49 / cg" |
54 | 699 |
! |
700 |
||
12 | 701 |
show |
514 | 702 |
"make myself visible (at the last or default position) and take control. |
703 |
If that position is out of the screen area, moves the receiver to make |
|
704 |
it fully visible." |
|
12 | 705 |
|
706 |
self fixSize. |
|
72 | 707 |
self makeFullyVisible. |
54 | 708 |
self openModal |
72 | 709 |
|
710 |
" |
|
711 |
|b| |
|
712 |
||
713 |
b := InfoBox title:'hello'. |
|
714 |
b show. |
|
715 |
" |
|
514 | 716 |
|
717 |
"Modified: 7.3.1996 / 17:57:49 / cg" |
|
12 | 718 |
! |
719 |
||
720 |
showAt:aPoint |
|
721 |
"make myself visible at aPoint. |
|
722 |
Fix position to make box fully visible" |
|
723 |
||
724 |
self fixSize. |
|
725 |
self fixPosition:aPoint. |
|
54 | 726 |
self openModal |
72 | 727 |
|
728 |
" |
|
729 |
|b| |
|
730 |
||
731 |
b := InfoBox title:'hello'. |
|
732 |
b showAt:(0 @ 0). |
|
733 |
b showAt:(400 @ 400). |
|
734 |
" |
|
735 |
! |
|
736 |
||
737 |
showAt:aPoint center:center |
|
738 |
"make myself visible at aPoint. center specifies |
|
739 |
if the view should show up centered around aPoint." |
|
740 |
||
741 |
self showAt:aPoint centerX:center centerY:center |
|
742 |
||
743 |
" |
|
744 |
|b| |
|
745 |
||
746 |
b := InfoBox title:'hello'. |
|
747 |
b showAt:(100 @ 100) center:true. |
|
748 |
b showAt:(100 @ 100) center:false. |
|
749 |
" |
|
750 |
! |
|
751 |
||
752 |
showAt:aPoint centerX:centerX centerY:centerY |
|
753 |
"make myself visible at aPoint. centerX/centerY specify |
|
754 |
if the view should show up centered around aPoint. |
|
755 |
Fix position to make box fully visible" |
|
756 |
||
757 |
|dx dy| |
|
758 |
||
759 |
self fixSize. |
|
760 |
centerX ifTrue:[ |
|
761 |
dx := self width // 2. |
|
762 |
] ifFalse:[ |
|
763 |
dx := 0 |
|
764 |
]. |
|
765 |
centerY ifTrue:[ |
|
766 |
dy := self height // 2. |
|
767 |
] ifFalse:[ |
|
768 |
dy := 0 |
|
769 |
]. |
|
770 |
self origin:(aPoint - (dx @ dy)). |
|
771 |
self makeFullyVisible. |
|
772 |
self openModal |
|
773 |
||
774 |
" |
|
775 |
|b| |
|
776 |
||
777 |
b := InfoBox title:'hello'. |
|
778 |
b showAt:(100 @ 100). |
|
779 |
b showAt:(100 @ 100) centerX:true centerY:false. |
|
780 |
" |
|
54 | 781 |
! |
782 |
||
783 |
showAtCenter |
|
784 |
"make myself visible at the screen center." |
|
785 |
||
72 | 786 |
self showAt:(device center) center:true |
787 |
||
788 |
" |
|
789 |
|b| |
|
790 |
||
791 |
b := InfoBox title:'hello'. |
|
792 |
b showAtCenter. |
|
793 |
" |
|
794 |
! |
|
795 |
||
0 | 796 |
showAtPointer |
12 | 797 |
"make myself visible at mouse pointer shifted to have |
66 | 798 |
convenient button under cursor. self positionOffset should |
799 |
return that offset (usually redefined, since we dont know here, |
|
800 |
which button should be under cursor)." |
|
12 | 801 |
|
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
802 |
|first positionOffset| |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
803 |
|
12 | 804 |
self fixSize. |
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
805 |
positionOffset := self positionOffset. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
806 |
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
|
807 |
|
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
808 |
"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
|
809 |
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
|
810 |
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
|
811 |
|
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
812 |
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
|
813 |
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
|
814 |
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
|
815 |
|
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
816 |
first := true. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
817 |
self openModal:[ |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
818 |
(first and:[shown]) ifTrue:[ |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
819 |
first := false. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
820 |
self setPointerPosition:positionOffset. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
821 |
]. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
822 |
true |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
823 |
]. |
72 | 824 |
|
514 | 825 |
"/ cannot use: |
826 |
"/ self showAt:(device pointerPosition - self positionOffset). |
|
827 |
"/ because the resizing must be done before the |
|
828 |
"/ positionOffset is grabbed (it may change due to the resize) |
|
829 |
||
72 | 830 |
" |
831 |
|b| |
|
832 |
||
833 |
b := InfoBox title:'hello'. |
|
834 |
b showAtPointer. |
|
835 |
" |
|
514 | 836 |
|
837 |
"Modified: 7.3.1996 / 17:56:53 / cg" |
|
0 | 838 |
! |
839 |
||
840 |
showAtPointerNotCovering:aView |
|
12 | 841 |
"make myself visible at mouse pointer shifted to have |
842 |
convenient button under cursor. |
|
514 | 843 |
Fix position to make the box fully visible AND to make sure that |
12 | 844 |
aView is not covered." |
845 |
||
54 | 846 |
|pos newX| |
0 | 847 |
|
12 | 848 |
pos := device pointerPosition - self positionOffset. |
54 | 849 |
|
850 |
((Rectangle origin:pos extent:self extent) |
|
514 | 851 |
intersects: (aView origin corner: aView corner)) |
54 | 852 |
ifTrue:[ |
514 | 853 |
" |
854 |
try to the right of the untouchable view |
|
855 |
" |
|
856 |
newX := (aView origin x + aView width). |
|
4936
9ac25d62f361
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
4935
diff
changeset
|
857 |
newX + width > device usableExtent x ifTrue:[ |
9ac25d62f361
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
4935
diff
changeset
|
858 |
newX := device usableExtent x - width |
514 | 859 |
]. |
860 |
pos x:newX. |
|
54 | 861 |
|
862 |
||
514 | 863 |
((Rectangle origin:pos extent:self extent) |
864 |
intersects: (aView origin corner: aView corner)) |
|
865 |
ifTrue:[ |
|
866 |
" |
|
867 |
try to the left of the untouchable view |
|
868 |
" |
|
869 |
newX := aView origin x - width. |
|
870 |
" |
|
871 |
should look for vertical possibilities too ... |
|
872 |
" |
|
873 |
pos x:newX. |
|
874 |
] |
|
270 | 875 |
|
876 |
]. |
|
877 |
self showAt:pos |
|
514 | 878 |
|
879 |
"Modified: 7.3.1996 / 17:58:10 / cg" |
|
270 | 880 |
! |
881 |
||
296 | 882 |
showCenteredIn:aView |
514 | 883 |
"make myself visible at the center if aView." |
270 | 884 |
|
296 | 885 |
|top| |
270 | 886 |
|
296 | 887 |
top := aView topView. |
888 |
top raise. |
|
889 |
self showAt:(top center + (aView originRelativeTo:top)) center:true |
|
270 | 890 |
|
891 |
" |
|
892 |
|b| |
|
893 |
||
296 | 894 |
b := InfoBox title:'hello'. |
895 |
b showCenteredIn:Transcript. |
|
270 | 896 |
" |
514 | 897 |
|
898 |
"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
|
899 |
! |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
900 |
|
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
901 |
unmapped |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
902 |
"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
|
903 |
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
|
904 |
Consider this a kludge." |
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 |
|r| |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
907 |
|
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
908 |
r := realized. |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
909 |
super unmapped. |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
910 |
realized := r. |
270 | 911 |
! ! |
912 |
||
1232 | 913 |
!ModalBox class methodsFor:'documentation'! |
270 | 914 |
|
296 | 915 |
version |
4936
9ac25d62f361
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
4935
diff
changeset
|
916 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.95 2008-04-11 13:16:49 cg Exp $' |
270 | 917 |
! ! |
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
918 |
|
296 | 919 |
ModalBox initialize! |