64-bit fix. Changed the user-supplied IDs used with
[AROS.git] / workbench / libs / workbench / addappwindowdropzonea.c
blob6699424e964aec04577cc4d385f33503f8a7a09a
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Add a dropzone to an AppWindow's list of AppWindowDropZones.
6 */
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 /*****************************************************************************
18 NAME */
19 #include <proto/workbench.h>
21 AROS_LH4(struct AppWindowDropZone *, AddAppWindowDropZoneA,
23 /* SYNOPSIS */
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),
29 /* LOCATION */
30 struct WorkbenchBase *, WorkbenchBase, 19, Workbench)
32 /* FUNCTION
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.
38 INPUTS
40 aw -- An AppWindow structure as returned by AddAppWindowA()
41 id -- drop zone identifier; for your convenience (ignored by
42 workbench.library)
43 taglist -- tags (see below)
45 TAGS
47 WBDZA_Left (WORD)
48 Left edge of the drop zone relative to the left window edge.
50 WBDZA_RelRight (WORD)
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
53 window edge.
55 WBDZA_Top (WORD)
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.
62 WBDZA_Width (WORD)
63 Widthof the drop zone in pixels.
65 WBDZA_RelWidth (WORD)
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.
69 WBDZA_Height (WORD)
70 Height of the drop zone in pixels.
72 WBDZA_RelHeight
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.
94 RESULT
96 A drop zone identifier or NULL if the drop zone could not be created.
98 NOTES
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
103 function.
104 Drop zones must be created with a position and a size; otherwise this
105 function will fail.
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.
110 EXAMPLE
112 BUGS
114 SEE ALSO
116 INTERNALS
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
120 solution.
122 ******************************************************************************/
124 AROS_LIBFUNC_INIT
126 struct TagItem *tagState = tags;
127 struct TagItem *tag;
129 struct AppWindowDropZone *dropZone;
131 dropZone = AllocVec(sizeof(struct AppWindowDropZone), MEMF_CLEAR);
133 if (dropZone == NULL)
135 return NULL;
138 dropZone->awdz_ID = id;
139 dropZone->awdz_UserData = userdata;
141 while ((tag = NextTagItem(&tagState)))
143 switch (tag->ti_Tag)
145 case WBDZA_Left:
146 dropZone->awdz_leftSpecifier = AWDZFlag_fix;
147 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
148 break;
150 case WBDZA_RelRight:
151 dropZone->awdz_leftSpecifier = AWDZFlag_relRight;
152 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
153 break;
155 case WBDZA_Top:
156 dropZone->awdz_topSpecifier = AWDZFlag_fix;
157 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
158 break;
160 case WBDZA_RelBottom:
161 dropZone->awdz_topSpecifier = AWDZFlag_relBottom;
162 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
163 break;
165 case WBDZA_Width:
166 dropZone->awdz_widthSpecifier = AWDZFlag_fix;
167 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
168 break;
170 case WBDZA_RelWidth:
171 dropZone->awdz_widthSpecifier = AWDZFlag_relWidth;
172 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
173 break;
175 case WBDZA_Height:
176 dropZone->awdz_heightSpecifier = AWDZFlag_fix;
177 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
178 break;
180 case WBDZA_RelHeight:
181 dropZone->awdz_heightSpecifier = AWDZFlag_relHeight;
182 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
183 break;
185 case WBDZA_Box:
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;
196 break;
198 case WBDZA_Hook:
199 if (tag->ti_Data != (IPTR)NULL)
201 dropZone->awdz_Hook = (struct Hook *)tag->ti_Data;
204 break;
208 /* Could use a local semaphore here... */
209 LockWorkbench();
210 AddTail(&aw->aw_DropZones, (struct Node *)dropZone);
211 UnlockWorkbench();
213 /* NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_DropZone, WorkbenchBase); */
215 return dropZone;
217 AROS_LIBFUNC_EXIT
218 } /* AddAppWindowDropZoneA */