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