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