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