DropContext.st
author Claus Gittinger <cg@exept.de>
Thu, 05 Jun 2008 17:30:14 +0200
changeset 2493 6aa0d6539c5d
parent 2492 5462e31d8af3
child 2564 10ed9ff5b0fc
permissions -rw-r--r--
targetPoint is in DEVICE coordinates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     1
"
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     4
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    11
"
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
    12
"{ Package: 'stx:libview2' }"
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
    13
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    14
Object subclass:#DropContext
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    15
	instanceVariableNames:'dropObjects rootPoint dropSource sourceWidget dropTarget
1662
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    16
		targetWidget targetId hasDropped dragHandler manager dropInfo'
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    17
	classVariableNames:''
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    18
	poolDictionaries:''
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    19
	category:'Interface-DragAndDrop'
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    20
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    21
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    22
!DropContext class methodsFor:'documentation'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    23
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    24
copyright
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    25
"
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    26
 COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    27
              All Rights Reserved
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    28
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    29
 This software is furnished under a license and may be used
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    34
 hereby transferred.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    35
"
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    36
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    37
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    38
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    39
documentation
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    40
"
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    41
    instance, which keeps information about the current drag & drop operation.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    42
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    43
    dropObjects         <Collection>    collection of dropObjects.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    44
    rootPoint           <Point>         the current mouse position on the screen (root view).
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    45
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    46
    [see also:]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    47
        DragAndDropManager
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    48
        DropObject
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    49
        DropSource
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    50
        DropTarget
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    51
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    52
    [author:]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    53
        Claus Atzkern
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    54
"
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    55
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    56
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    57
!DropContext methodsFor:'accessing'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    58
1161
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    59
dragHandler
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    60
    ^ dragHandler
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    61
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    62
!
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    63
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    64
dragHandler:aHandler
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    65
    dragHandler := aHandler
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    66
!
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    67
1662
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    68
dropInfo
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    69
    "a hook for additional info"
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    70
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    71
    dropInfo isNil ifTrue:[
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    72
        dropInfo := IdentityDictionary new
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    73
    ].
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    74
    ^ dropInfo
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    75
!
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
    76
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    77
dropObjects
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    78
    "returns the collection of dropobjects"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    79
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    80
    ^ dropObjects ? #()
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    81
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    82
1618
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
    83
manager:something
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
    84
    manager := something.
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
    85
!
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
    86
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    87
rootPoint
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    88
    "returns the absolute point on the screen (rootPoint)"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    89
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    90
    ^ rootPoint
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    91
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    92
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
    93
!DropContext methodsFor:'accessing-source'!
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    94
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    95
dropSource
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    96
    "returns the drop source or nil"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
    97
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    98
    ^ dropSource
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
    99
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   100
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   101
sourceWidget
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   102
    "returns the source widget the drag is started from"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   103
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   104
    ^ sourceWidget
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   105
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   106
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
   107
!DropContext methodsFor:'accessing-target'!
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   108
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   109
dropTarget
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   110
    "returns the drop target or nil"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   111
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   112
    ^ dropTarget
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   113
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   114
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   115
targetId
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   116
    "returns the id of the target widget"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   117
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   118
    ^ targetId
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   119
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   120
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   121
targetPoint
2493
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   122
    "returns the relative point on the target widget (in DEVICE coordinates)"
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   123
2444
3d985b31faf2 targetPoitn was computed wrong for textViews (scrollOffset)
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   124
    |trn org pnt dev|
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   125
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   126
    dev := sourceWidget device.
1430
572d486a52b8 use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   127
    pnt := dev translatePoint:rootPoint from:(dev rootWindowId) to:targetId.
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   128
2492
5462e31d8af3 fix: care for non.existing targetpoint
Claus Gittinger <cg@exept.de>
parents: 2444
diff changeset
   129
    (pnt notNil and:[targetWidget notNil]) ifTrue:[
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   130
        (trn := targetWidget transformation) notNil ifTrue:[
2444
3d985b31faf2 targetPoitn was computed wrong for textViews (scrollOffset)
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   131
            ^ trn applyInverseTo:pnt.
3d985b31faf2 targetPoitn was computed wrong for textViews (scrollOffset)
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   132
        ].
2493
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   133
        "/ ca: do not translate here - drop is in device coordinates EVERYWHERE
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   134
        "/ (org := targetWidget viewOrigin) notNil ifTrue:[
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   135
        "/     ^ pnt + org.
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   136
        "/ ].
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   137
    ].
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   138
    ^ pnt
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   139
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   140
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   141
targetWidget
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   142
    "returns the widget assigned to the current dropTarget"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   143
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   144
    ^ targetWidget
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   145
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   146
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   147
!DropContext methodsFor:'actions'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   148
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   149
doDrop
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   150
    "evaluate the drop operation; set the feedBack"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   151
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   152
    hasDropped := self canDrop.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   153
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   154
    self isAlienView ifFalse:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   155
        hasDropped ifTrue:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   156
            dropTarget drop:self
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   157
        ] ifFalse:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   158
            "/
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   159
            "/ called to restore the widget in
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   160
            "/ case that something has changed
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   161
            "/
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   162
            dropTarget notNil ifTrue:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   163
                dropTarget leave:self
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   164
            ]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   165
        ]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   166
    ] ifTrue:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   167
        "/
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   168
        "/ not one of my views
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   169
        "/ external clipboard mechanism via display
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   170
        "/
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   171
        "/ ??  FEEDBACK  ??  hasDropped  ??
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   172
        "/
