grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / intuition / icclass.c
blobb1182aac3f7310f39d21aa17f2b57c67fff7c0d6
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 #define DEBUG_IC(x) ;
33 /**********************************************************************************************/
35 static void _om_set(struct ICData *ic, struct TagItem *tags, struct IntuitionBase *IntuitionBase)
37 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
38 struct TagItem *tag, *tstate = tags;
40 while ((tag = NextTagItem(&tstate)))
42 switch(tag->ti_Tag)
44 case ICA_MAP:
45 ic->ic_Mapping = (struct TagItem *)tag->ti_Data;
46 break;
48 case ICA_TARGET:
49 ic->ic_Target = (Object *)tag->ti_Data;
50 break;
55 IPTR ICClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
57 IPTR retval;
58 struct ICData *ic;
59 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
61 DEBUG_IC(dprintf("dispatch_icclass: OM_NEW\n"));
63 retval = DoSuperMethodA(cl, o, (Msg)msg);
65 if (!retval) return (IPTR)FALSE;
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 _om_set(ic, msg->ops_AttrList, IntuitionBase);
76 return retval;
79 IPTR ICClass__OM_SET(Class *cl, Object *o, struct opSet *msg)
81 struct ICData *ic = INST_DATA(cl, o);
82 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
84 DEBUG_IC(dprintf("dispatch_icclass: OM_SET\n"));
85 _om_set(ic, msg->ops_AttrList, IntuitionBase);
86 DEBUG_IC(dprintf("dispatch_icclass: OM_SET Map 0x%lx Target 0x%lx\n",ic->ic_Mapping,ic->ic_Target));
88 return (IPTR)TRUE;
91 IPTR ICClass__OM_NOTIFY(Class *cl, Object *o, struct opUpdate *msg)
93 struct ICData *ic = INST_DATA(cl, o);
94 IPTR retval;
95 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
97 /* Send update notification to target
99 DEBUG_IC(dprintf("dispatch_icclass: OM_NOTIFY\n"));
100 DEBUG_IC(dprintf("dispatch_icclass: DoNotify\n"));
101 retval = DoNotify(cl, o, ic, msg);
102 DEBUG_IC(dprintf("dispatch_icclass: DoNotify done\n"));
104 return retval;
107 IPTR ICClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
109 struct ICData *ic = INST_DATA(cl, o);
110 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
112 DEBUG_IC(dprintf("dispatch_icclass: OM_DISPOSE\n"));
113 FreeICData(ic);
114 DoSuperMethodA(cl, o, msg);
116 return (IPTR)TRUE;
119 IPTR ICClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
121 struct ICData *ic = INST_DATA(cl, o);
123 DEBUG_IC(dprintf("dispatch_icclass: OM_GET\n"));
124 switch (msg->opg_AttrID)
126 case ICA_MAP:
127 *msg->opg_Storage = (IPTR)ic->ic_Mapping;
128 break;
130 case ICA_TARGET:
131 *msg->opg_Storage = (IPTR)ic->ic_Target;
132 break;
135 return (IPTR)TRUE;
140 * NOTE: I current don't see the purpose of the ICM_* methods
141 * this implementation could be WAY off base...
143 * stegerg: well, it is for example needed by modeclass which is
144 * a superclass of icclass.
146 * IMPORTANT: ICM_SETLOOP, ICM_CLEARLOOP, ICM_CHECKLOOP are also
147 * handled by gadgetclass: change here <-> change there!
150 void ICClass__ICM_SETLOOP(Class *cl, Object *o, Msg msg)
152 struct ICData *ic = INST_DATA(cl, o);
154 /* set/increment loop counter */
155 ic->ic_LoopCounter += 1UL;
156 DEBUG_IC(dprintf("dispatch_icclass: ICM_SETLOOP new LoopCounter %ld\n",ic->ic_LoopCounter));
159 void ICClass__ICM_CLEARLOOP(Class *cl, Object *o, Msg msg)
161 struct ICData *ic = INST_DATA(cl, o);
163 /* clear/decrement loop counter */
164 ic->ic_LoopCounter -= 1UL;
165 DEBUG_IC(dprintf("dispatch_icclass: ICM_CLEAR new LoopCounter %ld\n",ic->ic_LoopCounter));
168 IPTR ICClass__ICM_CHECKLOOP(Class *cl, Object *o, Msg msg)
170 struct ICData *ic = INST_DATA(cl, o);
172 /* get loop counter */
173 DEBUG_IC(dprintf("dispatch_icclass: ICM_CHECKLOOP new LoopCounter %ld\n",ic->ic_LoopCounter));
174 return (IPTR)ic->ic_LoopCounter;
177 /**********************************************************************************************/