author | Stefan Vogel <sv@exept.de> |
Fri, 14 Dec 2012 10:03:16 +0100 | |
changeset 5968 | 2fa02aa1b5a3 |
parent 5945 | 52161987f2f1 |
child 6269 | 703a7c20f524 |
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 |
||
5945 | 558 |
sizeFixed ifFalse:[ |
559 |
self resize. |
|
296 | 560 |
]. |
561 |
super fixSize. |
|
5945 | 562 |
|
563 |
"Modified: / 27-10-2012 / 12:16:58 / cg" |
|
296 | 564 |
! |
565 |
||
566 |
hide |
|
567 |
"make the receiver invisible and leave control" |
|
568 |
||
2579 | 569 |
|masterGroup| |
54 | 570 |
|
1314 | 571 |
realized ifFalse:[^ self]. |
572 |
||
644 | 573 |
shadowView notNil ifTrue:[shadowView unmap]. |
3313 | 574 |
windowGroup notNil ifTrue:[ |
5611 | 575 |
windowGroup focusView:nil. |
576 |
masterGroup := windowGroup previousGroup. |
|
3313 | 577 |
]. |
578 |
||
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
579 |
exclusiveKeyboard ifTrue:[ |
5611 | 580 |
self forceUngrabKeyboard |
675
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
581 |
]. |
fc15e8886089
removed leaveCOntrol (not used); added comments
Claus Gittinger <cg@exept.de>
parents:
644
diff
changeset
|
582 |
|
644 | 583 |
self unmap. |
54 | 584 |
|
2579 | 585 |
masterGroup notNil ifTrue:[ |
5611 | 586 |
" |
587 |
this is a kludge for IRIS and others which do not provide backingstore: |
|
588 |
when we hide a modalbox (such as a searchbox) which covered |
|
589 |
a scrollbar, the scrollbars bitblt-method will copy from the |
|
590 |
not-yet redrawn area - effectively clearing the scroller. |
|
591 |
We need a short delay here, since at this time, the expose event has |
|
592 |
not yet arrived. |
|
593 |
" |
|
594 |
device sync. "/ thats a round trip, to ensure that all expose events are present..." |
|
595 |
Delay waitForSeconds:0.05. |
|
596 |
masterGroup processExposeEvents |
|
296 | 597 |
]. |
644 | 598 |
|
599 |
"Modified: 3.5.1996 / 23:47:57 / stefan" |
|
1314 | 600 |
"Modified: 8.2.1997 / 17:41:16 / cg" |
296 | 601 |
! |
0 | 602 |
|
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
603 |
hideRequest |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
604 |
"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
|
605 |
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
|
606 |
|
3440 | 607 |
self hide |
393
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
608 |
! |
3504a0adbb2d
use hideRequest to close via Escape key (allows redefinition);
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
609 |
|
0 | 610 |
mapped |
611 |
"wait till visible for grabbing" |
|
612 |
||
613 |
super mapped. |
|
12 | 614 |
|
3344
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
615 |
"/ "take it away from any popup menu possibly still active" |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
616 |
"/ |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
617 |
"/ self forceUngrabKeyboard. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
618 |
"/ self forceUngrabPointer. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
619 |
"/ |
54 | 620 |
" |
621 |
if I am a super-modal box, take the keyboard |
|
622 |
" |
|
12 | 623 |
exclusiveKeyboard ifTrue:[ |
5611 | 624 |
self forceUngrabKeyboard. |
625 |
self grabKeyboard. |
|
12 | 626 |
]. |
3344
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 |
"/"/ UseTransientViews ifFalse:[ |
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 |
"/ get the focus |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
631 |
"/ " |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
632 |
"/ self getKeyboardFocus. |
4c3428823365
moved focus & grabHandling to TopViews openModal handling
ca
parents:
3328
diff
changeset
|
633 |
"/ self enableEnterLeaveEvents |
3351 | 634 |
"/"/ ] |
3440 | 635 |
! |
0 | 636 |
|
46 | 637 |
open |
72 | 638 |
"default for modalboxes is to come up modal at the pointer position" |
46 | 639 |
|
3520 | 640 |
ForceModalBoxesToOpenAtCenter == true ifTrue:[ |
5611 | 641 |
^ self showAtCenter |
3520 | 642 |
]. |
72 | 643 |
^ self showAtPointer |
46 | 644 |
! |
645 |
||
953 | 646 |
openAt:aPoint |
647 |
"default for modalboxes is to come up modal at the pointer position" |
|
648 |
||
649 |
^ self openModalAt:aPoint |
|
650 |
||
651 |
"Created: 17.7.1996 / 14:50:44 / cg" |
|
652 |
! |
|
653 |
||
654 |
openAtCenter |
|
655 |
"default for modalboxes is to come up modal at the pointer position" |
|
656 |
||
657 |
^ self openModalAtCenter |
|
658 |
||
659 |
"Created: 17.7.1996 / 14:50:35 / cg" |
|
660 |
! |
|
661 |
||
72 | 662 |
openModal:aBlock |
54 | 663 |
"open the box modal; |
664 |
In addition to the basic (inherited) modalloop, change |
|
72 | 665 |
the current active windowgroups cursors to the busy-stop cursor, show |
54 | 666 |
a shadow, and raise the box." |
667 |
||
1397
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
668 |
shadowView notNil ifTrue:[shadowView realize]. |
932c517ad29c
moved tranientView setup up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
669 |
super openModal:aBlock. |
300
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
670 |
|
6a63af1fec3e
passing group to avoid multiple activeGroup searches
Claus Gittinger <cg@exept.de>
parents:
296
diff
changeset
|
671 |
"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
|
672 |
"Modified: 28.2.1997 / 22:32:49 / cg" |
54 | 673 |
! |
674 |
||
12 | 675 |
show |
514 | 676 |
"make myself visible (at the last or default position) and take control. |
677 |
If that position is out of the screen area, moves the receiver to make |
|
678 |
it fully visible." |
|
12 | 679 |
|
680 |
self fixSize. |
|
72 | 681 |
self makeFullyVisible. |
54 | 682 |
self openModal |
72 | 683 |
|
684 |
" |
|
685 |
|b| |
|
686 |
||
687 |
b := InfoBox title:'hello'. |
|
688 |
b show. |
|
689 |
" |
|
514 | 690 |
|
691 |
"Modified: 7.3.1996 / 17:57:49 / cg" |
|
12 | 692 |
! |
693 |
||
694 |
showAt:aPoint |
|
695 |
"make myself visible at aPoint. |
|
696 |
Fix position to make box fully visible" |
|
697 |
||
698 |
self fixSize. |
|
699 |
self fixPosition:aPoint. |
|
54 | 700 |
self openModal |
72 | 701 |
|
702 |
" |
|
703 |
|b| |
|
704 |
||
705 |
b := InfoBox title:'hello'. |
|
706 |
b showAt:(0 @ 0). |
|
707 |
b showAt:(400 @ 400). |
|
708 |
" |
|
709 |
! |
|
710 |
||
711 |
showAt:aPoint center:center |
|
712 |
"make myself visible at aPoint. center specifies |
|
713 |
if the view should show up centered around aPoint." |
|
714 |
||
715 |
self showAt:aPoint centerX:center centerY:center |
|
716 |
||
717 |
" |
|
718 |
|b| |
|
719 |
||
720 |
b := InfoBox title:'hello'. |
|
721 |
b showAt:(100 @ 100) center:true. |
|
722 |
b showAt:(100 @ 100) center:false. |
|
723 |
" |
|
724 |
! |
|
725 |
||
726 |
showAt:aPoint centerX:centerX centerY:centerY |
|
727 |
"make myself visible at aPoint. centerX/centerY specify |
|
728 |
if the view should show up centered around aPoint. |
|
729 |
Fix position to make box fully visible" |
|
730 |
||
731 |
|dx dy| |
|
732 |
||
733 |
self fixSize. |
|
734 |
centerX ifTrue:[ |
|
5678
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
735 |
dx := self width // 2. |
72 | 736 |
] ifFalse:[ |
5678
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
737 |
dx := 0 |
72 | 738 |
]. |
739 |
centerY ifTrue:[ |
|
5678
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
740 |
dy := self height // 2. |
72 | 741 |
] ifFalse:[ |
5678
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
742 |
dy := 0 |
72 | 743 |
]. |
744 |
self origin:(aPoint - (dx @ dy)). |
|
745 |
self makeFullyVisible. |
|
746 |
self openModal |
|
747 |
||
748 |
" |
|
749 |
|b| |
|
750 |
||
751 |
b := InfoBox title:'hello'. |
|
752 |
b showAt:(100 @ 100). |
|
753 |
b showAt:(100 @ 100) centerX:true centerY:false. |
|
754 |
" |
|
5678
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
755 |
|
414d0473ad21
force the extent to be no bigger than the screen
Claus Gittinger <cg@exept.de>
parents:
5626
diff
changeset
|
756 |
"Modified: / 21-01-2011 / 13:58:29 / cg" |
54 | 757 |
! |
758 |
||
759 |
showAtCenter |
|
760 |
"make myself visible at the screen center." |
|
761 |
||
5968 | 762 |
self showAt:(device centerOfMonitorHavingPointer) center:true |
72 | 763 |
|
764 |
" |
|
765 |
|b| |
|
766 |
||
767 |
b := InfoBox title:'hello'. |
|
768 |
b showAtCenter. |
|
769 |
" |
|
770 |
! |
|
771 |
||
0 | 772 |
showAtPointer |
12 | 773 |
"make myself visible at mouse pointer shifted to have |
66 | 774 |
convenient button under cursor. self positionOffset should |
775 |
return that offset (usually redefined, since we dont know here, |
|
776 |
which button should be under cursor)." |
|
12 | 777 |
|
5611 | 778 |
|first pointerPosition positionOffset pos monitorBounds alignedPos| |
779 |
||
5626 | 780 |
"/ ****** MULTI SCREEN |
5611 | 781 |
|
782 |
pointerPosition := device pointerPosition. |
|
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
783 |
|
12 | 784 |
self fixSize. |
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
785 |
positionOffset := self positionOffset. |
5626 | 786 |
pos := alignedPos := pointerPosition - positionOffset. |
5611 | 787 |
|
5626 | 788 |
UserPreferences current forceWindowsIntoMonitorBounds ifTrue:[ |
789 |
monitorBounds := device monitorBoundsAt:pointerPosition. |
|
790 |
alignedPos := (pos x max:monitorBounds left) @ (pos y max:monitorBounds top). |
|
791 |
]. |
|
5611 | 792 |
|
793 |
positionOffset := pointerPosition - alignedPos. |
|
794 |
||
795 |
self fixPosition:alignedPos. |
|
5513 | 796 |
pos := self origin. |
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
797 |
|
5611 | 798 |
"We have got a problem here: |
5616 | 799 |
X11 adds some window decoration. The size of the decoration is only known |
800 |
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
|
801 |
|
5616 | 802 |
So there is a (hopefully) small offset from the pointer to the requested |
803 |
position. The only way to resolve this, is to move the pointer to |
|
804 |
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
|
805 |
|
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
806 |
first := true. |
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
807 |
self openModal:[ |
5616 | 808 |
(first and:[shown]) ifTrue:[ |
809 |
"/ self origin:pos. |
|
810 |
first := false. |
|
811 |
self setPointerPosition:positionOffset. |
|
812 |
]. |
|
813 |
true |
|
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
814 |
]. |
72 | 815 |
|
514 | 816 |
"/ cannot use: |
817 |
"/ self showAt:(device pointerPosition - self positionOffset). |
|
818 |
"/ because the resizing must be done before the |
|
819 |
"/ positionOffset is grabbed (it may change due to the resize) |
|
820 |
||
72 | 821 |
" |
822 |
|b| |
|
823 |
||
824 |
b := InfoBox title:'hello'. |
|
825 |
b showAtPointer. |
|
826 |
" |
|
514 | 827 |
|
5626 | 828 |
"Modified: / 22-10-2010 / 11:20:05 / cg" |
0 | 829 |
! |
830 |
||
831 |
showAtPointerNotCovering:aView |
|
12 | 832 |
"make myself visible at mouse pointer shifted to have |
833 |
convenient button under cursor. |
|
514 | 834 |
Fix position to make the box fully visible AND to make sure that |
12 | 835 |
aView is not covered." |
836 |
||
54 | 837 |
|pos newX| |
0 | 838 |
|
12 | 839 |
pos := device pointerPosition - self positionOffset. |
54 | 840 |
|
5611 | 841 |
((Rectangle origin:pos extent:self extent) |
842 |
intersects: (aView origin corner: aView corner)) |
|
54 | 843 |
ifTrue:[ |
5611 | 844 |
" |
845 |
try to the right of the untouchable view |
|
846 |
" |
|
847 |
newX := (aView origin x + aView width). |
|
848 |
newX + width > device usableWidth ifTrue:[ |
|
849 |
newX := device usableWidth - width |
|
850 |
]. |
|
851 |
pos x:newX. |
|
54 | 852 |
|
853 |
||
5611 | 854 |
((Rectangle origin:pos extent:self extent) |
855 |
intersects: (aView origin corner: aView corner)) |
|
856 |
ifTrue:[ |
|
857 |
" |
|
858 |
try to the left of the untouchable view |
|
859 |
" |
|
860 |
newX := aView origin x - width. |
|
861 |
" |
|
862 |
should look for vertical possibilities too ... |
|
863 |
" |
|
864 |
pos x:newX. |
|
865 |
] |
|
270 | 866 |
|
867 |
]. |
|
868 |
self showAt:pos |
|
514 | 869 |
|
870 |
"Modified: 7.3.1996 / 17:58:10 / cg" |
|
270 | 871 |
! |
872 |
||
296 | 873 |
showCenteredIn:aView |
514 | 874 |
"make myself visible at the center if aView." |
270 | 875 |
|
296 | 876 |
|top| |
270 | 877 |
|
296 | 878 |
top := aView topView. |
879 |
top raise. |
|
880 |
self showAt:(top center + (aView originRelativeTo:top)) center:true |
|
270 | 881 |
|
882 |
" |
|
883 |
|b| |
|
884 |
||
296 | 885 |
b := InfoBox title:'hello'. |
886 |
b showCenteredIn:Transcript. |
|
270 | 887 |
" |
514 | 888 |
|
889 |
"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
|
890 |
! |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
891 |
|
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
892 |
unmapped |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
893 |
"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
|
894 |
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
|
895 |
Consider this a kludge." |
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| |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
898 |
|
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
899 |
r := realized. |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
900 |
super unmapped. |
c7c9b49a3794
kludge workaround - keep realized flag value when unmapped
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
901 |
realized := r. |
270 | 902 |
! ! |
903 |
||
1232 | 904 |
!ModalBox class methodsFor:'documentation'! |
270 | 905 |
|
296 | 906 |
version |
5968 | 907 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.110 2012-12-14 09:03:16 stefan Exp $' |
5386
7bb5b24b9bb2
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
5226
diff
changeset
|
908 |
! |
7bb5b24b9bb2
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
5226
diff
changeset
|
909 |
|
7bb5b24b9bb2
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
5226
diff
changeset
|
910 |
version_CVS |
5968 | 911 |
^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.110 2012-12-14 09:03:16 stefan Exp $' |
270 | 912 |
! ! |
3859
a11d876ebc26
Fix #showAtPointer to take care of window manager title bars.
Stefan Vogel <sv@exept.de>
parents:
3715
diff
changeset
|
913 |
|
296 | 914 |
ModalBox initialize! |