grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / listtree / support.c
blobf79f55dadf1622ccb845bc05eb85c5e084771f70
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/muimaster.h>
7 #include <proto/utility.h>
8 #include <clib/alib_protos.h>
9 #include <mui/NListtree_mcc.h>
10 #include <mui/NList_mcc.h>
12 #include "support.h"
14 #include <aros/debug.h>
16 /* Internal version of NListtree that enables controling the dispatcher */
17 #include <aros/symbolsets.h>
18 #define ADD2INITCLASSES(symbol, pri) ADD2SET(symbol, CLASSESINIT, pri)
19 #define ADD2EXPUNGECLASSES(symbol, pri) ADD2SET(symbol, CLASSESEXPUNGE, pri)
21 /* Routing of inherited methods calls:
22 * Some methods are often overriden in child classes of Listree, for example DragReport.
23 * On the other hand, those methods get called as interaction on the NListtree object.
24 * To allow using overriden methods, the following call sequence is implemented:
25 * NListtreeInt.A -> Listreee.A
26 * Listtree.A -> NListtreeInt.SuperA
27 * In case user inherited code, the call sequence looks as follows
28 * NListtreeInt.A -> Listreee-inherited.A
29 * Listreee-inherited.A -> Listreee.A
30 * Listtree.A -> NListtreeInt.SuperA
33 #define MUIM_NListtreeInt_ForwardSuperMethod 0xfec81301UL
35 struct MUIP_NListtreeInt_ForwardSuperMethod
37 STACKED ULONG MethodID;
38 STACKED Msg msg;
41 struct NListtreeInt_DATA
43 Object * listtree;
46 struct MUI_CustomClass * CL_NListtreeInt;
48 IPTR NListtreeInt__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg)
50 struct NListtreeInt_DATA *data = INST_DATA(cl, obj);
51 struct TagItem *tstate = msg->ops_AttrList;
52 struct TagItem *tag;
54 while ((tag = NextTagItem(&tstate)) != NULL)
56 switch (tag->ti_Tag)
58 case(MUIA_NListtreeInt_Listtree):
59 data->listtree = (Object *)tag->ti_Data;
60 break;
64 return DoSuperMethodA(cl, obj, (Msg) msg);
67 IPTR NListtreeInt__ForwardListree(struct IClass *cl, Object *obj, Msg msg)
69 struct NListtreeInt_DATA *data = INST_DATA(cl, obj);
71 return DoMethodA(data->listtree, msg);
74 IPTR NListtreeInt__ForwardSuperMethod(struct IClass *cl, Object *obj, struct MUIP_NListtreeInt_ForwardSuperMethod * msg)
76 return DoSuperMethodA(cl, obj, msg->msg);
79 IPTR NListtreeInt__DoDrag(struct IClass *cl, Object *obj, struct MUIP_DoDrag * msg)
81 struct NListtreeInt_DATA *data = INST_DATA(cl, obj);
83 /* Use the listtree as the dragged object */
84 DoMethod(_win(data->listtree), MUIB_Window | 0x00000003,
85 (IPTR)data->listtree, msg->touchx, msg->touchy, msg->flags);
86 return 0;
89 IPTR NListtreeInt__DragQuery(struct IClass *cl, Object *obj, struct MUIP_DragQuery *msg)
91 struct NListtreeInt_DATA *data = INST_DATA(cl, obj);
93 if (data->listtree == msg->obj)
95 /* Forward to parent class passing "this" */
96 struct MUIP_DragQuery temp = *msg;
97 temp.obj = obj;
98 return DoSuperMethodA(cl, obj, &temp);
101 return DoSuperMethodA(cl, obj, msg);
104 BOOPSI_DISPATCHER(IPTR, NListtreeInt_Dispatcher, cl, obj, msg)
106 switch (msg->MethodID)
108 case(OM_SET): return NListtreeInt__OM_SET(cl, obj, (struct opSet *)msg);
109 case(MUIM_NListtreeInt_ForwardSuperMethod):
110 return NListtreeInt__ForwardSuperMethod(cl, obj, (struct MUIP_NListtreeInt_ForwardSuperMethod *)msg);
111 case(MUIM_DoDrag):
112 return NListtreeInt__DoDrag(cl, obj, (struct MUIP_DoDrag *)msg);
113 case(MUIM_DragQuery):
114 return NListtreeInt__DragQuery(cl, obj, (struct MUIP_DragQuery *)msg);
115 case(MUIM_ContextMenuBuild):
116 case(MUIM_ContextMenuChoice):
117 return NListtreeInt__ForwardListree(cl, obj, msg);
120 return DoSuperMethodA(cl, obj, msg);
122 BOOPSI_DISPATCHER_END
124 static int MCC_NListtreeInt_Startup(struct Library * lib)
126 CL_NListtreeInt = MUI_CreateCustomClass(lib, MUIC_NListtree, NULL, sizeof(struct NListtreeInt_DATA), NListtreeInt_Dispatcher);
127 return CL_NListtreeInt != NULL;
130 static void MCC_NListtreeInt_Shutdown(struct Library * lib)
132 MUI_DeleteCustomClass(CL_NListtreeInt);
135 ADD2INITCLASSES(MCC_NListtreeInt_Startup, -1);
136 ADD2EXPUNGECLASSES(MCC_NListtreeInt_Shutdown, -1);