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 |
|
1679
|
14 |
"{ Package: 'stx:libview2' }"
|
|
15 |
|
873
|
16 |
Object subclass:#DropSource
|
|
17 |
instanceVariableNames:'receiver argument feedBackSelector dropObjectSelector
|
|
18 |
displayObjectSelector startDragSelector'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-DragAndDrop'
|
|
22 |
!
|
|
23 |
|
|
24 |
!DropSource 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 source from which the drag and drop operation is started.
|
|
44 |
|
|
45 |
receiver <Object> the receiver of the drop feedBack; a widget or
|
|
46 |
application or ....
|
|
47 |
|
|
48 |
argument <Object> user defined argument
|
|
49 |
|
|
50 |
startDragSelector <Symbol> send to the receiver to start a DragAndDropManager.
|
|
51 |
If no selector is specified, the default drag & drop
|
|
52 |
operation is performed. Thus the operator is able
|
|
53 |
to set the cursor, .... before starting the operation.
|
|
54 |
|
|
55 |
feedBackSelector <Symbol> send to the receiver to give a feedBack of the
|
|
56 |
finished drag & drop operation
|
|
57 |
|
|
58 |
dropObjectSelector <Symbol> used to get to get the list of draggable objects.
|
|
59 |
|
|
60 |
displayObjectSelector <Symbol> used to get to get the list of display objects.
|
|
61 |
In case of an empty or undefined list, the draggable
|
|
62 |
objects are used as display objects.
|
|
63 |
|
|
64 |
[see also:]
|
|
65 |
DragAndDropManager
|
|
66 |
DropObject
|
|
67 |
DropTarget
|
|
68 |
DropContext
|
|
69 |
|
|
70 |
[author:]
|
|
71 |
Claus Atzkern
|
|
72 |
"
|
|
73 |
! !
|
|
74 |
|
|
75 |
!DropSource class methodsFor:'instance creation'!
|
|
76 |
|
|
77 |
receiver:aReceiver
|
|
78 |
^ self new receiver:aReceiver
|
|
79 |
!
|
|
80 |
|
|
81 |
receiver:aReceiver argument:anArgument
|
|
82 |
^ self receiver:aReceiver argument:anArgument
|
|
83 |
dropObjectSelector:nil
|
|
84 |
displayObjectSelector:nil
|
|
85 |
feedBackSelector:nil
|
|
86 |
!
|
|
87 |
|
|
88 |
receiver:aReceiver argument:anArgument dropObjectSelector:aSelector
|
|
89 |
|
|
90 |
^ self new receiver:aReceiver argument:anArgument
|
|
91 |
dropObjectSelector:aSelector
|
|
92 |
displayObjectSelector:nil
|
|
93 |
feedBackSelector:nil
|
|
94 |
!
|
|
95 |
|
|
96 |
receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2
|
|
97 |
|
|
98 |
^ self new receiver:aReceiver argument:anArgument
|
|
99 |
dropObjectSelector:s1
|
|
100 |
displayObjectSelector:s2
|
|
101 |
feedBackSelector:nil
|
|
102 |
!
|
|
103 |
|
|
104 |
receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2 feedBackSelector:s3
|
|
105 |
|
|
106 |
^ self new receiver:aReceiver argument:anArgument
|
|
107 |
dropObjectSelector:s1
|
|
108 |
displayObjectSelector:s2
|
|
109 |
feedBackSelector:s3
|
|
110 |
! !
|
|
111 |
|
|
112 |
!DropSource methodsFor:'accessing'!
|
|
113 |
|
|
114 |
argument
|
|
115 |
"returns the user defined argument
|
|
116 |
"
|
|
117 |
^ argument
|
|
118 |
!
|
|
119 |
|
|
120 |
argument:anArgument
|
|
121 |
"set the user defined argument
|
|
122 |
"
|
|
123 |
argument := anArgument
|
|
124 |
!
|
|
125 |
|
|
126 |
displayObjects
|
|
127 |
"returns a collection of display objects or nil
|
|
128 |
"
|
|
129 |
displayObjectSelector isNil ifTrue:[
|
|
130 |
^ nil
|
|
131 |
].
|
|
132 |
^ displayObjectSelector numArgs == 0 ifTrue:[receiver perform:displayObjectSelector]
|
|
133 |
ifFalse:[receiver perform:displayObjectSelector with:self]
|
|
134 |
!
|
|
135 |
|
|
136 |
dropObjects
|
|
137 |
"returns a collection of objects to drop
|
|
138 |
"
|
|
139 |
dropObjectSelector isNil ifTrue:[
|
|
140 |
^ nil
|
|
141 |
].
|
|
142 |
|
|
143 |
^ dropObjectSelector numArgs == 0 ifTrue:[receiver perform:dropObjectSelector]
|
|
144 |
ifFalse:[receiver perform:dropObjectSelector with:self]
|
|
145 |
!
|
|
146 |
|
|
147 |
receiver
|
|
148 |
"return the value of the instance variable 'receiver' (automatically generated)"
|
|
149 |
|
1679
|
150 |
^ receiver
|
|
151 |
!
|
873
|
152 |
|
|
153 |
receiver:something
|
|
154 |
"set the value of the instance variable 'receiver' (automatically generated)"
|
|
155 |
|
1679
|
156 |
receiver := something.
|
|
157 |
! !
|
873
|
158 |
|
1679
|
159 |
!DropSource methodsFor:'accessing-selectors'!
|
873
|
160 |
|
|
161 |
displayObjectSelector
|
|
162 |
"selector to access the displayObjects; a sequence of String, Text, Icon or Image,
|
|
163 |
LabelAndIcon ...
|
|
164 |
If an argument is required, the argument is the dropSource (self)
|
|
165 |
"
|
|
166 |
^ displayObjectSelector
|
|
167 |
!
|
|
168 |
|
|
169 |
displayObjectSelector:aSelectorWithNoneOrOneArgs
|
|
170 |
"selector to access the displayObjects; a sequence of String, Text, Icon or Image,
|
|
171 |
LabelAndIcon ...
|
|
172 |
If an argument is required, the argument is the dropSource (self)
|
|
173 |
"
|
|
174 |
displayObjectSelector := aSelectorWithNoneOrOneArgs.
|
|
175 |
!
|
|
176 |
|
|
177 |
dropObjectSelector
|
|
178 |
"selector to access the draggable objects; a sequence of DropObject's
|
|
179 |
If an argument is required, the argument is the dropSource (self)
|
|
180 |
"
|
|
181 |
^ dropObjectSelector
|
|
182 |
!
|
|
183 |
|
|
184 |
dropObjectSelector:aSelectorWithNoneOrOneArgs
|
|
185 |
"selector to access the draggable objects; a sequence of DropObject's
|
|
186 |
If an argument is required, the argument is the dropSource (self)
|
|
187 |
"
|
|
188 |
dropObjectSelector := aSelectorWithNoneOrOneArgs.
|
|
189 |
!
|
|
190 |
|
|
191 |
feedBackSelector
|
|
192 |
"selector called at end of a drop to give a feedback; the argument to
|
|
193 |
the selector is the dropContext
|
|
194 |
"
|
|
195 |
^ feedBackSelector
|
|
196 |
!
|
|
197 |
|
|
198 |
feedBackSelector:aSelectorWithNoneOrOneArgs
|
|
199 |
"selector called at end of a drop to give a feedback; the argument to
|
|
200 |
the selector is the dropContext
|
|
201 |
"
|
|
202 |
feedBackSelector := aSelectorWithNoneOrOneArgs.
|
|
203 |
!
|
|
204 |
|
|
205 |
startDragSelector
|
|
206 |
"send to the receiver to start a DragAndDropManager. If no selector is specified,
|
|
207 |
the default drag & drop operation is performed.
|
|
208 |
Thus the operator is able to set the cursor, .... before starting the operation.
|
|
209 |
|
|
210 |
the arguments to the selector are:
|
|
211 |
2 aDropSource (self) Widget
|
|
212 |
3 aDropSource (self) Widget Point
|
|
213 |
"
|
|
214 |
^ startDragSelector
|
|
215 |
!
|
|
216 |
|
|
217 |
startDragSelector:aTwoOrThreeArgSelector
|
|
218 |
"send to the receiver to start a DragAndDropManager. If no selector is specified,
|
|
219 |
the default drag & drop operation is performed.
|
|
220 |
Thus the operator is able to set the cursor, .... before starting the operation.
|
|
221 |
|
|
222 |
the arguments to the selector are:
|
|
223 |
2 aDropSource (self) Widget
|
|
224 |
3 aDropSource (self) Widget Point
|
|
225 |
"
|
|
226 |
startDragSelector := aTwoOrThreeArgSelector
|
|
227 |
! !
|
|
228 |
|
|
229 |
!DropSource methodsFor:'actions'!
|
|
230 |
|
|
231 |
feedBack:aDropContext
|
|
232 |
"feedback to receiver
|
|
233 |
"
|
|
234 |
feedBackSelector isNil ifTrue:[
|
|
235 |
^ self
|
|
236 |
].
|
|
237 |
|
|
238 |
^ feedBackSelector numArgs == 0 ifTrue:[receiver perform:feedBackSelector]
|
|
239 |
ifFalse:[receiver perform:feedBackSelector with:aDropContext]
|
|
240 |
!
|
|
241 |
|
|
242 |
startDragIn:aView at:aPoint
|
|
243 |
"start drag operation for a widget
|
|
244 |
"
|
|
245 |
|args|
|
|
246 |
|
|
247 |
startDragSelector notNil ifTrue:[
|
|
248 |
args := startDragSelector numArgs.
|
|
249 |
args == 2 ifTrue:[ ^ receiver perform:startDragSelector with:self with:aView ].
|
|
250 |
args == 3 ifTrue:[ ^ receiver perform:startDragSelector with:self with:aView with:aPoint ].
|
|
251 |
].
|
|
252 |
"/
|
|
253 |
"/ the default
|
|
254 |
"/
|
|
255 |
DragAndDropManager startDragFrom:aView dropSource:self
|
|
256 |
|
|
257 |
! !
|
|
258 |
|
|
259 |
!DropSource methodsFor:'instance creation'!
|
|
260 |
|
|
261 |
receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2 feedBackSelector:s3
|
|
262 |
|
|
263 |
receiver := aReceiver.
|
|
264 |
argument := anArgument.
|
|
265 |
dropObjectSelector := s1.
|
|
266 |
displayObjectSelector := s2.
|
|
267 |
feedBackSelector := s3.
|
|
268 |
! !
|
|
269 |
|
|
270 |
!DropSource class methodsFor:'documentation'!
|
|
271 |
|
|
272 |
version
|
1679
|
273 |
^ '$Header: /cvs/stx/stx/libview2/DropSource.st,v 1.2 2002-12-10 11:03:11 cg Exp $'
|
873
|
274 |
! !
|