Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / workbench / addappwindowdropzonea.c
blob27eb4a4722c64a2a3f631bf989bfa4e54841961a
1 /*
2 Copyright © 1995-2003, 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
126 AROS_LIBBASE_EXT_DECL(struct WorkbenchBase *, WorkbenchBase)
128 struct TagItem *tagState = tags;
129 struct TagItem *tag;
131 struct AppWindowDropZone *dropZone;
133 dropZone = AllocVec(sizeof(struct AppWindowDropZone),
134 MEMF_ANY | MEMF_CLEAR);
136 if (dropZone == NULL)
138 return NULL;
141 dropZone->awdz_ID = id;
142 dropZone->awdz_UserData = userdata;
144 while ((tag = NextTagItem(&tagState)))
146 switch (tag->ti_Tag)
148 case WBDZA_Left:
149 dropZone->awdz_leftSpecifier = AWDZFlag_fix;
150 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
151 break;
153 case WBDZA_RelRight:
154 dropZone->awdz_leftSpecifier = AWDZFlag_relRight;
155 dropZone->awdz_Box.Left = (WORD)tag->ti_Data;
156 break;
158 case WBDZA_Top:
159 dropZone->awdz_topSpecifier = AWDZFlag_fix;
160 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
161 break;
163 case WBDZA_RelBottom:
164 dropZone->awdz_topSpecifier = AWDZFlag_relBottom;
165 dropZone->awdz_Box.Top = (WORD)tag->ti_Data;
166 break;
168 case WBDZA_Width:
169 dropZone->awdz_widthSpecifier = AWDZFlag_fix;
170 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
171 break;
173 case WBDZA_RelWidth:
174 dropZone->awdz_widthSpecifier = AWDZFlag_relWidth;
175 dropZone->awdz_Box.Width = (WORD)tag->ti_Data;
176 break;
178 case WBDZA_Height:
179 dropZone->awdz_heightSpecifier = AWDZFlag_fix;
180 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
181 break;
183 case WBDZA_RelHeight:
184 dropZone->awdz_heightSpecifier = AWDZFlag_relHeight;
185 dropZone->awdz_Box.Height = (WORD)tag->ti_Data;
186 break;
188 case WBDZA_Box:
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;
199 break;
201 case WBDZA_Hook:
202 if (tag->ti_Data != NULL)
204 dropZone->awdz_Hook = (struct Hook *)tag->ti_Data;
207 break;
211 /* Could use a local semaphore here... */
212 LockWorkbench();
213 AddTail(&aw->aw_DropZones, (struct Node *)dropZone);
214 UnlockWorkbench();
216 /* NotifyWorkbench(WBNOTIFY_Create, WBNOTIFY_DropZone, WorkbenchBase); */
218 return dropZone;
220 AROS_LIBFUNC_EXIT
221 } /* AddAppWindowDropZoneA */