0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1989-93 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
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 |
|
|
13 |
View subclass:#PopUpView
|
|
14 |
instanceVariableNames:'shadowView haveControl'
|
|
15 |
classVariableNames:'PopShadow'
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Basic'
|
|
18 |
!
|
|
19 |
|
|
20 |
PopUpView comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1989-93 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
%W% %E%
|
|
26 |
|
|
27 |
written spring/summer 89 by claus
|
|
28 |
'!
|
|
29 |
|
|
30 |
Smalltalk at:#ActiveGrab put:nil!
|
|
31 |
|
2
|
32 |
!PopUpView class methodsFor:'documentation'!
|
|
33 |
|
|
34 |
documentation
|
|
35 |
"
|
|
36 |
this class implements an abstract superclass for all views which bypass the window manager
|
|
37 |
and pop up on top of the screen. They are usually not decorated by
|
|
38 |
window managers.
|
|
39 |
|
|
40 |
class variables:
|
|
41 |
|
|
42 |
PopShadow <Boolean> if true, popupviews show a shadow
|
|
43 |
|
|
44 |
"
|
|
45 |
! !
|
|
46 |
|
0
|
47 |
!PopUpView class methodsFor:'defaults'!
|
|
48 |
|
|
49 |
defaultExtent
|
|
50 |
^ (Display width // 2) @ (Display height // 2)
|
|
51 |
! !
|
|
52 |
|
|
53 |
!PopUpView class methodsFor:'initialization'!
|
|
54 |
|
|
55 |
initialize
|
|
56 |
super initialize.
|
2
|
57 |
PopShadow := self classResources name:'POPUP_SHADOW' default:false
|
0
|
58 |
! !
|
|
59 |
|
|
60 |
!PopUpView methodsFor:'initialization / release'!
|
|
61 |
|
|
62 |
initialize
|
|
63 |
|c|
|
|
64 |
|
|
65 |
super initialize.
|
|
66 |
c := device center.
|
|
67 |
left := c x - (width // 2).
|
|
68 |
top := c y - (height // 2).
|
|
69 |
self is3D ifTrue:[
|
|
70 |
borderWidth := 0.
|
|
71 |
self level:2
|
|
72 |
] ifFalse:[
|
|
73 |
borderWidth := 1
|
|
74 |
].
|
|
75 |
|
|
76 |
PopShadow ifTrue:[
|
|
77 |
shadowView := (ShadowView on:device) for:self.
|
|
78 |
device hasGreyscales ifTrue:[
|
|
79 |
shadowView paint:(Color darkGrey)
|
|
80 |
]
|
|
81 |
].
|
|
82 |
haveControl := false
|
|
83 |
!
|
|
84 |
|
|
85 |
destroy
|
|
86 |
haveControl := false.
|
|
87 |
super destroy.
|
|
88 |
shadowView notNil ifTrue:[shadowView destroy]
|
|
89 |
!
|
|
90 |
|
|
91 |
create
|
|
92 |
super create.
|
2
|
93 |
PopShadow ifFalse:[
|
|
94 |
self saveUnder:true
|
|
95 |
]
|
0
|
96 |
! !
|
|
97 |
|
|
98 |
!PopUpView methodsFor:'dispatching'!
|
|
99 |
|
|
100 |
modalLoop
|
|
101 |
haveControl := true.
|
|
102 |
|
|
103 |
"this is a kludge - we do not have multiple processes, therefore
|
|
104 |
we start another dispatch loop, which exits when control is lost"
|
|
105 |
|
|
106 |
device dispatchFor:nil "drawableId" while:[haveControl]
|
|
107 |
! !
|
|
108 |
|
|
109 |
!PopUpView methodsFor:'private'!
|
|
110 |
|
|
111 |
takeControl
|
|
112 |
^ self.
|
|
113 |
haveControl := true.
|
|
114 |
|
|
115 |
"this is a kludge - we do not have multiple processes, therefore
|
|
116 |
we start another dispatch loop, which exits when control is lost"
|
|
117 |
|
|
118 |
device dispatchFor:drawableId while:[haveControl]
|
|
119 |
!
|
|
120 |
|
|
121 |
leaveControl
|
|
122 |
haveControl := false
|
|
123 |
! !
|
|
124 |
|
|
125 |
!PopUpView methodsFor:'realize / unrealize'!
|
|
126 |
|
|
127 |
mapped
|
|
128 |
"wait till visible for grabbing"
|
|
129 |
|
|
130 |
super mapped.
|
|
131 |
device grabPointerIn:drawableId.
|
|
132 |
ActiveGrab := self.
|
|
133 |
!
|
|
134 |
|
|
135 |
realize
|
|
136 |
shadowView notNil ifTrue:[shadowView realize].
|
|
137 |
self raise.
|
|
138 |
super realize.
|
|
139 |
|
|
140 |
"get the pointer into my window"
|
|
141 |
"
|
|
142 |
device grabPointerIn:drawableId.
|
|
143 |
ActiveGrab := self.
|
|
144 |
"
|
|
145 |
"and handle events for me"
|
|
146 |
self takeControl
|
|
147 |
!
|
|
148 |
|
|
149 |
unrealize
|
|
150 |
haveControl := false.
|
|
151 |
ActiveGrab := nil.
|
|
152 |
device ungrabPointer.
|
2
|
153 |
super unrealize.
|
|
154 |
shadowView notNil ifTrue:[shadowView unrealize].
|
0
|
155 |
! !
|
|
156 |
|
|
157 |
!PopUpView methodsFor:'accessing'!
|
|
158 |
|
|
159 |
heightIncludingBorder
|
|
160 |
^ height
|
|
161 |
!
|
|
162 |
|
|
163 |
widthIncludingBorder
|
|
164 |
^ width
|
|
165 |
!
|
|
166 |
|
|
167 |
createOnTop
|
|
168 |
^ true
|
|
169 |
! !
|