2 Copyright © 2003-2013, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 #include <proto/alib.h>
9 #include <proto/exec.h>
10 #include <proto/intuition.h>
11 #include <proto/utility.h>
12 #include <proto/muimaster.h>
13 #include <proto/dos.h>
14 #include <proto/alib.h>
16 #include <zune/customclasses.h>
17 #include <zune/prefseditor.h>
22 #include "page_region.h"
23 #include "registertab.h"
25 static struct Hook display_hook
;
27 /*** Instance Data **********************************************************/
37 struct MUI_CustomClass
*Region_CLASS
;
39 /*** Helpers *****************************************************************/
41 /**********************************************
42 * The display function for the Region listview
43 **********************************************/
44 STATIC VOID
region_display_func(struct Hook
*h
, char **array
, struct ListviewEntry
*entry
)
46 *array
++ = entry
->displayflag
;
47 *array
= entry
->node
.ln_Name
;
50 /*** Methods ****************************************************************
54 Object
*Region__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
56 struct Region_DATA
*data
;
57 struct TagItem
*tstate
, *tag
;
58 struct RegionEntry
*entry
;
60 D(bug("[LocalePrefs-RegionClass] Region Class New\n"));
62 display_hook
.h_Entry
= HookEntry
;
63 display_hook
.h_SubEntry
= (HOOKFUNC
)region_display_func
;
66 * region flags are at the moment 17 pixels high
67 * MUIA_List_MinLineHeight, 19 leaves at least two
68 * pixel space between the images
69 * If images ever get bigger, this should be
73 obj
= (Object
*) DoSuperNewTags
78 MUIA_List_MinLineHeight
, 20,
79 MUIA_List_Format
, "P=\033c,",
80 MUIA_List_DisplayHook
, &display_hook
,
86 D(bug("[LocalePrefs-RegionClass] ERROR: DoSuperNewTags failed!\n"));
90 data
= INST_DATA(cl
, obj
);
92 tstate
= ((struct opSet
*)msg
)->ops_AttrList
;
93 while ((tag
= (struct TagItem
*) NextTagItem((APTR
) &tstate
)))
98 data
->prefs
= (Object
*) tag
->ti_Data
;
105 ForeachNode(®ion_list
, entry
)
110 MUIM_List_InsertSingle
,
112 MUIV_List_Insert_Bottom
116 /* we did remember that */
117 NNSET(data
->child
, MUIA_List_Active
, data
->active
);
119 DoMethod(obj
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
, (IPTR
) data
->prefs
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
125 /*** Get ******************************************************************/
126 static IPTR
Region__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
128 struct Region_DATA
*data
= INST_DATA(cl
, obj
);
129 struct RegionEntry
*entry
;
135 switch (msg
->opg_AttrID
)
137 case MUIA_Region_Regionname
:
138 GET(data
->child
, MUIA_List_Active
, &nr
);
141 ForeachNode(®ion_list
, entry
)
145 rc
= (IPTR
)entry
->lve
.realname
;
152 *msg
->opg_Storage
= 0;
158 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
161 *msg
->opg_Storage
= rc
;
165 /*** Set ******************************************************************/
166 static IPTR
Region__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
168 struct Region_DATA
*data
= INST_DATA(cl
, obj
);
169 struct TagItem
*tstate
, *tag
;
170 struct RegionEntry
*entry
;
175 tstate
= msg
->ops_AttrList
;
178 while ((tag
= (struct TagItem
*) NextTagItem((APTR
) &tstate
)))
182 case MUIA_Region_Regionname
:
186 ForeachNode(®ion_list
, entry
)
188 if (!stricmp(entry
->lve
.realname
, (STRPTR
)tag
->ti_Data
))
197 D(bug("[LocalePrefs-RegionClass] ERROR: could not find >%s< !?\n",tag
->ti_Data
));
201 NNSET(data
->child
, MUIA_List_Active
, nr
);
207 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
213 MUI_Redraw(obj
, MADF_DRAWOBJECT
);
219 /*** Setup ******************************************************************/
222 Region
, NULL
, MUIC_List
, NULL
,
223 OM_NEW
, struct opSet
*,
224 OM_SET
, struct opSet
*,
225 OM_GET
, struct opGet
*