5 typedef struct _Elm_Params_List
12 Eina_Bool h_mode_exists : 1;
14 Eina_Bool multi_exists : 1;
15 Eina_Bool always_select : 1;
16 Eina_Bool always_select_exists : 1;
19 #define CHOICE_GET(CHOICES, STR) \
21 for (i = 0; i < (sizeof(CHOICES)/sizeof(CHOICES[0])); i++) \
22 if (strcmp(STR, CHOICES[i]) == 0) \
25 static const char *scroller_policy_choices[] = {"auto", "on", "off", NULL};
26 static const char *list_mode_choices[] = {"compress", "scroll", "limit",
29 static Elm_Scroller_Policy
30 _scroller_policy_choices_setting_get(const char *policy_str)
32 assert(sizeof(scroller_policy_choices)/
33 sizeof(scroller_policy_choices[0]) == ELM_SCROLLER_POLICY_LAST + 1);
34 CHOICE_GET(scroller_policy_choices, policy_str);
35 return ELM_SCROLLER_POLICY_LAST;
39 _list_mode_setting_get(const char *mode_str)
41 assert(sizeof(list_mode_choices)/sizeof(list_mode_choices[0]) ==
43 CHOICE_GET(list_mode_choices, mode_str);
48 external_list_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
50 const Elm_Params_List *p;
51 Elm_Scroller_Policy policy_h, policy_v;
53 if (to_params) p = to_params;
54 else if (from_params) p = from_params;
59 Elm_List_Mode set = _list_mode_setting_get(p->mode);
61 if (set != ELM_LIST_LAST)
62 elm_list_mode_set(obj, set);
65 if ((p->policy_h) && (p->policy_v))
67 policy_h = _scroller_policy_choices_setting_get(p->policy_h);
68 policy_v = _scroller_policy_choices_setting_get(p->policy_v);
69 elm_list_scroller_policy_set(obj, policy_h, policy_v);
71 else if ((p->policy_h) || (p->policy_v))
73 elm_list_scroller_policy_get(obj, &policy_h, &policy_v);
76 policy_h = _scroller_policy_choices_setting_get(p->policy_h);
77 elm_list_scroller_policy_set(obj, policy_h, policy_v);
81 policy_v = _scroller_policy_choices_setting_get(p->policy_v);
82 elm_list_scroller_policy_set(obj, policy_h, policy_v);
87 elm_list_horizontal_set(obj, p->h_mode);
89 elm_list_multi_select_set(obj, p->multi);
90 if (p->always_select_exists)
93 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
95 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
100 external_list_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
102 if (!strcmp(param->name, "list mode"))
104 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
106 Elm_List_Mode set = _list_mode_setting_get(param->s);
107 if (set == ELM_LIST_LAST) return EINA_FALSE;
108 elm_list_mode_set(obj, set);
112 else if (!strcmp(param->name, "horizontal scroll"))
114 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
116 Elm_Scroller_Policy h, v;
117 elm_list_scroller_policy_get(obj, &h, &v);
118 h = _scroller_policy_choices_setting_get(param->s);
119 if (h == ELM_SCROLLER_POLICY_LAST) return EINA_FALSE;
120 elm_list_scroller_policy_set(obj, h, v);
124 else if (!strcmp(param->name, "vertical scroll"))
126 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
128 Elm_Scroller_Policy h, v;
129 elm_list_scroller_policy_get(obj, &h, &v);
130 v = _scroller_policy_choices_setting_get(param->s);
131 if (v == ELM_SCROLLER_POLICY_LAST) return EINA_FALSE;
132 elm_list_scroller_policy_set(obj, h, v);
136 else if (!strcmp(param->name, "horizontal mode"))
138 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
140 elm_list_horizontal_set(obj, param->i);
144 else if (!strcmp(param->name, "multi-select mode"))
146 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
148 elm_list_multi_select_set(obj, param->i);
152 else if (!strcmp(param->name, "always-select mode"))
154 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
157 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
159 elm_list_select_mode_set (obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
164 ERR("unknown parameter '%s' of type '%s'",
165 param->name, edje_external_param_type_str(param->type));
171 external_list_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
173 if (!strcmp(param->name, "horizontal mode"))
175 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
177 param->i = elm_list_horizontal_get(obj);
181 else if (!strcmp(param->name, "multi-select mode"))
183 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
185 param->i = elm_list_multi_select_get(obj);
189 else if (!strcmp(param->name, "always-select mode"))
191 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
193 if (elm_list_select_mode_get (obj) ==
194 ELM_OBJECT_SELECT_MODE_ALWAYS)
195 param->i = EINA_TRUE;
197 param->i = EINA_FALSE;
201 else if (!strcmp(param->name, "horizontal scroll"))
203 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
205 Elm_Scroller_Policy h, v;
206 elm_list_scroller_policy_get(obj, &h, &v);
208 param->s = scroller_policy_choices[h];
212 else if (!strcmp(param->name, "vertical scroll"))
214 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
216 Elm_Scroller_Policy h, v;
217 elm_list_scroller_policy_get(obj, &h, &v);
219 param->s = scroller_policy_choices[v];
223 else if (!strcmp(param->name, "list mode"))
225 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
227 Elm_List_Mode m = elm_list_mode_get(obj);
229 if (m == ELM_LIST_LAST)
232 param->s = list_mode_choices[m];
237 ERR("unknown parameter '%s' of type '%s'",
238 param->name, edje_external_param_type_str(param->type));
244 external_list_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
246 Elm_Params_List *mem;
247 Edje_External_Param *param;
250 mem = ELM_NEW(Elm_Params_List);
254 EINA_LIST_FOREACH(params, l, param)
256 if (!strcmp(param->name, "horizontal mode"))
258 mem->h_mode = param->i;
259 mem->h_mode_exists = EINA_TRUE;
261 else if (!strcmp(param->name, "multi-select mode"))
263 mem->multi = param->i;
264 mem->multi_exists = EINA_TRUE;
266 else if (!strcmp(param->name, "always-select mode"))
268 mem->always_select = param->i;
269 mem->always_select_exists = EINA_TRUE;
271 else if (!strcmp(param->name, "horizontal scroll"))
272 mem->policy_h = eina_stringshare_add(param->s);
273 else if (!strcmp(param->name, "vertical scroll"))
274 mem->policy_v = eina_stringshare_add(param->s);
275 else if (!strcmp(param->name, "list mode"))
276 mem->mode = eina_stringshare_add(param->s);
281 static Evas_Object *external_list_content_get(void *data __UNUSED__, const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
288 external_list_params_free(void *params)
290 Elm_Params_List *mem = params;
293 eina_stringshare_del(mem->mode);
295 eina_stringshare_del(mem->policy_h);
297 eina_stringshare_del(mem->policy_v);
302 static Edje_External_Param_Info external_list_params[] = {
303 DEFINE_EXTERNAL_COMMON_PARAMS,
304 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("list mode", "scroll",
306 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("horizontal scroll", "auto",
307 scroller_policy_choices),
308 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("vertical scroll", "auto",
309 scroller_policy_choices),
310 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal mode"),
311 EDJE_EXTERNAL_PARAM_INFO_BOOL("multi-select mode"),
312 EDJE_EXTERNAL_PARAM_INFO_BOOL("always-select mode"),
313 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
316 DEFINE_EXTERNAL_ICON_ADD(list, "list")
317 DEFINE_EXTERNAL_TYPE_SIMPLE(list, "List");