873
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
Object subclass:#DropContext
|
|
15 |
instanceVariableNames:'dropObjects rootPoint dropSource sourceWidget dropTarget
|
|
16 |
targetWidget targetId hasDropped'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Interface-DragAndDrop'
|
|
20 |
!
|
|
21 |
|
|
22 |
!DropContext class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1998 by eXept Software AG / Claus Gittinger
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
|
|
37 |
!
|
|
38 |
|
|
39 |
documentation
|
|
40 |
"
|
|
41 |
instance, which keeps information about the current drag & drop operation.
|
|
42 |
|
|
43 |
dropObjects <Collection> collection of dropObjects.
|
|
44 |
rootPoint <Point> the current mouse position on the screen (root view).
|
|
45 |
|
|
46 |
[see also:]
|
|
47 |
DragAndDropManager
|
|
48 |
DropObject
|
|
49 |
DropSource
|
|
50 |
DropTarget
|
|
51 |
|
|
52 |
[author:]
|
|
53 |
Claus Atzkern
|
|
54 |
"
|
|
55 |
! !
|
|
56 |
|
|
57 |
!DropContext methodsFor:'accessing'!
|
|
58 |
|
|
59 |
dropObjects
|
|
60 |
"returns the collection of droppable objects
|
|
61 |
"
|
|
62 |
^ dropObjects ? #()
|
|
63 |
!
|
|
64 |
|
|
65 |
rootPoint
|
|
66 |
"returns the absolute point on the screen (rootPoint)
|
|
67 |
"
|
|
68 |
^ rootPoint
|
|
69 |
! !
|
|
70 |
|
|
71 |
!DropContext methodsFor:'accessing source'!
|
|
72 |
|
|
73 |
dropSource
|
|
74 |
"returns the drop source or nil
|
|
75 |
"
|
|
76 |
^ dropSource
|
|
77 |
!
|
|
78 |
|
|
79 |
sourceWidget
|
|
80 |
"returns the source widget the drag is started from
|
|
81 |
"
|
|
82 |
^ sourceWidget
|
|
83 |
! !
|
|
84 |
|
|
85 |
!DropContext methodsFor:'accessing target'!
|
|
86 |
|
|
87 |
dropTarget
|
|
88 |
"returns the drop target or nil
|
|
89 |
"
|
|
90 |
^ dropTarget
|
|
91 |
!
|
|
92 |
|
|
93 |
targetId
|
|
94 |
"returns the id of the target widget
|
|
95 |
"
|
|
96 |
^ targetId
|
|
97 |
!
|
|
98 |
|
|
99 |
targetPoint
|
|
100 |
"returns the relative point on the target widget
|
|
101 |
"
|
|
102 |
|trn pnt dev|
|
|
103 |
|
|
104 |
dev := sourceWidget device.
|
|
105 |
pnt := dev translatePoint:rootPoint from:(dev rootView id) to:targetId.
|
|
106 |
|
|
107 |
targetWidget notNil ifTrue:[
|
|
108 |
(trn := targetWidget transformation) notNil ifTrue:[
|
|
109 |
^ trn applyInverseTo:pnt
|
|
110 |
]
|
|
111 |
].
|
|
112 |
^ pnt
|
|
113 |
!
|
|
114 |
|
|
115 |
targetWidget
|
|
116 |
"returns the widget assigned to the current dropTarget
|
|
117 |
"
|
|
118 |
^ targetWidget
|
|
119 |
! !
|
|
120 |
|
|
121 |
!DropContext methodsFor:'actions'!
|
|
122 |
|
|
123 |
doDrop
|
|
124 |
"evaluate the drop operation; set the feedBack
|
|
125 |
"
|
|
126 |
hasDropped := self canDrop.
|
|
127 |
|
|
128 |
self isAlienView ifFalse:[
|
|
129 |
hasDropped ifTrue:[
|
|
130 |
dropTarget drop:self
|
|
131 |
] ifFalse:[
|
|
132 |
"/
|
|
133 |
"/ called to restore the widget in
|
|
134 |
"/ case that something has changed
|
|
135 |
"/
|
|
136 |
dropTarget notNil ifTrue:[
|
|
137 |
dropTarget leave:self
|
|
138 |
]
|
|
139 |
]
|
|
140 |
] ifTrue:[
|
|
141 |
"/
|
|
142 |
"/ not one of my views
|
|
143 |
"/ external clipboard mechanism via display
|
|
144 |
"/
|
|
145 |
"/ ?? FEEDBACK ?? hasDropped ??
|
|
146 |
"/
|
|
147 |
sourceWidget device drop:dropObjects
|
|
148 |
inWindowID:targetId
|
|
149 |
position:(self targetPoint)
|
|
150 |
rootPosition:rootPoint.
|
|
151 |
].
|
|
152 |
|
|
153 |
dropSource notNil ifTrue:[
|
|
154 |
"/
|
|
155 |
"/ feedBack to dropSource
|
|
156 |
"/
|
|
157 |
dropSource feedBack:self
|
|
158 |
].
|
|
159 |
! !
|
|
160 |
|
|
161 |
!DropContext methodsFor:'drag & drop manager interface'!
|
|
162 |
|
|
163 |
dropObjects:something
|
|
164 |
"set the collection of droppable objects
|
|
165 |
"
|
|
166 |
something notNil ifTrue:[
|
|
167 |
dropObjects := something isCollection ifTrue:[something]
|
|
168 |
ifFalse:[Array with:something]
|
|
169 |
]
|
|
170 |
!
|
|
171 |
|
|
172 |
dropSource:aDropSource
|
|
173 |
"set the dropSource
|
|
174 |
"
|
|
175 |
dropSource := aDropSource.
|
|
176 |
!
|
|
177 |
|
|
178 |
dropTarget:aDropTargetOrNil
|
|
179 |
"set a new drop target
|
|
180 |
"
|
|
181 |
dropTarget := aDropTargetOrNil.
|
|
182 |
!
|
|
183 |
|
|
184 |
rootPoint:something
|
|
185 |
"set the absolute point on the screen (rootPoint); called by the drag
|
|
186 |
and drop manager
|
|
187 |
"
|
|
188 |
rootPoint := something.
|
|
189 |
!
|
|
190 |
|
|
191 |
sourceWidget:aView
|
|
192 |
"set the source widget the drag is started from
|
|
193 |
"
|
|
194 |
sourceWidget := aView.
|
|
195 |
!
|
|
196 |
|
|
197 |
targetWidget:aViewOrNil id:anId
|
|
198 |
"set a new drop widget
|
|
199 |
"
|
|
200 |
targetWidget := aViewOrNil.
|
|
201 |
targetId := anId.
|
|
202 |
! !
|
|
203 |
|
|
204 |
!DropContext methodsFor:'queries'!
|
|
205 |
|
|
206 |
canDrop
|
|
207 |
"returns true if current dropTarget can drop draggable objects
|
|
208 |
"
|
|
209 |
^ dropTarget notNil ifTrue:[dropTarget canDrop:self] ifFalse:[false]
|
|
210 |
!
|
|
211 |
|
|
212 |
hasDropped
|
|
213 |
^ hasDropped ? false
|
|
214 |
!
|
|
215 |
|
|
216 |
isAlienView
|
|
217 |
"returns true if current dropTarget is not a ST/X view
|
|
218 |
"
|
|
219 |
^ targetWidget isNil
|
|
220 |
!
|
|
221 |
|
|
222 |
isRootView
|
|
223 |
"returns true if the current target widget is the root view (screen)
|
|
224 |
"
|
|
225 |
^ targetWidget notNil ifTrue:[targetWidget isRootView]
|
|
226 |
ifFalse:[false]
|
|
227 |
! !
|
|
228 |
|
|
229 |
!DropContext class methodsFor:'documentation'!
|
|
230 |
|
|
231 |
version
|
|
232 |
^ '$Header: /cvs/stx/stx/libview2/DropContext.st,v 1.1 1998-03-30 12:00:14 ca Exp $'
|
|
233 |
! !
|