Workaround for includes conflict that stopped compilation with GCC 3.
[cake.git] / rom / workbench / addappwindowdropzonea.c
blobd1d8ed187a53c66e3ce1c6ad9bc50ac0e03f4d93
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Add a dropzone to an AppWindow's list of AppWindowDropZones.
6 */
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 /*****************************************************************************
19 NAME */
20 #include <proto/workbench.h>
22 AROS_LH4(struct AppWindowDropZone *, AddAppWindowDropZoneA,
24 /* SYNOPSIS */
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),
30 /* LOCATION */
31 struct WorkbenchBase *, WorkbenchBase, 19, Workbench)
33 /* FUNCTION
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.
39 INPUTS
41 aw -- An AppWindow structure as returned by AddAppWindowA()
42 id -- drop zone identifier; for your convenience (ignored by
43 workbench.library)
44 taglist -- tags (see below)
46 TAGS
48 WBDZA_Left (WORD)
49 Left edge of the drop zone relative to the left window edge.
51 WBDZA_RelRight (WORD)
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
54 window edge.
56 WBDZA_Top (WORD)
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.
63 WBDZA_Width (WORD)
64 Widthof the drop zone in pixels.
66 WBDZA_RelWidth (WORD)
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.
70 WBDZA_Height (WORD)
71 Height of the drop zone in pixels.
73 WBDZA_RelHeight
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.
95 RESULT
97 A drop zone identifier or NULL if the drop zone could not be created.
99 NOTES
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
104 function.
105 Drop zones must be created with a position and a size; otherwise this
106 function will fail.
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.
111 EXAMPLE
113 BUGS
115 SEE ALSO
117 INTERNALS
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
121 solution.
123 ******************************************************************************/
125 AROS_LIBFUNC_INIT
127 const struct TagItem *tagState = tags;
128 const struct TagItem *tag;
130 struct AppWindowDropZone *dropZone;
132 dropZone = AllocVec(sizeof(struct AppWindowDropZone), MEMF_CLEAR);
134 if (dropZone == NULL)
136 return NULL;
139 dropZone->awdz_ID = id;
140 dropZone->awdz_UserData = userdata;
142 while ((tag = NextTagItem(&tagState)))
144 switch (tag->ti_Tag)
146 case WBDZA_Left:
147 dropZone->awdz_leftSpecifier = AWDZFlag_fix;
148 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
149 break;
151 case WBDZA_RelRight:
152 dropZone->awdz_leftSpecifier = AWDZFlag_relRight;
153 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
154 break;
156 case WBDZA_Top:
157 dropZone->awdz_topSpecifier = AWDZFlag_fix;
158 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
159 break;
161 case WBDZA_RelBottom:
162 dropZone->awdz_topSpecifier = AWDZFlag_relBottom;
163 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
164 break;
166 case WBDZA_Width:
167 dropZone->awdz_widthSpecifier = AWDZFlag_fix;
168 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
169 break;
171 case WBDZA_RelWidth:
172 dropZone->awdz_widthSpecifier = AWDZFlag_relWidth;
173 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
174 break;
176 case WBDZA_Height:
177 dropZone->awdz_heightSpecifier = AWDZFlag_fix;
178 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
179 break;
181 case WBDZA_RelHeight:
182 dropZone->awdz_heightSpecifier = AWDZFlag_relHeight;
183 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
184 break;
186 case WBDZA_Box:
187 dropZone->awdz_leftSpecifier = AWDZFlag_fix;
188 dropZone->awdz_topSpecifier = AWDZFlag_fix;
189 dropZone->awdz_widthSpecifier = AWDZFlag_fix;
190 dropZone->awdz_heightSpecifier = AWDZFlag_fix;
192 if (tag->ti_Data != NULL)
194 dropZone->awdz_Box = *(struct IBox *)tag->ti_Data;
197 break;
199 case WBDZA_Hook:
200 if (tag->ti_Data != NULL)
202 dropZone->awdz_Hook = (struct Hook *)tag->ti_Data;
205 break;
209 /* Could use a local semaphore here... */
210 LockWorkbench();
211 AddTail(&aw->aw_DropZones, (struct Node *)dropZone);
212 UnlockWorkbench();
214 /* NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_DropZone, WorkbenchBase); */
216 return dropZone;
218 AROS_LIBFUNC_EXIT
219 } /* AddAppWindowDropZoneA */