2 Copyright (C) 2012, The AROS Development Team.
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>
17 #include <proto/alib.h>
20 #include "zunestuff.h"
22 struct MUI_CustomClass
*ClassListview_CLASS
;
24 struct ClassListview_DATA
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
;
53 IPTR
ClassListview__MUIM_Setup(struct IClass
*CLASS
, Object
*obj
, struct MUIP_Setup
*message
)
55 struct ClassListview_DATA
*data
= INST_DATA(CLASS
, obj
);
58 if (!DoSuperMethodA(CLASS
, obj
, (Msg
) message
)) return (IPTR
)NULL
;
60 DoMethod(_win(obj
), MUIM_Window_AddEventHandler
, (IPTR
)&data
->ehn
);
64 struct page_entry
*entry
;
66 DoMethod(data
->list
, MUIM_List_GetEntry
, i
, &entry
);
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
));
81 IPTR
ClassListview__MUIM_Cleanup(struct IClass
*CLASS
, Object
*obj
, struct MUIP_Cleanup
*message
)
83 struct ClassListview_DATA
*data
= INST_DATA(CLASS
, obj
);
86 DoMethod(_win(obj
), MUIM_Window_RemEventHandler
, (IPTR
)&data
->ehn
);
90 struct page_entry
*entry
;
92 DoMethod(data
->list
, MUIM_List_GetEntry
, i
, &entry
);
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
)
114 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_Top
);
117 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
120 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_PageUp
);
122 case RAWKEY_PAGEDOWN
:
123 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_PageDown
);
126 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_Up
);
129 SET(data
->list
, MUIA_List_Active
, MUIV_List_Active_Down
);
142 BOOPSI_DISPATCHER(IPTR
, ClassListview_Dispatcher
, CLASS
, self
, message
)
144 switch (message
->MethodID
)
147 return ClassListview__OM_NEW(CLASS
, self
, (struct opSet
*)message
);
150 return ClassListview__MUIM_Setup(CLASS
, self
, (struct MUIP_Setup
*)message
);
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
);
159 return DoSuperMethodA(CLASS
, self
, message
);
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
);