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