From 3f2338837e266bb44a3dc82ce0595bd8020516d7 Mon Sep 17 00:00:00 2001 From: deadwood Date: Mon, 15 Jun 2015 19:34:03 +0000 Subject: [PATCH] Listtree.mcc: implement mechanism for sending messages to Listtree-inherited classes with overridden functions Otherwise such overridden functions would never get called. This is needed for functionality invoked by user interaction (ie. Drag methods). git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50832 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/classes/zune/listtree/listtree.c | 75 +++++++++++++++++++++++++++ workbench/classes/zune/listtree/listtree.conf | 3 ++ 2 files changed, 78 insertions(+) diff --git a/workbench/classes/zune/listtree/listtree.c b/workbench/classes/zune/listtree/listtree.c index e9f11b3319..2b82ca2b40 100644 --- a/workbench/classes/zune/listtree/listtree.c +++ b/workbench/classes/zune/listtree/listtree.c @@ -25,6 +25,28 @@ #define ADD2INITCLASSES(symbol, pri) ADD2SET(symbol, CLASSESINIT, pri) #define ADD2EXPUNGECLASSES(symbol, pri) ADD2SET(symbol, CLASSESEXPUNGE, pri) +/* Routing of inherited methods calls: + * Some methods are often overriden in child classes of Listree, for example DragReport. + * On the other hand, those methods get called as interaction on the NListtree object. + * To allow using overriden methods, the following call sequence is implemented: + * NListtreeInt.A -> Listreee.A + * Listtree.A -> NListtreeInt.SuperA + * In case user inherited code, the call sequence looks as follows + * NListtreeInt.A -> Listreee-inherited.A + * Listreee-inherited.A -> Listreee.A + * Listtree.A -> NListtreeInt.SuperA + */ + +#define MUIA_NListtreeInt_Listtree 0xfec81401UL /* .s. Object * */ + +#define MUIM_NListtreeInt_ForwardSuperMethod 0xfec81301UL + +struct MUIP_NListtreeInt_ForwardSuperMethod +{ + STACKED ULONG MethodID; + STACKED Msg msg; +}; + struct NListtreeInt_DATA { Object * listtree; @@ -32,10 +54,48 @@ struct NListtreeInt_DATA static struct MUI_CustomClass * CL_NListtreeInt; +IPTR NListtreeInt__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) +{ + struct NListtreeInt_DATA *data = INST_DATA(cl, obj); + struct TagItem *tstate = msg->ops_AttrList; + struct TagItem *tag; + + while ((tag = NextTagItem(&tstate)) != NULL) + { + switch (tag->ti_Tag) + { + case(MUIA_NListtreeInt_Listtree): + data->listtree = (Object *)tag->ti_Data; + break; + } + } + + return DoSuperMethodA(cl, obj, (Msg) msg); +} + +IPTR NListtreeInt__ForwardListree(struct IClass *cl, Object *obj, Msg msg) +{ + struct NListtreeInt_DATA *data = INST_DATA(cl, obj); + + return DoMethodA(data->listtree, msg); +} + +IPTR NListtreeInt__ForwardSuperMethod(struct IClass *cl, Object *obj, struct MUIP_NListtreeInt_ForwardSuperMethod * msg) +{ + return DoSuperMethodA(cl, obj, msg->msg); +} + BOOPSI_DISPATCHER(IPTR, NListtreeInt_Dispatcher, cl, obj, msg) { switch (msg->MethodID) { + case(OM_SET): return NListtreeInt__OM_SET(cl, obj, (struct opSet *)msg); + case(MUIM_NListtreeInt_ForwardSuperMethod): + return NListtreeInt__ForwardSuperMethod(cl, obj, (struct MUIP_NListtreeInt_ForwardSuperMethod *)msg); + case(MUIM_DragBegin): + case(MUIM_DragFinish): + case(MUIM_DragReport): + return NListtreeInt__ForwardListree(cl, obj, msg); } return DoSuperMethodA(cl, obj, msg); @@ -216,6 +276,9 @@ Object *Listtree__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg) } } + /* Setup connection */ + set(data->nlisttree, MUIA_NListtreeInt_Listtree, obj); + /* Setup root node */ { struct MUIS_Listtree_TreeNodeInt * _int = AllocPooled(data->pool, sizeof(struct MUIS_Listtree_TreeNodeInt)); @@ -697,3 +760,15 @@ IPTR Listtree__MUIM_Listtree_Close(struct IClass *cl, Object *obj, struct MUIP_L return DoMethod(data->nlisttree, MUIM_NListtree_Close, ln, tn, msg->Flags); } + +#define FORWARDNLISTTREESUPERMETHOD(methodname) \ +IPTR Listtree__##methodname(struct IClass *cl, Object *obj, Msg msg) \ +{ \ + struct Listtree_DATA *data = INST_DATA(cl, obj); \ + return DoMethod(data->nlisttree, MUIM_NListtreeInt_ForwardSuperMethod, msg); \ +} + +FORWARDNLISTTREESUPERMETHOD(MUIM_DragBegin) +FORWARDNLISTTREESUPERMETHOD(MUIM_DragFinish) +FORWARDNLISTTREESUPERMETHOD(MUIM_DragReport) + diff --git a/workbench/classes/zune/listtree/listtree.conf b/workbench/classes/zune/listtree/listtree.conf index 0d4ae72c42..031a8b140a 100644 --- a/workbench/classes/zune/listtree/listtree.conf +++ b/workbench/classes/zune/listtree/listtree.conf @@ -33,4 +33,7 @@ MUIM_List_TestPos MUIM_List_Redraw MUIM_List_CreateImage MUIM_List_DeleteImage +MUIM_DragBegin +MUIM_DragFinish +MUIM_DragReport ##end methodlist -- 2.11.4.GIT