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