Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / boopsi / modelclass.c
blob8971670ef82aa0245f2ce098e12c13a31fce31cd
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: modelclass implementation.
6 Lang: english
7 */
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 */
28 #ifdef __AROS__
29 #include <aros/asmcall.h>
30 #include <proto/alib.h>
31 #endif
33 #include "intern.h"
35 /**********************************************************************************************/
37 #undef BOOPSIBase
38 #define BOOPSIBase ((struct Library *)(cl->cl_UserData))
40 struct ModelData
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;
56 IPTR retval = 0UL;
58 if (msg->MethodID != OM_NEW) data = INST_DATA(cl, o);
60 switch(msg->MethodID)
62 case OM_NEW:
63 if ((o = (Object *)DoSuperMethodA(cl, o, msg)))
65 data = INST_DATA(cl, o);
67 NEWLIST(&data->memberlist);
69 retval = (IPTR)o;
71 break;
73 case OM_DISPOSE:
74 for(;;)
76 /* free all member objects */
78 Object *member, *objstate;
80 objstate = (Object *)data->memberlist.mlh_Head;
81 member = NextObject(&objstate);
82 if (!member) break;
84 DoMethod(member, OM_REMOVE);
86 DisposeObject(member);
89 retval = DoSuperMethodA(cl, o, msg);
90 break;
92 case OM_ADDMEMBER:
93 DoMethod( ((struct opMember *)msg)->opam_Object, OM_ADDTAIL, &data->memberlist);
94 break;
96 case OM_REMMEMBER:
97 DoMethod( ((struct opMember *)msg)->opam_Object, OM_REMOVE);
98 break;
100 case OM_UPDATE:
101 case OM_NOTIFY:
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);
143 break;
145 default:
146 retval = DoSuperMethodA(cl, o, msg);
147 break;
149 } /* switch(msg->MethodID) */
151 return retval;
153 } /* dispatch_modelclass */
155 #undef BOOPSIBase
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;
171 AddClass (cl);
174 return (cl);
177 /**********************************************************************************************/