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