author | Claus Gittinger <cg@exept.de> |
Wed, 01 Dec 1999 21:25:19 +0100 | |
changeset 1278 | 0fc24ae3a3e3 |
parent 1161 | 1b0ae7be8de6 |
child 1397 | 47ac1d3e1df1 |
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 |
||
14 |
Object subclass:#DropContext |
|
15 |
instanceVariableNames:'dropObjects rootPoint dropSource sourceWidget dropTarget |
|
1161
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
16 |
targetWidget targetId hasDropped dragHandler' |
873 | 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 |
||
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 |
|
873 | 68 |
dropObjects |
69 |
"returns the collection of droppable objects |
|
70 |
" |
|
71 |
^ dropObjects ? #() |
|
72 |
! |
|
73 |
||
74 |
rootPoint |
|
75 |
"returns the absolute point on the screen (rootPoint) |
|
76 |
" |
|
77 |
^ rootPoint |
|
78 |
! ! |
|
79 |
||
80 |
!DropContext methodsFor:'accessing source'! |
|
81 |
||
82 |
dropSource |
|
83 |
"returns the drop source or nil |
|
84 |
" |
|
85 |
^ dropSource |
|
86 |
! |
|
87 |
||
88 |
sourceWidget |
|
89 |
"returns the source widget the drag is started from |
|
90 |
" |
|
91 |
^ sourceWidget |
|
92 |
! ! |
|
93 |
||
94 |
!DropContext methodsFor:'accessing target'! |
|
95 |
||
96 |
dropTarget |
|
97 |
"returns the drop target or nil |
|
98 |
" |
|
99 |
^ dropTarget |
|
100 |
! |
|
101 |
||
102 |
targetId |
|
103 |
"returns the id of the target widget |
|
104 |
" |
|
105 |
^ targetId |
|
106 |
! |
|
107 |
||
108 |
targetPoint |
|
109 |
"returns the relative point on the target widget |
|
110 |
" |
|
111 |
|trn pnt dev| |
|
112 |
||
113 |
dev := sourceWidget device. |
|
114 |
pnt := dev translatePoint:rootPoint from:(dev rootView id) to:targetId. |
|
115 |
||
116 |
targetWidget notNil ifTrue:[ |
|
117 |
(trn := targetWidget transformation) notNil ifTrue:[ |
|
118 |
^ trn applyInverseTo:pnt |
|
119 |
] |
|
120 |
]. |
|
121 |
^ pnt |
|
122 |
! |
|
123 |
||
124 |
targetWidget |
|
125 |
"returns the widget assigned to the current dropTarget |
|
126 |
" |
|
127 |
^ targetWidget |
|
128 |
! ! |
|
129 |
||
130 |
!DropContext methodsFor:'actions'! |
|
131 |
||
132 |
doDrop |
|
133 |
"evaluate the drop operation; set the feedBack |
|
134 |
" |
|
135 |
hasDropped := self canDrop. |
|
136 |
||
137 |
self isAlienView ifFalse:[ |
|
138 |
hasDropped ifTrue:[ |
|
139 |
dropTarget drop:self |
|
140 |
] ifFalse:[ |
|
141 |
"/ |
|
142 |
"/ called to restore the widget in |
|
143 |
"/ case that something has changed |
|
144 |
"/ |
|
145 |
dropTarget notNil ifTrue:[ |
|
146 |
dropTarget leave:self |
|
147 |
] |
|
148 |
] |
|
149 |
] ifTrue:[ |
|
150 |
"/ |
|
151 |
"/ not one of my views |
|
152 |
"/ external clipboard mechanism via display |
|
153 |
"/ |
|
154 |
"/ ?? FEEDBACK ?? hasDropped ?? |
|
155 |
"/ |
|
156 |
sourceWidget device drop:dropObjects |
|
157 |
inWindowID:targetId |
|
158 |
position:(self targetPoint) |
|
159 |
rootPosition:rootPoint. |
|
160 |
]. |
|
161 |
||
162 |
dropSource notNil ifTrue:[ |
|
163 |
"/ |
|
164 |
"/ feedBack to dropSource |
|
165 |
"/ |
|
166 |
dropSource feedBack:self |
|
167 |
]. |
|
168 |
! ! |
|
169 |
||
1161
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
170 |
!DropContext methodsFor:'change & update'! |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
171 |
|
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
172 |
contentsWillChange |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
173 |
"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
|
174 |
dragAndDrop operation |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
175 |
" |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
176 |
dragHandler notNil ifTrue:[ |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
177 |
dragHandler dropTargetWillChange |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
178 |
] |
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
179 |
|
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 |
|
873 | 183 |
!DropContext methodsFor:'drag & drop manager interface'! |
184 |
||
185 |
dropObjects:something |
|
186 |
"set the collection of droppable objects |
|
187 |
" |
|
188 |
something notNil ifTrue:[ |
|
189 |
dropObjects := something isCollection ifTrue:[something] |
|
190 |
ifFalse:[Array with:something] |
|
191 |
] |
|
192 |
! |
|
193 |
||
194 |
dropSource:aDropSource |
|
195 |
"set the dropSource |
|
196 |
" |
|
197 |
dropSource := aDropSource. |
|
198 |
! |
|
199 |
||
200 |
dropTarget:aDropTargetOrNil |
|
201 |
"set a new drop target |
|
202 |
" |
|
203 |
dropTarget := aDropTargetOrNil. |
|
204 |
! |
|
205 |
||
206 |
rootPoint:something |
|
207 |
"set the absolute point on the screen (rootPoint); called by the drag |
|
208 |
and drop manager |
|
209 |
" |
|
210 |
rootPoint := something. |
|
211 |
! |
|
212 |
||
213 |
sourceWidget:aView |
|
214 |
"set the source widget the drag is started from |
|
215 |
" |
|
216 |
sourceWidget := aView. |
|
217 |
! |
|
218 |
||
219 |
targetWidget:aViewOrNil id:anId |
|
220 |
"set a new drop widget |
|
221 |
" |
|
222 |
targetWidget := aViewOrNil. |
|
223 |
targetId := anId. |
|
224 |
! ! |
|
225 |
||
226 |
!DropContext methodsFor:'queries'! |
|
227 |
||
228 |
canDrop |
|
229 |
"returns true if current dropTarget can drop draggable objects |
|
230 |
" |
|
231 |
^ dropTarget notNil ifTrue:[dropTarget canDrop:self] ifFalse:[false] |
|
232 |
! |
|
233 |
||
234 |
hasDropped |
|
235 |
^ hasDropped ? false |
|
236 |
! |
|
237 |
||
238 |
isAlienView |
|
239 |
"returns true if current dropTarget is not a ST/X view |
|
240 |
" |
|
241 |
^ targetWidget isNil |
|
242 |
! |
|
243 |
||
244 |
isRootView |
|
245 |
"returns true if the current target widget is the root view (screen) |
|
246 |
" |
|
247 |
^ targetWidget notNil ifTrue:[targetWidget isRootView] |
|
248 |
ifFalse:[false] |
|
249 |
! ! |
|
250 |
||
251 |
!DropContext class methodsFor:'documentation'! |
|
252 |
||
253 |
version |
|
1161
1b0ae7be8de6
keep reference to DragHandler
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
254 |
^ '$Header: /cvs/stx/stx/libview2/DropContext.st,v 1.2 1999-04-16 14:18:19 cg Exp $' |
873 | 255 |
! ! |