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