include/muimaster/macros.h: get() compiler delint
[AROS.git] / workbench / libs / gadtools / freegadgets.c
blobb7f0c687a326dd77d91f18fbc06f7b8cab8aa9a5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "gadtools_intern.h"
11 /*********************************************************************
13 NAME */
14 #include <proto/gadtools.h>
15 #include <intuition/intuition.h>
17 AROS_LH1(VOID, FreeGadgets,
19 /* SYNOPSIS */
20 AROS_LHA(struct Gadget *, glist, A0),
22 /* LOCATION */
23 struct Library *, GadToolsBase, 6, GadTools)
25 /* FUNCTION
26 Frees all gadtools gadgets in a linked list of gadgets.
28 INPUTS
29 glist - pointer to the first gadget to be freed, may be NULL.
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
40 CreateGadgetA()
42 INTERNALS
44 HISTORY
46 ***************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct Gadget *lastgad = NULL, *nextgad = NULL;
52 DEBUG_FREEGADGETS(dprintf("FreeGadgets: glist 0x%lx\n", glist));
54 if (!glist)
55 return;
57 for (; glist; glist = nextgad)
59 nextgad = glist->NextGadget;
60 if (glist->GadgetType & GTYP_GADTOOLS)
62 if ((glist->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET)
64 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free gadget 0x%lx\n", glist));
66 /* must check this, because arrowclass uses GA_LabelImage! */
67 if ((glist->Flags & GFLG_LABELMASK) == GFLG_LABELITEXT)
69 freeitext(GTB(GadToolsBase), glist->GadgetText);
71 DisposeObject(glist);
73 } /* if ((glist->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) */
74 else
76 if ( (((struct GT_ContextGadget *)glist)->magic == CONTEXT_MAGIC) &&
77 (((struct GT_ContextGadget *)glist)->magic2 == CONTEXT_MAGIC2) )
79 /* This is a GadTools Context Gadget */
81 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free context 0x%lx\n", glist));
82 FreeMem(glist, sizeof(struct GT_ContextGadget));
84 else if ( (((struct GT_GenericGadget *)glist)->magic == GENERIC_MAGIC) &&
85 (((struct GT_GenericGadget *)glist)->magic2 == GENERIC_MAGIC2) )
87 /* This is a GadTools Generic Kind Gadget */
89 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free generic 0x%lx\n", glist));
90 freeitext(GTB(GadToolsBase), ((struct GT_GenericGadget *)glist)->itext);
91 FreeMem(glist, sizeof(struct GT_GenericGadget));
93 else
95 DEBUG_FREEGADGETS(dprintf("FreeGadgets: bad gadget 0x%lx\n", glist));
98 } /* if ((glist->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) else ... */
100 } /* if (glist->GadgetType & GTYP_GADTOOLS) */
101 else
103 DEBUG_FREEGADGETS(dprintf("FreeGadgets: skip non-gadtools 0x%lx\n", glist));
104 if (lastgad != NULL)
105 lastgad->NextGadget = glist;
106 lastgad = glist;
109 } /* for (; glist; glist = nextgad) */
111 if (lastgad != NULL)
112 lastgad->NextGadget = NULL;
114 DEBUG_FREEGADGETS(dprintf("FreeGadgets: done\n"));
116 AROS_LIBFUNC_EXIT
117 } /* FreeGadgets */