Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / boopsi / icclass.c
blob5c318b42312ac8fbbfc428e2aefb5038f1a94c97
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: icclass implementation.
6 Lang: english
7 */
9 /* AROS icclass implementation
10 * 10/25/96 caldi@usa.nai.net
13 #include <exec/types.h>
15 #include <intuition/classes.h>
16 #include <intuition/classusr.h>
17 #include <intuition/gadgetclass.h>
18 #include <intuition/cghooks.h>
19 #include <intuition/icclass.h>
21 #include <utility/tagitem.h>
22 #include <utility/hooks.h>
24 #include <clib/macros.h>
26 #include <proto/exec.h>
27 #include <proto/utility.h>
28 #include <proto/boopsi.h>
29 #include <clib/intuition_protos.h> /* UgH - Need DoMethod() etc */
31 #ifdef __AROS__
32 #include <aros/asmcall.h>
33 #include <proto/alib.h>
34 #endif
36 #include "intern.h"
38 /**********************************************************************************************/
40 #undef BOOPSIBase
41 #define BOOPSIBase ((struct Library *)(cl->cl_UserData))
43 /**********************************************************************************************/
45 /* icclass boopsi dispatcher
47 AROS_UFH3S(IPTR, dispatch_icclass,
48 AROS_UFHA(Class *, cl, A0),
49 AROS_UFHA(Object *, o, A2),
50 AROS_UFHA(Msg, msg, A1)
53 struct ICData *ic = NULL;
54 IPTR retval = 0UL;
56 if (msg->MethodID != OM_NEW)
57 ic = INST_DATA(cl, o);
59 switch(msg->MethodID)
61 case OM_NEW:
62 retval = DoSuperMethodA(cl, o, msg);
64 if (!retval)
65 break;
67 ic = INST_DATA(cl, retval);
69 /* set some defaults */
70 ic->ic_Target = NULL;
71 ic->ic_Mapping = NULL;
72 ic->ic_CloneTags = NULL;
74 /* Handle our special tags - overrides defaults */
75 /* Fall through */
77 case OM_SET:
79 struct TagItem *tstate = ((struct opSet *)msg)->ops_AttrList;
80 struct TagItem *tag;
82 while ((tag = NextTagItem((const struct TagItem **)&tstate)))
84 switch(tag->ti_Tag)
86 case ICA_MAP:
87 ic->ic_Mapping = (struct TagItem *)tag->ti_Data;
88 break;
90 case ICA_TARGET:
91 ic->ic_Target = (Object *)tag->ti_Data;
92 break;
96 break;
98 case OM_UPDATE: /* Maxon HotHelp says so and for example relied upon by modelclass */
99 case OM_NOTIFY:
100 /* Send update notification to target
102 retval = DoNotify(cl, o, INST_DATA(cl, o), (struct opUpdate *)msg);
103 break;
105 case OM_DISPOSE:
106 FreeICData(INST_DATA(cl, o));
107 DoSuperMethodA(cl, o, msg);
108 break;
110 case OM_GET:
111 switch (((struct opGet *)msg)->opg_AttrID)
113 case ICA_MAP:
114 *((struct opGet *)msg)->opg_Storage = (ULONG)ic->ic_Mapping;
115 break;
117 case ICA_TARGET:
118 *((struct opGet *)msg)->opg_Storage = (ULONG)ic->ic_Target;
119 break;
122 break;
125 NOTE: I current don't see the purpose of the ICM_* methods
126 this implementation could be WAY off base...
128 stegerg: well, it is for example needed by modeclass which is
129 a superclass of icclass.
131 IMPORTANT: ICM_SETLOOP, ICM_CLEARLOOP, ICM_CHECKLOOP are also
132 handled by gadgetclass: change here <-> change there!
136 case ICM_SETLOOP: /* set/increment loop counter */
138 struct ICData *ic = INST_DATA(cl, o);
140 ic->ic_LoopCounter += 1UL;
143 break;
145 case ICM_CLEARLOOP: /* clear/decrement loop counter */
147 struct ICData *ic = INST_DATA(cl, o);
149 ic->ic_LoopCounter -= 1UL;
152 break;
154 case ICM_CHECKLOOP: /* set/increment loop */
156 struct ICData *ic = INST_DATA(cl, o);
158 retval = (IPTR)ic->ic_LoopCounter;
161 break;
163 default:
164 retval = DoSuperMethodA(cl, o, msg);
165 break;
167 } /* switch */
169 return retval;
171 } /* dispatch_icclass */
173 #undef BOOPSIBase
175 /**********************************************************************************************/
177 struct IClass *InitICClass (struct Library * BOOPSIBase)
179 struct IClass *cl = NULL;
181 /* This is the code to make the icclass...
183 if ( (cl = MakeClass(ICCLASS, ROOTCLASS, NULL, sizeof(struct ICData), 0)) )
185 cl->cl_Dispatcher.h_Entry = (APTR)AROS_ASMSYMNAME(dispatch_icclass);
186 cl->cl_Dispatcher.h_SubEntry = NULL;
187 cl->cl_UserData = (IPTR)BOOPSIBase;
189 AddClass (cl);
192 return (cl);
195 /**********************************************************************************************/