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