author | Claus Gittinger <cg@exept.de> |
Tue, 29 Aug 2017 02:19:30 +0200 | |
changeset 3994 | 8ab8729d5dec |
parent 2334 | ec0c03d247f5 |
permissions | -rw-r--r-- |
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 |
" |
|
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
12 |
"{ Package: 'stx:libview2' }" |
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
13 |
|
873 | 14 |
Object subclass:#DropTarget |
15 |
instanceVariableNames:'receiver enterSelector leaveSelector overSelector dropSelector |
|
2258 | 16 |
canDropSelector argument oldDropAPI' |
873 | 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 |
||
2091 | 44 |
receiver <Object> receiver to which the requests are sent. |
45 |
The widget or an application. |
|
873 | 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 |
!DropTarget class methodsFor:'instance creation'! |
|
75 |
||
76 |
receiver:aReceiver |
|
77 |
^ self new receiver:aReceiver |
|
78 |
! |
|
79 |
||
2258 | 80 |
receiver:aReceiver argument:anArgument |
81 |
^ self new receiver:aReceiver argument:anArgument. |
|
873 | 82 |
|
2258 | 83 |
"Modified: / 13-10-2006 / 18:19:53 / cg" |
873 | 84 |
! |
85 |
||
2256 | 86 |
receiver:aReceiver argument:anArgument dropSelector:aSelector |
87 |
^ self new |
|
88 |
receiver:aReceiver |
|
89 |
argument:anArgument |
|
90 |
dropSelector:aSelector |
|
91 |
canDropSelector:nil |
|
873 | 92 |
|
2256 | 93 |
"Modified: / 13-10-2006 / 17:50:12 / cg" |
873 | 94 |
! |
95 |
||
2258 | 96 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2 |
97 |
^ self new |
|
98 |
receiver:aReceiver |
|
99 |
argument:anArgument |
|
100 |
dropSelector:s1 |
|
101 |
canDropSelector:s2 |
|
873 | 102 |
|
2258 | 103 |
"Modified: / 13-10-2006 / 18:19:58 / cg" |
873 | 104 |
! ! |
105 |
||
106 |
!DropTarget methodsFor:'accessing'! |
|
107 |
||
108 |
argument |
|
109 |
"returns the user defined argument; this argument is used for a drop action |
|
1822 | 110 |
with two arguments, the context and the argument" |
111 |
||
873 | 112 |
^ argument |
113 |
! |
|
114 |
||
115 |
argument:something |
|
116 |
"set the user defined argument; this argument is used for a drop action |
|
1822 | 117 |
with two arguments, the context and the argument" |
118 |
||
2334 | 119 |
argument := something. |
873 | 120 |
! |
121 |
||
122 |
canDropSelector |
|
123 |
"selector called to get a feedback if context is droppable. |
|
124 |
the arguments to the selector are: |
|
125 |
0 nothing |
|
126 |
1 aDropContext |
|
2091 | 127 |
2 aDropContext and the argument" |
128 |
||
873 | 129 |
^ canDropSelector |
130 |
! |
|
131 |
||
2091 | 132 |
canDropSelector:something |
873 | 133 |
"selector called to get a feedback if context is droppable. |
134 |
the arguments to the selector are: |
|
135 |
0 nothing |
|
136 |
1 aDropContext |
|
2091 | 137 |
2 aDropContext and the argument" |
138 |
||
873 | 139 |
canDropSelector := something. |
140 |
! |
|
141 |
||
142 |
dropSelector |
|
1822 | 143 |
"return the selector of the message which is sent to the drop target |
144 |
when the objects are to be dropped (i.e. when the mouse button is released). |
|
145 |
||
146 |
Depending on the number of arguments of the selector, |
|
147 |
the arguments of the message are: |
|
873 | 148 |
0 nothing |
149 |
1 aDropContext |
|
1822 | 150 |
2 aDropContext and the argument" |
151 |
||
873 | 152 |
^ dropSelector |
153 |
! |
|
154 |
||
155 |
dropSelector:something |
|
1822 | 156 |
"specify the selector of the message which is sent to the drop target |
157 |
when the objects are to be dropped (i.e. when the mouse button is released). |
|
873 | 158 |
|
1822 | 159 |
Depending on the number of arguments of the selector, |
160 |
the arguments of the message are: |
|
873 | 161 |
0 nothing |
162 |
1 aDropContext |
|
1822 | 163 |
2 aDropContext and the argument" |
164 |
||
873 | 165 |
dropSelector := something. |
166 |
! |
|
167 |
||
168 |
enterSelector |
|
1822 | 169 |
"return the selector of the message which is sent to the drop target |
170 |
when entering the widget for the first time. |
|
873 | 171 |
|
1822 | 172 |
Depending on the number of arguments of the selector, |
173 |
the arguments of the message are: |
|
873 | 174 |
0 nothing |
175 |
1 aDropContext |
|
176 |
2 aDropContext and the argument |
|
177 |
" |
|
178 |
^ enterSelector |
|
179 |
! |
|
180 |
||
181 |
enterSelector:something |
|
1822 | 182 |
"specify the selector of the message which is sent to the drop target |
183 |
when entering the widget for the first time. |
|
873 | 184 |
|
1822 | 185 |
Depending on the number of arguments of the selector, |
186 |
the arguments of the message are: |
|
873 | 187 |
0 nothing |
188 |
1 aDropContext |
|
1822 | 189 |
2 aDropContext and the argument" |
190 |
||
873 | 191 |
enterSelector := something. |
192 |
! |
|
193 |
||
194 |
leaveSelector |
|
1822 | 195 |
"return the selector of the message which is sent to the drop target |
196 |
when leaving the widget. |
|
873 | 197 |
|
1822 | 198 |
Depending on the number of arguments of the selector, |
199 |
the arguments of the message are: |
|
873 | 200 |
0 nothing |
201 |
1 aDropContext |
|
1822 | 202 |
2 aDropContext and the argument" |
203 |
||
873 | 204 |
^ leaveSelector |
205 |
! |
|
206 |
||
207 |
leaveSelector:something |
|
1822 | 208 |
"specify the selector of the message which is sent to the drop target |
209 |
when leaving the widget. |
|
873 | 210 |
|
1822 | 211 |
Depending on the number of arguments of the selector, |
212 |
the arguments of the message are: |
|
873 | 213 |
0 nothing |
214 |
1 aDropContext |
|
1822 | 215 |
2 aDropContext and the argument" |
216 |
||
873 | 217 |
leaveSelector := something. |
218 |
! |
|
219 |
||
2258 | 220 |
oldDropAPI:something |
221 |
oldDropAPI := something. |
|
222 |
! |
|
223 |
||
873 | 224 |
overSelector |
225 |
"send all the time to the drop target when moveing the mouse over the widget |
|
226 |
||
1822 | 227 |
Depending on the number of arguments of the selector, |
228 |
the arguments of the message are: |
|
873 | 229 |
0 nothing |
230 |
1 aDropContext |
|
2091 | 231 |
2 aDropContext and the argument" |
232 |
||
873 | 233 |
^ overSelector |
234 |
! |
|
235 |
||
236 |
overSelector:something |
|
1822 | 237 |
"specify the selector of the message which is sent to the drop target |
238 |
when the mouse is moved over the widget. |
|
873 | 239 |
|
1822 | 240 |
Depending on the number of arguments of the selector, |
241 |
the arguments of the message are: |
|
873 | 242 |
0 nothing |
243 |
1 aDropContext |
|
1822 | 244 |
2 aDropContext and the argument" |
245 |
||
873 | 246 |
overSelector := something. |
247 |
! |
|
248 |
||
249 |
receiver |
|
1822 | 250 |
"returns the receiver to which the requests are sent: a widget or an application." |
251 |
||
873 | 252 |
^ receiver |
253 |
! |
|
254 |
||
255 |
receiver:something |
|
1822 | 256 |
"define the receiver to which the requests are sent. |
257 |
The argument is a widget or an application." |
|
258 |
||
873 | 259 |
receiver := something. |
260 |
! ! |
|
261 |
||
262 |
!DropTarget methodsFor:'actions'! |
|
263 |
||
2251 | 264 |
drop:aDropContext |
2091 | 265 |
"sent, when the mouse button is released within the current widget." |
1822 | 266 |
|
2258 | 267 |
oldDropAPI == true ifTrue:[ |
268 |
receiver perform:dropSelector with:(aDropContext dropObjects) with:(aDropContext targetPoint) |
|
269 |
] ifFalse:[ |
|
270 |
receiver perform:dropSelector withOptionalArgument:aDropContext and:argument |
|
271 |
] |
|
2251 | 272 |
|
2258 | 273 |
"Modified: / 13-10-2006 / 18:21:26 / cg" |
873 | 274 |
! |
275 |
||
276 |
enter:aContext |
|
2091 | 277 |
"sent, when entering a widget." |
1822 | 278 |
|
2258 | 279 |
enterSelector notNil ifTrue:[ |
280 |
receiver perform:enterSelector withOptionalArgument:aContext and:argument |
|
281 |
] |
|
282 |
||
283 |
"Modified: / 13-10-2006 / 18:14:33 / cg" |
|
873 | 284 |
! |
285 |
||
286 |
leave:aContext |
|
2091 | 287 |
"sent, when leaving a widget." |
1822 | 288 |
|
2258 | 289 |
leaveSelector notNil ifTrue:[ |
290 |
receiver perform:leaveSelector withOptionalArgument:aContext and:argument |
|
291 |
] |
|
292 |
||
293 |
"Modified: / 13-10-2006 / 18:14:43 / cg" |
|
873 | 294 |
! |
295 |
||
296 |
over:aContext |
|
2091 | 297 |
"sent, whenever the mouse is moved over the widget." |
1822 | 298 |
|
2258 | 299 |
overSelector notNil ifTrue:[ |
300 |
receiver perform:overSelector withOptionalArgument:aContext and:argument |
|
301 |
] |
|
302 |
||
303 |
"Modified: / 13-10-2006 / 18:14:53 / cg" |
|
873 | 304 |
! ! |
305 |
||
306 |
!DropTarget methodsFor:'instance creation'! |
|
307 |
||
308 |
receiver:aReceiver argument:anArgument |
|
1822 | 309 |
"set the receiver and a user defined argument" |
310 |
||
873 | 311 |
receiver := aReceiver. |
312 |
argument := anArgument. |
|
313 |
! |
|
314 |
||
315 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2 |
|
1822 | 316 |
"set the receiver and a user defined argument" |
317 |
||
873 | 318 |
receiver := aReceiver. |
319 |
argument := anArgument. |
|
320 |
dropSelector := s1. |
|
321 |
canDropSelector := s2. |
|
322 |
! ! |
|
323 |
||
324 |
!DropTarget methodsFor:'private'! |
|
325 |
||
2091 | 326 |
receiverPerform:aSelector withContext:aContext |
327 |
"let the receiver perform the selector" |
|
1822 | 328 |
|
873 | 329 |
aSelector notNil ifTrue:[ |
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
330 |
^ receiver perform:aSelector withOptionalArgument:aContext and:argument |
873 | 331 |
] |
332 |
! ! |
|
333 |
||
334 |
!DropTarget methodsFor:'queries'! |
|
335 |
||
2251 | 336 |
canDrop:aDropContext |
1822 | 337 |
"send to the receiver to ask if the context is droppable" |
338 |
||
873 | 339 |
canDropSelector notNil ifTrue:[ |
2258 | 340 |
^ receiver perform:canDropSelector withOptionalArgument:aDropContext and:argument |
873 | 341 |
]. |
342 |
^ true |
|
2251 | 343 |
|
2258 | 344 |
"Modified: / 13-10-2006 / 18:13:34 / cg" |
873 | 345 |
! ! |
346 |
||
347 |
!DropTarget class methodsFor:'documentation'! |
|
348 |
||
349 |
version |
|
2334 | 350 |
^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.8 2007-07-03 13:18:40 sr Exp $' |
873 | 351 |
! ! |