Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / intuition / addgadget.c
blob4b22f2cb64b0795fa4c9e9e0dc8f27389ac1b009
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Add a single gadget to a window.
7 */
9 #include <proto/layers.h>
10 #include "intuition_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <intuition/intuition.h>
16 #include <proto/intuition.h>
18 AROS_LH3(UWORD, AddGadget,
20 /* SYNOPSIS */
21 AROS_LHA(struct Window *, window, A0),
22 AROS_LHA(struct Gadget *, gadget, A1),
23 AROS_LHA(ULONG , position, D0),
25 /* LOCATION */
26 struct IntuitionBase *, IntuitionBase, 7, Intuition)
28 /* FUNCTION
29 Adds a single gadget to a window.
31 INPUTS
32 window - Add gadget to this window
33 gadget - Add this gadget
34 position - The position to add the gadget in the list of
35 gadgets already in the window. Use 0 to insert the
36 gadget before all others or ~0 to append it to the
37 list.
39 RESULT
40 The position where the gadget was really inserted.
42 NOTES
43 This just adds the gadget to the list. It will not be visible
44 until you refresh the window.
46 EXAMPLE
48 BUGS
50 SEE ALSO
52 INTERNALS
54 HISTORY
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
59 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
61 struct Gadget *pred;
62 UWORD count;
64 EXTENDUWORD(position);
66 DEBUG_ADDGADGET(dprintf("AddGadget: Window 0x%lx Gadget 0x%lx Pos %ld\n",
67 window, gadget, position));
69 if (!window) return 0;
70 if (!gadget) return 0;
72 gadget->GadgetType &= ~GTYP_REQGADGET;
74 pred = (struct Gadget *)&window->FirstGadget;
75 count = 0;
77 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
78 DoGMLayout(gadget, window, NULL, 1, TRUE, IntuitionBase);
80 //obtain semaphore here. gadget list must NOT be accessed while it's being modified!
81 #ifdef USEGADGETLOCK
82 LOCKGADGET
83 #else
84 LOCKWINDOWLAYERS(window);
85 #endif
87 while (position && pred->NextGadget)
89 position --;
90 pred = pred->NextGadget;
91 count ++;
94 gadget->NextGadget = pred->NextGadget;
95 pred->NextGadget = gadget;
97 #ifdef USEGADGETLOCK
98 UNLOCKGADGET
99 #else
100 UNLOCKWINDOWLAYERS(window);
101 #endif
103 DEBUG_ADDGADGET(dprintf("AddGadget: Pos %ld\n", count));
105 return count;
106 AROS_LIBFUNC_EXIT
107 } /* AddGadget */