author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2000 12:46:23 +0100 | |
changeset 1420 | 418a8f90b7bc |
parent 1397 | 47ac1d3e1df1 |
child 1430 | 572d486a52b8 |
permissions | -rw-r--r-- |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
2 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
1166 | 3 |
All Rights Reserved |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
4 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
5 |
This software is furnished under a license and may be used |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
10 |
hereby transferred. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
11 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
12 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
13 |
|
1397 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
341 | 16 |
Object subclass:#DragAndDropManager |
874 | 17 |
instanceVariableNames:'dropContext dragView dropAction dragOffset handler restoreBlock |
18 |
alienCursor enabledCursor disabledCursor canDrop' |
|
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
19 |
classVariableNames:'DragOriginatorQuerySignal DragOffsetQuerySignal' |
628 | 20 |
poolDictionaries:'' |
874 | 21 |
category:'Interface-DragAndDrop' |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
22 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
23 |
|
341 | 24 |
!DragAndDropManager class methodsFor:'documentation'! |
25 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
26 |
copyright |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
27 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
28 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
1166 | 29 |
All Rights Reserved |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
30 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
31 |
This software is furnished under a license and may be used |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
32 |
only in accordance with the terms of that license and with the |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
33 |
inclusion of the above copyright notice. This software may not |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
34 |
be provided or otherwise made available to, or used by, any |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
35 |
other person. No title to or ownership of the software is |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
36 |
hereby transferred. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
37 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
38 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
39 |
! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
40 |
|
348 | 41 |
documentation |
42 |
" |
|
43 |
this class provides low-level drag & drop mechanisms. |
|
44 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
45 |
Easy to use interface interfaces: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
46 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
47 |
A drag is usually initiated by a view or its application model, |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
48 |
when a selection is moved (for example, SelectionInListView can |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
49 |
be initializd to do so). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
50 |
There, the view creates a collection of dropObjects from its selection, |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
51 |
and starts the drag operation with: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
52 |
|
1166 | 53 |
DragAndDropManager startDrag:collectionOfDragObjects from:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
54 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
55 |
This easy to use interface starts a drag and also drops the collection |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
56 |
into the target view. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
57 |
While dragging, a thumbsUp cursor is shown, if the view-under-the-drag |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
58 |
can handle a drop, a thumbsDown is shown if not, and a question mark |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
59 |
is shown for alien views (which means: we dont know). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
60 |
Alien view drop is supported (but no 'canDrop' query). |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
61 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
62 |
For rubber-band line dragging, two more easy-to-use startup methods are |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
63 |
provided: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
64 |
|
1166 | 65 |
DragAndDropManager |
66 |
startLineDragIn:aView at:position |
|
67 |
atEnd:aFourArgEndBlock |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
68 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
69 |
and: |
1166 | 70 |
DragAndDropManager |
71 |
startArrowDragIn:aView at:position |
|
72 |
atEnd:aFourArgEndBlock |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
73 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
74 |
both of the above expect a 4-arg block to be passed, which will be |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
75 |
evaluated at end-drag, with the target view, its viewID, the drop position |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
76 |
on the screen and within the target view as arguments. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
77 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
78 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
79 |
Expert interface: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
80 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
81 |
More control over the dragging (i.e. the drawing procedure) |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
82 |
can be optained, by passing a dragBlock and an endDrag action: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
83 |
|
1166 | 84 |
aDragAndDropMgr := DragAndDropManager new. |
85 |
aDragAndDropMgr dropObjects:(self collectionOfDragObjects). |
|
86 |
aDragAndDropMgr |
|
87 |
startOpaqueDrag:[:aPoint :aView :dropObjects | |
|
88 |
self |
|
89 |
showDragging:dropObjects |
|
90 |
in:aView |
|
91 |
at:aPoint - (xOffset@0) |
|
92 |
] |
|
93 |
offset:clickOffset |
|
94 |
extent:saveUnderExtent |
|
95 |
in:self |
|
96 |
at:clickPoint |
|
97 |
atEnd:[:v :vId :posScreen :posView | ... ] |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
98 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
99 |
the arguments are: |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
100 |
startOpaqueDrag: |
1166 | 101 |
a 3-arg block, which is evaluated by the d&d manager whenever the |
102 |
mouse moves; it is supposed to draw the dropObjects at some position |
|
103 |
in the passed view. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
104 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
105 |
offset: |
1166 | 106 |
a clickOffset; drawing is offset by this amount |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
107 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
108 |
extent: |
1166 | 109 |
a save extent; the size of the screen area that must be saved during |
110 |
the drag operation |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
111 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
112 |
in: |
1166 | 113 |
initiating view |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
114 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
115 |
at: |
1166 | 116 |
position where d&d operation starts |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
117 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
118 |
atEnd: |
1166 | 119 |
a 4-arg block that is evaluated when the d&d is finished. |
120 |
It gets the target view (or nil, for alien views), the targets |
|
121 |
view ID (needed if its an alien view), the screen position and the |
|
122 |
relative position within the target view of the drop as arguments. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
123 |
|
1166 | 124 |
For internal (ST/X) views, the dropBlock should perform |
125 |
a simple canDrop:/doDrop message. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
126 |
|
1166 | 127 |
For alien views, the Displays d&d functions can be used. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
128 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
129 |
|
348 | 130 |
[author:] |
1166 | 131 |
Claus Gittinger |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
132 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
133 |
[see also:] |
1166 | 134 |
DemoView1, DemoView2, ... |
135 |
SelectionInListView FileBrowser - for a concrete example |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
136 |
|
348 | 137 |
" |
138 |
||
139 |
! |
|
140 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
141 |
examples |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
142 |
" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
143 |
a button, which initiates dragging of a file-object |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
144 |
Notice that this can be dropped into the launchers panel, |
549 | 145 |
to open a fileBrowser on that directory ... |
1166 | 146 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
147 |
|o top v| |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
148 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
149 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
150 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
151 |
v pressAction:[ |
1166 | 152 |
|o| |
153 |
o := DropObject newFile:('/etc'). |
|
154 |
DragAndDropManager startDrag:o from:v. |
|
155 |
v turnOff |
|
156 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
157 |
top openWithExtent:200@200 |
1166 | 158 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
159 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
160 |
initiate a drag with some offset: |
1166 | 161 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
162 |
|o top v| |
341 | 163 |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
164 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
165 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
166 |
v pressAction:[ |
1166 | 167 |
|o| |
168 |
o := DropObject newFile:('.'). |
|
169 |
DragAndDropManager startDrag:o from:v offset:10@10. |
|
170 |
v turnOff |
|
171 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
172 |
top openWithExtent:200@200 |
1166 | 173 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
174 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
175 |
initiate a line drag: |
1166 | 176 |
[exBegin] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
177 |
|o top v endAction| |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
178 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
179 |
endAction := [ :v :vID :sPos :vPos | |
1166 | 180 |
Transcript show:'end drag in '. |
181 |
v isNil ifTrue:[ |
|
182 |
Transcript show:'alien view' |
|
183 |
] ifFalse:[ |
|
184 |
Transcript show:v |
|
185 |
]. |
|
186 |
Transcript show:' at screen: '; show:sPos; |
|
187 |
show:' in view: '; showCR:vPos |
|
188 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
189 |
top := StandardSystemView new. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
190 |
v := Button label:'press for drag' in:top. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
191 |
v pressAction:[ |
1166 | 192 |
DragAndDropManager |
193 |
startLineDragIn:v at:10@10 atEnd:endAction. |
|
194 |
v turnOff |
|
195 |
]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
196 |
top openWithExtent:200@200 |
1166 | 197 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
198 |
|
874 | 199 |
more drag & drop; offset, displayObjects, ... |
1166 | 200 |
[exBegin] |
874 | 201 |
|dropObj topView pannel icon buttonAction addButton| |
202 |
||
203 |
topView := StandardSystemView new. |
|
204 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
205 |
pannel horizontalLayout:#fit. |
|
206 |
pannel verticalLayout:#fitSpace. |
|
207 |
||
208 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
209 |
dropObj := DropObject newFile:('.'). |
|
210 |
||
211 |
addButton := [:offset :label :dispObj| |button| |
|
1166 | 212 |
button := Button label:label in:pannel. |
874 | 213 |
|
1166 | 214 |
button pressAction:[ |
215 |
DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj. |
|
216 |
button turnOff. |
|
217 |
] |
|
874 | 218 |
]. |
219 |
||
881 | 220 |
addButton value:(0@-5) value:'String' value:'String'. |
874 | 221 |
addButton value:#topLeft value:'String' value:'String'. |
222 |
addButton value:#topRight value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
223 |
addButton value:#bottomLeft value:'Icon' value:icon. |
|
224 |
addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
225 |
addButton value:#center value:'Mixed' value:(Array with:'String' with:icon). |
|
226 |
||
227 |
topView label:'Drag & Drop'. |
|
228 |
topView openWithExtent:200@200. |
|
1166 | 229 |
[exEnd] |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
230 |
" |
341 | 231 |
! ! |
232 |
||
628 | 233 |
!DragAndDropManager class methodsFor:'initialization'! |
234 |
||
235 |
initialize |
|
236 |
DragOriginatorQuerySignal := QuerySignal new. |
|
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
237 |
DragOffsetQuerySignal := QuerySignal new. |
628 | 238 |
|
239 |
" |
|
240 |
self initialize |
|
241 |
" |
|
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
242 |
|
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
243 |
"Modified: 11.8.1997 / 00:54:21 / cg" |
1420 | 244 |
! ! |
245 |
||
246 |
!DragAndDropManager class methodsFor:'instance creation'! |
|
874 | 247 |
|
248 |
new |
|
249 |
^ self basicNew initialize |
|
628 | 250 |
! ! |
251 |
||
252 |
!DragAndDropManager class methodsFor:'Signal constants'! |
|
253 |
||
680
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
254 |
dragOffsetQuerySignal |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
255 |
^ DragOffsetQuerySignal |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
256 |
|
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
257 |
"Created: 11.8.1997 / 00:54:10 / cg" |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
258 |
! |
6157661790fd
keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
259 |
|
628 | 260 |
dragOriginatorQuerySignal |
261 |
^ DragOriginatorQuerySignal |
|
262 |
! ! |
|
263 |
||
874 | 264 |
!DragAndDropManager class methodsFor:'simple start - drop source'! |
265 |
||
266 |
startDragFrom:aView dropSource:aDropSource |
|
267 |
"start a drop at the current pointer position. |
|
268 |
" |
|
269 |
^ (self new) startDragFrom:aView dropSource:aDropSource |
|
270 |
! ! |
|
271 |
||
272 |
!DragAndDropManager class methodsFor:'simple start - generic'! |
|
273 |
||
274 |
startDrag:draggableObjects from:aView |
|
275 |
"start a drop at the current pointer position |
|
276 |
" |
|
277 |
^ self startDrag:draggableObjects |
|
1166 | 278 |
from:aView |
279 |
offset:0@0 |
|
280 |
atEnd:nil |
|
281 |
display:draggableObjects |
|
874 | 282 |
|
283 |
" |
|
284 |
EXAMPLE: |
|
285 |
||
286 |
|button| |
|
287 |
||
288 |
button := (Button label:'press me'). |
|
289 |
||
290 |
button pressAction:[ |
|
1166 | 291 |
DragAndDropManager startDrag:(DropObject newFile:('.')) from:button. |
292 |
button turnOff |
|
874 | 293 |
]. |
294 |
||
295 |
button openAt:100@100 |
|
296 |
" |
|
297 |
! |
|
298 |
||
299 |
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock |
|
300 |
"start a drop at the current pointer position |
|
301 |
When finished, the endAction is called with four args: |
|
302 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
303 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
304 |
" |
|
305 |
^ self startDrag:draggableObjects |
|
1166 | 306 |
from:aView |
307 |
offset:0@0 |
|
308 |
atEnd:aFourArgEndBlock |
|
309 |
display:draggableObjects |
|
874 | 310 |
|
311 |
" |
|
312 |
EXAMPLE: |
|
313 |
||
314 |
|button| |
|
315 |
||
316 |
button := (Button label:'press me'). |
|
317 |
||
318 |
button pressAction:[ |
|
1166 | 319 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
320 |
from:button |
|
321 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
322 |
Transcript showCR:'target view: ', targetView printString. |
|
323 |
Transcript showCR:'target id: ', targetViewId printString. |
|
324 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
325 |
Transcript showCR:'point target: ', targetPoint printString. |
|
326 |
]. |
|
327 |
button turnOff |
|
874 | 328 |
]. |
329 |
||
330 |
button openAt:100@100 |
|
331 |
" |
|
332 |
||
333 |
! |
|
334 |
||
335 |
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock display:something |
|
336 |
"start a drop at the current pointer position |
|
337 |
When finished, the endAction is called with four args: |
|
338 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
339 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
340 |
" |
|
341 |
^ self startDrag:draggableObjects |
|
1166 | 342 |
from:aView |
343 |
offset:0@0 |
|
344 |
atEnd:aFourArgEndBlock |
|
345 |
display:something |
|
874 | 346 |
|
347 |
" |
|
348 |
EXAMPLE: |
|
349 |
||
350 |
|button| |
|
351 |
||
352 |
button := (Button label:'press me'). |
|
353 |
||
354 |
button pressAction:[ |
|
1166 | 355 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
356 |
from:button |
|
357 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
358 |
Transcript showCR:'target view: ', targetView printString. |
|
359 |
Transcript showCR:'target id: ', targetViewId printString. |
|
360 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
361 |
Transcript showCR:'point target: ', targetPoint printString. |
|
362 |
] |
|
363 |
display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))). |
|
364 |
button turnOff |
|
874 | 365 |
]. |
366 |
||
367 |
button openAt:100@100 |
|
368 |
" |
|
369 |
! |
|
370 |
||
371 |
startDrag:draggableObjects from:aView display:something |
|
372 |
"start a drop at the current pointer position |
|
373 |
" |
|
374 |
^ self startDrag:draggableObjects |
|
1166 | 375 |
from:aView |
376 |
offset:0@0 |
|
377 |
atEnd:nil |
|
378 |
display:something |
|
874 | 379 |
|
380 |
" |
|
381 |
EXAMPLE: |
|
382 |
||
383 |
|dropObj topView pannel icon buttonAction addButton| |
|
384 |
||
385 |
topView := StandardSystemView new. |
|
386 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
387 |
pannel horizontalLayout:#fit. |
|
388 |
pannel verticalLayout:#fitSpace. |
|
389 |
||
390 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
391 |
dropObj := DropObject newFile:('.'). |
|
392 |
||
393 |
addButton := [:label :dispObj| |button| |
|
1166 | 394 |
button := Button label:label in:pannel. |
874 | 395 |
|
1166 | 396 |
button pressAction:[ |
397 |
DragAndDropManager startDrag:dropObj from:button display:dispObj. |
|
398 |
button turnOff. |
|
399 |
] |
|
874 | 400 |
]. |
401 |
||
402 |
addButton value:'String' value:'String'. |
|
403 |
addButton value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
404 |
addButton value:'Icon' value:icon. |
|
405 |
addButton value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
406 |
addButton value:'Mixed' value:(Array with:'String' with:icon). |
|
407 |
||
408 |
topView label:'Drag & Drop'. |
|
409 |
topView openWithExtent:200@200. |
|
410 |
" |
|
411 |
! |
|
412 |
||
413 |
startDrag:draggableObjects from:aView offset:anOffset |
|
414 |
"start a drop at the current pointer position |
|
415 |
" |
|
416 |
^ self startDrag:draggableObjects |
|
1166 | 417 |
from:aView |
418 |
offset:anOffset |
|
419 |
atEnd:nil |
|
420 |
display:draggableObjects |
|
874 | 421 |
|
422 |
" |
|
423 |
EXAMPLE: |
|
424 |
||
425 |
|button| |
|
426 |
||
427 |
button := (Button label:'press me'). |
|
428 |
||
429 |
button pressAction:[ |
|
1166 | 430 |
DragAndDropManager startDrag:(DropObject newFile:('.')) from:button offset:(-10 @ -10). |
431 |
button turnOff |
|
874 | 432 |
]. |
433 |
||
434 |
button openAt:100@100 |
|
435 |
" |
|
436 |
||
437 |
! |
|
438 |
||
439 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock |
|
440 |
"start a drop at the current pointer position |
|
441 |
When finished, the endAction is called with four args: |
|
442 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
443 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
444 |
" |
|
445 |
^ self startDrag:draggableObjects |
|
1166 | 446 |
from:aView |
447 |
offset:anOffset |
|
448 |
atEnd:aFourArgEndBlock |
|
449 |
display:draggableObjects |
|
874 | 450 |
|
451 |
" |
|
452 |
EXAMPLE: |
|
453 |
||
454 |
|button| |
|
455 |
||
456 |
button := (Button label:'press me'). |
|
457 |
||
458 |
button pressAction:[ |
|
1166 | 459 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
460 |
from:button |
|
461 |
offset:(-10 @ -10) |
|
462 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
463 |
Transcript showCR:'target view: ', targetView printString. |
|
464 |
Transcript showCR:'target id: ', targetViewId printString. |
|
465 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
466 |
Transcript showCR:'point target: ', targetPoint printString. |
|
467 |
]. |
|
468 |
button turnOff |
|
874 | 469 |
]. |
470 |
||
471 |
button openAt:100@100 |
|
472 |
" |
|
473 |
||
474 |
! |
|
475 |
||
476 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock display:something |
|
477 |
"start a drop at the current pointer position |
|
478 |
When finished, the endAction is called with four args: |
|
479 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
480 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
481 |
" |
|
482 |
|manager| |
|
483 |
||
484 |
manager := self new. |
|
485 |
||
486 |
manager startDrag:draggableObjects |
|
1166 | 487 |
from:aView |
488 |
offset:anOffset |
|
489 |
atEnd:aFourArgEndBlock |
|
490 |
display:something. |
|
874 | 491 |
|
492 |
^ manager |
|
493 |
||
494 |
" |
|
495 |
EXAMPLE: |
|
496 |
||
497 |
|button| |
|
498 |
||
499 |
button := (Button label:'press me'). |
|
500 |
||
501 |
button pressAction:[ |
|
1166 | 502 |
DragAndDropManager startDrag:(DropObject newFile:('.')) |
503 |
from:button |
|
504 |
offset:(-10 @ -10) |
|
505 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
506 |
Transcript showCR:'target view: ', targetView printString. |
|
507 |
Transcript showCR:'target id: ', targetViewId printString. |
|
508 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
509 |
Transcript showCR:'point target: ', targetPoint printString. |
|
510 |
] |
|
511 |
display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))). |
|
512 |
button turnOff |
|
874 | 513 |
]. |
514 |
||
515 |
button openAt:100@100 |
|
516 |
" |
|
517 |
||
518 |
! |
|
519 |
||
520 |
startDrag:draggableObjects from:aView offset:anOffset display:something |
|
521 |
"start a drop at the current pointer position |
|
522 |
" |
|
523 |
^ self startDrag:draggableObjects |
|
1166 | 524 |
from:aView |
525 |
offset:anOffset |
|
526 |
atEnd:nil |
|
527 |
display:something |
|
874 | 528 |
|
529 |
" |
|
530 |
EXAMPLE: |
|
531 |
||
532 |
|dropObj topView pannel icon buttonAction addButton| |
|
533 |
||
534 |
topView := StandardSystemView new. |
|
535 |
pannel := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
|
536 |
pannel horizontalLayout:#fit. |
|
537 |
pannel verticalLayout:#fitSpace. |
|
538 |
||
539 |
icon := Image fromFile:('xpmBitmaps/QUESTION3.xpm'). |
|
540 |
dropObj := DropObject newFile:('.'). |
|
541 |
||
542 |
addButton := [:offset :label :dispObj| |button| |
|
1166 | 543 |
button := Button label:label in:pannel. |
874 | 544 |
|
1166 | 545 |
button pressAction:[ |
546 |
DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj. |
|
547 |
button turnOff. |
|
548 |
] |
|
874 | 549 |
]. |
550 |
||
551 |
addButton value:#topLeft value:'String' value:'String'. |
|
552 |
addButton value:#topRight value:'Text' value:(Text string:'hello' emphasis:#bold). |
|
553 |
addButton value:#bottomLeft value:'Icon' value:icon. |
|
554 |
addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon'). |
|
555 |
addButton value:#center value:'Mixed' value:(Array with:'String' with:icon). |
|
556 |
||
557 |
topView label:'Drag & Drop'. |
|
558 |
topView openWithExtent:200@200. |
|
559 |
" |
|
560 |
||
561 |
! ! |
|
562 |
||
563 |
!DragAndDropManager class methodsFor:'simple start - lines'! |
|
397 | 564 |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
565 |
startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
566 |
"start a rubber-arrow-line dragging in aView at dragPoint. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
567 |
When finished, evaluate the fourArgBlock with targetView, |
874 | 568 |
targetID, screenPosition and targetViewPosition as arguments |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
569 |
" |
874 | 570 |
^ self new startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
571 |
|
874 | 572 |
" |
573 |
EXAMPLE: |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
574 |
|
874 | 575 |
|button| |
397 | 576 |
|
874 | 577 |
button := (Button label:'press me'). |
861 | 578 |
|
874 | 579 |
button pressAction:[ |
1166 | 580 |
button turnOff. |
861 | 581 |
|
1166 | 582 |
DragAndDropManager startArrowDragIn:button |
583 |
at:(button preferredExtent // 2) |
|
584 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
585 |
targetView isNil ifTrue:[ |
|
586 |
Transcript show:'alien view' |
|
587 |
] ifFalse:[ |
|
588 |
Transcript showCR:'target: ', targetView printString |
|
589 |
]. |
|
590 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
591 |
Transcript showCR:'point target: ', targetPoint printString. |
|
592 |
] |
|
874 | 593 |
]. |
594 |
button openAt:100@100 |
|
595 |
" |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
596 |
! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
597 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
598 |
startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
599 |
"start a rubber-line dragging in aView at dragPoint. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
600 |
When finished, evaluate the fourArgBlock with targetView, |
874 | 601 |
targetID, screenPosition and targetViewPosition as arguments |
602 |
" |
|
603 |
^ self new startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock |
|
604 |
||
605 |
" |
|
606 |
EXAMPLE: |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
607 |
|
874 | 608 |
|button| |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
609 |
|
874 | 610 |
button := (Button label:'press me'). |
611 |
||
612 |
button pressAction:[ |
|
1166 | 613 |
button turnOff. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
614 |
|
1166 | 615 |
DragAndDropManager startLineDragIn:button |
616 |
at:(button preferredExtent // 2) |
|
617 |
atEnd:[:targetView :targetViewId :screenPoint :targetPoint| |
|
618 |
targetView isNil ifTrue:[ |
|
619 |
Transcript show:'alien view' |
|
620 |
] ifFalse:[ |
|
621 |
Transcript showCR:'target: ', targetView printString |
|
622 |
]. |
|
623 |
Transcript showCR:'point screen: ', screenPoint printString. |
|
624 |
Transcript showCR:'point target: ', targetPoint printString. |
|
625 |
] |
|
874 | 626 |
]. |
627 |
button openAt:100@100 |
|
628 |
" |
|
397 | 629 |
! ! |
630 |
||
394 | 631 |
!DragAndDropManager methodsFor:'accessing'! |
632 |
||
861 | 633 |
device |
634 |
"returns the device of the source view |
|
635 |
" |
|
636 |
^ dragView device |
|
637 |
||
638 |
||
639 |
! |
|
640 |
||
874 | 641 |
dropContext |
642 |
"return the current context |
|
643 |
" |
|
644 |
^ dropContext |
|
645 |
! |
|
646 |
||
397 | 647 |
dropObjects |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
648 |
"return the current dropObject collection" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
649 |
|
874 | 650 |
^ dropContext dropObjects |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
651 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
652 |
"Modified: 19.4.1997 / 10:19:06 / cg" |
397 | 653 |
! |
654 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
655 |
dropObjects:aCollectionOfDropObjects |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
656 |
"set the current dropObject collection" |
397 | 657 |
|
874 | 658 |
^ dropContext dropObjects:aCollectionOfDropObjects |
861 | 659 |
! |
660 |
||
661 |
font |
|
662 |
"returns the font of the source view |
|
663 |
" |
|
664 |
^ dragView font |
|
665 |
||
666 |
||
874 | 667 |
! |
668 |
||
669 |
sourceWidget |
|
670 |
^ dragView |
|
671 |
! ! |
|
672 |
||
1397 | 673 |
!DragAndDropManager methodsFor:'accessing-cursor'! |
874 | 674 |
|
675 |
alienCursor:aCursorOrImage |
|
676 |
"set the cursor used for an alien widget; not an ST/X view |
|
677 |
" |
|
678 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 679 |
alienCursor := Cursor fromImage:aCursorOrImage |
874 | 680 |
] ifFalse:[ |
1166 | 681 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
682 |
alienCursor := aCursorOrImage |
|
683 |
] ifFalse:[ |
|
684 |
"/ |
|
685 |
"/ use disabled cursor |
|
686 |
"/ |
|
687 |
alienCursor := nil |
|
688 |
] |
|
874 | 689 |
] |
690 |
! |
|
691 |
||
692 |
disabledCursor:aCursorOrImage |
|
693 |
"set the cursor for an ST/X view, which can not drop the objects |
|
694 |
" |
|
695 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 696 |
disabledCursor := Cursor fromImage:aCursorOrImage |
874 | 697 |
] ifFalse:[ |
1166 | 698 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
699 |
disabledCursor := aCursorOrImage |
|
700 |
] |
|
874 | 701 |
] |
702 |
! |
|
703 |
||
704 |
enabledCursor:aCursorOrImage |
|
705 |
"set the cursor for an ST/X view, which can drop the objects |
|
706 |
" |
|
707 |
aCursorOrImage isImage ifTrue:[ |
|
1166 | 708 |
enabledCursor := Cursor fromImage:aCursorOrImage |
874 | 709 |
] ifFalse:[ |
1166 | 710 |
(aCursorOrImage isMemberOf:Cursor) ifTrue:[ |
711 |
enabledCursor := aCursorOrImage |
|
712 |
] |
|
874 | 713 |
] |
714 |
||
715 |
! ! |
|
716 |
||
717 |
!DragAndDropManager methodsFor:'dragging - drop source'! |
|
718 |
||
719 |
startDragFrom:aView dropSource:aDropSource |
|
720 |
"start a drop at the current pointer position. |
|
721 |
" |
|
722 |
^ self startDragFrom:aView dropSource:aDropSource offset:#topLeft "/ #center |
|
723 |
! |
|
724 |
||
725 |
startDragFrom:aView dropSource:aDropSource offset:anOffset |
|
726 |
"start a drop at the current pointer position. |
|
727 |
" |
|
728 |
dropContext dropSource:aDropSource. |
|
729 |
||
730 |
^ self startDrag:(aDropSource dropObjects) |
|
1166 | 731 |
from:aView |
732 |
offset:anOffset |
|
733 |
atEnd:nil |
|
734 |
display:(aDropSource displayObjects) |
|
874 | 735 |
! ! |
736 |
||
737 |
!DragAndDropManager methodsFor:'dragging - easy startup'! |
|
738 |
||
739 |
startDrag:draggableObjects from:aView |
|
740 |
"start a drop at the current pointer position |
|
741 |
" |
|
742 |
^ self startDrag:draggableObjects |
|
1166 | 743 |
from:aView |
744 |
offset:0@0 |
|
874 | 745 |
! |
746 |
||
747 |
startDrag:draggableObjects from:aView display:something |
|
748 |
"start a drop at the current pointer position. |
|
749 |
" |
|
750 |
^ self startDrag:draggableObjects |
|
1166 | 751 |
from:aView |
752 |
offset:nil |
|
753 |
atEnd:nil |
|
754 |
display:something |
|
874 | 755 |
! |
756 |
||
757 |
startDrag:draggableObjects from:aView offset:anOffset |
|
758 |
"start a drop at the current pointer position with an offset |
|
759 |
" |
|
760 |
^ self startDrag:draggableObjects |
|
1166 | 761 |
from:aView |
762 |
offset:anOffset |
|
763 |
atEnd:nil |
|
874 | 764 |
! |
765 |
||
766 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock |
|
767 |
"start a drop at the current pointer position. |
|
768 |
When finished, the endAction is called with four args: |
|
769 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
770 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
771 |
" |
|
772 |
^ self startDrag:draggableObjects |
|
1166 | 773 |
from:aView |
774 |
offset:anOffset |
|
775 |
atEnd:aFourArgEndBlock |
|
776 |
display:draggableObjects |
|
874 | 777 |
! |
778 |
||
779 |
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgBlock display:something |
|
780 |
"start a drop at the current pointer position. |
|
781 |
When finished, the endAction is called with four args: |
|
782 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
783 |
the dropPoint in root-coordinates and the dropPoint within the targetView. |
|
784 |
" |
|
785 |
|height width fontWdt dispObj offset ascent device dispObjs list space| |
|
786 |
||
787 |
self dropObjects:draggableObjects. |
|
788 |
||
789 |
self dropObjects size == 0 ifTrue:[ |
|
1166 | 790 |
^ self |
874 | 791 |
]. |
792 |
||
793 |
device := aView device. |
|
794 |
space := 1. |
|
795 |
height := space negated. |
|
796 |
width := 0. |
|
797 |
fontWdt := aView font width. |
|
798 |
ascent := aView font ascent. |
|
799 |
||
800 |
(list := something) isNil ifTrue:[ |
|
1166 | 801 |
list := self dropObjects |
874 | 802 |
] ifFalse:[ |
1166 | 803 |
(list isCollection not or:[list isString]) ifTrue:[ |
804 |
list := Array with:something |
|
805 |
] |
|
874 | 806 |
]. |
807 |
dispObjs := OrderedCollection new. |
|
808 |
||
809 |
list do:[:el| |
|
1166 | 810 |
|obj asc| |
874 | 811 |
|
1166 | 812 |
obj := self displayObjectFor:el on:device. |
813 |
asc := (obj respondsTo:#string) ifTrue:[ascent] ifFalse:[0]. |
|
814 |
height := height + space. |
|
874 | 815 |
|
1166 | 816 |
dispObjs add:(Array with:obj with:(0 @ (height + asc))). |
817 |
width := width max:(obj widthOn:aView). |
|
818 |
height := height + (obj heightOn:aView). |
|
874 | 819 |
]. |
820 |
||
881 | 821 |
anOffset isSymbol ifTrue:[ |
1166 | 822 |
offset := (0@0 extent:(width @ height)) perform:anOffset. |
881 | 823 |
] ifFalse:[ |
1166 | 824 |
offset := anOffset ? (0@0). |
881 | 825 |
]. |
826 |
offset := offset rounded. |
|
874 | 827 |
|
828 |
dispObjs do:[:el| el at:2 put:((el at:2) - offset) ]. |
|
829 |
||
830 |
self startOpaqueDrag:[:p :v| dispObjs do:[:el| (el at:1) displayOn:v at:p + (el at:2)] ] |
|
1166 | 831 |
offset:offset |
832 |
extent:width @ height |
|
833 |
in:aView |
|
834 |
at:nil |
|
835 |
atEnd:aFourArgBlock |
|
881 | 836 |
|
837 |
"Modified: / 31.3.1998 / 11:18:04 / cg" |
|
874 | 838 |
! |
839 |
||
840 |
startDrag:draggableObjects from:aView offset:anOffset display:something |
|
841 |
"start a drop at the current pointer position. |
|
842 |
" |
|
843 |
^ self startDrag:draggableObjects |
|
1166 | 844 |
from:aView |
845 |
offset:anOffset |
|
846 |
atEnd:nil |
|
847 |
display:something |
|
394 | 848 |
! ! |
849 |
||
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
850 |
!DragAndDropManager methodsFor:'dragging - generic'! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
851 |
|
348 | 852 |
startGenericDrag:aTwoArgDragBlock in:aView at:p atEnd:aFourArgEndBlock |
853 |
"start a generic (caller-provided drag); |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
854 |
Here, an inverting drag is initiated (i.e. the drawing is undone |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
855 |
by inverting again). See startOpaqueDrag for another variant. |
348 | 856 |
the dragBlock, aTwoArgDragBlock will be called with two args |
857 |
aPoint and a drawingGC, to perform the drawing at some dragPoint. |
|
858 |
The drag starts in aView at point p. |
|
859 |
When finished, the endAction is called with four args: |
|
860 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 861 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
862 |
" |
|
863 |
^ self startOpaqueDrag:aTwoArgDragBlock |
|
1166 | 864 |
offset:nil |
865 |
extent:nil |
|
866 |
in:aView |
|
867 |
at:nil |
|
868 |
atEnd:aFourArgEndBlock |
|
394 | 869 |
! |
870 |
||
874 | 871 |
startOpaqueDrag:aDragBlock offset:offs extent:anExtent in:aView at:aDummyPoint atEnd:aFourArgEndBlock |
872 |
"start an opaque or generic opaque (caller-provided drag); |
|
394 | 873 |
opaque drag means, that the drawing cannot be undone by two inverting |
874 |
draws, but instead, the area under the dragged object must be saved |
|
874 | 875 |
and restored. The areas size to be saved/restored is passed in anExtent. |
876 |
the dragBlock, aDragBlock will be called with up to three args aPoint, a |
|
877 |
drawingGC and the display objects, to perform the drawing at some dragPoint. |
|
394 | 878 |
The drag starts in aView at point p. |
879 |
When finished, the endAction is called with four args: |
|
880 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 881 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
882 |
" |
|
883 |
|handler numArgs dragBlock dobjs| |
|
394 | 884 |
|
874 | 885 |
dragOffset := offs ? (Point x:0 y:0). |
886 |
numArgs := aDragBlock numArgs. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
887 |
|
874 | 888 |
numArgs == 3 ifTrue:[ |
1289 | 889 |
dobjs := self dropObjects. |
890 |
dragBlock := [:p :v| aDragBlock value:p value:v value:dobjs ] |
|
874 | 891 |
] ifFalse:[ |
1289 | 892 |
numArgs == 1 ifTrue:[ |
893 |
dragBlock := [:p :v| aDragBlock value:p ] |
|
894 |
] ifFalse:[ |
|
895 |
dragBlock := aDragBlock |
|
896 |
] |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
897 |
]. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
898 |
|
874 | 899 |
anExtent isNil ifTrue:[ |
1289 | 900 |
handler := DragHandler startGenericDrag:dragBlock. |
874 | 901 |
] ifFalse:[ |
1289 | 902 |
handler := DragHandler startOpaqueDrag:dragBlock extent:anExtent offset:dragOffset. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
903 |
]. |
1289 | 904 |
self doStart:handler for:aView atEnd:aFourArgEndBlock. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
905 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
906 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
907 |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
908 |
!DragAndDropManager methodsFor:'dragging - lines'! |
341 | 909 |
|
874 | 910 |
startArrowDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock |
911 |
"start a line-drag of an arrow-line. |
|
912 |
The drag starts in aView at point aStartPoint. |
|
913 |
When finished, the endAction is called with four args: |
|
914 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
915 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
|
916 |
" |
|
917 |
|p| |
|
341 | 918 |
|
874 | 919 |
p := self translatePointToScreen:aStartPoint from:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
920 |
|
874 | 921 |
self doStart:(DragHandler startArrowDragAt:p) |
1166 | 922 |
for:aView |
923 |
atEnd:aFourArgEndBlock |
|
341 | 924 |
! |
925 |
||
874 | 926 |
startLineDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock |
927 |
"start a line-drag of a normal line. |
|
928 |
The drag starts in aView at point aStartPoint. |
|
348 | 929 |
When finished, the endAction is called with four args: |
930 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
874 | 931 |
the dropPoint in root-coordinates and the dropPoint within the targetView |
932 |
" |
|
933 |
|p| |
|
341 | 934 |
|
874 | 935 |
p := self translatePointToScreen:aStartPoint from:aView. |
348 | 936 |
|
874 | 937 |
self doStart:(DragHandler startLineDragAt:p) |
1166 | 938 |
for:aView |
939 |
atEnd:aFourArgEndBlock |
|
341 | 940 |
! ! |
941 |
||
397 | 942 |
!DragAndDropManager methodsFor:'drawing'! |
943 |
||
874 | 944 |
displayObjectFor:anObject on:aDevice |
945 |
"converts an object to a display object |
|
946 |
" |
|
947 |
|obj icon s1 s2| |
|
948 |
||
949 |
obj := (anObject respondsTo:#displayObject) ifTrue:[anObject displayObject] |
|
1166 | 950 |
ifFalse:[anObject]. |
874 | 951 |
|
952 |
obj isString ifTrue:[ |
|
1166 | 953 |
^ obj |
874 | 954 |
]. |
955 |
||
956 |
obj messageNotUnderstoodSignal handle:[:ex|] do:[ |
|
1166 | 957 |
obj := obj on:aDevice |
874 | 958 |
]. |
959 |
||
960 |
obj isImage ifTrue:[ |
|
1166 | 961 |
^ obj clearMaskedPixels |
874 | 962 |
]. |
963 |
||
964 |
obj class == LabelAndIcon ifTrue:[ |
|
1166 | 965 |
obj image notNil ifTrue:[obj image clearMaskedPixels]. |
966 |
obj icon notNil ifTrue:[obj icon clearMaskedPixels]. |
|
874 | 967 |
^ obj |
968 |
]. |
|
969 |
||
970 |
(obj class == MultiColListEntry) ifFalse:[ |
|
1166 | 971 |
^ obj |
874 | 972 |
]. |
973 |
s1 := obj colAt:1. |
|
974 |
s2 := obj colAt:2. |
|
975 |
||
976 |
s1 isImage ifTrue:[ |
|
1166 | 977 |
s2 isImage ifTrue:[ ^ self displayObjectFor:(LabelAndIcon form:s1 image:s2) on:aDevice ]. |
978 |
s2 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s1 string:s2) on:aDevice ]. |
|
979 |
^ (s1 on:aDevice) clearMaskedPixels |
|
874 | 980 |
]. |
981 |
||
982 |
s2 isImage ifTrue:[ |
|
1166 | 983 |
s1 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s2 string:s1) on:aDevice ]. |
984 |
^ (s2 on:aDevice) clearMaskedPixels |
|
874 | 985 |
]. |
986 |
||
987 |
s1 isString ifTrue:[^ s1]. |
|
988 |
s2 isString ifTrue:[^ s2]. |
|
989 |
^ obj |
|
990 |
! |
|
991 |
||
397 | 992 |
showDragging:items in:aView at:p |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
993 |
"helper for dragging dragObjects: draw them all" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
994 |
|
397 | 995 |
|offs| |
996 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
997 |
offs := 0. |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
998 |
items do:[:item | |
1166 | 999 |
item displayOn:aView at:p + (0@offs). |
1000 |
offs := offs + (item heightOn:self) |
|
397 | 1001 |
] |
1002 |
||
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1003 |
"Modified: 19.4.1997 / 12:41:24 / cg" |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1004 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1005 |
|
341 | 1006 |
!DragAndDropManager methodsFor:'event catching'! |
1007 |
||
1008 |
buttonMotion:button x:x y:y view:aView |
|
874 | 1009 |
"handle a button motion event |
1010 |
" |
|
1011 |
|oldPt oldTgt oldWg oldId newWg newId newTgt point rootId cursor device isDroppable| |
|
1012 |
||
1013 |
device := dragView device. |
|
1014 |
rootId := device rootView id. |
|
1015 |
point := self translatePointToScreen:(x @ y) from:dragView. |
|
1016 |
oldWg := dropContext targetWidget. |
|
1017 |
oldId := dropContext targetId. |
|
1018 |
oldPt := dropContext rootPoint. |
|
1019 |
||
1020 |
dropContext rootPoint:point. |
|
1021 |
||
1022 |
"/ |
|
1023 |
"/ search view the drop is in |
|
1024 |
"/ |
|
1025 |
[ newId := rootId. |
|
1289 | 1026 |
(rootId := device viewIdFromPoint:point in:newId) notNil |
874 | 1027 |
] whileTrue. |
1028 |
||
1029 |
newWg := device viewFromId:newId. |
|
1030 |
dropContext targetWidget:newWg id:newId. |
|
1031 |
||
1032 |
handler isInterestedInDropTarget ifFalse:[ |
|
1289 | 1033 |
"/ |
1034 |
"/ line or arrow handler |
|
1035 |
"/ |
|
1036 |
handler dragTo:point. |
|
1037 |
^ self |
|
874 | 1038 |
]. |
1039 |
||
1040 |
oldWg ~~ newWg ifTrue:[ |
|
1289 | 1041 |
"/ |
1042 |
"/ widget has changed: drop target might change |
|
1043 |
"/ |
|
1044 |
oldTgt := dropContext dropTarget. |
|
1045 |
newTgt := self doFindDropTargetIn:newWg at:point. |
|
874 | 1046 |
|
1289 | 1047 |
newTgt ~= oldTgt ifTrue:[ |
1048 |
"/ |
|
1049 |
"/ drop target changed: handler might restore the screen |
|
1050 |
"/ |
|
1051 |
handler dropTargetWillChange. |
|
341 | 1052 |
|
1289 | 1053 |
oldTgt notNil ifTrue:[ |
1054 |
"/ |
|
1055 |
"/ setup old context |
|
1056 |
"/ |
|
1057 |
dropContext targetWidget:oldWg id:oldId. |
|
1058 |
oldTgt leave:dropContext. |
|
1059 |
dropContext targetWidget:newWg id:newId. |
|
1060 |
]. |
|
1061 |
dropContext dropTarget:newTgt. |
|
1062 |
newTgt notNil ifTrue:[ newTgt enter:dropContext ] |
|
1063 |
] ifFalse:[ |
|
1064 |
dropContext dropTarget:newTgt |
|
1065 |
] |
|
874 | 1066 |
] ifFalse:[ |
1289 | 1067 |
(oldPt notNil and:[(oldPt dist:point) < 2 ]) ifTrue:[ |
1068 |
"/ |
|
1069 |
"/ ignore the button motion event; restore old rootPoint |
|
1070 |
"/ |
|
1071 |
dropContext rootPoint:oldPt. |
|
1072 |
^ self |
|
1073 |
]. |
|
1074 |
newTgt := dropContext dropTarget |
|
874 | 1075 |
]. |
1076 |
"/ |
|
1077 |
"/ update the cursor |
|
1078 |
"/ |
|
1079 |
(isDroppable := dropContext canDrop) ifTrue:[ |
|
1289 | 1080 |
cursor := enabledCursor |
874 | 1081 |
] ifFalse:[ |
1289 | 1082 |
cursor := dropContext isAlienView ifFalse:[disabledCursor] |
1083 |
ifTrue:[alienCursor] |
|
874 | 1084 |
]. |
1085 |
dragView cursor:cursor now:true. |
|
1086 |
"/ |
|
1087 |
"/ test if droppable state changed |
|
1088 |
"/ |
|
1089 |
canDrop == isDroppable ifFalse:[ |
|
1289 | 1090 |
"/ |
1091 |
"/ droppable state changed: handler might restore the screen |
|
1092 |
"/ |
|
1093 |
canDrop := isDroppable. |
|
1094 |
handler dropTargetWillChange |
|
874 | 1095 |
]. |
394 | 1096 |
|
874 | 1097 |
newTgt notNil ifTrue:[ newTgt over:dropContext ]. |
1098 |
handler dragTo:point. |
|
1099 |
! |
|
394 | 1100 |
|
874 | 1101 |
buttonMultiPress:button x:x y:y view:aView |
1102 |
"discard each buttonMultiPress event |
|
1103 |
" |
|
1104 |
! |
|
1105 |
||
1106 |
buttonPress:button x:x y:y view:aView |
|
1107 |
"discard each buttonPress event |
|
1108 |
" |
|
341 | 1109 |
! |
1110 |
||
1111 |
buttonRelease:button x:x y:y view:aView |
|
874 | 1112 |
"button released; do the drop |
1113 |
" |
|
1114 |
((button == 2) or:[button == #menu]) ifTrue:[ |
|
1166 | 1115 |
^ self |
874 | 1116 |
]. |
1117 |
"/ |
|
1118 |
"/ update the context |
|
1119 |
"/ |
|
1120 |
self buttonMotion:button x:x y:y view:aView. |
|
1121 |
||
1122 |
"/ |
|
1123 |
"/ restore source view |
|
1124 |
"/ |
|
1125 |
restoreBlock value. |
|
394 | 1126 |
|
874 | 1127 |
"/ |
1128 |
"/ at least do the drop operation |
|
1129 |
"/ |
|
1130 |
dropAction isNil ifTrue:[ |
|
1166 | 1131 |
dropContext doDrop |
874 | 1132 |
] ifFalse:[ |
1166 | 1133 |
"/ |
1134 |
"/ initiator wants to do it himself, manually. |
|
1135 |
"/ Thus, no feedBack operation invoked. |
|
1136 |
"/ |
|
1137 |
dropAction value:(dropContext targetWidget) |
|
1138 |
value:(dropContext targetId) |
|
1139 |
value:(dropContext rootPoint) |
|
1140 |
value:(dropContext targetPoint). |
|
874 | 1141 |
] |
341 | 1142 |
! |
1143 |
||
1289 | 1144 |
delegatesTo:someone |
1145 |
^false |
|
1146 |
! |
|
1147 |
||
341 | 1148 |
handlesButtonMotion:button inView:aView |
1149 |
"query from event processor: am I interested in button-events ? |
|
1150 |
yes I am (to activate the clicked-on field)." |
|
1151 |
||
874 | 1152 |
^ dragView == aView |
1153 |
! |
|
1154 |
||
1155 |
handlesButtonMultiPress:button inView:aView |
|
1156 |
"query from event processor: am I interested in button-events ? |
|
1157 |
yes I am (to activate the clicked-on field)." |
|
341 | 1158 |
|
874 | 1159 |
^ dragView == aView |
1160 |
! |
|
394 | 1161 |
|
874 | 1162 |
handlesButtonPress:button inView:aView |
1163 |
"query from event processor: am I interested in button-events ? |
|
1164 |
yes I am (to activate the clicked-on field)." |
|
1165 |
||
1166 |
^ dragView == aView |
|
341 | 1167 |
! |
1168 |
||
1169 |
handlesButtonRelease:button inView:aView |
|
1170 |
"query from event processor: am I interested in button-events ? |
|
1171 |
yes I am (to activate the clicked-on field)." |
|
1172 |
||
874 | 1173 |
^ dragView == aView |
1174 |
! ! |
|
1175 |
||
1176 |
!DragAndDropManager methodsFor:'initialization'! |
|
341 | 1177 |
|
874 | 1178 |
initialize |
1179 |
super initialize. |
|
394 | 1180 |
|
874 | 1181 |
dragOffset := 0 @ 0. |
1182 |
dropContext := DropContext new. |
|
1183 |
alienCursor := Cursor questionMark. |
|
1184 |
enabledCursor := Cursor thumbsUp. |
|
1185 |
disabledCursor := Cursor thumbsDown. |
|
1186 |
canDrop := false. |
|
341 | 1187 |
! ! |
1188 |
||
1189 |
!DragAndDropManager methodsFor:'private'! |
|
1190 |
||
874 | 1191 |
doDrop:aContext in:aWidget |
1192 |
"old drop mechanism |
|
1193 |
" |
|
1194 |
|point| |
|
628 | 1195 |
|
1196 |
DragOriginatorQuerySignal answer:dragView do:[ |
|
1166 | 1197 |
DragOffsetQuerySignal answer:dragOffset do:[ |
1198 |
aContext targetWidget == aWidget ifTrue:[ |
|
1199 |
point := aContext targetPoint |
|
1200 |
] ifFalse:[ |
|
1201 |
point := 0@0. "/ nil. |
|
1202 |
"/ |
|
1203 |
"/ FeedBack: set the widget which handles the drop |
|
1204 |
"/ |
|
1205 |
aContext targetWidget:aWidget id:(aWidget id). |
|
1206 |
]. |
|
1207 |
aWidget drop:(aContext dropObjects) at:point |
|
1208 |
] |
|
609
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1209 |
]. |
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1210 |
|
1072
be90bc383d83
do not pas nil point to dropDestination
Claus Gittinger <cg@exept.de>
parents:
881
diff
changeset
|
1211 |
"Modified: / 11.9.1998 / 00:53:22 / cg" |
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
1212 |
! |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
1213 |
|
874 | 1214 |
doFindDropTargetIn:aView at:aPoint |
1215 |
"get the drop target for a view and source at a point or nil |
|
411 | 1216 |
" |
874 | 1217 |
|target view dobj| |
628 | 1218 |
|
874 | 1219 |
aView isNil ifTrue:[ ^ nil ]. |
1220 |
"/ |
|
1221 |
"/ new mechanism to get a dropTarget |
|
1222 |
"/ |
|
1223 |
aView messageNotUnderstoodSignal handle:[:ex| |
|
1166 | 1224 |
target := nil. |
874 | 1225 |
] do:[ |
1166 | 1226 |
target := aView dropTarget |
874 | 1227 |
]. |
1228 |
target notNil ifTrue:[ ^ target ]. |
|
1229 |
"/ |
|
1230 |
"/ old mechanism to get a dropTarget |
|
1231 |
"/ |
|
1232 |
view := aView. |
|
1233 |
dobj := dropContext dropObjects. |
|
628 | 1234 |
|
874 | 1235 |
DragOriginatorQuerySignal answer:dragView do:[ |
1166 | 1236 |
DragOffsetQuerySignal answer:dragOffset do:[ |
1237 |
[ (view canDrop:dobj) ifTrue:[ |
|
1238 |
^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:. |
|
1239 |
]. |
|
1240 |
(view := view superView) notNil |
|
628 | 1241 |
|
1166 | 1242 |
] whileTrue. |
1243 |
] |
|
874 | 1244 |
]. |
1245 |
^ nil |
|
1246 |
! |
|
628 | 1247 |
|
874 | 1248 |
doStart:aHandler for:aView atEnd:aFourArgEndBlock |
1249 |
"setup a handler and a restore block |
|
628 | 1250 |
" |
1289 | 1251 |
|savedCursor savedDelegate prevGrab sensor p| |
628 | 1252 |
|
874 | 1253 |
dropContext sourceWidget:aView. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1254 |
|
874 | 1255 |
dragOffset isNil ifTrue:[ dragOffset := 0 @ 0 ]. |
1256 |
alienCursor isNil ifTrue:[ alienCursor := disabledCursor ]. |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1257 |
|
874 | 1258 |
dragView := aView. |
1259 |
dropAction := aFourArgEndBlock. |
|
1289 | 1260 |
savedCursor := aView cursor. |
1261 |
savedDelegate := aView delegate. |
|
874 | 1262 |
handler := aHandler. |
609
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1263 |
|
1162
0539b64679ce
set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1264 |
dropContext dragHandler:aHandler. |
0539b64679ce
set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1265 |
|
874 | 1266 |
restoreBlock := [ |
1289 | 1267 |
aHandler postDragging. |
1268 |
aView delegate:savedDelegate. |
|
1269 |
aView cursor:savedCursor now:true. |
|
1270 |
prevGrab notNil ifTrue:[ |
|
1271 |
aView forceUngrabPointer. |
|
1272 |
prevGrab grabPointer. |
|
1273 |
] ifFalse:[ |
|
1274 |
aView ungrabPointer. |
|
1275 |
]. |
|
874 | 1276 |
]. |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1277 |
|
874 | 1278 |
aHandler preDraggingIn:aView. |
1279 |
aView delegate:self. |
|
1289 | 1280 |
prevGrab := aView device activePointerGrab. |
1281 |
aView grabPointer. |
|
1282 |
||
1283 |
"/ must wait for all pending motion events to arrive, and ignore them |
|
1284 |
(sensor := aView sensor) notNil ifTrue:[ |
|
1285 |
aView device sync. |
|
1286 |
sensor flushMotionEventsFor:nil. |
|
1287 |
]. |
|
1288 |
||
1289 |
"/ start with a first draw at the current mouse position |
|
1290 |
p := aView device pointerPosition. |
|
1291 |
p := aView device translatePoint:p from:(aView device rootView id) to:(aView id). |
|
1292 |
self buttonMotion:1 x:p x y:p y view:aView |
|
609
1343bda17876
pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
1293 |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1294 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1295 |
|
874 | 1296 |
!DragAndDropManager methodsFor:'translation'! |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1297 |
|
874 | 1298 |
translatePointToScreen:aPoint from:aView |
1299 |
"translate a point to screen |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1300 |
" |
874 | 1301 |
|device trans point offset| |
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1302 |
|
874 | 1303 |
device := aView device. |
1304 |
"/ |
|
1305 |
"/ get device coordinates |
|
1306 |
"/ |
|
1307 |
(trans := aView transformation) notNil ifTrue:[ |
|
1166 | 1308 |
point := trans applyTo:aPoint |
874 | 1309 |
] ifFalse:[ |
1166 | 1310 |
point := aPoint |
874 | 1311 |
]. |
1312 |
"/ |
|
1313 |
"/ translate to screen |
|
1314 |
"/ |
|
1315 |
offset := device translatePoint:0@0 from:(aView id) to:(device rootView id). |
|
1316 |
^ offset + point |
|
548
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1317 |
|
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1318 |
! ! |
1a81d6be65b4
added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents:
515
diff
changeset
|
1319 |
|
341 | 1320 |
!DragAndDropManager class methodsFor:'documentation'! |
1321 |
||
1322 |
version |
|
1420 | 1323 |
^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.26 2000-11-09 11:46:23 cg Exp $' |
341 | 1324 |
! ! |
628 | 1325 |
DragAndDropManager initialize! |