author | Claus Gittinger <cg@exept.de> |
Fri, 14 Dec 2001 11:51:34 +0100 | |
changeset 1550 | b58979898957 |
parent 873 | c5cd8f56dc6e |
child 1822 | ceeb17948f5d |
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 |
|
109 |
with two arguments, the context and the argument |
|
110 |
" |
|
111 |
^ argument |
|
112 |
! |
|
113 |
||
114 |
argument:something |
|
115 |
"set the user defined argument; this argument is used for a drop action |
|
116 |
with two arguments, the context and the argument |
|
117 |
" |
|
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 |
|
142 |
"selector called to drop a collection of draggable objects. |
|
143 |
the arguments to the selector are: |
|
144 |
0 nothing |
|
145 |
1 aDropContext |
|
146 |
2 aDropContext and the argument |
|
147 |
" |
|
148 |
^ dropSelector |
|
149 |
! |
|
150 |
||
151 |
dropSelector:something |
|
152 |
"selector called to drop a collection of draggable objects. |
|
153 |
||
154 |
the arguments to the selector are: |
|
155 |
0 nothing |
|
156 |
1 aDropContext |
|
157 |
2 aDropContext and the argument |
|
158 |
" |
|
159 |
dropSelector := something. |
|
160 |
! |
|
161 |
||
162 |
enterSelector |
|
163 |
"send the first time to the drop target when entering the widget. |
|
164 |
||
165 |
the arguments to the selector are: |
|
166 |
0 nothing |
|
167 |
1 aDropContext |
|
168 |
2 aDropContext and the argument |
|
169 |
" |
|
170 |
^ enterSelector |
|
171 |
! |
|
172 |
||
173 |
enterSelector:something |
|
174 |
"send the first time to the drop target when entering the widget. |
|
175 |
||
176 |
the arguments to the selector are: |
|
177 |
0 nothing |
|
178 |
1 aDropContext |
|
179 |
2 aDropContext and the argument |
|
180 |
" |
|
181 |
enterSelector := something. |
|
182 |
! |
|
183 |
||
184 |
leaveSelector |
|
185 |
"send the last time to the drop target when leaving the widget. |
|
186 |
||
187 |
the arguments to the selector are: |
|
188 |
0 nothing |
|
189 |
1 aDropContext |
|
190 |
2 aDropContext and the argument |
|
191 |
" |
|
192 |
^ leaveSelector |
|
193 |
! |
|
194 |
||
195 |
leaveSelector:something |
|
196 |
"send the last time to the drop target when leaving the widget. |
|
197 |
||
198 |
the arguments to the selector are: |
|
199 |
0 nothing |
|
200 |
1 aDropContext |
|
201 |
2 aDropContext and the argument |
|
202 |
" |
|
203 |
leaveSelector := something. |
|
204 |
! |
|
205 |
||
206 |
overSelector |
|
207 |
"send all the time to the drop target when moveing the mouse over the widget |
|
208 |
||
209 |
the arguments to the selector are: |
|
210 |
0 nothing |
|
211 |
1 aDropContext |
|
212 |
2 aDropContext and the argument |
|
213 |
" |
|
214 |
^ overSelector |
|
215 |
! |
|
216 |
||
217 |
overSelector:something |
|
218 |
"send all the time to the drop target when moveing the mouse over the widget |
|
219 |
||
220 |
the arguments to the selector are: |
|
221 |
0 nothing |
|
222 |
1 aDropContext |
|
223 |
2 aDropContext and the argument |
|
224 |
" |
|
225 |
overSelector := something. |
|
226 |
! |
|
227 |
||
228 |
receiver |
|
229 |
"receiver to which the requests are sent. a widget or an application ... |
|
230 |
" |
|
231 |
^ receiver |
|
232 |
! |
|
233 |
||
234 |
receiver:something |
|
235 |
"receiver to which the requests are sent. a widget or an application ... |
|
236 |
" |
|
237 |
receiver := something. |
|
238 |
! ! |
|
239 |
||
240 |
!DropTarget methodsFor:'actions'! |
|
241 |
||
242 |
drop:aContext |
|
243 |
"send when the mouse button is released within the current widget. |
|
244 |
" |
|
245 |
self perform:dropSelector withContext:aContext |
|
246 |
! |
|
247 |
||
248 |
enter:aContext |
|
249 |
"send the first time, when entering the widget |
|
250 |
" |
|
251 |
self perform:enterSelector withContext:aContext |
|
252 |
! |
|
253 |
||
254 |
leave:aContext |
|
255 |
"send the last time, when leaving the widget |
|
256 |
" |
|
257 |
self perform:leaveSelector withContext:aContext |
|
258 |
! |
|
259 |
||
260 |
over:aContext |
|
261 |
"send all the time, when moveing the mouse over the widget |
|
262 |
" |
|
263 |
self perform:overSelector withContext:aContext |
|
264 |
||
265 |
! ! |
|
266 |
||
267 |
!DropTarget methodsFor:'instance creation'! |
|
268 |
||
269 |
receiver:aReceiver argument:anArgument |
|
270 |
"set the receiver and an user defined argument |
|
271 |
" |
|
272 |
receiver := aReceiver. |
|
273 |
argument := anArgument. |
|
274 |
! |
|
275 |
||
276 |
receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2 |
|
277 |
"set the receiver and an user defined argument |
|
278 |
" |
|
279 |
receiver := aReceiver. |
|
280 |
argument := anArgument. |
|
281 |
dropSelector := s1. |
|
282 |
canDropSelector := s2. |
|
283 |
! ! |
|
284 |
||
285 |
!DropTarget methodsFor:'private'! |
|
286 |
||
287 |
perform:aSelector withContext:aContext |
|
288 |
"perform the selector |
|
289 |
" |
|
290 |
aSelector notNil ifTrue:[ |
|
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
291 |
^ receiver perform:aSelector withOptionalArgument:aContext and:argument |
873 | 292 |
] |
293 |
! ! |
|
294 |
||
295 |
!DropTarget methodsFor:'queries'! |
|
296 |
||
297 |
canDrop:aContext |
|
298 |
"send to the receiver to ask if the context is droppable |
|
299 |
" |
|
300 |
canDropSelector notNil ifTrue:[ |
|
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
301 |
^ receiver perform:canDropSelector withOptionalArgument:aContext and:argument |
873 | 302 |
]. |
303 |
^ true |
|
304 |
! ! |
|
305 |
||
306 |
!DropTarget class methodsFor:'documentation'! |
|
307 |
||
308 |
version |
|
1550
b58979898957
use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
309 |
^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.2 2001-12-14 10:51:34 cg Exp $' |
873 | 310 |
! ! |