2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
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
;
51 while(!found
&& mn
->m_Node
.mln_Succ
)
53 if(mn
->m_Object
==object
)
56 mn
=(struct MemberNode
*)mn
->m_Node
.mln_Succ
;
62 IPTR
abstractIconConNew(Class
* cl
, Object
* obj
, struct opSet
*ops
)
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
)))
75 desktop
=(Object
*)tag
->ti_Data
;
77 case AICA_ApplyMethodsToMembers
:
78 applyMethodsToMembers
=(BOOL
)tag
->ti_Data
;
81 continue; // Don't supress non-processed tags
84 tag
->ti_Tag
=TAG_IGNORE
;
87 retval
=DoSuperMethodA(cl
, obj
, (Msg
)ops
);
92 data
=(struct AbstractIconContainerData
*)INST_DATA(cl
, obj
);
94 // FIXME: this doesn't look right
98 NEWLIST((struct List
*)&data
->memberList
);
99 NEWLIST((struct List
*)&data
->selectedList
);
102 data
->applyMethodsToMembers
=applyMethodsToMembers
;
103 data
->desktop
=desktop
;
109 IPTR
abstractIconConAdd(Class
*cl
, Object
*obj
, struct opMember
*msg
)
111 struct AbstractIconContainerData
*data
;
112 struct MemberNode
*mn
;
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
);
127 AddTail((struct List
*)&data
->memberList
, (struct Node
*)mn
);
132 IPTR
abstractIconConRemove(Class
*cl
, Object
*obj
, struct opMember
*msg
)
134 struct AbstractIconContainerData
*data
;
135 struct MemberNode
*mn
;
138 data
=(struct AbstractIconContainerData
*)INST_DATA(cl
, obj
);
140 mn
=findMember(&data
->memberList
, msg
->opam_Object
);
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
;
159 IPTR
abstractIconConSet(Class
* cl
, Object
* obj
, struct opSet
* msg
)
161 struct AbstractIconContainerData
*data
;
163 struct TagItem
*tag
, *tstate
=msg
->ops_AttrList
;
165 data
=(struct AbstractIconContainerData
*)INST_DATA(cl
, obj
);
167 while((tag
=NextTagItem(&tstate
)))
172 data
->desktop
=(Object
*)tag
->ti_Data
;
173 tag
->ti_Tag
=TAG_IGNORE
;
175 case AICA_ApplyMethodsToMembers
:
176 data
->applyMethodsToMembers
=(BOOL
)tag
->ti_Data
;
177 tag
->ti_Tag
=TAG_IGNORE
;
182 retval
=DoSuperMethodA(cl
, obj
, (Msg
) msg
);
183 broadcastMessage(cl
, obj
, (Msg
) msg
);
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
);
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
;
206 IPTR
abstractIconConGet(Class
* cl
, Object
* obj
, struct opGet
* msg
)
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
;
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
;
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
;
239 *msg
->opg_Storage
=(ULONG
)data
->desktop
;
242 retval
=DoSuperMethodA(cl
, obj
, (Msg
)msg
);
250 IPTR
abstractIconConUnselectAll(Class
* cl
, Object
* obj
, Msg msg
)
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)
261 // if(_selected(mn->m_Object) && )
263 // SetAttrs(mn->m_Object, IA_Selected, FALSE, TAG_END);
265 // mn=(struct MemberNode*)mn->m_Node.mln_Succ;
271 IPTR
abstractIconConUpdateSelectList(Class
*cl
, Object
*obj
, struct opUpdateSelectList
* msg
)
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
));
286 IPTR
abstractIconConDispose(Class
* cl
, Object
* obj
, Msg msg
)
290 broadcastMessage(cl
, obj
, msg
);
291 retval
=DoSuperMethodA(cl
, obj
, msg
);
296 BOOPSI_DISPATCHER(IPTR
, abstractIconContainerDispatcher
, cl
, obj
, msg
)
301 switch(msg
->MethodID
)
304 retval
=abstractIconConNew(cl
, obj
, (struct opSet
*)msg
);
307 retval
=abstractIconConAdd(cl
, obj
, (struct opMember
*)msg
);
310 retval
=abstractIconConRemove(cl
, obj
, (struct opMember
*)msg
);
313 retval
=abstractIconConSet(cl
, obj
, (struct opSet
*)msg
);
316 retval
=abstractIconConGet(cl
, obj
, (struct opGet
*)msg
);
318 case AICM_UnselectAll
:
319 retval
=abstractIconConUnselectAll(cl
, obj
, msg
);
321 case AICM_UpdateSelectList
:
322 retval
=abstractIconConUpdateSelectList(cl
, obj
, (struct opUpdateSelectList
*)msg
);
325 retval
=abstractIconConDispose(cl
, obj
, msg
);
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
);
342 BOOPSI_DISPATCHER_END