CopyToAFS: Remove dead FMF_* flags
[AROS.git] / rom / intuition / modelclass.c
blob0d000516c7be4bdddf1f99d7294116849538be0c
1 /*
2 Copyright © 1995-2005, 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 #undef IntuitionBase
34 #define IntuitionBase ((struct IntuiBase *)(cl->cl_UserData))
36 /**********************************************************************************************/
38 IPTR ModelClass__OM_NEW(Class *cl, Object *o, Msg msg)
40 struct ModelData *data;
42 if ((o = (Object *)DoSuperMethodA(cl, o, msg)))
44 data = INST_DATA(cl, o);
46 NEWLIST(&data->memberlist);
49 return (IPTR)o;
52 IPTR ModelClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
54 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
56 for(;;)
58 /* free all member objects */
60 Object *member, *objstate;
61 ULONG method;
63 objstate = (Object *)data->memberlist.mlh_Head;
64 member = NextObject(&objstate);
65 if (!member) break;
67 method = OM_REMOVE;
68 DoMethodA(member, (Msg)&method);
70 DisposeObject(member);
74 return DoSuperMethodA(cl, o, msg);
77 IPTR ModelClass__OM_ADDMEMBER(Class *cl, Object *o, struct opMember *msg)
79 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
80 struct opAddTail method;
82 method.MethodID = OM_ADDTAIL;
83 method.opat_List = (struct List *)&data->memberlist;
85 DoMethodA( msg->opam_Object, (Msg)&method);
87 return (IPTR)0;
90 IPTR ModelClass__OM_REMMEMBER(Class *cl, Object *o, struct opMember *msg)
92 STACKULONG method = OM_REMOVE;
94 return DoMethodA(msg->opam_Object, (Msg)&method);
97 IPTR ModelClass__OM_UPDATE(Class *cl, Object *o, struct opUpdate *msg)
99 struct ModelData *data = (struct ModelData *)INST_DATA(cl, o);
101 /* send OM_UPDATE to all members without mapping the tags! */
103 if (!IsListEmpty((struct List *)&data->memberlist))
105 STACKULONG method = ICM_CHECKLOOP;
107 if (DoMethodA(o, (Msg)&method) == 0) /* avoid loops */
109 struct TagItem *clonetags;
111 if ((clonetags = CloneTagItems(msg->opu_AttrList)))
113 struct opUpdate opu = *msg;
114 Object *member, *objstate;
116 opu.MethodID = OM_UPDATE; /* not OM_NOTIFY! */
117 opu.opu_AttrList = clonetags;
119 method = ICM_SETLOOP;
120 DoMethodA(o, (Msg)&method);
122 objstate = (Object *)data->memberlist.mlh_Head;
123 while((member = NextObject(&objstate)))
125 DoMethodA(member, (Msg)&opu);
127 /* in case the member object poked around in the taglist: */
128 RefreshTagItemClones(clonetags, msg->opu_AttrList);
131 method = ICM_CLEARLOOP;
132 DoMethodA(o, (Msg)&method);
134 FreeTagItems(clonetags);
137 } /* if (DoMethod(o, ICM_CHECKLOOP) == 0) */
139 } /* if (!IsListEmpty(&data->memberlist)) */
141 /* modelclass is a superclass of icclass so not only the members are targets,
142 * but possibly also the modelclass object itself could have an ICA_Target.
143 * This is handled by the superclass */
145 return DoSuperMethodA(cl, o, (Msg)msg);