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