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