author | Claus Gittinger <cg@exept.de> |
Thu, 23 Feb 2006 22:03:19 +0100 | |
changeset 2112 | 3c4dd2e9203f |
parent 2091 | 0fdd1265fd82 |
child 2251 | 7e4757269c0c |
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 |
" |
|
12 |
||
13 |
||
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
14 |
"{ Package: 'stx:libview2' }" |
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
15 |
|
873 | 16 |
Object subclass:#DropTarget |
17 |
instanceVariableNames:'receiver enterSelector leaveSelector overSelector dropSelector |
|
18 |
canDropSelector argument' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-DragAndDrop' |
|
22 |
! |
|
23 |
||
24 |
!DropTarget class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
this class keeps the current target of the drop operation; the object respoonsible |
|
44 |
for the widget under the current mouse position. |
|
45 |
||
2091 | 46 |
receiver <Object> receiver to which the requests are sent. |
47 |
The widget or an application. |
|
873 | 48 |
|
49 |
argument <Object> user defined argument |
|
50 |
||
51 |
enterSelector <Symbol> send the first time to the drop target when entering |
|
52 |
the widget. |
|
53 |
||
54 |
leaveSelector <Symbol> send the last time to the drop target when leaving |
|
55 |
the widget. |
|
56 |
||
57 |
overSelector <Symbol> send all the time to the drop target when moveing the |
|
58 |
mouse over the widget. |
|
59 |
||
60 |
dropSelector <Symbol> send to the drop target to drop the collection of |
|
61 |
objects. |
|
62 |
||
63 |
canDropSelector <Symbol> send to the drop target to ask if the context could |
|
64 |
be dropped. |
|
65 |
||
66 |
[see also:] |
|
67 |
DragAndDropManager |
|
68 |
DropSource |
|
69 |
DropContext |
|
70 |
||
71 |
[author:] |
|
72 |
Claus Atzkern |
|
73 |
" |
|
74 |
! ! |
|
75 |
||
76 |
!DropTarget class methodsFor:'instance creation'! |
|
77 |
||
78 |
receiver:aReceiver |
|
79 |
^ self new receiver:aReceiver |
|
80 |
! |
|
81 |
||
82 |
receiver:aReceiver argument:anArgument |
|
83 |
||
84 |
^ self new receiver:aReceiver |
|
85 |
argument:anArgument. |
|
86 |
! |
|
87 |
||
88 |
receiver:aReceiver argument:anArgument dropSelector:aSelector |
|
89 |
||
90 |
^ self new receiver:aReceiver |
|
91 |
argument:anArgument |
|
92 |
dropSelector:aSelector |
|
93 |
canDropSelector:nil |
|
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 |
||
258 |
drop:aContext |
|
2091 | 259 |
"sent, when the mouse button is released within the current widget." |
1822 | 260 |
|
2091 | 261 |
self receiverPerform:dropSelector withContext:aContext |
873 | 262 |
! |
263 |
||
264 |
enter:aContext |
|
2091 | 265 |
"sent, when entering a widget." |
1822 | 266 |
|
2091 | 267 |
self receiverPerform:enterSelector withContext:aContext |
873 | 268 |
! |
269 |
||
270 |
leave:aContext |
|
2091 | 271 |
"sent, when leaving a widget." |
1822 | 272 |
|
2091 | 273 |
self receiverPerform:leaveSelector withContext:aContext |
873 | 274 |
! |
275 |
||
276 |
over:aContext |
|
2091 | 277 |
"sent, whenever the mouse is moved over the widget." |
1822 | 278 |
|
2091 | 279 |
self receiverPerform:overSelector withContext:aContext |
873 | 280 |
! ! |
281 |
||
282 |
!DropTarget methodsFor:'instance creation'! |
|
283 |
||
284 |
receiver:aReceiver argument:anArgument |
|
1822 | 285 |
"set the receiver and a user defined argument" |
286 |
||
873 | 287 |
receiver := aReceiver. |
288 |
argument := anArgument. |
|
289 |
! |
|
290 |
||
291 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2 |
|
1822 | 292 |
"set the receiver and a user defined argument" |
293 |
||
873 | 294 |
receiver := aReceiver. |
295 |
argument := anArgument. |
|
296 |
dropSelector := s1. |
|
297 |
canDropSelector := s2. |
|
298 |
! ! |
|
299 |
||
300 |
!DropTarget methodsFor:'private'! |
|
301 |
||
2091 | 302 |
receiverPerform:aSelector withContext:aContext |
303 |
"let the receiver perform the selector" |
|
1822 | 304 |
|
873 | 305 |
aSelector notNil ifTrue:[ |
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
306 |
^ receiver perform:aSelector withOptionalArgument:aContext and:argument |
873 | 307 |
] |
308 |
! ! |
|
309 |
||
310 |
!DropTarget methodsFor:'queries'! |
|
311 |
||
312 |
canDrop:aContext |
|
1822 | 313 |
"send to the receiver to ask if the context is droppable" |
314 |
||
873 | 315 |
canDropSelector notNil ifTrue:[ |
2091 | 316 |
^ self receiverPerform:canDropSelector withContext:aContext |
873 | 317 |
]. |
318 |
^ true |
|
319 |
! ! |
|
320 |
||
321 |
!DropTarget class methodsFor:'documentation'! |
|
322 |
||
323 |
version |
|
2091 | 324 |
^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.4 2006-01-24 16:53:42 cg Exp $' |
873 | 325 |
! ! |