2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 Add a dropzone to an AppWindow's list of AppWindowDropZones.
8 #include <exec/types.h>
9 #include <exec/ports.h>
10 #include <utility/tagitem.h>
11 #include <intuition/intuition.h>
13 #include "workbench_intern.h"
14 #include <workbench/workbench.h>
15 #include <proto/utility.h>
17 /*****************************************************************************
20 #include <proto/workbench.h>
22 AROS_LH4(struct AppWindowDropZone
*, AddAppWindowDropZoneA
,
25 AROS_LHA(struct AppWindow
*, aw
, A0
),
26 AROS_LHA(ULONG
, id
, D0
),
27 AROS_LHA(ULONG
, userdata
, D1
),
28 AROS_LHA(struct TagItem
* , tags
, A1
),
31 struct WorkbenchBase
*, WorkbenchBase
, 19, Workbench
)
35 A regular AppWindow, when created with AddAppWindowA() will respond to
36 dropping icons anywhere in the window. With this function you can specify
37 which parts of the window are suitable for dropping icons on.
41 aw -- An AppWindow structure as returned by AddAppWindowA()
42 id -- drop zone identifier; for your convenience (ignored by
44 taglist -- tags (see below)
49 Left edge of the drop zone relative to the left window edge.
52 Left edge of the drop zone relative to the right window edge. A value
53 of -20 would create a zone located 20 pixels to the left of the right
57 Top edge of the drop zone relative to the top of the window.
59 WBDZA_RelBottom (WORD)
60 Top edge of the drop zone relative to the window height; a value of -20
61 would create a zone located 20 pixels above the window bottom edge.
64 Widthof the drop zone in pixels.
67 Width of the drop zone relative to the width of the window; a value of
68 -20 would create a zone that is 20 pixels narrower than the window.
71 Height of the drop zone in pixels.
74 Height of the drop zone relative to the height of the window; a value of
75 -20 would create a zone that is 20 pixels smaller than the window.
77 WBDZA_Box (struct IBox *)
78 Position and size of the drop zone
80 WBDZA_Hook (struct Hook *)
81 Pointer to a hook that will be called whenever the mouse enters or leaves
82 your drop zone. The hook will be called with the following parameters.
84 hookFunc(hook, reserved, arm);
86 where the 'hookFunc' is prototyped as:
88 LONG hookFunc(struct Hook *hook, APTR reserved,
89 struct AppWindowDropZoneMsg *adzm);
91 Your hook function should always return 0. You must limit the rendering
92 done in the 'hookFunc' to simple graphics.library operations as otherwise
93 you risk deadlocking the system.
97 A drop zone identifier or NULL if the drop zone could not be created.
101 When a drop zone is installed, the messages received when icons are
102 dropped are of type 'AMTYPE_APPWINDOWZONE' instead of 'AMTYPE_APPWINDOW'.
103 You must be able to handle both types of messages if you call this
105 Drop zones must be created with a position and a size; otherwise this
107 When an icon is dropped on a drop zone, the AppMessage am_MouseX and
108 am_MouseY members will be relative to the window top left corner and NOT
109 relative to the drop zone coordinates.
119 This crap with dropzones should be straightened out. Only ONE type of
120 message should be sent! Question is if there is a backwards compatible
123 ******************************************************************************/
126 AROS_LIBBASE_EXT_DECL(struct WorkbenchBase
*, WorkbenchBase
)
128 struct TagItem
*tagState
= tags
;
131 struct AppWindowDropZone
*dropZone
;
133 dropZone
= AllocVec(sizeof(struct AppWindowDropZone
),
134 MEMF_ANY
| MEMF_CLEAR
);
136 if (dropZone
== NULL
)
141 dropZone
->awdz_ID
= id
;
142 dropZone
->awdz_UserData
= userdata
;
144 while ((tag
= NextTagItem(&tagState
)))
149 dropZone
->awdz_leftSpecifier
= AWDZFlag_fix
;
150 dropZone
->awdz_Box
.Left
= (WORD
)tag
->ti_Data
;
154 dropZone
->awdz_leftSpecifier
= AWDZFlag_relRight
;
155 dropZone
->awdz_Box
.Left
= (WORD
)tag
->ti_Data
;
159 dropZone
->awdz_topSpecifier
= AWDZFlag_fix
;
160 dropZone
->awdz_Box
.Top
= (WORD
)tag
->ti_Data
;
163 case WBDZA_RelBottom
:
164 dropZone
->awdz_topSpecifier
= AWDZFlag_relBottom
;
165 dropZone
->awdz_Box
.Top
= (WORD
)tag
->ti_Data
;
169 dropZone
->awdz_widthSpecifier
= AWDZFlag_fix
;
170 dropZone
->awdz_Box
.Width
= (WORD
)tag
->ti_Data
;
174 dropZone
->awdz_widthSpecifier
= AWDZFlag_relWidth
;
175 dropZone
->awdz_Box
.Width
= (WORD
)tag
->ti_Data
;
179 dropZone
->awdz_heightSpecifier
= AWDZFlag_fix
;
180 dropZone
->awdz_Box
.Height
= (WORD
)tag
->ti_Data
;
183 case WBDZA_RelHeight
:
184 dropZone
->awdz_heightSpecifier
= AWDZFlag_relHeight
;
185 dropZone
->awdz_Box
.Height
= (WORD
)tag
->ti_Data
;
189 dropZone
->awdz_leftSpecifier
= AWDZFlag_fix
;
190 dropZone
->awdz_topSpecifier
= AWDZFlag_fix
;
191 dropZone
->awdz_widthSpecifier
= AWDZFlag_fix
;
192 dropZone
->awdz_heightSpecifier
= AWDZFlag_fix
;
194 if (tag
->ti_Data
!= NULL
)
196 dropZone
->awdz_Box
= *(struct IBox
*)tag
->ti_Data
;
202 if (tag
->ti_Data
!= NULL
)
204 dropZone
->awdz_Hook
= (struct Hook
*)tag
->ti_Data
;
211 /* Could use a local semaphore here... */
213 AddTail(&aw
->aw_DropZones
, (struct Node
*)dropZone
);
216 /* NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_DropZone, WorkbenchBase); */
221 } /* AddAppWindowDropZoneA */