2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Add a single gadget to a window.
9 #include <proto/layers.h>
10 #include "intuition_intern.h"
12 /*****************************************************************************
15 #include <intuition/intuition.h>
16 #include <proto/intuition.h>
18 AROS_LH3(UWORD
, AddGadget
,
21 AROS_LHA(struct Window
*, window
, A0
),
22 AROS_LHA(struct Gadget
*, gadget
, A1
),
23 AROS_LHA(ULONG
, position
, D0
),
26 struct IntuitionBase
*, IntuitionBase
, 7, Intuition
)
29 Adds a single gadget to a window.
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
40 The position where the gadget was really inserted.
43 This just adds the gadget to the list. It will not be visible
44 until you refresh the window.
54 *****************************************************************************/
61 EXTENDUWORD(position
);
63 DEBUG_ADDGADGET(dprintf("AddGadget: Window 0x%lx Gadget 0x%lx Pos %ld\n",
64 window
, gadget
, position
));
66 if (!window
) return 0;
67 if (!gadget
) return 0;
69 gadget
->GadgetType
&= ~GTYP_REQGADGET
;
71 pred
= (struct Gadget
*)&window
->FirstGadget
;
74 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
75 DoGMLayout(gadget
, window
, NULL
, 1, TRUE
, IntuitionBase
);
77 //obtain semaphore here. gadget list must NOT be accessed while it's being modified!
79 LOCKGADGET(IntuitionBase
)
81 LOCKWINDOWLAYERS(window
);
84 while (position
&& pred
->NextGadget
)
87 pred
= pred
->NextGadget
;
91 gadget
->NextGadget
= pred
->NextGadget
;
92 pred
->NextGadget
= gadget
;
95 UNLOCKGADGET(IntuitionBase
)
97 UNLOCKWINDOWLAYERS(window
);
100 DEBUG_ADDGADGET(dprintf("AddGadget: Pos %ld\n", count
));