2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: modelclass implementation.
10 #include <exec/types.h>
12 #include <intuition/classes.h>
13 #include <intuition/classusr.h>
14 #include <intuition/gadgetclass.h>
15 #include <intuition/cghooks.h>
16 #include <intuition/icclass.h>
18 #include <utility/tagitem.h>
19 #include <utility/hooks.h>
21 #include <clib/macros.h>
23 #include <proto/exec.h>
24 #include <proto/utility.h>
25 #include <proto/boopsi.h>
26 #include <clib/intuition_protos.h> /* UgH - Need DoMethod() etc */
29 #include <aros/asmcall.h>
30 #include <proto/alib.h>
35 /**********************************************************************************************/
38 #define BOOPSIBase ((struct Library *)(cl->cl_UserData))
42 struct MinList memberlist
;
45 /**********************************************************************************************/
47 /* icclass boopsi dispatcher
49 AROS_UFH3S(IPTR
, dispatch_modelclass
,
50 AROS_UFHA(Class
*, cl
, A0
),
51 AROS_UFHA(Object
*, o
, A2
),
52 AROS_UFHA(Msg
, msg
, A1
)
55 struct ModelData
*data
;
58 if (msg
->MethodID
!= OM_NEW
) data
= INST_DATA(cl
, o
);
63 if ((o
= (Object
*)DoSuperMethodA(cl
, o
, msg
)))
65 data
= INST_DATA(cl
, o
);
67 NEWLIST(&data
->memberlist
);
76 /* free all member objects */
78 Object
*member
, *objstate
;
80 objstate
= (Object
*)data
->memberlist
.mlh_Head
;
81 member
= NextObject(&objstate
);
84 DoMethod(member
, OM_REMOVE
);
86 DisposeObject(member
);
89 retval
= DoSuperMethodA(cl
, o
, msg
);
93 DoMethod( ((struct opMember
*)msg
)->opam_Object
, OM_ADDTAIL
, &data
->memberlist
);
97 DoMethod( ((struct opMember
*)msg
)->opam_Object
, OM_REMOVE
);
102 /* send OM_UPDATE to all members without mapping the tags! */
104 if (!IsListEmpty(&data
->memberlist
))
106 if (DoMethod(o
, ICM_CHECKLOOP
) == 0) /* avoid loops */
108 struct TagItem
*clonetags
;
110 if ((clonetags
= CloneTagItems(((struct opUpdate
*)msg
)->opu_AttrList
)))
112 struct opUpdate opu
= *(struct opUpdate
*)msg
;
113 Object
*member
, *objstate
;
115 opu
.MethodID
= OM_UPDATE
; /* not OM_NOTIFY! */
116 opu
.opu_AttrList
= clonetags
;
118 DoMethod(o
, ICM_SETLOOP
);
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
, ((struct opUpdate
*)msg
)->opu_AttrList
);
129 DoMethod(o
, ICM_CLEARLOOP
);
131 FreeTagItems(clonetags
);
134 } /* if (DoMethod(o, ICM_CHECKLOOP) == 0) */
136 } /* if (!IsListEmpty(&data->memberlist)) */
138 /* modelclass is a superclass of icclass so not only the members are targets,
139 but possibly also the modelclass object itself could have an ICA_Target.
140 This is handled by the superclass */
142 retval
= DoSuperMethodA(cl
, o
, msg
);
146 retval
= DoSuperMethodA(cl
, o
, msg
);
149 } /* switch(msg->MethodID) */
153 } /* dispatch_modelclass */
157 /**********************************************************************************************/
159 struct IClass
*InitModelClass (struct Library
* BOOPSIBase
)
161 struct IClass
*cl
= NULL
;
163 /* This is the code to make the modelclass...
165 if ( (cl
= MakeClass(MODELCLASS
, ICCLASS
, NULL
, sizeof(struct ModelData
), 0)) )
167 cl
->cl_Dispatcher
.h_Entry
= (APTR
)AROS_ASMSYMNAME(dispatch_modelclass
);
168 cl
->cl_Dispatcher
.h_SubEntry
= NULL
;
169 cl
->cl_UserData
= (IPTR
)BOOPSIBase
;
177 /**********************************************************************************************/