tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / intuition / refreshglist.c
blob2e8d0090c0d71bad097c986da4c98239e274f20c
1 /*
2 Copyright © 1995-2013, 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 *****************************************************************************/
78 AROS_LIBFUNC_INIT
80 EXTENDWORD(numGad);
82 if (!gadgets || !numGad)
83 return;
85 if ((gadgets->GadgetType & GTYP_REQGADGET) == 0)
87 requester = NULL;
89 else if (numGad == -2)
91 gadgets = requester->ReqGadget;
94 #ifdef USEGADGETLOCK
95 LOCKGADGET(IntuitionBase)
96 #else
97 LOCKWINDOWLAYERS(window);
98 #endif
100 int_refreshglist(gadgets,
101 window,
102 requester,
103 numGad,
106 IntuitionBase);
108 #ifdef USEGADGETLOCK
109 UNLOCKGADGET(IntuitionBase)
110 #else
111 UNLOCKWINDOWLAYERS(window);
112 #endif
114 ReturnVoid("RefreshGList");
116 AROS_LIBFUNC_EXIT
117 } /* RefreshGList */
119 void int_refreshglist(struct Gadget *gadgets, struct Window *window,
120 struct Requester *requester, LONG numGad, LONG mustbe, LONG mustnotbe,
121 struct IntuitionBase *IntuitionBase)
123 #ifdef GADTOOLSCOMPATIBLE
125 struct Gadget *gadtoolsgadget = 0;
126 LONG num = numGad;
127 #endif
129 DEBUG_INTREFRESHGLIST(dprintf("IntRefreshGList: Gadgets 0x%lx Window 0x%lx Req 0x%lx Num %ld Must 0x%lx MustNot 0x%lx\n",
130 gadgets, window, requester, numGad, mustbe, mustnotbe));
132 // in case we're not called from RefreshGList...
133 #ifdef USEGADGETLOCK
134 LOCKGADGET(IntuitionBase)
135 #else
136 LOCKWINDOWLAYERS(window);
137 #endif
139 for ( ; gadgets && numGad; gadgets=gadgets->NextGadget, numGad --)
141 #ifdef GADTOOLSCOMPATIBLE
142 if (gadgets->GadgetType & 0x100)
144 gadtoolsgadget = gadgets;
145 continue;
147 #endif
149 if (!(qualifygadget(gadgets,mustbe,mustnotbe,IntuitionBase))) continue;
150 //DEBUG_REFRESHGLIST(dprintf("IntRefreshGList: Gadget %p Type 0x%04lx\n",
151 // gadgets, gadgets->GadgetType));
153 D(bug("RefreshGList: gadget=%p type 0x%x [%d %d %d %d]\n",
154 gadgets,gadgets->GadgetType,
155 gadgets->LeftEdge,gadgets->TopEdge,
156 gadgets->Width,gadgets->Height));
158 /*SetAPen(window->RPort, 4);
159 Move(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge-1);
160 Draw(window->RPort, gadgets->LeftEdge+gadgets->Width, gadgets->TopEdge-1);
161 Draw(window->RPort, gadgets->LeftEdge+gadgets->Width, gadgets->TopEdge+gadgets->Height);
162 Draw(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge+gadgets->Height);
163 Draw(window->RPort, gadgets->LeftEdge-1, gadgets->TopEdge-1);*/
165 rendergadget(gadgets,window,requester,IntuitionBase);
166 } /* for ( ; gadgets && numGad; gadgets=gadgets->NextGadget, numGad --) */
168 #ifdef GADTOOLSCOMPATIBLE
169 if (gadtoolsgadget)
171 for ( ; gadtoolsgadget && num; num --)
173 if ((gadtoolsgadget->GadgetType & 0x100) && (qualifygadget(gadtoolsgadget,mustbe,mustnotbe,IntuitionBase))) rendergadget(gadtoolsgadget,window,requester,IntuitionBase);
174 gadtoolsgadget = findprevgadget(gadtoolsgadget,window,IntuitionBase);
177 #endif
179 #ifdef USEGADGETLOCK
180 UNLOCKGADGET(IntuitionBase)
181 #else
182 UNLOCKWINDOWLAYERS(window);
183 #endif
186 BOOL qualifygadget(struct Gadget *gadgets,LONG mustbe, LONG mustnotbe,struct IntuitionBase *IntuitionBase)
188 if ((mustbe != 0) || (mustnotbe != 0))
190 if (gadgets->Activation & (GACT_LEFTBORDER | GACT_RIGHTBORDER |
191 GACT_TOPBORDER | GACT_BOTTOMBORDER |
192 GACT_BORDERSNIFF))
194 if (mustnotbe & REFRESHGAD_BORDER) return FALSE; /* don't refresh if border gadget */
196 else
198 if (mustbe & REFRESHGAD_BORDER) return FALSE; /* don't refresh if not a border gadget */
201 if (gadgets->Activation & GACT_TOPBORDER)
203 if (mustnotbe & REFRESHGAD_TOPBORDER) return FALSE; /* don't refresh if border gadget */
205 else
207 if (mustbe & REFRESHGAD_TOPBORDER) return FALSE; /* don't refresh if not a border gadget */
210 if (gadgets->Flags & (GFLG_RELRIGHT | GFLG_RELBOTTOM |
211 GFLG_RELWIDTH | GFLG_RELHEIGHT))
213 if (mustnotbe & REFRESHGAD_REL) return FALSE; /* don't refresh if rel??? gadget */
215 else
217 if (mustbe & REFRESHGAD_REL) return FALSE; /* don't refresh if not rel??? gadget */
220 if (gadgets->Flags & GFLG_RELSPECIAL)
222 if (mustnotbe & REFRESHGAD_RELS) return FALSE; /* don't refresh if relspecial gadget */
224 else
226 if (mustbe & REFRESHGAD_RELS) return FALSE; /* don't refresh if not relspecial gadget */
229 if ((gadgets->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET)
231 if (mustnotbe & REFRESHGAD_BOOPSI) return FALSE; /* don't refresh if boopsi gadget */
233 else
235 if (mustbe & REFRESHGAD_BOOPSI) return FALSE; /* don't refresh if not boopsi gadget */
238 } /* if ((mustbe != 0) || (mustnotbe != 0)) */
239 return TRUE;
242 void rendergadget(struct Gadget *gadgets,struct Window *window, struct Requester *requester,struct IntuitionBase *IntuitionBase)
244 switch (gadgets->GadgetType & GTYP_GTYPEMASK)
246 case GTYP_BOOLGADGET:
247 RefreshBoolGadget (gadgets, window, requester, IntuitionBase);
248 break;
250 case GTYP_GADGET0002:
251 break;
253 case GTYP_PROPGADGET:
254 RefreshPropGadget (gadgets, window, requester, IntuitionBase);
255 break;
257 case GTYP_STRGADGET:
258 RefreshStrGadget (gadgets, window, requester, IntuitionBase);
259 break;
261 case GTYP_CUSTOMGADGET:
262 RefreshBoopsiGadget (gadgets, window, requester, IntuitionBase);
263 break;
265 default:
266 RefreshBoolGadget (gadgets, window, requester, IntuitionBase);
267 break;
269 } /* switch GadgetType */
272 struct Gadget *findprevgadget(struct Gadget *gadget,struct Window *window,struct IntuitionBase *IntuitionBase)
274 struct Gadget *prevgad = 0, *gad;
276 for (gad = window->FirstGadget; gad; gad = gad->NextGadget)
278 if (gad == gadget) return prevgad;
279 prevgad = gad;
282 return 0;