Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / intuition / addglist.c
blob226a5111457c1d0c49231314db97748844578ed0
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$
5 */
7 #include <proto/layers.h>
8 #include "intuition_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <intuition/intuition.h>
14 #include <proto/intuition.h>
15 #include "boopsigadgets.h"
17 #undef DEBUG
18 #define DEBUG 0
19 # include <aros/debug.h>
21 AROS_LH5(UWORD, AddGList,
23 /* SYNOPSIS */
24 AROS_LHA(struct Window *, window, A0),
25 AROS_LHA(struct Gadget *, gadget, A1),
26 AROS_LHA(ULONG , position, D0),
27 AROS_LHA(LONG , numGad, D1),
28 AROS_LHA(struct Requester *, requester, A2),
30 /* LOCATION */
31 struct IntuitionBase *, IntuitionBase, 73, Intuition)
33 /* FUNCTION
34 Add some gadgets to a window.
36 INPUTS
37 window - Add gadgets to this window
38 gadget - This is the list of gadgets to add
39 position - Where to insert the gadgets in the list of gadgets
40 already in the window. Use 0 to insert the gadgets
41 before all others in the window or ~0 to append them.
42 numGad - How many gadgets of the list should be added.
43 Use -1 to add all gadgets in the list.
44 requester - Pointer to the requester structure if the window is
45 a requester.
47 RESULT
48 The actual position where the gadgets were inserted.
50 NOTES
51 The gadgets will just be added. To make them visible, you must
52 refresh the window or the gadgets.
54 EXAMPLE
56 BUGS
58 SEE ALSO
59 RefreshGadgets(), RefresgGList()
61 INTERNALS
63 HISTORY
65 *****************************************************************************/
67 AROS_LIBFUNC_INIT
68 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
70 struct Gadget *pred;
71 struct Gadget *last;
72 UWORD count, count2;
74 EXTENDUWORD(position);
75 EXTENDWORD(numGad);
77 DEBUG_ADDGLIST(dprintf("AddGList: Window 0x%lx Gadget 0x%lx Pos %ld Num %ld Req 0x%lx\n",
78 window, gadget, position, numGad, requester));
80 if (!gadget || !numGad || !window)
81 return (UWORD)-1;
83 D(bug("AddGList()\n"));
85 if (gadget->GadgetType & GTYP_REQGADGET)
87 for (last=gadget, count2 = numGad; last && count2--; last=last->NextGadget)
89 DEBUG_ADDGLIST(dprintf("AddGList: Gadget 0x%lx Flags 0x%lx Type 0x%lx Activation 0x%lx %d,%d %d×%d ID 0x%x\n",
90 last, last->Flags, last->GadgetType, last->Activation,
91 last->LeftEdge, last->TopEdge, last->Width, last->Height,
92 last->GadgetID));
93 last->GadgetType |= GTYP_REQGADGET;
95 pred = (struct Gadget *)&requester->ReqGadget;
97 else
99 for (last=gadget, count2 = numGad; last && count2--; last=last->NextGadget)
101 DEBUG_ADDGLIST(dprintf("AddGList: Gadget 0x%lx Flags 0x%lx Type 0x%lx Activation 0x%lx %d,%d %d×%d ID 0x%lx\n",
102 last, last->Flags, last->GadgetType, last->Activation,
103 last->LeftEdge, last->TopEdge, last->Width, last->Height,
104 last->GadgetID));
105 last->GadgetType &= ~GTYP_REQGADGET;
108 pred = (struct Gadget *)&window->FirstGadget;
109 requester = NULL;
112 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
113 if (!requester || requester->ReqLayer)
115 DEBUG_ADDGLIST(dprintf("AddGList: send layout message\n"));
116 DoGMLayout(gadget, window, requester, numGad, TRUE, IntuitionBase);
117 DEBUG_ADDGLIST(dprintf("AddGList: send layout message done ...\n"));
120 /* gadget list must NOT be modified while gadget accesses are possible */
121 #ifdef USEGADGETLOCK
122 LOCKGADGET
123 #else
124 LOCKWINDOWLAYERS(window);
125 #endif
127 count = 0;
128 while (position && pred->NextGadget)
130 position --;
131 pred = pred->NextGadget;
132 count ++;
133 D(bug("count=%d\n", count));
135 D(bug("Finished iterating window list\n"));
137 count2 = numGad;
138 for (last=gadget; last->NextGadget && --count2; last=last->NextGadget);
140 D(bug("Finished finding end of supplied glist\n"));
141 last->NextGadget = pred->NextGadget;
142 pred->NextGadget = gadget;
144 DEBUG_ADDGLIST(dprintf("AddGList: Pos %ld\n", count));
146 if (!requester || requester->ReqLayer)
148 #if 1
149 /* Refresh REL gadgets first. Wizard.library (die, die, die!) seems to rely on that. */
150 int_refreshglist(gadget, window, requester, numGad, REFRESHGAD_REL, 0, IntuitionBase);
151 int_refreshglist(gadget, window, requester, numGad, 0, REFRESHGAD_REL, IntuitionBase);
152 #else
153 RefreshGList(gadget, window, requester, numGad);
154 #endif
157 #ifdef USEGADGETLOCK
158 UNLOCKGADGET
159 #else
160 UNLOCKWINDOWLAYERS(window);
161 #endif
163 ReturnInt ("AddGList", UWORD, count);
164 AROS_LIBFUNC_EXIT
165 } /* AddGList */