author | Claus Gittinger <cg@exept.de> |
Wed, 31 Jan 1996 02:50:48 +0100 | |
changeset 388 | 64e43f82d93e |
parent 371 | cc32d8f8bc8d |
child 485 | 47c3cfae7ae2 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 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 |
" |
|
12 |
||
135 | 13 |
TopView subclass:#PopUpView |
269 | 14 |
instanceVariableNames:'shadowView haveControl exclusivePointer' |
15 |
classVariableNames:'DefaultShadow DefaultLevel DefaultBorderWidth DefaultBorderColor' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Basic' |
|
0 | 18 |
! |
19 |
||
2 | 20 |
!PopUpView class methodsFor:'documentation'! |
21 |
||
46 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
72 | 25 |
All Rights Reserved |
46 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
2 | 36 |
documentation |
37 |
" |
|
46 | 38 |
this class implements an abstract superclass for all views which bypass the |
89 | 39 |
window manager and pop up on top of the screen. A typical example is |
40 |
a PopUpMenu. PopUpView itself is abstract, providing basic mechanisms. |
|
41 |
They are not decorated by window managers. |
|
2 | 42 |
|
81 | 43 |
styleSheet parameters: |
2 | 44 |
|
81 | 45 |
popupShadow <Boolean> if true, popupViews show a shadow below |
46 |
popupLevel <nil | Integer> 3D level |
|
47 |
popupBorderWidth <nil | Integer> borderWidth |
|
2 | 48 |
" |
49 |
! ! |
|
50 |
||
0 | 51 |
!PopUpView class methodsFor:'defaults'! |
52 |
||
53 |
defaultExtent |
|
135 | 54 |
^ (Display width // 3) @ (Display height // 3) |
81 | 55 |
! |
0 | 56 |
|
269 | 57 |
shadows |
58 |
"return the shadows-flag. False means: turned off." |
|
59 |
||
60 |
^ DefaultShadow |
|
144 | 61 |
! |
62 |
||
63 |
shadows:aBoolean |
|
64 |
"turn on/off shadows under popUpViews. |
|
65 |
On slow displays, turning them off makes menus appear a bit snappier. |
|
66 |
The default is set via the styleSheet and changes when the viewStyle |
|
67 |
is changed." |
|
68 |
||
69 |
DefaultShadow := aBoolean |
|
70 |
! |
|
71 |
||
269 | 72 |
updateStyleCache |
73 |
ShadowView isNil ifTrue:[ |
|
74 |
DefaultShadow := false |
|
75 |
] ifFalse:[ |
|
76 |
DefaultShadow := StyleSheet at:'popupShadow' default:false. |
|
77 |
]. |
|
78 |
DefaultLevel := StyleSheet at:'popupLevel'. |
|
79 |
DefaultBorderWidth := StyleSheet at:'popupBorderWidth'. |
|
80 |
DefaultBorderColor := StyleSheet colorAt:'popupBorderColor'. |
|
81 |
! ! |
|
82 |
||
83 |
!PopUpView methodsFor:'accessing'! |
|
84 |
||
85 |
exclusivePointer:aBoolean |
|
86 |
exclusivePointer := aBoolean |
|
87 |
! |
|
88 |
||
89 |
noShadow |
|
90 |
"turn off the shadow" |
|
91 |
||
92 |
shadowView := nil |
|
93 |
! ! |
|
94 |
||
95 |
!PopUpView methodsFor:'activation'! |
|
96 |
||
97 |
hide |
|
98 |
"hide the view, leave its modal event loop" |
|
99 |
||
100 |
windowGroup notNil ifTrue:[ |
|
101 |
windowGroup removeView:self. |
|
102 |
windowGroup := nil. |
|
103 |
]. |
|
104 |
self unrealize. |
|
105 |
! |
|
106 |
||
107 |
show |
|
108 |
"realize the view at its last position" |
|
109 |
||
110 |
self fixSize. |
|
111 |
self openModal:[true] "realize " |
|
112 |
! |
|
144 | 113 |
|
269 | 114 |
showAt:aPoint |
115 |
"realize the view at aPoint" |
|
116 |
||
117 |
self showAt:aPoint resizing:true |
|
118 |
! |
|
119 |
||
120 |
showAt:aPoint resizing:aBoolean |
|
121 |
"realize the view at aPoint" |
|
122 |
||
123 |
aBoolean ifTrue:[ |
|
124 |
self fixSize. |
|
125 |
]. |
|
126 |
self origin:aPoint. |
|
127 |
self makeFullyVisible. |
|
128 |
self openModal:[true] "realize " |
|
129 |
! |
|
130 |
||
131 |
showAtPointer |
|
132 |
"realize the view at the current pointer position" |
|
133 |
||
134 |
self showAt:(device pointerPosition) resizing:true |
|
135 |
! |
|
136 |
||
137 |
showCenteredIn:aView |
|
138 |
"make myself visible at the screen center." |
|
139 |
||
140 |
|top| |
|
141 |
||
142 |
top := aView topView. |
|
143 |
top raise. |
|
144 |
self showAt:(top origin |
|
145 |
+ (aView originRelativeTo:top) |
|
146 |
+ (aView extent // 2) |
|
147 |
- (self extent // 2)) |
|
148 |
! ! |
|
149 |
||
150 |
!PopUpView methodsFor:'dispatching'! |
|
151 |
||
152 |
modalLoop |
|
153 |
haveControl := true. |
|
154 |
||
155 |
"this is a kludge - we do not have multiple processes, therefore |
|
156 |
we start another dispatch loop, which exits when control is lost" |
|
157 |
||
158 |
device dispatchFor:nil while:[haveControl] |
|
0 | 159 |
! ! |
160 |
||
89 | 161 |
!PopUpView methodsFor:'initialize / release'! |
0 | 162 |
|
269 | 163 |
create |
164 |
super create. |
|
165 |
shadowView isNil ifTrue:[ |
|
166 |
self saveUnder:true |
|
167 |
] |
|
168 |
! |
|
169 |
||
170 |
destroy |
|
141 | 171 |
haveControl := false. |
269 | 172 |
super destroy. |
173 |
shadowView notNil ifTrue:[shadowView destroy. shadowView := nil] |
|
81 | 174 |
! |
175 |
||
176 |
initStyle |
|
177 |
super initStyle. |
|
178 |
||
151 | 179 |
styleSheet is3D == true ifTrue:[ |
72 | 180 |
borderWidth := 0. |
81 | 181 |
level := 2 |
0 | 182 |
] ifFalse:[ |
81 | 183 |
borderWidth := 1. |
184 |
level := 0 |
|
0 | 185 |
]. |
186 |
||
81 | 187 |
DefaultBorderColor notNil ifTrue:[ |
188 |
self borderColor:(DefaultBorderColor on:device). |
|
189 |
]. |
|
190 |
DefaultBorderWidth notNil ifTrue:[ |
|
191 |
borderWidth := DefaultBorderWidth. |
|
192 |
]. |
|
193 |
"/ DefaultEdgeStyle notNil ifTrue:[ |
|
194 |
"/ edgeStyle := DefaultEdgeStyle. |
|
195 |
"/ ]. |
|
196 |
DefaultLevel notNil ifTrue:[ |
|
197 |
self level:DefaultLevel. |
|
198 |
]. |
|
199 |
||
200 |
DefaultShadow ifTrue:[ |
|
135 | 201 |
shadowView := (ShadowView onDevice:device) for:self. |
0 | 202 |
]. |
203 |
! |
|
204 |
||
269 | 205 |
initialize |
206 |
super initialize. |
|
207 |
exclusivePointer := true. |
|
0 | 208 |
haveControl := false. |
269 | 209 |
type := #popup |
162 | 210 |
! |
211 |
||
212 |
releasePointer |
|
213 |
device activePointerGrab == self ifTrue:[ |
|
214 |
device ungrabPointer. |
|
215 |
]. |
|
0 | 216 |
! ! |
217 |
||
269 | 218 |
!PopUpView methodsFor:'private'! |
0 | 219 |
|
269 | 220 |
leaveControl |
221 |
haveControl := false |
|
222 |
! |
|
0 | 223 |
|
269 | 224 |
regainControl |
225 |
device grabPointerInView:self |
|
226 |
! |
|
0 | 227 |
|
228 |
takeControl |
|
229 |
^ self. |
|
230 |
haveControl := true. |
|
231 |
||
232 |
"this is a kludge - we do not have multiple processes, therefore |
|
233 |
we start another dispatch loop, which exits when control is lost" |
|
234 |
||
235 |
device dispatchFor:drawableId while:[haveControl] |
|
89 | 236 |
! ! |
237 |
||
269 | 238 |
!PopUpView methodsFor:'queries'! |
89 | 239 |
|
269 | 240 |
isPopUpView |
241 |
^ true |
|
0 | 242 |
! ! |
243 |
||
244 |
!PopUpView methodsFor:'realize / unrealize'! |
|
245 |
||
246 |
mapped |
|
162 | 247 |
"grab the pointer here, when visible (but not control is already lost). |
248 |
If the grab fails, try again and unrealize myself if that fails too." |
|
0 | 249 |
|
250 |
super mapped. |
|
162 | 251 |
|
157 | 252 |
(haveControl |
162 | 253 |
and:[true "/ exclusivePointer |
157 | 254 |
and:[realized]]) ifTrue:[ |
141 | 255 |
(device grabPointerInView:self) ifFalse:[ |
256 |
"wait a little bit and try again" |
|
157 | 257 |
"/ 'grab pointer failed' errorPrintNL. |
371 | 258 |
Delay waitForSeconds:0.1. |
141 | 259 |
(device grabPointerInView:self) ifFalse:[ |
260 |
"give up" |
|
261 |
'could not grab pointer' errorPrintNL. |
|
262 |
self unrealize |
|
263 |
] |
|
162 | 264 |
]. |
265 |
exclusivePointer ifFalse:[ |
|
266 |
self releasePointer |
|
267 |
]. |
|
388
64e43f82d93e
Escape leaves modalBoxes or PopUpViews
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
268 |
self getKeyboardFocus |
81 | 269 |
] |
0 | 270 |
! |
271 |
||
272 |
realize |
|
273 |
shadowView notNil ifTrue:[shadowView realize]. |
|
274 |
self raise. |
|
81 | 275 |
haveControl := true. |
0 | 276 |
super realize. |
277 |
! |
|
278 |
||
269 | 279 |
restarted |
280 |
^ self |
|
281 |
! |
|
282 |
||
0 | 283 |
unrealize |
284 |
haveControl := false. |
|
81 | 285 |
device activePointerGrab == self ifTrue:[ |
72 | 286 |
device ungrabPointer. |
12 | 287 |
]. |
2 | 288 |
super unrealize. |
289 |
shadowView notNil ifTrue:[shadowView unrealize]. |
|
0 | 290 |
! ! |
291 |
||
269 | 292 |
!PopUpView class methodsFor:'documentation'! |
0 | 293 |
|
269 | 294 |
version |
388
64e43f82d93e
Escape leaves modalBoxes or PopUpViews
Claus Gittinger <cg@exept.de>
parents:
371
diff
changeset
|
295 |
^ '$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.21 1996-01-31 01:50:42 cg Exp $' |
157 | 296 |
! ! |