Use hardcoded settings for VIA VT1708S (they are reported to work
[AROS.git] / workbench / prefs / locale / page_country.c
blob081919fca82727ecdb746595d037d95097ef3786
1 /*
2 Copyright 2003-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 // #define MUIMASTER_YES_INLINE_STDARG
8 //#define DEBUG 1
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>
20 #include <stdio.h>
22 #include <aros/debug.h>
24 #include "prefs.h"
25 #include "page_country.h"
26 #include "registertab.h"
28 static struct Hook display_hook;
30 /*** Instance Data **********************************************************/
32 struct Country_DATA
34 Object *me;
35 Object *child;
36 Object *prefs;
37 ULONG active;
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
73 * no problem.
76 obj = (Object *) DoSuperNewTags
78 cl, obj, NULL,
80 InputListFrame,
81 MUIA_List_MinLineHeight, 19,
82 MUIA_List_Format, "P=\033c,",
83 MUIA_List_DisplayHook, &display_hook,
84 TAG_DONE
87 if (obj == NULL)
89 D(bug("ERROR: [country class] DoSuperNewTags failed!\n"));
90 return NULL;
93 data = INST_DATA(cl, obj);
95 tstate = ((struct opSet *)msg)->ops_AttrList;
96 while ((tag = (struct TagItem *) NextTagItem((APTR) &tstate)))
98 switch (tag->ti_Tag)
100 case MUIA_UserData:
101 data->prefs = (Object *) tag->ti_Data;
102 break;
106 data->child = obj;
108 ForeachNode(&country_list, entry)
110 DoMethod
112 data->child,
113 MUIM_List_InsertSingle,
114 (IPTR)entry,
115 MUIV_List_Insert_Bottom
119 /* we did remember that */
120 NNSET(data->child, MUIA_List_Active, data->active);
121 /* changed hook */
122 DoMethod(obj, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, (IPTR) data->prefs, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE);
124 data->me = obj;
125 return obj;
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;
133 IPTR rc;
134 IPTR nr = 0;
135 ULONG i;
138 switch (msg->opg_AttrID)
140 case MUIA_Country_Countryname:
141 GET(data->child, MUIA_List_Active, &nr);
142 rc = -1;
143 i = 0;
144 ForeachNode(&country_list, entry)
146 if (i == nr)
148 rc = (IPTR)entry->lve.realname;
150 i++;
153 if (rc == -1)
155 *msg->opg_Storage = 0;
156 return FALSE;
158 break;
160 default:
161 return DoSuperMethodA(cl, obj, (Msg)msg);
164 *msg->opg_Storage = rc;
165 return TRUE;
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;
174 ULONG update;
175 ULONG nr;
176 ULONG i;
178 tstate = msg->ops_AttrList;
179 update = FALSE;
181 while ((tag = (struct TagItem *) NextTagItem((APTR) &tstate)))
183 switch (tag->ti_Tag)
185 case MUIA_Country_Countryname:
187 nr = -1;
188 i = 0;
189 ForeachNode(&country_list, entry)
191 if (!stricmp(entry->lve.realname, (STRPTR)tag->ti_Data))
193 nr=i;
195 i++;
198 if (nr < 0)
200 D(bug("ERROR: [country class] could not find >%s< !?\n",tag->ti_Data));
202 else
204 NNSET(data->child, MUIA_List_Active, nr);
205 update = TRUE;
207 break;
209 default:
210 return DoSuperMethodA(cl, obj, (Msg)msg);
214 if(update)
216 MUI_Redraw(obj, MADF_DRAWOBJECT);
219 return TRUE;
222 /*** Setup ******************************************************************/
223 ZUNE_CUSTOMCLASS_3
225 Country, NULL, MUIC_List, NULL,
226 OM_NEW, struct opSet *,
227 OM_SET, struct opSet *,
228 OM_GET, struct opGet *