2 Copyright 2003-2011, The AROS Development Team. All rights reserved.
6 // #define MUIMASTER_YES_INLINE_STDARG
9 #include <zune/customclasses.h>
10 #include <zune/prefseditor.h>
12 #include <proto/alib.h>
13 #include <proto/exec.h>
14 #include <proto/intuition.h>
15 #include <proto/utility.h>
16 #include <proto/muimaster.h>
17 #include <proto/dos.h>
18 #include <proto/alib.h>
22 #include <aros/debug.h>
25 #include "page_country.h"
26 #include "registertab.h"
28 static struct Hook display_hook
;
30 /*** Instance Data **********************************************************/
40 struct MUI_CustomClass
*Country_CLASS
;
42 /*** Helpers *****************************************************************/
44 /*************************************************
45 * The display function for the KeyTypes listview
46 *************************************************/
47 STATIC VOID
country_display_func(struct Hook
*h
, char **array
, struct ListviewEntry
*entry
)
49 *array
++ = entry
->displayflag
;
50 *array
= entry
->node
.ln_Name
;
53 /*** Methods ****************************************************************
57 Object
*Country__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
59 struct Country_DATA
*data
;
60 struct TagItem
*tstate
, *tag
;
61 struct CountryEntry
*entry
;
63 D(bug("[country class] Country Class New\n"));
65 display_hook
.h_Entry
= HookEntry
;
66 display_hook
.h_SubEntry
= (HOOKFUNC
)country_display_func
;
69 * country flags are at the moment 17 pixels high
70 * MUIA_List_MinLineHeight, 19 leaves at least two
71 * pixel space between the images
72 * If images ever get bigger, this should be
76 obj
= (Object
*) DoSuperNewTags
81 MUIA_List_MinLineHeight
, 19,
82 MUIA_List_Format
, "P=\033c,",
83 MUIA_List_DisplayHook
, &display_hook
,
89 D(bug("ERROR: [country class] DoSuperNewTags failed!\n"));
93 data
= INST_DATA(cl
, obj
);
95 tstate
= ((struct opSet
*)msg
)->ops_AttrList
;
96 while ((tag
= (struct TagItem
*) NextTagItem((APTR
) &tstate
)))
101 data
->prefs
= (Object
*) tag
->ti_Data
;
108 ForeachNode(&country_list
, entry
)
113 MUIM_List_InsertSingle
,
115 MUIV_List_Insert_Bottom
119 /* we did remember that */
120 NNSET(data
->child
, MUIA_List_Active
, data
->active
);
122 DoMethod(obj
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
, (IPTR
) data
->prefs
, 3, MUIM_Set
, MUIA_PrefsEditor_Changed
, TRUE
);
128 /*** Get ******************************************************************/
129 static IPTR
Country__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
131 struct Country_DATA
*data
= INST_DATA(cl
, obj
);
132 struct CountryEntry
*entry
;
138 switch (msg
->opg_AttrID
)
140 case MUIA_Country_Countryname
:
141 GET(data
->child
, MUIA_List_Active
, &nr
);
144 ForeachNode(&country_list
, entry
)
148 rc
= (IPTR
)entry
->lve
.realname
;
155 *msg
->opg_Storage
= 0;
161 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
164 *msg
->opg_Storage
= rc
;
168 /*** Set ******************************************************************/
169 static IPTR
Country__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
171 struct Country_DATA
*data
= INST_DATA(cl
, obj
);
172 struct TagItem
*tstate
, *tag
;
173 struct CountryEntry
*entry
;
178 tstate
= msg
->ops_AttrList
;
181 while ((tag
= (struct TagItem
*) NextTagItem((APTR
) &tstate
)))
185 case MUIA_Country_Countryname
:
189 ForeachNode(&country_list
, entry
)
191 if (!stricmp(entry
->lve
.realname
, (STRPTR
)tag
->ti_Data
))
200 D(bug("ERROR: [country class] could not find >%s< !?\n",tag
->ti_Data
));
204 NNSET(data
->child
, MUIA_List_Active
, nr
);
210 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
216 MUI_Redraw(obj
, MADF_DRAWOBJECT
);
222 /*** Setup ******************************************************************/
225 Country
, NULL
, MUIC_List
, NULL
,
226 OM_NEW
, struct opSet
*,
227 OM_SET
, struct opSet
*,
228 OM_GET
, struct opGet
*