--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DragAndDropManager.st Sat Oct 26 16:40:21 1996 +0200
@@ -0,0 +1,161 @@
+Object subclass:#DragAndDropManager
+ instanceVariableNames:'dragView motionAction releaseAction initialPoint previousPoint
+ rememberedDelegate'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Support'
+!
+
+View subclass:#DragAndDropTestClass
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:DragAndDropManager
+!
+
+!DragAndDropManager class methodsFor:'documentation'!
+
+history
+
+ "Created: 26.10.1996 / 15:02:00 / cg"
+ "Modified: 26.10.1996 / 15:21:42 / cg"
+! !
+
+!DragAndDropManager privateMethodsFor:'dragging - lines'!
+
+doLineDragX:x y:y
+ previousPoint notNil ifTrue:[
+ self invertLineFrom:initialPoint to:previousPoint
+ ].
+ previousPoint := x @ y.
+ self invertLineFrom:initialPoint to:previousPoint
+
+ "Modified: 26.10.1996 / 15:16:59 / cg"
+!
+
+endLineDragX:x y:y
+ previousPoint notNil ifTrue:[
+ self invertLineFrom:initialPoint to:previousPoint
+ ].
+ previousPoint := nil.
+ self uncatchEvents
+
+ "Created: 26.10.1996 / 15:17:20 / cg"
+ "Modified: 26.10.1996 / 15:22:41 / cg"
+!
+
+invertLineFrom:ip1 to:ip2
+ |t offs p1 p2 rootView|
+
+ rootView := dragView device rootView.
+
+ p1 := ip1.
+ p2 := ip2.
+
+ "
+ get device coordinates
+ "
+ (t := dragView transformation) notNil ifTrue:[
+ p1 := t applyTo:p1.
+ p2 := t applyTo:p2.
+ ].
+
+ "
+ translate to screen
+ "
+ offs := dragView device
+ translatePoint:0@0
+ from:(dragView id) to:(rootView id).
+ p1 := p1 + offs.
+ p2 := p2 + offs.
+
+ rootView clippedByChildren:false.
+ rootView xoring:[
+ rootView lineWidth:0.
+ rootView displayLineFrom:p1 to:p2.
+ rootView flush
+ ].
+
+ "Created: 26.10.1996 / 15:15:26 / cg"
+ "Modified: 26.10.1996 / 15:27:09 / cg"
+! !
+
+!DragAndDropManager methodsFor:'dragging - lines'!
+
+setupForLineDragFrom:aView at:p
+ self catchEventsFrom:aView.
+ motionAction := #doLineDragX:y:.
+ releaseAction := #endLineDragX:y:.
+ initialPoint := p.
+ previousPoint := nil
+
+ "Modified: 26.10.1996 / 15:09:26 / cg"
+ "Created: 26.10.1996 / 15:16:13 / cg"
+! !
+
+!DragAndDropManager methodsFor:'event catching'!
+
+buttonMotion:button x:x y:y view:aView
+ self perform:motionAction with:x with:y
+
+ "Created: 26.10.1996 / 15:09:00 / cg"
+!
+
+buttonRelease:button x:x y:y view:aView
+ self perform:releaseAction with:x with:y
+
+ "Created: 26.10.1996 / 15:09:14 / cg"
+!
+
+handlesButtonMotion:button inView:aView
+ "query from event processor: am I interested in button-events ?
+ yes I am (to activate the clicked-on field)."
+
+ ^ aView == dragView
+
+ "Created: 26.10.1996 / 15:05:36 / cg"
+!
+
+handlesButtonRelease:button inView:aView
+ "query from event processor: am I interested in button-events ?
+ yes I am (to activate the clicked-on field)."
+
+ ^ aView == dragView
+
+ "Created: 26.10.1996 / 15:05:48 / cg"
+! !
+
+!DragAndDropManager methodsFor:'private'!
+
+catchEventsFrom:aView
+ dragView := aView.
+ rememberedDelegate := aView delegate.
+ aView delegate:self
+
+ "Created: 26.10.1996 / 15:03:12 / cg"
+ "Modified: 26.10.1996 / 15:21:57 / cg"
+!
+
+uncatchEvents
+ dragView delegate:rememberedDelegate.
+ dragView := nil.
+
+ "Created: 26.10.1996 / 15:22:29 / cg"
+! !
+
+!DragAndDropManager::DragAndDropTestClass methodsFor:'events'!
+
+buttonPress:button x:x y:y
+ DragAndDropManager new
+ setupForLineDragFrom:self at:(x@y)
+
+ "
+ self new open
+ "
+! !
+
+!DragAndDropManager class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.1 1996-10-26 14:40:21 cg Exp $'
+! !