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