DragAndDropManager.st
author Claus Gittinger <cg@exept.de>
Sat, 26 Oct 1996 16:40:21 +0200
changeset 341 5afe98e6185b
child 342 7563cbf04502
permissions -rw-r--r--
intitial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
Object subclass:#DragAndDropManager
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
	instanceVariableNames:'dragView motionAction releaseAction initialPoint previousPoint
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
		rememberedDelegate'
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	classVariableNames:''
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	poolDictionaries:''
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	category:'Interface-Support'
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
View subclass:#DragAndDropTestClass
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	instanceVariableNames:''
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	classVariableNames:''
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
	poolDictionaries:''
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
	privateIn:DragAndDropManager
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
history
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    "Created: 26.10.1996 / 15:02:00 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    "Modified: 26.10.1996 / 15:21:42 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!DragAndDropManager privateMethodsFor:'dragging - lines'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
doLineDragX:x y:y
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    previousPoint notNil ifTrue:[
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
        self invertLineFrom:initialPoint to:previousPoint
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
    ].
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    previousPoint := x @ y.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
    self invertLineFrom:initialPoint to:previousPoint
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
    "Modified: 26.10.1996 / 15:16:59 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
endLineDragX:x y:y
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
    previousPoint notNil ifTrue:[
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
        self invertLineFrom:initialPoint to:previousPoint
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    ].
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    previousPoint := nil.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    self uncatchEvents
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    "Created: 26.10.1996 / 15:17:20 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    "Modified: 26.10.1996 / 15:22:41 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
invertLineFrom:ip1 to:ip2
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    |t offs p1 p2 rootView|
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    rootView := dragView device rootView.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    p1 := ip1.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    p2 := ip2.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
     get device coordinates
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    (t := dragView transformation) notNil ifTrue:[
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        p1 := t applyTo:p1.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        p2 := t applyTo:p2.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    ].
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     translate to screen
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    offs := dragView device 
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
                translatePoint:0@0 
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
                from:(dragView id) to:(rootView id).
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    p1 := p1 + offs.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    p2 := p2 + offs.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    rootView clippedByChildren:false.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    rootView xoring:[
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        rootView lineWidth:0. 
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        rootView displayLineFrom:p1 to:p2.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        rootView flush
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    ].
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "Created: 26.10.1996 / 15:15:26 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "Modified: 26.10.1996 / 15:27:09 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
!DragAndDropManager methodsFor:'dragging - lines'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
setupForLineDragFrom:aView at:p
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    self catchEventsFrom:aView.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    motionAction := #doLineDragX:y:.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    releaseAction := #endLineDragX:y:.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    initialPoint := p.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    previousPoint := nil
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "Modified: 26.10.1996 / 15:09:26 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "Created: 26.10.1996 / 15:16:13 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!DragAndDropManager methodsFor:'event catching'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
buttonMotion:button x:x y:y view:aView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    self perform:motionAction with:x with:y
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "Created: 26.10.1996 / 15:09:00 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
buttonRelease:button x:x y:y view:aView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    self perform:releaseAction with:x with:y
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "Created: 26.10.1996 / 15:09:14 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
handlesButtonMotion:button inView:aView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "query from event processor: am I interested in button-events ?
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
     yes I am (to activate the clicked-on field)."
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    ^ aView == dragView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "Created: 26.10.1996 / 15:05:36 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
handlesButtonRelease:button inView:aView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    "query from event processor: am I interested in button-events ?
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
     yes I am (to activate the clicked-on field)."
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    ^ aView == dragView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "Created: 26.10.1996 / 15:05:48 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!DragAndDropManager methodsFor:'private'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
catchEventsFrom:aView
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    dragView := aView.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    rememberedDelegate := aView delegate.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    aView delegate:self
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    "Created: 26.10.1996 / 15:03:12 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    "Modified: 26.10.1996 / 15:21:57 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
uncatchEvents
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    dragView delegate:rememberedDelegate.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    dragView := nil.
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    "Created: 26.10.1996 / 15:22:29 / cg"
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!DragAndDropManager::DragAndDropTestClass methodsFor:'events'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
buttonPress:button x:x y:y
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    DragAndDropManager new
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        setupForLineDragFrom:self at:(x@y)
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     self new open
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    "
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
version
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.1 1996-10-26 14:40:21 cg Exp $'
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
! !