873
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG / 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 |
|
|
14 |
Object subclass:#DropTarget
|
|
15 |
instanceVariableNames:'receiver enterSelector leaveSelector overSelector dropSelector
|
|
16 |
canDropSelector argument'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-DragAndDrop'
|
|
20 |
!
|
|
21 |
|
|
22 |
!DropTarget class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
|
|
37 |
!
|
|
38 |
|
|
39 |
documentation
|
|
40 |
"
|
|
41 |
this class keeps the current target of the drop operation; the object respoonsible
|
|
42 |
for the widget under the current mouse position.
|
|
43 |
|
|
44 |
receiver <Object> receiver to which the requests are sent. the
|
|
45 |
widget or an application.
|
|
46 |
|
|
47 |
argument <Object> user defined argument
|
|
48 |
|
|
49 |
enterSelector <Symbol> send the first time to the drop target when entering
|
|
50 |
the widget.
|
|
51 |
|
|
52 |
leaveSelector <Symbol> send the last time to the drop target when leaving
|
|
53 |
the widget.
|
|
54 |
|
|
55 |
overSelector <Symbol> send all the time to the drop target when moveing the
|
|
56 |
mouse over the widget.
|
|
57 |
|
|
58 |
dropSelector <Symbol> send to the drop target to drop the collection of
|
|
59 |
objects.
|
|
60 |
|
|
61 |
canDropSelector <Symbol> send to the drop target to ask if the context could
|
|
62 |
be dropped.
|
|
63 |
|
|
64 |
[see also:]
|
|
65 |
DragAndDropManager
|
|
66 |
DropSource
|
|
67 |
DropContext
|
|
68 |
|
|
69 |
[author:]
|
|
70 |
Claus Atzkern
|
|
71 |
"
|
|
72 |
|
|
73 |
! !
|
|
74 |
|
|
75 |
!DropTarget class methodsFor:'instance creation'!
|
|
76 |
|
|
77 |
receiver:aReceiver
|
|
78 |
^ self new receiver:aReceiver
|
|
79 |
!
|
|
80 |
|
|
81 |
receiver:aReceiver argument:anArgument
|
|
82 |
|
|
83 |
^ self new receiver:aReceiver
|
|
84 |
argument:anArgument.
|
|
85 |
!
|
|
86 |
|
|
87 |
receiver:aReceiver argument:anArgument dropSelector:aSelector
|
|
88 |
|
|
89 |
^ self new receiver:aReceiver
|
|
90 |
argument:anArgument
|
|
91 |
dropSelector:aSelector
|
|
92 |
canDropSelector:nil
|
|
93 |
!
|
|
94 |
|
|
95 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2
|
|
96 |
|
|
97 |
^ self new receiver:aReceiver
|
|
98 |
argument:anArgument
|
|
99 |
dropSelector:s1
|
|
100 |
canDropSelector:s2
|
|
101 |
! !
|
|
102 |
|
|
103 |
!DropTarget methodsFor:'accessing'!
|
|
104 |
|
|
105 |
argument
|
|
106 |
"returns the user defined argument; this argument is used for a drop action
|
|
107 |
with two arguments, the context and the argument
|
|
108 |
"
|
|
109 |
^ argument
|
|
110 |
!
|
|
111 |
|
|
112 |
argument:something
|
|
113 |
"set the user defined argument; this argument is used for a drop action
|
|
114 |
with two arguments, the context and the argument
|
|
115 |
"
|
|
116 |
^ something
|
|
117 |
!
|
|
118 |
|
|
119 |
canDropSelector
|
|
120 |
"selector called to get a feedback if context is droppable.
|
|
121 |
the arguments to the selector are:
|
|
122 |
0 nothing
|
|
123 |
1 aDropContext
|
|
124 |
2 aDropContext and the argument
|
|
125 |
"
|
|
126 |
^ canDropSelector
|
|
127 |
!
|
|
128 |
|
|
129 |
canDropSelector:something
|
|
130 |
"selector called to get a feedback if context is droppable.
|
|
131 |
the arguments to the selector are:
|
|
132 |
0 nothing
|
|
133 |
1 aDropContext
|
|
134 |
2 aDropContext and the argument
|
|
135 |
"
|
|
136 |
canDropSelector := something.
|
|
137 |
!
|
|
138 |
|
|
139 |
dropSelector
|
|
140 |
"selector called to drop a collection of draggable objects.
|
|
141 |
the arguments to the selector are:
|
|
142 |
0 nothing
|
|
143 |
1 aDropContext
|
|
144 |
2 aDropContext and the argument
|
|
145 |
"
|
|
146 |
^ dropSelector
|
|
147 |
!
|
|
148 |
|
|
149 |
dropSelector:something
|
|
150 |
"selector called to drop a collection of draggable objects.
|
|
151 |
|
|
152 |
the arguments to the selector are:
|
|
153 |
0 nothing
|
|
154 |
1 aDropContext
|
|
155 |
2 aDropContext and the argument
|
|
156 |
"
|
|
157 |
dropSelector := something.
|
|
158 |
!
|
|
159 |
|
|
160 |
enterSelector
|
|
161 |
"send the first time to the drop target when entering the widget.
|
|
162 |
|
|
163 |
the arguments to the selector are:
|
|
164 |
0 nothing
|
|
165 |
1 aDropContext
|
|
166 |
2 aDropContext and the argument
|
|
167 |
"
|
|
168 |
^ enterSelector
|
|
169 |
!
|
|
170 |
|
|
171 |
enterSelector:something
|
|
172 |
"send the first time to the drop target when entering the widget.
|
|
173 |
|
|
174 |
the arguments to the selector are:
|
|
175 |
0 nothing
|
|
176 |
1 aDropContext
|
|
177 |
2 aDropContext and the argument
|
|
178 |
"
|
|
179 |
enterSelector := something.
|
|
180 |
!
|
|
181 |
|
|
182 |
leaveSelector
|
|
183 |
"send the last time to the drop target when leaving the widget.
|
|
184 |
|
|
185 |
the arguments to the selector are:
|
|
186 |
0 nothing
|
|
187 |
1 aDropContext
|
|
188 |
2 aDropContext and the argument
|
|
189 |
"
|
|
190 |
^ leaveSelector
|
|
191 |
!
|
|
192 |
|
|
193 |
leaveSelector:something
|
|
194 |
"send the last time to the drop target when leaving the widget.
|
|
195 |
|
|
196 |
the arguments to the selector are:
|
|
197 |
0 nothing
|
|
198 |
1 aDropContext
|
|
199 |
2 aDropContext and the argument
|
|
200 |
"
|
|
201 |
leaveSelector := something.
|
|
202 |
!
|
|
203 |
|
|
204 |
overSelector
|
|
205 |
"send all the time to the drop target when moveing the mouse over the widget
|
|
206 |
|
|
207 |
the arguments to the selector are:
|
|
208 |
0 nothing
|
|
209 |
1 aDropContext
|
|
210 |
2 aDropContext and the argument
|
|
211 |
"
|
|
212 |
^ overSelector
|
|
213 |
!
|
|
214 |
|
|
215 |
overSelector:something
|
|
216 |
"send all the time to the drop target when moveing the mouse over the widget
|
|
217 |
|
|
218 |
the arguments to the selector are:
|
|
219 |
0 nothing
|
|
220 |
1 aDropContext
|
|
221 |
2 aDropContext and the argument
|
|
222 |
"
|
|
223 |
overSelector := something.
|
|
224 |
!
|
|
225 |
|
|
226 |
receiver
|
|
227 |
"receiver to which the requests are sent. a widget or an application ...
|
|
228 |
"
|
|
229 |
^ receiver
|
|
230 |
!
|
|
231 |
|
|
232 |
receiver:something
|
|
233 |
"receiver to which the requests are sent. a widget or an application ...
|
|
234 |
"
|
|
235 |
receiver := something.
|
|
236 |
! !
|
|
237 |
|
|
238 |
!DropTarget methodsFor:'actions'!
|
|
239 |
|
|
240 |
drop:aContext
|
|
241 |
"send when the mouse button is released within the current widget.
|
|
242 |
"
|
|
243 |
self perform:dropSelector withContext:aContext
|
|
244 |
!
|
|
245 |
|
|
246 |
enter:aContext
|
|
247 |
"send the first time, when entering the widget
|
|
248 |
"
|
|
249 |
self perform:enterSelector withContext:aContext
|
|
250 |
!
|
|
251 |
|
|
252 |
leave:aContext
|
|
253 |
"send the last time, when leaving the widget
|
|
254 |
"
|
|
255 |
self perform:leaveSelector withContext:aContext
|
|
256 |
!
|
|
257 |
|
|
258 |
over:aContext
|
|
259 |
"send all the time, when moveing the mouse over the widget
|
|
260 |
"
|
|
261 |
self perform:overSelector withContext:aContext
|
|
262 |
|
|
263 |
! !
|
|
264 |
|
|
265 |
!DropTarget methodsFor:'instance creation'!
|
|
266 |
|
|
267 |
receiver:aReceiver argument:anArgument
|
|
268 |
"set the receiver and an user defined argument
|
|
269 |
"
|
|
270 |
receiver := aReceiver.
|
|
271 |
argument := anArgument.
|
|
272 |
!
|
|
273 |
|
|
274 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2
|
|
275 |
"set the receiver and an user defined argument
|
|
276 |
"
|
|
277 |
receiver := aReceiver.
|
|
278 |
argument := anArgument.
|
|
279 |
dropSelector := s1.
|
|
280 |
canDropSelector := s2.
|
|
281 |
! !
|
|
282 |
|
|
283 |
!DropTarget methodsFor:'private'!
|
|
284 |
|
|
285 |
perform:aSelector withContext:aContext
|
|
286 |
"perform the selector
|
|
287 |
"
|
|
288 |
|numArgs|
|
|
289 |
|
|
290 |
aSelector notNil ifTrue:[
|
|
291 |
(numArgs := aSelector numArgs) == 0 ifTrue:[
|
|
292 |
receiver perform:aSelector
|
|
293 |
] ifFalse:[
|
|
294 |
numArgs == 1 ifTrue:[
|
|
295 |
receiver perform:aSelector with:aContext
|
|
296 |
] ifFalse:[
|
|
297 |
receiver perform:aSelector with:aContext with:argument
|
|
298 |
]
|
|
299 |
]
|
|
300 |
]
|
|
301 |
! !
|
|
302 |
|
|
303 |
!DropTarget methodsFor:'queries'!
|
|
304 |
|
|
305 |
canDrop:aContext
|
|
306 |
"send to the receiver to ask if the context is droppable
|
|
307 |
"
|
|
308 |
|numArgs|
|
|
309 |
|
|
310 |
canDropSelector notNil ifTrue:[
|
|
311 |
(numArgs := canDropSelector numArgs) == 0 ifTrue:[
|
|
312 |
^ receiver perform:canDropSelector
|
|
313 |
].
|
|
314 |
numArgs == 1 ifTrue:[
|
|
315 |
^ receiver perform:canDropSelector with:aContext
|
|
316 |
].
|
|
317 |
^ receiver perform:canDropSelector with:aContext with:argument
|
|
318 |
].
|
|
319 |
^ true
|
|
320 |
! !
|
|
321 |
|
|
322 |
!DropTarget class methodsFor:'documentation'!
|
|
323 |
|
|
324 |
version
|
|
325 |
^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.1 1998-03-30 11:59:33 ca Exp $'
|
|
326 |
! !
|