2 Copyright © 1995-2003, 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>
19 #include "desktop_intern.h"
21 #include <proto/dos.h>
22 #include <proto/intuition.h>
23 #include <proto/utility.h>
25 #include "presentation.h"
28 #include "desktop_intern_protos.h"
30 IPTR
observerNew(Class
* cl
, Object
* obj
, struct opSet
* msg
)
33 struct ObserverClassData
*data
;
34 struct TagItem
*tstate
= msg
->ops_AttrList
,
36 Object
*presentation
= NULL
,
39 while ((tag
= NextTagItem(&tstate
)) != NULL
)
44 presentation
= (Object
*) tag
->ti_Data
;
48 parent
= (Object
*) tag
->ti_Data
;
52 continue; /* Don't supress non-processed tags */
55 tag
->ti_Tag
= TAG_IGNORE
;
58 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
61 obj
= (Object
*) retval
;
62 data
= INST_DATA(cl
, obj
);
63 data
->presentation
= presentation
;
64 data
->parent
= parent
;
65 NEWLIST((struct List
*) &data
->freeList
);
68 DoMethod(presentation
, MUIM_Notify
, PA_InTree
, MUIV_EveryTime
, (IPTR
) obj
, 3,
69 MUIM_Set
, OA_InTree
, TRUE
);
75 IPTR
observerSet(Class
* cl
, Object
* obj
, struct opSet
* msg
)
77 struct ObserverClassData
*data
;
80 *tstate
= msg
->ops_AttrList
;
82 data
= (struct ObserverClassData
*) INST_DATA(cl
, obj
);
84 while ((tag
= NextTagItem(&tstate
)))
90 Object
*pparent
= NULL
;
92 data
->inTree
= tag
->ti_Data
;
93 GetAttr(MUIA_Parent
, data
->presentation
, (IPTR
*) &pparent
);
94 // something has to be at the top of the tree...
95 // the top object won't have a parent
98 data
->parent
= _observer(pparent
);
100 DoMethod(obj
, MUIM_Notify
, OA_Disused
, TRUE
,
101 MUIV_EveryTime
, (IPTR
) data
->parent
, 2,
102 OM_Delete
, (IPTR
) obj
);
104 DoMethod(data
->presentation
, MUIM_Notify
, PA_Disused
,
105 TRUE
, MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_Set
,
110 data
->parent
= (Object
*) tag
->ti_Data
;
112 DoMethod(obj
, MUIM_Notify
, OA_Disused
, TRUE
,
113 MUIV_EveryTime
, (IPTR
) data
->parent
, 2, OM_Delete
, (IPTR
) obj
);
120 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
125 IPTR
observerGet(Class
* cl
, Object
* obj
, struct opGet
* msg
)
128 struct ObserverClassData
*data
;
130 data
= (struct ObserverClassData
*) INST_DATA(cl
, obj
);
132 switch (msg
->opg_AttrID
)
135 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
142 IPTR
observerDispose(Class
* cl
, Object
* obj
, Msg msg
)
145 struct ObserverClassData
*data
;
148 data
= (struct ObserverClassData
*) INST_DATA(cl
, obj
);
150 fn
= (struct FreeNode
*) RemHead((struct List
*) &data
->freeList
);
157 retval
= DoSuperMethodA(cl
, obj
, msg
);
162 IPTR
observerFreeListAdd(Class
* cl
, Object
* obj
,
163 struct ObsFreeListAddMsg
* msg
)
167 struct ObserverClassData
*data
;
169 data
= (struct ObserverClassData
*) INST_DATA(cl
, obj
);
171 fn
= AllocVec(sizeof(struct FreeNode
), MEMF_ANY
);
172 fn
->f_mem
= msg
->free
;
174 AddTail((struct List
*) &data
->freeList
, (struct Node
*) fn
);
179 IPTR
observerDelete(Class
* cl
, Object
* obj
, struct ObsDeleteMsg
* msg
)
182 struct ObserverClassData
*data
;
184 data
= (struct ObserverClassData
*) INST_DATA(cl
, obj
);
186 DisposeObject(msg
->obj
);
191 BOOPSI_DISPATCHER(IPTR
, observerDispatcher
, cl
, obj
, msg
)
195 switch (msg
->MethodID
)
198 retval
= observerNew(cl
, obj
, (struct opSet
*) msg
);
201 retval
= observerSet(cl
, obj
, (struct opSet
*) msg
);
204 retval
= observerGet(cl
, obj
, (struct opGet
*) msg
);
207 retval
= observerDispose(cl
, obj
, msg
);
209 case OM_FreeList_Add
:
211 observerFreeListAdd(cl
, obj
,
212 (struct ObsFreeListAddMsg
*) msg
);
215 retval
= observerDelete(cl
, obj
, (struct ObsDeleteMsg
*) msg
);
218 retval
= DoSuperMethodA(cl
, obj
, msg
);
224 BOOPSI_DISPATCHER_END