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