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