grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / prefs / Zune / listview.c
blobe7bb7c6f569656e9b0d09fbadcc2e2938045ca38
1 /*
2 Copyright (C) 2012, The AROS Development Team.
3 $Id$
4 */
6 #define DEBUG 0
7 #include <aros/debug.h>
9 #include <proto/intuition.h>
10 #include <proto/utility.h>
11 #include <proto/muimaster.h>
12 #include <libraries/mui.h>
13 #include <devices/rawkeycodes.h>
14 #include <zune/customclasses.h>
16 #ifdef __AROS__
17 #include <proto/alib.h>
18 #endif
20 #include "zunestuff.h"
22 struct MUI_CustomClass *ClassListview_CLASS;
24 struct ClassListview_DATA
26 Object *list;
27 struct MUI_EventHandlerNode ehn;
31 IPTR ClassListview__OM_NEW(struct IClass *CLASS, Object *obj, struct opSet *message)
33 struct ClassListview_DATA *data = NULL;
35 obj = (Object *)DoSuperNewTags(CLASS, obj, NULL,
36 TAG_MORE, (IPTR) message->ops_AttrList);
38 if (!obj) return FALSE;
40 data = INST_DATA(CLASS, obj);
42 data->list = (Object *)GetTagData(MUIA_Listview_List, (IPTR)NULL, message->ops_AttrList);
44 data->ehn.ehn_Events = IDCMP_RAWKEY;
45 data->ehn.ehn_Priority = 0;
46 data->ehn.ehn_Flags = 0;
47 data->ehn.ehn_Object = obj;
48 data->ehn.ehn_Class = CLASS;
50 return (IPTR)obj;
53 IPTR ClassListview__MUIM_Setup(struct IClass *CLASS, Object *obj, struct MUIP_Setup *message)
55 struct ClassListview_DATA *data = INST_DATA(CLASS, obj);
56 LONG i;
58 if (!DoSuperMethodA(CLASS, obj, (Msg) message)) return (IPTR)NULL;
60 DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn);
62 for(i = 0; ; i++)
64 struct page_entry *entry;
66 DoMethod(data->list, MUIM_List_GetEntry, i, &entry);
67 if (!entry)
68 break;
70 if (entry->mcp_icon)
72 entry->mcp_listimage =
73 (APTR)DoMethod(data->list, MUIM_List_CreateImage, entry->mcp_icon, 0);
75 D(bug("listview setup image %p listimage %p\n",
76 entry->mcp_icon, entry->mcp_listimage));
78 return 1;
81 IPTR ClassListview__MUIM_Cleanup(struct IClass *CLASS, Object *obj, struct MUIP_Cleanup *message)
83 struct ClassListview_DATA *data = INST_DATA(CLASS, obj);
84 LONG i;
86 DoMethod(_win(obj), MUIM_Window_RemEventHandler, (IPTR)&data->ehn);
88 for(i = 0; ; i++)
90 struct page_entry *entry;
92 DoMethod(data->list, MUIM_List_GetEntry, i, &entry);
93 if (!entry)
94 break;
96 if (entry->mcp_listimage)
98 DoMethod(data->list, MUIM_List_DeleteImage, entry->mcp_listimage, 0);
101 return DoSuperMethodA(CLASS, obj, (Msg)message);
104 IPTR ClassListview__MUIM_HandleEvent(struct IClass *CLASS, Object *obj, struct MUIP_HandleEvent *message)
106 struct ClassListview_DATA *data = INST_DATA(CLASS, obj);
107 IPTR retval = MUI_EventHandlerRC_Eat;
109 if ((message->imsg) && (message->imsg->Class == IDCMP_RAWKEY) && ((IPTR)obj == XGET(_win(obj), MUIA_Window_ActiveObject)))
111 switch(message->imsg->Code)
113 case RAWKEY_HOME:
114 SET(data->list, MUIA_List_Active, MUIV_List_Active_Top);
115 break;
116 case RAWKEY_END:
117 SET(data->list, MUIA_List_Active, MUIV_List_Active_Bottom);
118 break;
119 case RAWKEY_PAGEUP:
120 SET(data->list, MUIA_List_Active, MUIV_List_Active_PageUp);
121 break;
122 case RAWKEY_PAGEDOWN:
123 SET(data->list, MUIA_List_Active, MUIV_List_Active_PageDown);
124 break;
125 case RAWKEY_UP:
126 SET(data->list, MUIA_List_Active, MUIV_List_Active_Up);
127 break;
128 case RAWKEY_DOWN:
129 SET(data->list, MUIA_List_Active, MUIV_List_Active_Down);
130 break;
131 default:
132 retval = 0;
133 break;
136 else
137 retval = 0;
139 return retval;
142 BOOPSI_DISPATCHER(IPTR, ClassListview_Dispatcher, CLASS, self, message)
144 switch (message->MethodID)
146 case OM_NEW:
147 return ClassListview__OM_NEW(CLASS, self, (struct opSet *)message);
149 case MUIM_Setup:
150 return ClassListview__MUIM_Setup(CLASS, self, (struct MUIP_Setup *)message);
152 case MUIM_Cleanup:
153 return ClassListview__MUIM_Cleanup(CLASS, self, (struct MUIP_Cleanup *)message);
155 case MUIM_HandleEvent:
156 return ClassListview__MUIM_HandleEvent(CLASS, self, (struct MUIP_HandleEvent *)message);
158 default:
159 return DoSuperMethodA(CLASS, self, message);
162 return 0;
164 BOOPSI_DISPATCHER_END
167 struct MUI_CustomClass *create_listview_class(void)
169 return MUI_CreateCustomClass(NULL, MUIC_Listview, NULL, sizeof(struct ClassListview_DATA), ClassListview_Dispatcher);
172 void delete_listview_class(void)
174 if (ClassListview_CLASS)
175 MUI_DeleteCustomClass(ClassListview_CLASS);