Tabs to spaces, more consistent formatting.
[AROS.git] / workbench / libs / muimaster / classes / poplist.c
blob73207420a1cfefdc370bb373fe5a8f27defb569c
1 /*
2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/memory.h>
9 #include <clib/alib_protos.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
13 #include <proto/intuition.h>
14 #include <proto/muimaster.h>
16 #include <string.h>
17 #include <stdio.h>
19 #include "mui.h"
20 #include "muimaster_intern.h"
21 #include "support.h"
22 #include "support_classes.h"
23 #include "debug.h"
24 #include "poplist_private.h"
26 extern struct Library *MUIMasterBase;
28 LONG PoplistStrObjFunc(struct Hook *hook, Object *popup, Object *str)
30 struct Poplist_DATA *data = (struct Poplist_DATA *)hook->h_Data;
31 STRPTR strtext = NULL, listentry;
32 LONG index;
34 get(str, MUIA_String_Contents, &strtext);
36 for (index = 0;; index++)
38 DoMethod(data->list, MUIM_List_GetEntry, index, (IPTR) & listentry);
40 if (!listentry)
42 set(data->list, MUIA_List_Active, MUIV_List_Active_Off);
43 break;
46 if (stricmp(strtext, listentry) == 0)
48 set(data->list, MUIA_List_Active, index);
49 break;
53 return TRUE;
56 void PoplistObjStrFunc(struct Hook *hook, Object *popup, Object *str)
58 STRPTR listentry;
60 DoMethod(popup, MUIM_List_GetEntry, MUIV_List_GetEntry_Active,
61 (IPTR) & listentry);
63 if (listentry)
65 set(str, MUIA_String_Contents, listentry);
69 IPTR Poplist__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
71 STRPTR array =
72 (STRPTR) GetTagData(MUIA_Poplist_Array, 0, msg->ops_AttrList);
73 Object *lv, *list;
75 obj = (Object *) DoSuperNewTags(cl, obj, NULL,
76 MUIA_Popobject_Object, (IPTR) (lv = (Object *) ListviewObject,
77 MUIA_Listview_List, (IPTR) (list = (Object *) ListObject,
78 InputListFrame,
79 array ? MUIA_List_SourceArray : TAG_IGNORE, (IPTR) array,
80 End),
81 End),
82 TAG_MORE, (IPTR) msg->ops_AttrList);
84 if (obj)
86 struct Poplist_DATA *data = INST_DATA(cl, obj);
88 data->list = list;
90 data->strobj_hook.h_Entry = HookEntry;
91 data->strobj_hook.h_SubEntry = (HOOKFUNC) PoplistStrObjFunc;
92 data->strobj_hook.h_Data = data;
94 data->objstr_hook.h_Entry = HookEntry;
95 data->objstr_hook.h_SubEntry = (HOOKFUNC) PoplistObjStrFunc;
96 data->objstr_hook.h_Data = data;
98 SetAttrs(obj, MUIA_Popobject_StrObjHook, (IPTR) & data->strobj_hook,
99 MUIA_Popobject_ObjStrHook, (IPTR) & data->objstr_hook,
100 TAG_DONE);
102 DoMethod(lv, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
103 (IPTR) obj, 2, MUIM_Popstring_Close, TRUE);
106 return (IPTR) obj;
109 #if ZUNE_BUILTIN_POPLIST
110 BOOPSI_DISPATCHER(IPTR, Poplist_Dispatcher, cl, obj, msg)
112 switch (msg->MethodID)
114 case OM_NEW:
115 return Poplist__OM_NEW(cl, obj, (struct opSet *)msg);
116 default:
117 return DoSuperMethodA(cl, obj, msg);
120 BOOPSI_DISPATCHER_END
122 const struct __MUIBuiltinClass _MUI_Poplist_desc =
124 MUIC_Poplist,
125 MUIC_Popobject,
126 sizeof(struct Poplist_DATA),
127 (void *) Poplist_Dispatcher
129 #endif /* ZUNE_BUILTIN_POPLIST */