author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 18:02:37 +0100 | |
changeset 365 | 47e0d48fd769 |
parent 348 | 74f1fda9deb0 |
child 394 | 0539d7b29aa7 |
permissions | -rw-r--r-- |
341 | 1 |
Object subclass:#DragAndDropManager |
2 |
instanceVariableNames:'dragView motionAction releaseAction initialPoint previousPoint |
|
345 | 3 |
rememberedDelegate dragBlock lineMode dropAction' |
341 | 4 |
classVariableNames:'' |
5 |
poolDictionaries:'' |
|
6 |
category:'Interface-Support' |
|
7 |
! |
|
8 |
||
343 | 9 |
View subclass:#DemoView2 |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
10 |
instanceVariableNames:'' |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
11 |
classVariableNames:'' |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
12 |
poolDictionaries:'' |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
13 |
privateIn:DragAndDropManager |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
14 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
15 |
|
345 | 16 |
View subclass:#DemoView3 |
341 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
privateIn:DragAndDropManager |
|
21 |
! |
|
22 |
||
348 | 23 |
View subclass:#DemoView |
24 |
instanceVariableNames:'' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:DragAndDropManager |
|
28 |
! |
|
29 |
||
341 | 30 |
!DragAndDropManager class methodsFor:'documentation'! |
31 |
||
348 | 32 |
documentation |
33 |
" |
|
34 |
this class provides low-level drag & drop mechanisms. |
|
35 |
||
36 |
[author:] |
|
37 |
Claus Gittinger |
|
38 |
" |
|
39 |
||
40 |
! |
|
41 |
||
341 | 42 |
history |
43 |
||
44 |
"Created: 26.10.1996 / 15:02:00 / cg" |
|
45 |
"Modified: 26.10.1996 / 15:21:42 / cg" |
|
46 |
! ! |
|
47 |
||
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
48 |
!DragAndDropManager methodsFor:'dragging - generic'! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
49 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
50 |
doGenericDragX:x y:y |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
51 |
previousPoint notNil ifTrue:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
52 |
self invertGenericAt:previousPoint |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
53 |
]. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
54 |
previousPoint := x @ y. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
55 |
self invertGenericAt:previousPoint |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
56 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
57 |
"Modified: 26.10.1996 / 15:16:59 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
58 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
59 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
60 |
endGenericDragX:x y:y |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
61 |
previousPoint notNil ifTrue:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
62 |
self invertGenericAt:previousPoint |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
63 |
]. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
64 |
previousPoint := nil. |
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
65 |
self uncatchEvents. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
66 |
self endDragAt:x @ y |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
67 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
68 |
"Created: 26.10.1996 / 15:17:20 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
69 |
"Modified: 26.10.1996 / 15:22:41 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
70 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
71 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
72 |
invertGenericAt:ip |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
73 |
|t offs p rootView| |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
74 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
75 |
rootView := dragView device rootView. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
76 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
77 |
p := ip. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
78 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
79 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
80 |
get device coordinates |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
81 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
82 |
(t := dragView transformation) notNil ifTrue:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
83 |
p := t applyTo:p. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
84 |
]. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
85 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
86 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
87 |
translate to screen |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
88 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
89 |
offs := dragView device |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
90 |
translatePoint:0@0 |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
91 |
from:(dragView id) to:(rootView id). |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
92 |
p := p + offs. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
93 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
94 |
rootView clippedByChildren:false. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
95 |
rootView xoring:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
96 |
rootView lineWidth:0. |
348 | 97 |
dragBlock value:p value:rootView. |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
98 |
rootView flush |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
99 |
]. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
100 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
101 |
"Created: 26.10.1996 / 15:15:26 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
102 |
"Modified: 26.10.1996 / 15:27:09 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
103 |
! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
104 |
|
348 | 105 |
startGenericDrag:aTwoArgDragBlock in:aView at:p atEnd:aFourArgEndBlock |
106 |
"start a generic (caller-provided drag); |
|
107 |
the dragBlock, aTwoArgDragBlock will be called with two args |
|
108 |
aPoint and a drawingGC, to perform the drawing at some dragPoint. |
|
109 |
The drag starts in aView at point p. |
|
110 |
When finished, the endAction is called with four args: |
|
111 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
112 |
the dropPoint in root-coordinates and the dropPoint within the targetView" |
|
113 |
||
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
114 |
self catchEventsFrom:aView. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
115 |
motionAction := #doGenericDragX:y:. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
116 |
releaseAction := #endGenericDragX:y:. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
117 |
initialPoint := p. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
118 |
previousPoint := nil. |
348 | 119 |
dragBlock := aTwoArgDragBlock. |
120 |
dropAction := aFourArgEndBlock. |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
121 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
122 |
"Modified: 26.10.1996 / 15:09:26 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
123 |
"Created: 26.10.1996 / 15:16:13 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
124 |
! ! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
125 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
126 |
!DragAndDropManager methodsFor:'dragging - lines'! |
341 | 127 |
|
128 |
doLineDragX:x y:y |
|
129 |
previousPoint notNil ifTrue:[ |
|
130 |
self invertLineFrom:initialPoint to:previousPoint |
|
131 |
]. |
|
132 |
previousPoint := x @ y. |
|
133 |
self invertLineFrom:initialPoint to:previousPoint |
|
134 |
||
135 |
"Modified: 26.10.1996 / 15:16:59 / cg" |
|
136 |
! |
|
137 |
||
138 |
endLineDragX:x y:y |
|
139 |
previousPoint notNil ifTrue:[ |
|
140 |
self invertLineFrom:initialPoint to:previousPoint |
|
141 |
]. |
|
142 |
previousPoint := nil. |
|
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
143 |
self uncatchEvents. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
144 |
self endDragAt:x @ y |
341 | 145 |
|
146 |
"Created: 26.10.1996 / 15:17:20 / cg" |
|
147 |
"Modified: 26.10.1996 / 15:22:41 / cg" |
|
148 |
! |
|
149 |
||
150 |
invertLineFrom:ip1 to:ip2 |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
151 |
|t offs p1 p2 rootView a| |
341 | 152 |
|
153 |
rootView := dragView device rootView. |
|
154 |
||
155 |
p1 := ip1. |
|
156 |
p2 := ip2. |
|
157 |
||
158 |
" |
|
159 |
get device coordinates |
|
160 |
" |
|
161 |
(t := dragView transformation) notNil ifTrue:[ |
|
162 |
p1 := t applyTo:p1. |
|
163 |
p2 := t applyTo:p2. |
|
164 |
]. |
|
165 |
||
166 |
" |
|
167 |
translate to screen |
|
168 |
" |
|
169 |
offs := dragView device |
|
170 |
translatePoint:0@0 |
|
171 |
from:(dragView id) to:(rootView id). |
|
172 |
p1 := p1 + offs. |
|
173 |
p2 := p2 + offs. |
|
174 |
||
175 |
rootView clippedByChildren:false. |
|
176 |
rootView xoring:[ |
|
177 |
rootView lineWidth:0. |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
178 |
lineMode == #arrow ifTrue:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
179 |
a := Arrow from:p1 to:p2. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
180 |
a arrowHeadLength:(rootView device horizontalPixelPerMillimeter * 4) rounded. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
181 |
a displayFilledOn:rootView. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
182 |
] ifFalse:[ |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
183 |
rootView displayLineFrom:p1 to:p2. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
184 |
]. |
341 | 185 |
rootView flush |
186 |
]. |
|
187 |
||
188 |
"Created: 26.10.1996 / 15:15:26 / cg" |
|
189 |
"Modified: 26.10.1996 / 15:27:09 / cg" |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
190 |
! |
341 | 191 |
|
345 | 192 |
startArrowDragIn:aView at:p atEnd:aBlock |
348 | 193 |
"start a line-drag of an arrow-line. |
194 |
The drag starts in aView at point p. |
|
195 |
When finished, the endAction is called with four args: |
|
196 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
197 |
the dropPoint in root-coordinates and the dropPoint within the targetView" |
|
198 |
||
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
199 |
self catchEventsFrom:aView. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
200 |
motionAction := #doLineDragX:y:. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
201 |
releaseAction := #endLineDragX:y:. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
202 |
initialPoint := p. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
203 |
previousPoint := nil. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
204 |
dragBlock := nil. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
205 |
lineMode := #arrow. |
345 | 206 |
dropAction := aBlock. |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
207 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
208 |
"Modified: 26.10.1996 / 15:09:26 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
209 |
"Created: 26.10.1996 / 15:16:13 / cg" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
210 |
! |
341 | 211 |
|
348 | 212 |
startLineDragIn:aView at:p atEnd:aFourArgEndBlock |
213 |
"start a line-drag of a normal line. |
|
214 |
The drag starts in aView at point p. |
|
215 |
When finished, the endAction is called with four args: |
|
216 |
the targetView, the targetViews windowID (useful, if its an alien view), |
|
217 |
the dropPoint in root-coordinates and the dropPoint within the targetView" |
|
218 |
||
341 | 219 |
self catchEventsFrom:aView. |
220 |
motionAction := #doLineDragX:y:. |
|
221 |
releaseAction := #endLineDragX:y:. |
|
222 |
initialPoint := p. |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
223 |
previousPoint := nil. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
224 |
dragBlock := nil. |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
225 |
lineMode := nil. |
348 | 226 |
dropAction := aFourArgEndBlock. |
341 | 227 |
|
228 |
"Modified: 26.10.1996 / 15:09:26 / cg" |
|
229 |
"Created: 26.10.1996 / 15:16:13 / cg" |
|
230 |
! ! |
|
231 |
||
232 |
!DragAndDropManager methodsFor:'event catching'! |
|
233 |
||
234 |
buttonMotion:button x:x y:y view:aView |
|
235 |
self perform:motionAction with:x with:y |
|
236 |
||
237 |
"Created: 26.10.1996 / 15:09:00 / cg" |
|
238 |
! |
|
239 |
||
240 |
buttonRelease:button x:x y:y view:aView |
|
241 |
self perform:releaseAction with:x with:y |
|
242 |
||
243 |
"Created: 26.10.1996 / 15:09:14 / cg" |
|
244 |
! |
|
245 |
||
246 |
handlesButtonMotion:button inView:aView |
|
247 |
"query from event processor: am I interested in button-events ? |
|
248 |
yes I am (to activate the clicked-on field)." |
|
249 |
||
250 |
^ aView == dragView |
|
251 |
||
252 |
"Created: 26.10.1996 / 15:05:36 / cg" |
|
253 |
! |
|
254 |
||
255 |
handlesButtonRelease:button inView:aView |
|
256 |
"query from event processor: am I interested in button-events ? |
|
257 |
yes I am (to activate the clicked-on field)." |
|
258 |
||
259 |
^ aView == dragView |
|
260 |
||
261 |
"Created: 26.10.1996 / 15:05:48 / cg" |
|
262 |
! ! |
|
263 |
||
264 |
!DragAndDropManager methodsFor:'private'! |
|
265 |
||
266 |
catchEventsFrom:aView |
|
267 |
dragView := aView. |
|
268 |
rememberedDelegate := aView delegate. |
|
269 |
aView delegate:self |
|
270 |
||
271 |
"Created: 26.10.1996 / 15:03:12 / cg" |
|
272 |
"Modified: 26.10.1996 / 15:21:57 / cg" |
|
273 |
! |
|
274 |
||
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
275 |
endDragAt:ip |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
276 |
|rootPoint t viewId offs destinationId lastViewId destinationView |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
277 |
rootView destinationPoint device| |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
278 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
279 |
dropAction notNil ifTrue:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
280 |
device := dragView device. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
281 |
rootView := device rootView. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
282 |
rootPoint := ip. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
283 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
284 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
285 |
get device coordinates |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
286 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
287 |
(t := dragView transformation) notNil ifTrue:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
288 |
rootPoint := t applyTo:ip. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
289 |
]. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
290 |
viewId := rootView id. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
291 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
292 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
293 |
translate to screen |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
294 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
295 |
offs := device translatePoint:0@0 from:(dragView id) to:viewId. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
296 |
rootPoint := rootPoint + offs. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
297 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
298 |
"search view the drop is in" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
299 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
300 |
[viewId notNil] whileTrue:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
301 |
destinationId := device viewIdFromPoint:rootPoint in:viewId. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
302 |
lastViewId := viewId. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
303 |
viewId := destinationId |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
304 |
]. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
305 |
destinationView := device viewFromId:lastViewId. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
306 |
destinationId := lastViewId. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
307 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
308 |
"into another one" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
309 |
destinationView notNil ifTrue:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
310 |
destinationPoint := device translatePoint:rootPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
311 |
from:(rootView id) |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
312 |
to:(destinationView id). |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
313 |
destinationView transformation notNil ifTrue:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
314 |
destinationPoint := destinationView transformation applyInverseTo:destinationPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
315 |
]. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
316 |
] ifFalse:[ |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
317 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
318 |
not one of my views |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
319 |
" |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
320 |
]. |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
321 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
322 |
dropAction value:destinationView |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
323 |
value:destinationId |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
324 |
value:rootPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
325 |
value:destinationPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
326 |
] |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
327 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
328 |
|
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
329 |
! |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
330 |
|
341 | 331 |
uncatchEvents |
332 |
dragView delegate:rememberedDelegate. |
|
333 |
||
334 |
"Created: 26.10.1996 / 15:22:29 / cg" |
|
335 |
! ! |
|
336 |
||
343 | 337 |
!DragAndDropManager::DemoView2 methodsFor:'events'! |
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
338 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
339 |
buttonPress:button x:x y:y |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
340 |
DragAndDropManager new |
348 | 341 |
startGenericDrag:[:p :v | v displayString:'hello' at:p] |
345 | 342 |
in:self |
343 |
at:(x@y) |
|
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
344 |
atEnd:[:view |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
345 |
:viewID |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
346 |
:rootPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
347 |
:viewPoint | ] |
345 | 348 |
|
342
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
349 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
350 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
351 |
self new open |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
352 |
" |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
353 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
354 |
|
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
355 |
! ! |
7563cbf04502
added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents:
341
diff
changeset
|
356 |
|
345 | 357 |
!DragAndDropManager::DemoView3 methodsFor:'events'! |
341 | 358 |
|
359 |
buttonPress:button x:x y:y |
|
360 |
DragAndDropManager new |
|
345 | 361 |
startArrowDragIn:self |
362 |
at:(x@y) |
|
346
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
363 |
atEnd:[:view |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
364 |
:viewID |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
365 |
:rootPoint |
1612c23d9c5d
pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
366 |
:viewPoint | ] |
341 | 367 |
|
368 |
" |
|
369 |
self new open |
|
370 |
" |
|
371 |
! ! |
|
372 |
||
348 | 373 |
!DragAndDropManager::DemoView methodsFor:'events'! |
374 |
||
375 |
buttonPress:button x:x y:y |
|
376 |
DragAndDropManager new |
|
377 |
startLineDragIn:self at:(x@y) |
|
378 |
atEnd:[:view |
|
379 |
:viewID |
|
380 |
:rootPoint |
|
381 |
:viewPoint | |
|
382 |
||
383 |
Transcript show:'dropped at '; |
|
384 |
show:viewPoint; |
|
385 |
show:' in '. |
|
386 |
view notNil ifTrue:[ |
|
387 |
Transcript showCR:view |
|
388 |
] ifFalse:[ |
|
389 |
Transcript show:'alien view '; |
|
390 |
showCR:viewID address |
|
391 |
] |
|
392 |
]. |
|
393 |
||
394 |
" |
|
395 |
self new open |
|
396 |
" |
|
397 |
! ! |
|
398 |
||
341 | 399 |
!DragAndDropManager class methodsFor:'documentation'! |
400 |
||
401 |
version |
|
348 | 402 |
^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.6 1996-11-14 15:16:42 cg Exp $' |
341 | 403 |
! ! |