--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DragHandler.st Mon Mar 30 14:00:30 1998 +0200
@@ -0,0 +1,429 @@
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+
+
+Object subclass:#DragHandler
+ instanceVariableNames:'rootView'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-DragAndDrop'
+!
+
+DragHandler subclass:#Generic
+ instanceVariableNames:'prevPoint lastPoint dragBlock'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:DragHandler
+!
+
+DragHandler subclass:#Line
+ instanceVariableNames:'startPoint endPoint lineMode'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:DragHandler
+!
+
+DragHandler subclass:#Opaque
+ instanceVariableNames:'dragSize dragBlock dragOffset saveUnder saveArea tmpForm'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:DragHandler
+!
+
+!DragHandler class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+
+!
+
+documentation
+"
+ this abstract class describes the protocol common to any DragHandler.
+ The DragAndDropManger creates one instance responsible to show the
+ dragging objects on the screen.
+
+ [author:]
+ Claus Gittinger
+
+ [see also:]
+ DragAndDropManager
+"
+
+
+
+! !
+
+!DragHandler class methodsFor:'instance creation'!
+
+startArrowDragAt:aStartPoint
+ "creates and returns the drag handler which is responsible
+ for an arrow drag.
+ "
+ ^ Line new startPoint:aStartPoint mode:#arrow
+!
+
+startGenericDrag:aTwoArgDragBlock
+ "creates and returns the drag handler which is responsible
+ for a generic drag.
+ "
+ ^ Generic new dragBlock:aTwoArgDragBlock
+!
+
+startLineDragAt:aStartPoint
+ "creates and returns the drag handler which is responsible
+ for a line drag.
+ "
+ ^ Line new startPoint:aStartPoint mode:nil
+!
+
+startOpaqueDrag:aTwoArgDragBlock extent:anExtent offset:anOffset
+ "creates and returns the drag handler which is responsible
+ for a generic opaque drag.
+ "
+ ^ Opaque new dragSize:anExtent dragOffset:anOffset dragBlock:aTwoArgDragBlock
+! !
+
+!DragHandler methodsFor:'event dropTarget'!
+
+dropTargetWillChange
+ "called before the drop target or widget changed.
+ restore root view ... (optional)
+ "
+
+!
+
+isInterestedInDropTarget
+ "returns true, if the handler is interested in the underlying
+ drop target and the target should be tested to be able to drop
+ the objects.
+ "
+ ^ true
+
+
+! !
+
+!DragHandler methodsFor:'protocol'!
+
+dragTo:aRootPoint
+ "drag to a root point
+ "
+ self subclassResponsibility
+
+
+!
+
+postDragging
+ "after dragging; restore root view ...
+ "
+ self subclassResponsibility
+
+
+!
+
+preDraggingIn:aSourceWidget
+ "called before starting the drag & drop operation
+ "
+ rootView := aSourceWidget device rootView.
+
+! !
+
+!DragHandler::Generic class methodsFor:'documentation'!
+
+documentation
+"
+ this class handles a generic drag on the screen. It is not visible to
+ the user and is created automatically by the DragAndDropManger.
+
+ [author:]
+ Claus Gittinger
+
+ [see also:]
+ DragAndDropManager
+"
+
+
+! !
+
+!DragHandler::Generic methodsFor:'instance creation'!
+
+dragBlock:aTwoArgBlock
+ "the dragBlock will be called with two arguments, aPoint and the drawing GC,
+ to perform the drawing at some dragPoint.
+ "
+ dragBlock := aTwoArgBlock
+! !
+
+!DragHandler::Generic methodsFor:'protocol'!
+
+dragTo:aRootPoint
+ "drag to a root point
+ "
+ prevPoint notNil ifTrue:[
+ self postDragging
+ ].
+ lastPoint := nil.
+ prevPoint := aRootPoint.
+ self postDragging
+
+
+!
+
+postDragging
+
+ lastPoint isNil ifTrue:[
+ lastPoint := prevPoint.
+ ].
+ rootView clippedByChildren:false.
+
+ rootView xoring:[
+ rootView lineWidth:0.
+ dragBlock value:lastPoint value:rootView.
+ rootView flush
+ ]
+
+! !
+
+!DragHandler::Line class methodsFor:'documentation'!
+
+documentation
+"
+ this class handles a line or arrow drag on the screen. It is not visible to
+ the user and is created automatically by the DragAndDropManger.
+
+ [author:]
+ Claus Gittinger
+
+ [see also:]
+ DragAndDropManager
+"
+
+
+! !
+
+!DragHandler::Line methodsFor:'event dropTarget'!
+
+isInterestedInDropTarget
+ ^ false
+
+
+! !
+
+!DragHandler::Line methodsFor:'instance creation'!
+
+startPoint:aPoint mode:aMode
+
+ lineMode := aMode.
+ startPoint := aPoint.
+
+
+! !
+
+!DragHandler::Line methodsFor:'protocol'!
+
+dragTo:aRootPoint
+ "do a line or arrow drag
+ "
+ self postDragging.
+ endPoint := aRootPoint.
+ self postDragging.
+
+
+!
+
+postDragging
+ "invert for a line or arrow drag
+ "
+ |arrow|
+
+ endPoint isNil ifTrue:[
+ ^ self
+ ].
+ rootView clippedByChildren:false.
+
+ rootView xoring:[
+ rootView lineWidth:0.
+
+ lineMode == #arrow ifTrue:[
+ arrow := Arrow from:startPoint to:endPoint.
+ arrow arrowHeadLength:(rootView device horizontalPixelPerMillimeter * 4) rounded.
+ arrow displayFilledOn:rootView.
+ ] ifFalse:[
+ rootView displayLineFrom:startPoint to:endPoint.
+ ].
+ rootView flush
+ ]
+
+! !
+
+!DragHandler::Opaque class methodsFor:'constants'!
+
+additionalSaveSize
+ ^ 50 @ 50
+
+
+! !
+
+!DragHandler::Opaque class methodsFor:'documentation'!
+
+documentation
+"
+ this class handles an generic opaque drag on the screen. It is not visible
+ to the user and is created automatically by the DragAndDropManger.
+
+ [author:]
+ Claus Gittinger
+
+ [see also:]
+ DragAndDropManager
+"
+
+
+! !
+
+!DragHandler::Opaque methodsFor:'instance creation'!
+
+dragSize:anExtent dragOffset:anOffset dragBlock:aTwoArgBlock
+ "the dragBlock will be called with two arguments, aPoint and the drawing GC,
+ to perform the drawing at some dragPoint.
+ "
+ dragSize := anExtent.
+ dragOffset := anOffset.
+ dragBlock := aTwoArgBlock
+! !
+
+!DragHandler::Opaque methodsFor:'protocol'!
+
+dragTo:aRootPoint
+ "drag to a root point
+ "
+ |p extent point|
+ "/
+ "/ copy from screen to saveUnder
+ "/
+ rootView clippedByChildren:false.
+ extent := saveUnder extent.
+ point := aRootPoint - dragOffset.
+
+ saveArea notNil ifTrue:[
+ ( (saveArea left <= point x)
+ and:[(saveArea top <= point y)
+ and:[(saveArea right >= (point x + dragSize x))
+ and:[(saveArea bottom >= (point y + dragSize y))]]]
+ ) ifFalse:[
+ "/
+ "/ draggable objects no longer contained in saved area;
+ "/ thus we have to restore the saved area on the screen.
+ "/
+ self postDragging
+ ]
+ ].
+
+ saveArea isNil ifTrue:[
+ "/
+ "/ screen not yet saved; thus we have to save the area
+ "/
+ p := point - (self class additionalSaveSize).
+
+ saveUnder copyFrom:rootView
+ x:p x
+ y:p y
+ toX:0
+ y:0
+ width:extent x
+ height:extent y.
+
+ saveArea := p extent:extent.
+ ].
+ "/
+ "/ draw into the form using the dragAction block
+ "/
+ tmpForm copyFrom:saveUnder toX:0 y:0.
+ tmpForm paint:Color black.
+ dragBlock value:(point - saveArea origin + dragOffset) value:tmpForm.
+
+ rootView copyFrom:tmpForm
+ x:saveArea origin x
+ y:saveArea origin y
+ width:extent x
+ height:extent y
+
+
+
+!
+
+dropTargetWillChange
+ "restore old saveArea
+ "
+ self postDragging
+
+
+!
+
+postDragging
+ "restore from saveUnder for a generic opaque drag
+ "
+ saveArea notNil ifTrue:[
+ rootView clippedByChildren:false.
+ "/
+ "/ copy from saveUnder back to screen
+ "/
+ rootView copyFrom:saveUnder
+ x:saveArea origin x
+ y:saveArea origin y
+ width:saveArea extent x
+ height:saveArea extent y.
+
+ saveArea := nil.
+ ]
+
+!
+
+preDraggingIn:aSourceWidget
+ "setup my default values
+ "
+ |depth extent device|
+
+ super preDraggingIn:aSourceWidget.
+
+ device := aSourceWidget device.
+ depth := rootView device depth.
+ extent := dragSize + (2 * (self class additionalSaveSize)).
+ saveUnder := Form extent:extent depth:depth on:device.
+ tmpForm := Form extent:extent depth:depth on:device.
+
+ saveUnder clippedByChildren:false.
+ tmpForm initGC.
+ tmpForm font:(aSourceWidget font).
+
+
+! !
+
+!DragHandler class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DragHandler.st,v 1.1 1998-03-30 12:00:30 ca Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DropContext.st Mon Mar 30 14:00:30 1998 +0200
@@ -0,0 +1,233 @@
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+Object subclass:#DropContext
+ instanceVariableNames:'dropObjects rootPoint dropSource sourceWidget dropTarget
+ targetWidget targetId hasDropped'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-DragAndDrop'
+!
+
+!DropContext class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+!
+
+documentation
+"
+ instance, which keeps information about the current drag & drop operation.
+
+ dropObjects <Collection> collection of dropObjects.
+ rootPoint <Point> the current mouse position on the screen (root view).
+
+ [see also:]
+ DragAndDropManager
+ DropObject
+ DropSource
+ DropTarget
+
+ [author:]
+ Claus Atzkern
+"
+! !
+
+!DropContext methodsFor:'accessing'!
+
+dropObjects
+ "returns the collection of droppable objects
+ "
+ ^ dropObjects ? #()
+!
+
+rootPoint
+ "returns the absolute point on the screen (rootPoint)
+ "
+ ^ rootPoint
+! !
+
+!DropContext methodsFor:'accessing source'!
+
+dropSource
+ "returns the drop source or nil
+ "
+ ^ dropSource
+!
+
+sourceWidget
+ "returns the source widget the drag is started from
+ "
+ ^ sourceWidget
+! !
+
+!DropContext methodsFor:'accessing target'!
+
+dropTarget
+ "returns the drop target or nil
+ "
+ ^ dropTarget
+!
+
+targetId
+ "returns the id of the target widget
+ "
+ ^ targetId
+!
+
+targetPoint
+ "returns the relative point on the target widget
+ "
+ |trn pnt dev|
+
+ dev := sourceWidget device.
+ pnt := dev translatePoint:rootPoint from:(dev rootView id) to:targetId.
+
+ targetWidget notNil ifTrue:[
+ (trn := targetWidget transformation) notNil ifTrue:[
+ ^ trn applyInverseTo:pnt
+ ]
+ ].
+ ^ pnt
+!
+
+targetWidget
+ "returns the widget assigned to the current dropTarget
+ "
+ ^ targetWidget
+! !
+
+!DropContext methodsFor:'actions'!
+
+doDrop
+ "evaluate the drop operation; set the feedBack
+ "
+ hasDropped := self canDrop.
+
+ self isAlienView ifFalse:[
+ hasDropped ifTrue:[
+ dropTarget drop:self
+ ] ifFalse:[
+ "/
+ "/ called to restore the widget in
+ "/ case that something has changed
+ "/
+ dropTarget notNil ifTrue:[
+ dropTarget leave:self
+ ]
+ ]
+ ] ifTrue:[
+ "/
+ "/ not one of my views
+ "/ external clipboard mechanism via display
+ "/
+ "/ ?? FEEDBACK ?? hasDropped ??
+ "/
+ sourceWidget device drop:dropObjects
+ inWindowID:targetId
+ position:(self targetPoint)
+ rootPosition:rootPoint.
+ ].
+
+ dropSource notNil ifTrue:[
+ "/
+ "/ feedBack to dropSource
+ "/
+ dropSource feedBack:self
+ ].
+! !
+
+!DropContext methodsFor:'drag & drop manager interface'!
+
+dropObjects:something
+ "set the collection of droppable objects
+ "
+ something notNil ifTrue:[
+ dropObjects := something isCollection ifTrue:[something]
+ ifFalse:[Array with:something]
+ ]
+!
+
+dropSource:aDropSource
+ "set the dropSource
+ "
+ dropSource := aDropSource.
+!
+
+dropTarget:aDropTargetOrNil
+ "set a new drop target
+ "
+ dropTarget := aDropTargetOrNil.
+!
+
+rootPoint:something
+ "set the absolute point on the screen (rootPoint); called by the drag
+ and drop manager
+ "
+ rootPoint := something.
+!
+
+sourceWidget:aView
+ "set the source widget the drag is started from
+ "
+ sourceWidget := aView.
+!
+
+targetWidget:aViewOrNil id:anId
+ "set a new drop widget
+ "
+ targetWidget := aViewOrNil.
+ targetId := anId.
+! !
+
+!DropContext methodsFor:'queries'!
+
+canDrop
+ "returns true if current dropTarget can drop draggable objects
+ "
+ ^ dropTarget notNil ifTrue:[dropTarget canDrop:self] ifFalse:[false]
+!
+
+hasDropped
+ ^ hasDropped ? false
+!
+
+isAlienView
+ "returns true if current dropTarget is not a ST/X view
+ "
+ ^ targetWidget isNil
+!
+
+isRootView
+ "returns true if the current target widget is the root view (screen)
+ "
+ ^ targetWidget notNil ifTrue:[targetWidget isRootView]
+ ifFalse:[false]
+! !
+
+!DropContext class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DropContext.st,v 1.1 1998-03-30 12:00:14 ca Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DropSource.st Mon Mar 30 14:00:30 1998 +0200
@@ -0,0 +1,270 @@
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+Object subclass:#DropSource
+ instanceVariableNames:'receiver argument feedBackSelector dropObjectSelector
+ displayObjectSelector startDragSelector'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-DragAndDrop'
+!
+
+!DropSource class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+!
+
+documentation
+"
+ this class keeps the source from which the drag and drop operation is started.
+
+ receiver <Object> the receiver of the drop feedBack; a widget or
+ application or ....
+
+ argument <Object> user defined argument
+
+ startDragSelector <Symbol> send to the receiver to start a DragAndDropManager.
+ If no selector is specified, the default drag & drop
+ operation is performed. Thus the operator is able
+ to set the cursor, .... before starting the operation.
+
+ feedBackSelector <Symbol> send to the receiver to give a feedBack of the
+ finished drag & drop operation
+
+ dropObjectSelector <Symbol> used to get to get the list of draggable objects.
+
+ displayObjectSelector <Symbol> used to get to get the list of display objects.
+ In case of an empty or undefined list, the draggable
+ objects are used as display objects.
+
+ [see also:]
+ DragAndDropManager
+ DropObject
+ DropTarget
+ DropContext
+
+ [author:]
+ Claus Atzkern
+"
+! !
+
+!DropSource class methodsFor:'instance creation'!
+
+receiver:aReceiver
+ ^ self new receiver:aReceiver
+!
+
+receiver:aReceiver argument:anArgument
+ ^ self receiver:aReceiver argument:anArgument
+ dropObjectSelector:nil
+ displayObjectSelector:nil
+ feedBackSelector:nil
+!
+
+receiver:aReceiver argument:anArgument dropObjectSelector:aSelector
+
+ ^ self new receiver:aReceiver argument:anArgument
+ dropObjectSelector:aSelector
+ displayObjectSelector:nil
+ feedBackSelector:nil
+!
+
+receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2
+
+ ^ self new receiver:aReceiver argument:anArgument
+ dropObjectSelector:s1
+ displayObjectSelector:s2
+ feedBackSelector:nil
+!
+
+receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2 feedBackSelector:s3
+
+ ^ self new receiver:aReceiver argument:anArgument
+ dropObjectSelector:s1
+ displayObjectSelector:s2
+ feedBackSelector:s3
+! !
+
+!DropSource methodsFor:'accessing'!
+
+argument
+ "returns the user defined argument
+ "
+ ^ argument
+!
+
+argument:anArgument
+ "set the user defined argument
+ "
+ argument := anArgument
+!
+
+displayObjects
+ "returns a collection of display objects or nil
+ "
+ displayObjectSelector isNil ifTrue:[
+ ^ nil
+ ].
+ ^ displayObjectSelector numArgs == 0 ifTrue:[receiver perform:displayObjectSelector]
+ ifFalse:[receiver perform:displayObjectSelector with:self]
+!
+
+dropObjects
+ "returns a collection of objects to drop
+ "
+ dropObjectSelector isNil ifTrue:[
+ ^ nil
+ ].
+
+ ^ dropObjectSelector numArgs == 0 ifTrue:[receiver perform:dropObjectSelector]
+ ifFalse:[receiver perform:dropObjectSelector with:self]
+!
+
+receiver
+ "return the value of the instance variable 'receiver' (automatically generated)"
+
+ ^ receiver!
+
+receiver:something
+ "set the value of the instance variable 'receiver' (automatically generated)"
+
+ receiver := something.! !
+
+!DropSource methodsFor:'accessing selectors'!
+
+displayObjectSelector
+ "selector to access the displayObjects; a sequence of String, Text, Icon or Image,
+ LabelAndIcon ...
+ If an argument is required, the argument is the dropSource (self)
+ "
+ ^ displayObjectSelector
+!
+
+displayObjectSelector:aSelectorWithNoneOrOneArgs
+ "selector to access the displayObjects; a sequence of String, Text, Icon or Image,
+ LabelAndIcon ...
+ If an argument is required, the argument is the dropSource (self)
+ "
+ displayObjectSelector := aSelectorWithNoneOrOneArgs.
+!
+
+dropObjectSelector
+ "selector to access the draggable objects; a sequence of DropObject's
+ If an argument is required, the argument is the dropSource (self)
+ "
+ ^ dropObjectSelector
+!
+
+dropObjectSelector:aSelectorWithNoneOrOneArgs
+ "selector to access the draggable objects; a sequence of DropObject's
+ If an argument is required, the argument is the dropSource (self)
+ "
+ dropObjectSelector := aSelectorWithNoneOrOneArgs.
+!
+
+feedBackSelector
+ "selector called at end of a drop to give a feedback; the argument to
+ the selector is the dropContext
+ "
+ ^ feedBackSelector
+!
+
+feedBackSelector:aSelectorWithNoneOrOneArgs
+ "selector called at end of a drop to give a feedback; the argument to
+ the selector is the dropContext
+ "
+ feedBackSelector := aSelectorWithNoneOrOneArgs.
+!
+
+startDragSelector
+ "send to the receiver to start a DragAndDropManager. If no selector is specified,
+ the default drag & drop operation is performed.
+ Thus the operator is able to set the cursor, .... before starting the operation.
+
+ the arguments to the selector are:
+ 2 aDropSource (self) Widget
+ 3 aDropSource (self) Widget Point
+ "
+ ^ startDragSelector
+!
+
+startDragSelector:aTwoOrThreeArgSelector
+ "send to the receiver to start a DragAndDropManager. If no selector is specified,
+ the default drag & drop operation is performed.
+ Thus the operator is able to set the cursor, .... before starting the operation.
+
+ the arguments to the selector are:
+ 2 aDropSource (self) Widget
+ 3 aDropSource (self) Widget Point
+ "
+ startDragSelector := aTwoOrThreeArgSelector
+! !
+
+!DropSource methodsFor:'actions'!
+
+feedBack:aDropContext
+ "feedback to receiver
+ "
+ feedBackSelector isNil ifTrue:[
+ ^ self
+ ].
+
+ ^ feedBackSelector numArgs == 0 ifTrue:[receiver perform:feedBackSelector]
+ ifFalse:[receiver perform:feedBackSelector with:aDropContext]
+!
+
+startDragIn:aView at:aPoint
+ "start drag operation for a widget
+ "
+ |args|
+
+ startDragSelector notNil ifTrue:[
+ args := startDragSelector numArgs.
+ args == 2 ifTrue:[ ^ receiver perform:startDragSelector with:self with:aView ].
+ args == 3 ifTrue:[ ^ receiver perform:startDragSelector with:self with:aView with:aPoint ].
+ ].
+ "/
+ "/ the default
+ "/
+ DragAndDropManager startDragFrom:aView dropSource:self
+
+! !
+
+!DropSource methodsFor:'instance creation'!
+
+receiver:aReceiver argument:anArgument dropObjectSelector:s1 displayObjectSelector:s2 feedBackSelector:s3
+
+ receiver := aReceiver.
+ argument := anArgument.
+ dropObjectSelector := s1.
+ displayObjectSelector := s2.
+ feedBackSelector := s3.
+! !
+
+!DropSource class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DropSource.st,v 1.1 1998-03-30 11:59:53 ca Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DropTarget.st Mon Mar 30 14:00:30 1998 +0200
@@ -0,0 +1,326 @@
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+Object subclass:#DropTarget
+ instanceVariableNames:'receiver enterSelector leaveSelector overSelector dropSelector
+ canDropSelector argument'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-DragAndDrop'
+!
+
+!DropTarget class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+!
+
+documentation
+"
+ this class keeps the current target of the drop operation; the object respoonsible
+ for the widget under the current mouse position.
+
+ receiver <Object> receiver to which the requests are sent. the
+ widget or an application.
+
+ argument <Object> user defined argument
+
+ enterSelector <Symbol> send the first time to the drop target when entering
+ the widget.
+
+ leaveSelector <Symbol> send the last time to the drop target when leaving
+ the widget.
+
+ overSelector <Symbol> send all the time to the drop target when moveing the
+ mouse over the widget.
+
+ dropSelector <Symbol> send to the drop target to drop the collection of
+ objects.
+
+ canDropSelector <Symbol> send to the drop target to ask if the context could
+ be dropped.
+
+ [see also:]
+ DragAndDropManager
+ DropSource
+ DropContext
+
+ [author:]
+ Claus Atzkern
+"
+
+! !
+
+!DropTarget class methodsFor:'instance creation'!
+
+receiver:aReceiver
+ ^ self new receiver:aReceiver
+!
+
+receiver:aReceiver argument:anArgument
+
+ ^ self new receiver:aReceiver
+ argument:anArgument.
+!
+
+receiver:aReceiver argument:anArgument dropSelector:aSelector
+
+ ^ self new receiver:aReceiver
+ argument:anArgument
+ dropSelector:aSelector
+ canDropSelector:nil
+!
+
+receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2
+
+ ^ self new receiver:aReceiver
+ argument:anArgument
+ dropSelector:s1
+ canDropSelector:s2
+! !
+
+!DropTarget methodsFor:'accessing'!
+
+argument
+ "returns the user defined argument; this argument is used for a drop action
+ with two arguments, the context and the argument
+ "
+ ^ argument
+!
+
+argument:something
+ "set the user defined argument; this argument is used for a drop action
+ with two arguments, the context and the argument
+ "
+ ^ something
+!
+
+canDropSelector
+ "selector called to get a feedback if context is droppable.
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ ^ canDropSelector
+!
+
+canDropSelector:something
+ "selector called to get a feedback if context is droppable.
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ canDropSelector := something.
+!
+
+dropSelector
+ "selector called to drop a collection of draggable objects.
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ ^ dropSelector
+!
+
+dropSelector:something
+ "selector called to drop a collection of draggable objects.
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ dropSelector := something.
+!
+
+enterSelector
+ "send the first time to the drop target when entering the widget.
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ ^ enterSelector
+!
+
+enterSelector:something
+ "send the first time to the drop target when entering the widget.
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ enterSelector := something.
+!
+
+leaveSelector
+ "send the last time to the drop target when leaving the widget.
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ ^ leaveSelector
+!
+
+leaveSelector:something
+ "send the last time to the drop target when leaving the widget.
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ leaveSelector := something.
+!
+
+overSelector
+ "send all the time to the drop target when moveing the mouse over the widget
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ ^ overSelector
+!
+
+overSelector:something
+ "send all the time to the drop target when moveing the mouse over the widget
+
+ the arguments to the selector are:
+ 0 nothing
+ 1 aDropContext
+ 2 aDropContext and the argument
+ "
+ overSelector := something.
+!
+
+receiver
+ "receiver to which the requests are sent. a widget or an application ...
+ "
+ ^ receiver
+!
+
+receiver:something
+ "receiver to which the requests are sent. a widget or an application ...
+ "
+ receiver := something.
+! !
+
+!DropTarget methodsFor:'actions'!
+
+drop:aContext
+ "send when the mouse button is released within the current widget.
+ "
+ self perform:dropSelector withContext:aContext
+!
+
+enter:aContext
+ "send the first time, when entering the widget
+ "
+ self perform:enterSelector withContext:aContext
+!
+
+leave:aContext
+ "send the last time, when leaving the widget
+ "
+ self perform:leaveSelector withContext:aContext
+!
+
+over:aContext
+ "send all the time, when moveing the mouse over the widget
+ "
+ self perform:overSelector withContext:aContext
+
+! !
+
+!DropTarget methodsFor:'instance creation'!
+
+receiver:aReceiver argument:anArgument
+ "set the receiver and an user defined argument
+ "
+ receiver := aReceiver.
+ argument := anArgument.
+!
+
+receiver:aReceiver argument:anArgument dropSelector:s1 canDropSelector:s2
+ "set the receiver and an user defined argument
+ "
+ receiver := aReceiver.
+ argument := anArgument.
+ dropSelector := s1.
+ canDropSelector := s2.
+! !
+
+!DropTarget methodsFor:'private'!
+
+perform:aSelector withContext:aContext
+ "perform the selector
+ "
+ |numArgs|
+
+ aSelector notNil ifTrue:[
+ (numArgs := aSelector numArgs) == 0 ifTrue:[
+ receiver perform:aSelector
+ ] ifFalse:[
+ numArgs == 1 ifTrue:[
+ receiver perform:aSelector with:aContext
+ ] ifFalse:[
+ receiver perform:aSelector with:aContext with:argument
+ ]
+ ]
+ ]
+! !
+
+!DropTarget methodsFor:'queries'!
+
+canDrop:aContext
+ "send to the receiver to ask if the context is droppable
+ "
+ |numArgs|
+
+ canDropSelector notNil ifTrue:[
+ (numArgs := canDropSelector numArgs) == 0 ifTrue:[
+ ^ receiver perform:canDropSelector
+ ].
+ numArgs == 1 ifTrue:[
+ ^ receiver perform:canDropSelector with:aContext
+ ].
+ ^ receiver perform:canDropSelector with:aContext with:argument
+ ].
+ ^ true
+! !
+
+!DropTarget class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.1 1998-03-30 11:59:33 ca Exp $'
+! !