2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Add a dropzone to an AppWindow's list of AppWindowDropZones.
8 #include <exec/ports.h>
9 #include <utility/tagitem.h>
10 #include <intuition/intuition.h>
11 #include <workbench/workbench.h>
12 #include <proto/utility.h>
14 #include "workbench_intern.h"
16 /*****************************************************************************
19 #include <proto/workbench.h>
21 AROS_LH4(struct AppWindowDropZone
*, AddAppWindowDropZoneA
,
24 AROS_LHA(struct AppWindow
*, aw
, A0
),
25 AROS_LHA(IPTR
, id
, D0
),
26 AROS_LHA(IPTR
, userdata
, D1
),
27 AROS_LHA(struct TagItem
* , tags
, A1
),
30 struct WorkbenchBase
*, WorkbenchBase
, 19, Workbench
)
34 A regular AppWindow, when created with AddAppWindowA() will respond to
35 dropping icons anywhere in the window. With this function you can specify
36 which parts of the window are suitable for dropping icons on.
40 aw -- An AppWindow structure as returned by AddAppWindowA()
41 id -- drop zone identifier; for your convenience (ignored by
43 taglist -- tags (see below)
48 Left edge of the drop zone relative to the left window edge.
51 Left edge of the drop zone relative to the right window edge. A value
52 of -20 would create a zone located 20 pixels to the left of the right
56 Top edge of the drop zone relative to the top of the window.
58 WBDZA_RelBottom (WORD)
59 Top edge of the drop zone relative to the window height; a value of -20
60 would create a zone located 20 pixels above the window bottom edge.
63 Widthof the drop zone in pixels.
66 Width of the drop zone relative to the width of the window; a value of
67 -20 would create a zone that is 20 pixels narrower than the window.
70 Height of the drop zone in pixels.
73 Height of the drop zone relative to the height of the window; a value of
74 -20 would create a zone that is 20 pixels smaller than the window.
76 WBDZA_Box (struct IBox *)
77 Position and size of the drop zone
79 WBDZA_Hook (struct Hook *)
80 Pointer to a hook that will be called whenever the mouse enters or leaves
81 your drop zone. The hook will be called with the following parameters.
83 hookFunc(hook, reserved, arm);
85 where the 'hookFunc' is prototyped as:
87 LONG hookFunc(struct Hook *hook, APTR reserved,
88 struct AppWindowDropZoneMsg *adzm);
90 Your hook function should always return 0. You must limit the rendering
91 done in the 'hookFunc' to simple graphics.library operations as otherwise
92 you risk deadlocking the system.
96 A drop zone identifier or NULL if the drop zone could not be created.
100 When a drop zone is installed, the messages received when icons are
101 dropped are of type 'AMTYPE_APPWINDOWZONE' instead of 'AMTYPE_APPWINDOW'.
102 You must be able to handle both types of messages if you call this
104 Drop zones must be created with a position and a size; otherwise this
106 When an icon is dropped on a drop zone, the AppMessage am_MouseX and
107 am_MouseY members will be relative to the window top left corner and NOT
108 relative to the drop zone coordinates.
118 This crap with dropzones should be straightened out. Only ONE type of
119 message should be sent! Question is if there is a backwards compatible
122 ******************************************************************************/
126 struct TagItem
*tagState
= tags
;
129 struct AppWindowDropZone
*dropZone
;
131 dropZone
= AllocVec(sizeof(struct AppWindowDropZone
), MEMF_CLEAR
);
133 if (dropZone
== NULL
)
138 dropZone
->awdz_ID
= id
;
139 dropZone
->awdz_UserData
= userdata
;
141 while ((tag
= NextTagItem(&tagState
)))
146 dropZone
->awdz_leftSpecifier
= AWDZFlag_fix
;
147 dropZone
->awdz_Box
.Left
= (WORD
)tag
->ti_Data
;
151 dropZone
->awdz_leftSpecifier
= AWDZFlag_relRight
;
152 dropZone
->awdz_Box
.Left
= (WORD
)tag
->ti_Data
;
156 dropZone
->awdz_topSpecifier
= AWDZFlag_fix
;
157 dropZone
->awdz_Box
.Top
= (WORD
)tag
->ti_Data
;
160 case WBDZA_RelBottom
:
161 dropZone
->awdz_topSpecifier
= AWDZFlag_relBottom
;
162 dropZone
->awdz_Box
.Top
= (WORD
)tag
->ti_Data
;
166 dropZone
->awdz_widthSpecifier
= AWDZFlag_fix
;
167 dropZone
->awdz_Box
.Width
= (WORD
)tag
->ti_Data
;
171 dropZone
->awdz_widthSpecifier
= AWDZFlag_relWidth
;
172 dropZone
->awdz_Box
.Width
= (WORD
)tag
->ti_Data
;
176 dropZone
->awdz_heightSpecifier
= AWDZFlag_fix
;
177 dropZone
->awdz_Box
.Height
= (WORD
)tag
->ti_Data
;
180 case WBDZA_RelHeight
:
181 dropZone
->awdz_heightSpecifier
= AWDZFlag_relHeight
;
182 dropZone
->awdz_Box
.Height
= (WORD
)tag
->ti_Data
;
186 dropZone
->awdz_leftSpecifier
= AWDZFlag_fix
;
187 dropZone
->awdz_topSpecifier
= AWDZFlag_fix
;
188 dropZone
->awdz_widthSpecifier
= AWDZFlag_fix
;
189 dropZone
->awdz_heightSpecifier
= AWDZFlag_fix
;
191 if (tag
->ti_Data
!= (IPTR
)NULL
)
193 dropZone
->awdz_Box
= *(struct IBox
*)tag
->ti_Data
;
199 if (tag
->ti_Data
!= (IPTR
)NULL
)
201 dropZone
->awdz_Hook
= (struct Hook
*)tag
->ti_Data
;
208 /* Could use a local semaphore here... */
210 AddTail(&aw
->aw_DropZones
, (struct Node
*)dropZone
);
213 /* NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_DropZone, WorkbenchBase); */
218 } /* AddAppWindowDropZoneA */