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