tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / intuition / modelclass.c
blobcbdb30bc0e50d7eea35f8f48ea9523d9b50434d6
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <exec/types.h>
9 #include <intuition/classes.h>
10 #include <intuition/classusr.h>
11 #include <intuition/gadgetclass.h>
12 #include <intuition/cghooks.h>
13 #include <intuition/icclass.h>
15 #include <utility/tagitem.h>
16 #include <utility/hooks.h>
18 #include <clib/macros.h>
20 #include <proto/exec.h>
21 #include <proto/utility.h>
22 #include <proto/intuition.h>
24 #ifndef __MORPHOS__
25 #include <aros/asmcall.h>
26 #include <proto/alib.h>
27 #endif /* !__MORPHOS__ */
29 #include "intuition_intern.h"
31 /**********************************************************************************************/
33 IPTR ModelClass__OM_NEW(Class *cl, Object *o, Msg msg)
35 struct ModelData *data;
37 if ((o = (Object *)DoSuperMethodA(cl, o, msg)))
39 data = INST_DATA(cl, o);
41 NEWLIST(&data->memberlist);
44 return (IPTR)o;
47 IPTR ModelClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
49 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
50 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
52 for(;;)
54 /* free all member objects */
56 Object *member, *objstate;
57 ULONG method;
59 objstate = (Object *)data->memberlist.mlh_Head;
60 member = NextObject(&objstate);
61 if (!member) break;
63 method = OM_REMOVE;
64 DoMethodA(member, (Msg)&method);
66 DisposeObject(member);
70 return DoSuperMethodA(cl, o, msg);
73 IPTR ModelClass__OM_ADDMEMBER(Class *cl, Object *o, struct opMember *msg)
75 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
76 struct opAddTail method;
78 method.MethodID = OM_ADDTAIL;
79 method.opat_List = (struct List *)&data->memberlist;
81 DoMethodA( msg->opam_Object, (Msg)&method);
83 return (IPTR)0;
86 IPTR ModelClass__OM_REMMEMBER(Class *cl, Object *o, struct opMember *msg)
88 STACKULONG method = OM_REMOVE;
90 return DoMethodA(msg->opam_Object, (Msg)&method);
93 IPTR ModelClass__OM_UPDATE(Class *cl, Object *o, struct opUpdate *msg)
95 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
96 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
97 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
99 /* send OM_UPDATE to all members without mapping the tags! */
101 if (!IsListEmpty(&data->memberlist))
103 STACKULONG method = ICM_CHECKLOOP;
105 if (DoMethodA(o, (Msg)&method) == 0) /* avoid loops */
107 struct TagItem *clonetags;
109 if ((clonetags = CloneTagItems(msg->opu_AttrList)))
111 struct opUpdate opu = *msg;
112 Object *member, *objstate;
114 opu.MethodID = OM_UPDATE; /* not OM_NOTIFY! */
115 opu.opu_AttrList = clonetags;
117 method = ICM_SETLOOP;
118 DoMethodA(o, (Msg)&method);
120 objstate = (Object *)data->memberlist.mlh_Head;
121 while((member = NextObject(&objstate)))
123 DoMethodA(member, (Msg)&opu);
125 /* in case the member object poked around in the taglist: */
126 RefreshTagItemClones(clonetags, msg->opu_AttrList);
129 method = ICM_CLEARLOOP;
130 DoMethodA(o, (Msg)&method);
132 FreeTagItems(clonetags);
135 } /* if (DoMethod(o, ICM_CHECKLOOP) == 0) */
137 } /* if (!IsListEmpty(&data->memberlist)) */
139 /* modelclass is a superclass of icclass so not only the members are targets,
140 * but possibly also the modelclass object itself could have an ICA_Target.
141 * This is handled by the superclass */
143 return DoSuperMethodA(cl, o, (Msg)msg);