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
|
0
|
14 |
instanceVariableNames:'shadowView haveControl'
|
81
|
15 |
classVariableNames:'DefaultShadow DefaultLevel DefaultBorderWidth
|
|
16 |
DefaultBorderColor'
|
0
|
17 |
poolDictionaries:''
|
|
18 |
category:'Views-Basic'
|
|
19 |
!
|
|
20 |
|
|
21 |
PopUpView comment:'
|
6
|
22 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
72
|
23 |
All Rights Reserved
|
54
|
24 |
|
135
|
25 |
$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.11 1995-05-03 00:25:03 claus Exp $
|
0
|
26 |
'!
|
|
27 |
|
2
|
28 |
!PopUpView class methodsFor:'documentation'!
|
|
29 |
|
46
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
72
|
33 |
All Rights Reserved
|
46
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
version
|
|
45 |
"
|
135
|
46 |
$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.11 1995-05-03 00:25:03 claus Exp $
|
46
|
47 |
"
|
|
48 |
!
|
|
49 |
|
2
|
50 |
documentation
|
|
51 |
"
|
46
|
52 |
this class implements an abstract superclass for all views which bypass the
|
89
|
53 |
window manager and pop up on top of the screen. A typical example is
|
|
54 |
a PopUpMenu. PopUpView itself is abstract, providing basic mechanisms.
|
|
55 |
They are not decorated by window managers.
|
2
|
56 |
|
81
|
57 |
styleSheet parameters:
|
2
|
58 |
|
81
|
59 |
popupShadow <Boolean> if true, popupViews show a shadow below
|
|
60 |
popupLevel <nil | Integer> 3D level
|
|
61 |
popupBorderWidth <nil | Integer> borderWidth
|
2
|
62 |
"
|
|
63 |
! !
|
|
64 |
|
0
|
65 |
!PopUpView class methodsFor:'defaults'!
|
|
66 |
|
|
67 |
defaultExtent
|
135
|
68 |
^ (Display width // 3) @ (Display height // 3)
|
81
|
69 |
!
|
0
|
70 |
|
81
|
71 |
updateStyleCache
|
135
|
72 |
ShadowView isNil ifTrue:[
|
|
73 |
DefaultShadow := false
|
|
74 |
] ifFalse:[
|
|
75 |
DefaultShadow := StyleSheet at:'popupShadow' default:false.
|
|
76 |
].
|
81
|
77 |
DefaultLevel := StyleSheet at:'popupLevel'.
|
|
78 |
DefaultBorderWidth := StyleSheet at:'popupBorderWidth'.
|
|
79 |
DefaultBorderColor := StyleSheet colorAt:'popupBorderColor'.
|
0
|
80 |
! !
|
|
81 |
|
89
|
82 |
!PopUpView methodsFor:'initialize / release'!
|
0
|
83 |
|
|
84 |
initialize
|
|
85 |
super initialize.
|
81
|
86 |
haveControl := false
|
|
87 |
!
|
|
88 |
|
|
89 |
initStyle
|
|
90 |
super initStyle.
|
|
91 |
|
|
92 |
StyleSheet is3D == true ifTrue:[
|
72
|
93 |
borderWidth := 0.
|
81
|
94 |
level := 2
|
0
|
95 |
] ifFalse:[
|
81
|
96 |
borderWidth := 1.
|
|
97 |
level := 0
|
0
|
98 |
].
|
|
99 |
|
81
|
100 |
DefaultBorderColor notNil ifTrue:[
|
|
101 |
self borderColor:(DefaultBorderColor on:device).
|
|
102 |
].
|
|
103 |
DefaultBorderWidth notNil ifTrue:[
|
|
104 |
borderWidth := DefaultBorderWidth.
|
|
105 |
].
|
|
106 |
"/ DefaultEdgeStyle notNil ifTrue:[
|
|
107 |
"/ edgeStyle := DefaultEdgeStyle.
|
|
108 |
"/ ].
|
|
109 |
DefaultLevel notNil ifTrue:[
|
|
110 |
self level:DefaultLevel.
|
|
111 |
].
|
|
112 |
|
|
113 |
DefaultShadow ifTrue:[
|
135
|
114 |
shadowView := (ShadowView onDevice:device) for:self.
|
0
|
115 |
].
|
|
116 |
!
|
|
117 |
|
|
118 |
destroy
|
|
119 |
haveControl := false.
|
|
120 |
super destroy.
|
12
|
121 |
shadowView notNil ifTrue:[shadowView destroy. shadowView := nil]
|
0
|
122 |
!
|
|
123 |
|
|
124 |
create
|
|
125 |
super create.
|
12
|
126 |
shadowView isNil ifTrue:[
|
72
|
127 |
self saveUnder:true
|
2
|
128 |
]
|
0
|
129 |
! !
|
|
130 |
|
|
131 |
!PopUpView methodsFor:'dispatching'!
|
|
132 |
|
|
133 |
modalLoop
|
|
134 |
haveControl := true.
|
|
135 |
|
|
136 |
"this is a kludge - we do not have multiple processes, therefore
|
|
137 |
we start another dispatch loop, which exits when control is lost"
|
|
138 |
|
12
|
139 |
device dispatchFor:nil while:[haveControl]
|
0
|
140 |
! !
|
|
141 |
|
|
142 |
!PopUpView methodsFor:'private'!
|
|
143 |
|
|
144 |
takeControl
|
|
145 |
^ self.
|
|
146 |
haveControl := true.
|
|
147 |
|
|
148 |
"this is a kludge - we do not have multiple processes, therefore
|
|
149 |
we start another dispatch loop, which exits when control is lost"
|
|
150 |
|
|
151 |
device dispatchFor:drawableId while:[haveControl]
|
|
152 |
!
|
|
153 |
|
|
154 |
leaveControl
|
|
155 |
haveControl := false
|
89
|
156 |
!
|
|
157 |
|
|
158 |
regainControl
|
|
159 |
device grabPointerInView:self
|
|
160 |
! !
|
|
161 |
|
|
162 |
!PopUpView methodsFor:'activation'!
|
|
163 |
|
|
164 |
show
|
|
165 |
"realize the view at its last position"
|
|
166 |
|
|
167 |
self fixSize.
|
|
168 |
self openModal:[true] "realize "
|
|
169 |
!
|
|
170 |
|
|
171 |
showAt:aPoint resizing:aBoolean
|
|
172 |
"realize the view at aPoint"
|
|
173 |
|
|
174 |
aBoolean ifTrue:[
|
|
175 |
self fixSize.
|
|
176 |
].
|
|
177 |
self origin:aPoint.
|
|
178 |
self makeFullyVisible.
|
|
179 |
self openModal:[true] "realize "
|
|
180 |
!
|
|
181 |
|
|
182 |
showAt:aPoint
|
|
183 |
"realize the view at aPoint"
|
|
184 |
|
|
185 |
self showAt:aPoint resizing:true
|
|
186 |
!
|
|
187 |
|
|
188 |
showCenteredIn:aView
|
|
189 |
"make myself visible at the screen center."
|
|
190 |
|
|
191 |
|top|
|
|
192 |
|
|
193 |
top := aView topView.
|
|
194 |
top raise.
|
|
195 |
self showAt:(top origin
|
|
196 |
+ (aView originRelativeTo:top)
|
|
197 |
+ (aView extent // 2)
|
|
198 |
- (self extent // 2))
|
|
199 |
!
|
|
200 |
|
|
201 |
showAtPointer
|
|
202 |
"realize the view at the current pointer position"
|
|
203 |
|
|
204 |
self showAt:(device pointerPosition) resizing:true
|
|
205 |
!
|
|
206 |
|
|
207 |
hide
|
|
208 |
"hide the view, leave its modal event loop"
|
|
209 |
|
|
210 |
windowGroup notNil ifTrue:[
|
|
211 |
windowGroup removeView:self.
|
|
212 |
windowGroup := nil.
|
|
213 |
].
|
|
214 |
self unrealize.
|
0
|
215 |
! !
|
|
216 |
|
|
217 |
!PopUpView methodsFor:'realize / unrealize'!
|
|
218 |
|
|
219 |
mapped
|
|
220 |
"wait till visible for grabbing"
|
|
221 |
|
|
222 |
super mapped.
|
81
|
223 |
haveControl ifTrue:[
|
|
224 |
device grabPointerInView:self.
|
|
225 |
]
|
0
|
226 |
!
|
|
227 |
|
|
228 |
realize
|
|
229 |
shadowView notNil ifTrue:[shadowView realize].
|
|
230 |
self raise.
|
81
|
231 |
haveControl := true.
|
0
|
232 |
super realize.
|
|
233 |
!
|
|
234 |
|
|
235 |
unrealize
|
|
236 |
haveControl := false.
|
81
|
237 |
device activePointerGrab == self ifTrue:[
|
72
|
238 |
device ungrabPointer.
|
12
|
239 |
].
|
2
|
240 |
super unrealize.
|
|
241 |
shadowView notNil ifTrue:[shadowView unrealize].
|
0
|
242 |
! !
|
|
243 |
|
|
244 |
!PopUpView methodsFor:'accessing'!
|
|
245 |
|
135
|
246 |
noShadow
|
|
247 |
"turn off the shadow"
|
0
|
248 |
|
135
|
249 |
shadowView := nil
|
0
|
250 |
!
|
|
251 |
|
|
252 |
createOnTop
|
|
253 |
^ true
|
|
254 |
! !
|