New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / desktop / abstracticoncontainer.c
blob0bbd145e6e591b14b6838160bc407162aa77b677
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #define DEBUG 1
9 #include <aros/debug.h>
11 #include <exec/types.h>
12 #include <exec/memory.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <libraries/mui.h>
17 #include <proto/dos.h>
18 #include <proto/desktop.h>
19 #include <proto/intuition.h>
20 #include <proto/utility.h>
22 #include "desktop_intern.h"
23 #include "presentation.h"
24 // FIXME: for IA_Selected, but it should be in abstracticon
25 #include "iconclass.h"
27 #include "desktop_intern_protos.h"
29 #include "abstracticoncontainer.h"
31 void broadcastMessage(Class * cl, Object * obj, Msg msg)
33 struct MemberNode *mn;
34 struct AbstractIconContainerData *data;
36 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
38 mn=(struct MemberNode *) data->memberList.mlh_Head;
39 while(mn->m_Node.mln_Succ)
41 DoMethodA(mn->m_Object, msg);
42 mn=(struct MemberNode*)mn->m_Node.mln_Succ;
46 struct MemberNode* findMember(struct MinList *list, Object *object)
48 struct MemberNode *mn=(struct MemberNode*)list->mlh_Head;
49 BOOL found=FALSE;
51 while(!found && mn->m_Node.mln_Succ)
53 if(mn->m_Object==object)
54 found=TRUE;
55 else
56 mn=(struct MemberNode*)mn->m_Node.mln_Succ;
59 return mn;
62 IPTR abstractIconConNew(Class * cl, Object * obj, struct opSet *ops)
64 IPTR retval = 0;
65 struct AbstractIconContainerData *data;
66 struct TagItem *tag, *tstate = ops->ops_AttrList;
67 Object *desktop = NULL;
68 BOOL applyMethodsToMembers=TRUE;
70 while((tag=NextTagItem(&tstate)))
72 switch(tag->ti_Tag)
74 case AICA_Desktop:
75 desktop=(Object*)tag->ti_Data;
76 break;
77 case AICA_ApplyMethodsToMembers:
78 applyMethodsToMembers=(BOOL)tag->ti_Data;
79 break;
80 default:
81 continue; // Don't supress non-processed tags
84 tag->ti_Tag=TAG_IGNORE;
87 retval=DoSuperMethodA(cl, obj, (Msg)ops);
89 if(retval)
91 obj=(Object*)retval;
92 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
94 // FIXME: this doesn't look right
95 if(desktop==NULL)
96 desktop=obj;
98 NEWLIST((struct List*)&data->memberList);
99 NEWLIST((struct List*)&data->selectedList);
101 data->memberCount=0;
102 data->applyMethodsToMembers=applyMethodsToMembers;
103 data->desktop=desktop;
106 return retval;
109 IPTR abstractIconConAdd(Class *cl, Object *obj, struct opMember *msg)
111 struct AbstractIconContainerData *data;
112 struct MemberNode *mn;
113 ULONG retval=1;
115 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
117 mn=AllocVec(sizeof(struct MemberNode), MEMF_ANY);
118 mn->m_Object=msg->opam_Object;
120 muiNotifyData(msg->opam_Object)->mnd_ParentObject=obj;
121 DoMethod(msg->opam_Object, MUIM_ConnectParent, (IPTR) obj);
123 DoMethod(msg->opam_Object, MUIM_Notify, IA_Selected, MUIV_EveryTime,
124 (IPTR) obj, 3, AICM_UpdateSelectList, (IPTR) msg->opam_Object, MUIV_TriggerValue);
126 data->memberCount++;
127 AddTail((struct List*)&data->memberList, (struct Node*)mn);
129 return retval;
132 IPTR abstractIconConRemove(Class *cl, Object *obj, struct opMember *msg)
134 struct AbstractIconContainerData *data;
135 struct MemberNode *mn;
136 ULONG retval=-1;
138 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
140 mn=findMember(&data->memberList, msg->opam_Object);
141 if(mn)
143 data->memberCount--;
144 Remove((struct Node*)mn);
146 if(muiNotifyData(obj)->mnd_GlobalInfo)
148 DoMethod(msg->opam_Object, MUIM_DisconnectParent);
149 muiNotifyData(msg->opam_Object)->mnd_ParentObject=NULL;
152 FreeVec(mn);
153 retval=1;
156 return retval;
159 IPTR abstractIconConSet(Class* cl, Object* obj, struct opSet* msg)
161 struct AbstractIconContainerData *data;
162 IPTR retval;
163 struct TagItem *tag, *tstate=msg->ops_AttrList;
165 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
167 while((tag=NextTagItem(&tstate)))
169 switch(tag->ti_Tag)
171 case AICA_Desktop:
172 data->desktop=(Object*)tag->ti_Data;
173 tag->ti_Tag=TAG_IGNORE;
174 break;
175 case AICA_ApplyMethodsToMembers:
176 data->applyMethodsToMembers=(BOOL)tag->ti_Data;
177 tag->ti_Tag=TAG_IGNORE;
178 break;
182 retval=DoSuperMethodA(cl, obj, (Msg) msg);
183 broadcastMessage(cl, obj, (Msg) msg);
185 return 0;
188 struct MinList* createObjectList(struct MinList *copyFrom, struct AbstractIconContainerData *data)
190 struct MinList *list;
191 struct MemberNode *mn;
193 list=AllocVec(sizeof(struct MinList), MEMF_ANY);
194 NEWLIST(list);
196 mn=(struct MemberNode*)data->selectedList.mlh_Head;
197 while(mn->m_Node.mln_Succ)
199 AddTail((struct List*)list, (struct Node *)_OBJECT(mn->m_Object));
200 mn=(struct MemberNode*)mn->m_Node.mln_Succ;
203 return list;
206 IPTR abstractIconConGet(Class * cl, Object * obj, struct opGet * msg)
208 IPTR retval=1;
209 struct AbstractIconContainerData *data;
211 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
213 switch(msg->opg_AttrID)
215 case AICA_ApplyMethodsToMembers:
216 *msg->opg_Storage=(ULONG)data->applyMethodsToMembers;
217 break;
218 // FIXME: change this to a Lock/Unlock method pair, to
219 // deallocate objectList
220 case AICA_SelectedIcons:
222 struct MinList *objectList;
224 objectList=createObjectList(&data->selectedList, data);
225 *msg->opg_Storage=(ULONG)objectList;
226 break;
228 // FIXME: change this to a Lock/Unlock method pair, to
229 // deallocate objectList
230 case AICA_MemberList:
232 struct MinList *objectList;
234 objectList=createObjectList(&data->memberList, data);
235 *msg->opg_Storage=(ULONG)objectList;
236 break;
238 case AICA_Desktop:
239 *msg->opg_Storage=(ULONG)data->desktop;
240 break;
241 default:
242 retval=DoSuperMethodA(cl, obj, (Msg)msg);
243 break;
246 return retval;
249 // FIXME: finish me
250 IPTR abstractIconConUnselectAll(Class * cl, Object * obj, Msg msg)
252 IPTR retval = 0;
253 // struct MemberNode *mn;
254 // struct AbstractIconContainerData *data;
256 // data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
258 // mn=(struct MemberNode*)data->memberList.mlh_Head;
259 // while(mn->m_Node.mln_Succ)
260 // {
261 // if(_selected(mn->m_Object) && )
262 // {
263 // SetAttrs(mn->m_Object, IA_Selected, FALSE, TAG_END);
264 // }
265 // mn=(struct MemberNode*)mn->m_Node.mln_Succ;
266 // }
268 return retval;
271 IPTR abstractIconConUpdateSelectList(Class *cl, Object *obj, struct opUpdateSelectList * msg)
273 IPTR retval=0;
274 struct AbstractIconContainerData *data;
276 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
278 if(msg->selectState==TRUE)
279 AddTail((struct List*)&(data->selectedList), (struct Node*)_OBJECT(msg->target));
280 else if(msg->selectState==FALSE)
281 Remove((struct Node *)_OBJECT(msg->target));
283 return retval;
286 IPTR abstractIconConDispose(Class* cl, Object* obj, Msg msg)
288 IPTR retval;
290 broadcastMessage(cl, obj, msg);
291 retval=DoSuperMethodA(cl, obj, msg);
293 return retval;
296 BOOPSI_DISPATCHER(IPTR, abstractIconContainerDispatcher, cl, obj, msg)
299 ULONG retval=0;
301 switch(msg->MethodID)
303 case OM_NEW:
304 retval=abstractIconConNew(cl, obj, (struct opSet*)msg);
305 break;
306 case OM_ADDMEMBER:
307 retval=abstractIconConAdd(cl, obj, (struct opMember*)msg);
308 break;
309 case OM_REMMEMBER:
310 retval=abstractIconConRemove(cl, obj, (struct opMember*)msg);
311 break;
312 case OM_SET:
313 retval=abstractIconConSet(cl, obj, (struct opSet*)msg);
314 break;
315 case OM_GET:
316 retval=abstractIconConGet(cl, obj, (struct opGet*)msg);
317 break;
318 case AICM_UnselectAll:
319 retval=abstractIconConUnselectAll(cl, obj, msg);
320 break;
321 case AICM_UpdateSelectList:
322 retval=abstractIconConUpdateSelectList(cl, obj, (struct opUpdateSelectList*)msg);
323 break;
324 case OM_DISPOSE:
325 retval=abstractIconConDispose(cl, obj, msg);
326 break;
327 default:
329 struct AbstractIconContainerData *data;
331 data=(struct AbstractIconContainerData*)INST_DATA(cl, obj);
333 if(data->applyMethodsToMembers)
334 broadcastMessage(cl, obj, msg);
335 retval=DoSuperMethodA(cl, obj, msg);
336 break;
340 return retval;
342 BOOPSI_DISPATCHER_END