author | Claus Gittinger <cg@exept.de> |
Fri, 13 Oct 2006 13:08:31 +0200 | |
changeset 2251 | 7e4757269c0c |
parent 2091 | 0fdd1265fd82 |
child 2256 | 02d92cd76f35 |
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 |
||
86 |
receiver:aReceiver argument:anArgument dropSelector:aSelector |
|
87 |
||
88 |
^ self new receiver:aReceiver |
|
89 |
argument:anArgument |
|
90 |
dropSelector:aSelector |
|
91 |
canDropSelector:nil |
|
92 |
! |
|
93 |
||
94 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2 |
|
95 |
||
96 |
^ self new receiver:aReceiver |
|
97 |
argument:anArgument |
|
98 |
dropSelector:s1 |
|
99 |
canDropSelector:s2 |
|
100 |
! ! |
|
101 |
||
102 |
!DropTarget methodsFor:'accessing'! |
|
103 |
||
104 |
argument |
|
105 |
"returns the user defined argument; this argument is used for a drop action |
|
1822 | 106 |
with two arguments, the context and the argument" |
107 |
||
873 | 108 |
^ argument |
109 |
! |
|
110 |
||
111 |
argument:something |
|
112 |
"set the user defined argument; this argument is used for a drop action |
|
1822 | 113 |
with two arguments, the context and the argument" |
114 |
||
873 | 115 |
^ something |
116 |
! |
|
117 |
||
118 |
canDropSelector |
|
119 |
"selector called to get a feedback if context is droppable. |
|
120 |
the arguments to the selector are: |
|
121 |
0 nothing |
|
122 |
1 aDropContext |
|
2091 | 123 |
2 aDropContext and the argument" |
124 |
||
873 | 125 |
^ canDropSelector |
126 |
! |
|
127 |
||
2091 | 128 |
canDropSelector:something |
873 | 129 |
"selector called to get a feedback if context is droppable. |
130 |
the arguments to the selector are: |
|
131 |
0 nothing |
|
132 |
1 aDropContext |
|
2091 | 133 |
2 aDropContext and the argument" |
134 |
||
873 | 135 |
canDropSelector := something. |
136 |
! |
|
137 |
||
138 |
dropSelector |
|
1822 | 139 |
"return the selector of the message which is sent to the drop target |
140 |
when the objects are to be dropped (i.e. when the mouse button is released). |
|
141 |
||
142 |
Depending on the number of arguments of the selector, |
|
143 |
the arguments of the message are: |
|
873 | 144 |
0 nothing |
145 |
1 aDropContext |
|
1822 | 146 |
2 aDropContext and the argument" |
147 |
||
873 | 148 |
^ dropSelector |
149 |
! |
|
150 |
||
151 |
dropSelector:something |
|
1822 | 152 |
"specify the selector of the message which is sent to the drop target |
153 |
when the objects are to be dropped (i.e. when the mouse button is released). |
|
873 | 154 |
|
1822 | 155 |
Depending on the number of arguments of the selector, |
156 |
the arguments of the message are: |
|
873 | 157 |
0 nothing |
158 |
1 aDropContext |
|
1822 | 159 |
2 aDropContext and the argument" |
160 |
||
873 | 161 |
dropSelector := something. |
162 |
! |
|
163 |
||
164 |
enterSelector |
|
1822 | 165 |
"return the selector of the message which is sent to the drop target |
166 |
when entering the widget for the first time. |
|
873 | 167 |
|
1822 | 168 |
Depending on the number of arguments of the selector, |
169 |
the arguments of the message are: |
|
873 | 170 |
0 nothing |
171 |
1 aDropContext |
|
172 |
2 aDropContext and the argument |
|
173 |
" |
|
174 |
^ enterSelector |
|
175 |
! |
|
176 |
||
177 |
enterSelector:something |
|
1822 | 178 |
"specify the selector of the message which is sent to the drop target |
179 |
when entering the widget for the first time. |
|
873 | 180 |
|
1822 | 181 |
Depending on the number of arguments of the selector, |
182 |
the arguments of the message are: |
|
873 | 183 |
0 nothing |
184 |
1 aDropContext |
|
1822 | 185 |
2 aDropContext and the argument" |
186 |
||
873 | 187 |
enterSelector := something. |
188 |
! |
|
189 |
||
190 |
leaveSelector |
|
1822 | 191 |
"return the selector of the message which is sent to the drop target |
192 |
when leaving the widget. |
|
873 | 193 |
|
1822 | 194 |
Depending on the number of arguments of the selector, |
195 |
the arguments of the message are: |
|
873 | 196 |
0 nothing |
197 |
1 aDropContext |
|
1822 | 198 |
2 aDropContext and the argument" |
199 |
||
873 | 200 |
^ leaveSelector |
201 |
! |
|
202 |
||
203 |
leaveSelector:something |
|
1822 | 204 |
"specify the selector of the message which is sent to the drop target |
205 |
when leaving the widget. |
|
873 | 206 |
|
1822 | 207 |
Depending on the number of arguments of the selector, |
208 |
the arguments of the message are: |
|
873 | 209 |
0 nothing |
210 |
1 aDropContext |
|
1822 | 211 |
2 aDropContext and the argument" |
212 |
||
873 | 213 |
leaveSelector := something. |
214 |
! |
|
215 |
||
216 |
overSelector |
|
217 |
"send all the time to the drop target when moveing the mouse over the widget |
|
218 |
||
1822 | 219 |
Depending on the number of arguments of the selector, |
220 |
the arguments of the message are: |
|
873 | 221 |
0 nothing |
222 |
1 aDropContext |
|
2091 | 223 |
2 aDropContext and the argument" |
224 |
||
873 | 225 |
^ overSelector |
226 |
! |
|
227 |
||
228 |
overSelector:something |
|
1822 | 229 |
"specify the selector of the message which is sent to the drop target |
230 |
when the mouse is moved over the widget. |
|
873 | 231 |
|
1822 | 232 |
Depending on the number of arguments of the selector, |
233 |
the arguments of the message are: |
|
873 | 234 |
0 nothing |
235 |
1 aDropContext |
|
1822 | 236 |
2 aDropContext and the argument" |
237 |
||
873 | 238 |
overSelector := something. |
239 |
! |
|
240 |
||
241 |
receiver |
|
1822 | 242 |
"returns the receiver to which the requests are sent: a widget or an application." |
243 |
||
873 | 244 |
^ receiver |
245 |
! |
|
246 |
||
247 |
receiver:something |
|
1822 | 248 |
"define the receiver to which the requests are sent. |
249 |
The argument is a widget or an application." |
|
250 |
||
873 | 251 |
receiver := something. |
252 |
! ! |
|
253 |
||
254 |
!DropTarget methodsFor:'actions'! |
|
255 |
||
2251 | 256 |
drop:aDropContext |
2091 | 257 |
"sent, when the mouse button is released within the current widget." |
1822 | 258 |
|
2251 | 259 |
self receiverPerform:dropSelector withContext:aDropContext |
260 |
||
261 |
"Modified: / 13-10-2006 / 11:35:28 / cg" |
|
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 |
||
2251 | 312 |
canDrop:aDropContext |
1822 | 313 |
"send to the receiver to ask if the context is droppable" |
314 |
||
873 | 315 |
canDropSelector notNil ifTrue:[ |
2251 | 316 |
^ self receiverPerform:canDropSelector withContext:aDropContext |
873 | 317 |
]. |
318 |
^ true |
|
2251 | 319 |
|
320 |
"Modified: / 13-10-2006 / 11:35:22 / cg" |
|
873 | 321 |
! ! |
322 |
||
323 |
!DropTarget class methodsFor:'documentation'! |
|
324 |
||
325 |
version |
|
2251 | 326 |
^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.5 2006-10-13 11:08:31 cg Exp $' |
873 | 327 |
! ! |