revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / muimaster / classes / listview.c
blob13700344eb88645c12c679ce7f3d82c5cc8647a2
1 /*
2 Copyright © 2002-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <clib/alib_protos.h>
9 #include <proto/utility.h>
10 #include <proto/intuition.h>
11 #include <proto/muimaster.h>
13 #include "mui.h"
15 extern struct Library *MUIMasterBase;
17 struct MUI_ListviewData
19 Object *list;
22 /****** Listview.mui/MUIA_Listview_DefClickColumn ****************************
24 * NAME
25 * MUIA_Listview_DefClickColumn -- (V7) [ISG], LONG
27 * FUNCTION
28 * The default value to be returned for MUIA_Listview_ClickColumn when a
29 * list entry is "double clicked" by pressing the "press" key (usually
30 * return/enter). The default default is zero.
32 * SEE ALSO
33 * MUIA_Listview_ClickColumn
35 ******************************************************************************
39 /****** Listview.mui/MUIA_Listview_DoubleClick *******************************
41 * NAME
42 * MUIA_Listview_DoubleClick -- (V4) [..G], BOOL
44 * FUNCTION
45 * Set to TRUE when a list entry is double-clicked or the "press" key
46 * (usually return/enter) is received.
48 * SEE ALSO
49 * MUIA_Listview_ClickColumn, MUIA_Listview_DefClickColumn,
50 * MUIA_Listview_SelectChange
52 ******************************************************************************
56 /****** Listview.mui/MUIA_Listview_DragType **********************************
58 * NAME
59 * MUIA_Listview_DragType -- (V11) [ISG], LONG
61 * FUNCTION
62 * Specifies whether list entries can be dragged as part of a
63 * drag-and-drop operation. Two values can be used:
64 * MUIV_Listview_DragType_None: entries cannot be dragged
65 * MUIV_Listview_DragType_Immediate: entries can be dragged
67 * SEE ALSO
68 * MUIA_Listview_DragSortable, MUIA_Draggable
70 ******************************************************************************
74 /**************************************************************************
75 OM_NEW
76 **************************************************************************/
77 IPTR Listview__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
79 struct MUI_ListviewData *data;
80 struct TagItem *tag, *tags;
81 Object *list =
82 (Object *) GetTagData(MUIA_Listview_List, (IPTR) NULL,
83 msg->ops_AttrList);
85 if (!list)
86 return (IPTR) NULL;
88 obj = (Object *) DoSuperNewTags(cl, obj, NULL,
89 MUIA_Group_Horiz, TRUE,
90 MUIA_InnerLeft, 0,
91 MUIA_InnerRight, 0,
92 MUIA_Group_Spacing, 0,
93 Child, list,
94 TAG_MORE, msg->ops_AttrList);
96 if (!obj)
97 return (IPTR) NULL;
99 data = INST_DATA(cl, obj);
100 data->list = list;
102 /* parse initial taglist, forward to list */
103 for (tags = msg->ops_AttrList; (tag = NextTagItem(&tags));)
105 switch (tag->ti_Tag)
107 case MUIA_Listview_DefClickColumn:
108 case MUIA_Listview_DragType:
109 case MUIA_Listview_Input:
110 case MUIA_Listview_MultiSelect:
111 case MUIA_Listview_ScrollerPos:
112 set(list, tag->ti_Tag, tag->ti_Data);
113 break;
117 return (IPTR) obj;
120 /**************************************************************************
121 OM_GET
122 **************************************************************************/
123 IPTR Listview__OM_GET(struct IClass *cl, Object *obj, struct opGet *msg)
125 /* small macro to simplify return value storage */
126 #define STORE *(msg->opg_Storage)
127 struct MUI_ListviewData *data = INST_DATA(cl, obj);
129 switch (msg->opg_AttrID)
131 case MUIA_List_CompareHook:
132 case MUIA_List_ConstructHook:
133 case MUIA_List_DestructHook:
134 case MUIA_List_DisplayHook:
135 case MUIA_List_VertProp_First:
136 case MUIA_List_Format:
137 case MUIA_List_VertProp_Entries:
138 case MUIA_List_VertProp_Visible:
139 case MUIA_List_Active:
140 case MUIA_List_First:
141 case MUIA_List_Visible:
142 case MUIA_List_Entries:
143 case MUIA_List_Quiet:
144 case MUIA_Listview_ClickColumn:
145 case MUIA_Listview_DefClickColumn:
146 case MUIA_Listview_DoubleClick:
147 case MUIA_Listview_DragType:
148 case MUIA_Listview_SelectChange:
149 return GetAttr(msg->opg_AttrID, data->list, msg->opg_Storage);
151 case MUIA_Listview_List:
152 STORE = (IPTR) data->list;
153 return 1;
156 return DoSuperMethodA(cl, obj, (Msg) msg);
157 #undef STORE
160 static IPTR RedirectNotify(struct IClass *cl, Object *obj, Msg msg,
161 ULONG attr)
163 struct MUI_ListviewData *data = INST_DATA(cl, obj);
165 switch (attr)
167 case MUIA_List_Active:
168 case MUIA_List_AutoVisible:
169 case MUIA_List_CompareHook:
170 case MUIA_List_ConstructHook:
171 case MUIA_List_DestructHook:
172 case MUIA_List_DisplayHook:
173 case MUIA_List_DragSortable:
174 case MUIA_List_DropMark:
175 case MUIA_List_Entries:
176 case MUIA_List_First:
177 case MUIA_List_Format:
178 case MUIA_List_InsertPosition:
179 case MUIA_List_MultiTestHook:
180 case MUIA_List_Quiet:
181 case MUIA_List_ShowDropMarks:
182 case MUIA_List_Title:
183 case MUIA_List_VertProp_Entries:
184 case MUIA_List_VertProp_First:
185 case MUIA_List_VertProp_Visible:
186 case MUIA_List_Visible:
187 case MUIA_Listview_ClickColumn:
188 case MUIA_Listview_DoubleClick:
189 case MUIA_Listview_SelectChange:
190 return DoMethodA(data->list, msg);
193 return DoSuperMethodA(cl, obj, msg);
196 /**************************************************************************
197 MUIM_Notify
198 **************************************************************************/
199 IPTR Listview__MUIM_Notify(struct IClass *cl, Object *obj,
200 struct MUIP_Notify *msg)
202 if ((IPTR)msg->DestObj == MUIV_Notify_Self)
203 msg->DestObj = obj;
205 return RedirectNotify(cl, obj, (Msg) msg, msg->TrigAttr);
208 /**************************************************************************
209 MUIM_KillNotify
210 **************************************************************************/
211 IPTR Listview__MUIM_KillNotify(struct IClass *cl, Object *obj,
212 struct MUIP_KillNotify *msg)
214 return RedirectNotify(cl, obj, (Msg) msg, msg->TrigAttr);
217 /**************************************************************************
218 MUIM_KillNotifyObj
219 **************************************************************************/
220 IPTR Listview__MUIM_KillNotifyObj(struct IClass *cl, Object *obj,
221 struct MUIP_KillNotifyObj *msg)
223 if ((IPTR)msg->dest == MUIV_Notify_Self)
224 msg->dest = obj;
226 return RedirectNotify(cl, obj, (Msg) msg, msg->TrigAttr);
229 /* Note that there is no OM_SET method here because this method will be
230 propagated to the list by the Group class (superclass of both List and
231 Listview) */
232 BOOPSI_DISPATCHER(IPTR, Listview_Dispatcher, cl, obj, msg)
234 switch (msg->MethodID)
236 case OM_GET:
237 return Listview__OM_GET(cl, obj, (struct opGet *)msg);
238 case OM_NEW:
239 return Listview__OM_NEW(cl, obj, (struct opSet *)msg);
240 case MUIM_Notify:
241 return Listview__MUIM_Notify(cl, obj, (struct MUIP_Notify *)msg);
242 case MUIM_KillNotify:
243 return Listview__MUIM_KillNotify(cl, obj,
244 (struct MUIP_KillNotify *)msg);
245 case MUIM_KillNotifyObj:
246 return Listview__MUIM_KillNotifyObj(cl, obj,
247 (struct MUIP_KillNotifyObj *)msg);
248 case MUIM_List_Clear:
249 case MUIM_List_CreateImage:
250 case MUIM_List_DeleteImage:
251 case MUIM_List_Exchange:
252 case MUIM_List_GetEntry:
253 case MUIM_List_Insert:
254 case MUIM_List_InsertSingle:
255 case MUIM_List_Jump:
256 case MUIM_List_NextSelected:
257 case MUIM_List_Redraw:
258 case MUIM_List_Remove:
259 case MUIM_List_Select:
260 case MUIM_List_Sort:
261 case MUIM_List_TestPos:
263 struct MUI_ListviewData *data = INST_DATA(cl, obj);
265 return DoMethodA(data->list, msg);
270 return DoSuperMethodA(cl, obj, msg);
272 BOOPSI_DISPATCHER_END
275 * Class descriptor.
277 const struct __MUIBuiltinClass _MUI_Listview_desc =
279 MUIC_Listview,
280 MUIC_Group,
281 sizeof(struct MUI_ListviewData),
282 (void *) Listview_Dispatcher