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