1732
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   173
        sourceWidget device 
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   174
            drop:dropObjects
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   175
            inWindowID:targetId
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   176
            position:(self targetPoint)
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   177
            rootPosition:rootPoint.
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   178
    ].
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   179
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   180
    dropSource notNil ifTrue:[
1732
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   181
        hasDropped ifTrue:[     "/ could have been cleared in drop-code
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   182
            dropSource dropFeedBackFrom:self
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   183
        ]
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   184
    ].
1618
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   185
!
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   186
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
   187
exchangeDragHandler:aHandler 
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
   188
    "make the new handler to the active handler"
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
   189
    
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
   190
    (aHandler notNil and:[ aHandler ~~ dragHandler ]) ifTrue:[
2014
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   191
        dragHandler postDragging.
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   192
        dragHandler := aHandler.
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   193
        manager dragHandler:dragHandler.
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   194
    ].
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   195
!
321b318ab346 exchange active DragHandler
ca
parents: 2000
diff changeset
   196
1662
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   197
passiveAction:aBlock
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   198
    manager passiveAction:aBlock
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   199
!
3ee5036d510c passiveAction and dropInfo
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   200
1618
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   201
saveDraw:aBlock
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   202
    "evaluate aBlock with the drag temporarily being undrawn 
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   203
     (i.e. restore original picture, evaluate the block, and draw dragged objects again).
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   204
     Return blocks value."
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   205
70470d120a13 drop context have to know about his manager
penk
parents: 1430
diff changeset
   206
    ^  manager saveDraw:aBlock
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   207
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   208
1161
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   209
!DropContext methodsFor:'change & update'!
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   210
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   211
contentsWillChange
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   212
    "called by the dropTarget-widget if the contents will change during a
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   213
     dragAndDrop operation"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   214
1161
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   215
    dragHandler notNil ifTrue:[
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   216
        dragHandler dropTargetWillChange
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   217
    ]
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   218
! !
1b0ae7be8de6 keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   219
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   220
!DropContext methodsFor:'drag & drop manager interface'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   221
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   222
dropObjects:something
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   223
    "set the collection of dropobjects"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   224
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   225
    something notNil ifTrue:[
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   226
        dropObjects := something isCollection ifTrue:[something]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   227
                                             ifFalse:[Array with:something]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   228
    ]
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   229
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   230
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   231
dropSource:aDropSource
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   232
    "set the dropSource"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   233
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   234
    dropSource := aDropSource.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   235
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   236
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   237
dropTarget:aDropTargetOrNil
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   238
    "set a new drop target"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   239
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   240
    dropTarget := aDropTargetOrNil.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   241
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   242
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   243
rootPoint:something
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   244
    "set the absolute point on the screen (rootPoint); 
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   245
     called by the drag and drop manager"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   246
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   247
    rootPoint := something.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   248
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   249
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   250
sourceWidget:aView
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   251
    "set the source widget the drag is started from"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   252
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   253
    sourceWidget := aView.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   254
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   255
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   256
targetWidget:aViewOrNil id:anId
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   257
    "set a new drop widget"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   258
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   259
    targetWidget := aViewOrNil.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   260
    targetId     := anId.
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   261
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   262
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   263
!DropContext methodsFor:'queries'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   264
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   265
canDrop
2260
6bd7e8101386 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
   266
    "returns true if the current dropTarget can drop the objects"
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   267
2260
6bd7e8101386 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
   268
    ^ dropTarget notNil and:[dropTarget canDrop:self]
6bd7e8101386 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
   269
6bd7e8101386 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2091
diff changeset
   270
    "Modified: / 13-10-2006 / 15:48:02 / cg"
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   271
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   272
1732
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   273
clearHasDroppedFlagToSuppressFeedBack
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   274
    "can be used from within a targets drop code,
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   275
     to signal that no feedBack should be send to the
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   276
     dropSource (because the drop did not happen)"
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   277
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   278
    hasDropped := false
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   279
!
d31fef80f6e5 feedBackSelector -> dropFeedBackSelector
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
   280
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   281
hasDropped
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   282
    ^ hasDropped ? false
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   283
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   284
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   285
isAlienView
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   286
    "returns true if current dropTarget is not an ST/X view"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   287
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   288
    ^ targetWidget isNil
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   289
!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   290
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   291
isRootView
1824
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   292
    "returns true if the current target widget is the root view (screen)"
518e1e861f7c comments
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   293
2000
64755b92daab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
   294
    ^ targetWidget isNil 
64755b92daab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
   295
        ifTrue:[false]
64755b92daab *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1824
diff changeset
   296
        ifFalse:[targetWidget isRootView]
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   297
! !
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   298
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   299
!DropContext class methodsFor:'documentation'!
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   300
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   301
version
2493
6aa0d6539c5d targetPoint is in DEVICE coordinates
Claus Gittinger <cg@exept.de>
parents: 2492
diff changeset
   302
    ^ '$Header: /cvs/stx/stx/libview2/DropContext.st,v 1.15 2008-06-05 15:30:14 cg Exp $'
873
c5cd8f56dc6e initial checkin
ca
parents:
diff changeset
   303
! !