dos.library: Fix C:AddDataTypes on OS 3.9
[AROS.git] / rom / intuition / refreshglist.c
blob72a7ef14f4df0a26782a56a11104da01a0fdc5c8
1 /*
2 Copyright © 1995-2007, 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"
9 #include "boolgadgets.h"
10 #include "boopsigadgets.h"
11 #include "propgadgets.h"
12 #include "strgadgets.h"
14 #undef DEBUG
15 #define DEBUG 0
16 #include <aros/debug.h>
18 #include <intuition/classes.h>
20 BOOL qualifygadget(struct Gadget *gadgets,LONG mustbe, LONG mustnotbe,struct IntuitionBase *IntuitionBase);
21 void rendergadget(struct Gadget *gadgets,struct Window *window, struct Requester *requester,struct IntuitionBase *IntuitionBase);
22 struct Gadget *findprevgadget(struct Gadget *gadget,struct Window *window,struct IntuitionBase *IntuitionBase);
24 /*****************************************************************************
26 NAME */
27 #include <intuition/intuition.h>
28 #include <proto/intuition.h>
30 AROS_LH4(void, RefreshGList,
32 /* SYNOPSIS */
33 AROS_LHA(struct Gadget *, gadgets, A0),
34 AROS_LHA(struct Window *, window, A1),
35 AROS_LHA(struct Requester *, requester, A2),
36 AROS_LHA(LONG , numGad, D0),
38 /* LOCATION */
39 struct IntuitionBase *, IntuitionBase, 72, Intuition)
41 /* FUNCTION
42 Refresh (draw anew) the specified number of gadgets starting
43 at the specified gadget.
45 INPUTS
46 gadgets - This is the first gadget which will be refreshed.
47 window - The window which contains the gadget
48 requester - If the gadget has GTYP_REQGADGET set, this must be
49 a pointer to a Requester; otherwise the value is
50 ignored.
51 numGad - How many gadgets should be refreshed. The value
52 may range from 0 to MAXLONG. If there are less gadgets
53 in the list than numGad, only the gadgets in the
54 list will be refreshed.
56 RESULT
57 None.
59 NOTES
60 This function *must not* be called inside a
61 BeginRefresh()/EndRefresh() pair.
63 EXAMPLE
64 // Refresh one gadget
65 RefreshGList (&gadget, win, NULL, 1);
67 // Refresh all gadgets in the window
68 RefreshGList (win->FirstGadget, win, NULL, -1L);
70 BUGS
72 SEE ALSO
74 INTERNALS
76 HISTORY
77 29-10-95 digulla automatically created from
78 intuition_lib.fd and clib/intuition_protos.h
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
84 EXTENDWORD(numGad);
86 if (!gadgets || !numGad)
87 return;
89 if ((gadgets->GadgetType & GTYP_REQGADGET) == 0)
91 requester = NULL;
93 else if (numGad == -2)
95 gadgets = requester->ReqGadget;
98 #ifdef USEGADGETLOCK
99 LOCKGADGET(IntuitionBase)
100 #else
101 LOCKWINDOWLAYERS(window);
102 #endif
104 int_refreshglist(gadgets,
105 window,
106 requester,
107 numGad,
110 IntuitionBase);
112 #ifdef USEGADGETLOCK
113 UNLOCKGADGET(IntuitionBase)
114 #else
115 UNLOCKWINDOWLAYERS(window);
116 #endif
118 ReturnVoid("RefreshGList");
120 AROS_LIBFUNC_EXIT
121 } /* RefreshGList */
123 void int_refreshglist(struct Gadget *gadgets, struct Window *window,
124 struct Requester *requester, LONG numGad, LONG mustbe, LONG mustnotbe,
125 struct IntuitionBase *IntuitionBase)
127 #ifdef GADTOOLSCOMPATIBLE
129 struct Gadget *gadtoolsgadget = 0;
130 LONG num = numGad;
131 #endif
133 DEBUG_INTREFRESHGLIST(dprintf("IntRefreshGList: Gadgets 0x%lx Window 0x%lx Req 0x%lx Num %ld Must 0x%lx MustNot 0x%lx\n",
134 gadgets, window, requester, numGad, mustbe, mustnotbe));
136 // in case we're not called from RefreshGList...
137 #ifdef USEGADGETLOCK
138 LOCKGADGET(IntuitionBase)
139 #else
140 LOCKWINDOWLAYERS(window);
141 #endif
143 for ( ; gadgets && numGad; gadgets=gadgets->NextGadget, numGad --)
145 #ifdef GADTOOLSCOMPATIBLE
146 if (gadgets->GadgetType & 0x100)
148 gadtoolsgadget = gadgets;
149 continue;
151 #endif
153 if (!(qualifygadget(gadgets,mustbe,mustnotbe,IntuitionBase))) continue;
154 //DEBUG_REFRESHGLIST(dprintf("IntRefreshGList: Gadget %p Type 0x%04lx\n",
155 // gadgets, gadgets->GadgetType));
157 D(bug("RefreshGList: gadget=%p type 0x%x [%d %d %d %d]\n",
158 gadgets,gadgets->GadgetType,
159 gadgets->LeftEdge,gadgets->TopEdge,
160 gadgets->Width,gadgets->Height));
162 /*SetAPen(window->RPort, 4);
163 Move(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge-1);
164 Draw(window->RPort, gadgets->LeftEdge+gadgets->Width, gadgets->TopEdge-1);
165 Draw(window->RPort, gadgets->LeftEdge+gadgets->Width, gadgets->TopEdge+gadgets->Height);
166 Draw(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge+gadgets->Height);
167 Draw(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge-1);*/
169 rendergadget(gadgets,window,requester,IntuitionBase);
170 } /* for ( ; gadgets && numGad; gadgets=gadgets->NextGadget, numGad --) */
172 #ifdef GADTOOLSCOMPATIBLE
173 if (gadtoolsgadget)
175 for ( ; gadtoolsgadget && num; num --)
177 if ((gadtoolsgadget->GadgetType & 0x100) && (qualifygadget(gadtoolsgadget,mustbe,mustnotbe,IntuitionBase))) rendergadget(gadtoolsgadget,window,requester,IntuitionBase);
178 gadtoolsgadget = findprevgadget(gadtoolsgadget,window,IntuitionBase);
181 #endif
183 #ifdef USEGADGETLOCK
184 UNLOCKGADGET(IntuitionBase)
185 #else
186 UNLOCKWINDOWLAYERS(window);
187 #endif
190 BOOL qualifygadget(struct Gadget *gadgets,LONG mustbe, LONG mustnotbe,struct IntuitionBase *IntuitionBase)
192 if ((mustbe != 0) || (mustnotbe != 0))
194 if (gadgets->Activation & (GACT_LEFTBORDER | GACT_RIGHTBORDER |
195 GACT_TOPBORDER | GACT_BOTTOMBORDER |
196 GACT_BORDERSNIFF))
198 if (mustnotbe & REFRESHGAD_BORDER) return FALSE; /* don't refresh if border gadget */
200 else
202 if (mustbe & REFRESHGAD_BORDER) return FALSE; /* don't refresh if not a border gadget */
205 if (gadgets->Activation & GACT_TOPBORDER)
207 if (mustnotbe & REFRESHGAD_TOPBORDER) return FALSE; /* don't refresh if border gadget */
209 else
211 if (mustbe & REFRESHGAD_TOPBORDER) return FALSE; /* don't refresh if not a border gadget */
214 if (gadgets->Flags & (GFLG_RELRIGHT | GFLG_RELBOTTOM |
215 GFLG_RELWIDTH | GFLG_RELHEIGHT))
217 if (mustnotbe & REFRESHGAD_REL) return FALSE; /* don't refresh if rel??? gadget */
219 else
221 if (mustbe & REFRESHGAD_REL) return FALSE; /* don't refresh if not rel??? gadget */
224 if (gadgets->Flags & GFLG_RELSPECIAL)
226 if (mustnotbe & REFRESHGAD_RELS) return FALSE; /* don't refresh if relspecial gadget */
228 else
230 if (mustbe & REFRESHGAD_RELS) return FALSE; /* don't refresh if not relspecial gadget */
233 if ((gadgets->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET)
235 if (mustnotbe & REFRESHGAD_BOOPSI) return FALSE; /* don't refresh if boopsi gadget */
237 else
239 if (mustbe & REFRESHGAD_BOOPSI) return FALSE; /* don't refresh if not boopsi gadget */
242 } /* if ((mustbe != 0) || (mustnotbe != 0)) */
243 return TRUE;
246 void rendergadget(struct Gadget *gadgets,struct Window *window, struct Requester *requester,struct IntuitionBase *IntuitionBase)
248 switch (gadgets->GadgetType & GTYP_GTYPEMASK)
250 case GTYP_BOOLGADGET:
251 RefreshBoolGadget (gadgets, window, requester, IntuitionBase);
252 break;
254 case GTYP_GADGET0002:
255 break;
257 case GTYP_PROPGADGET:
258 RefreshPropGadget (gadgets, window, requester, IntuitionBase);
259 break;
261 case GTYP_STRGADGET:
262 RefreshStrGadget (gadgets, window, requester, IntuitionBase);
263 break;
265 case GTYP_CUSTOMGADGET:
266 RefreshBoopsiGadget (gadgets, window, requester, IntuitionBase);
267 break;
269 default:
270 RefreshBoolGadget (gadgets, window, requester, IntuitionBase);
271 break;
273 } /* switch GadgetType */
276 struct Gadget *findprevgadget(struct Gadget *gadget,struct Window *window,struct IntuitionBase *IntuitionBase)
278 struct Gadget *prevgad = 0, *gad;
280 for (gad = window->FirstGadget; gad; gad = gad->NextGadget)
282 if (gad == gadget) return prevgad;
283 prevgad = gad;
286 return 0;