3 typedef struct _Elm_Params_Datefield
8 Eina_Bool mode_exists:1;
10 Eina_Bool year_exists:1;
12 Eina_Bool mon_exists:1;
14 Eina_Bool day_exists:1;
16 Eina_Bool hour_exists:1;
18 Eina_Bool min_exists:1;
19 } Elm_Params_Datefield;
21 static const char *datefield_layout_choices[] = {"time", "date", "dateandtime", NULL};
23 static Elm_Datefield_Layout
24 _datefield_layout_setting_get(const char *layout_str)
28 for (i = 0; i < sizeof(datefield_layout_choices)/sizeof(datefield_layout_choices[0]); i++)
30 if (!strcmp(layout_str, datefield_layout_choices[i]))
33 return ELM_DATEFIELD_LAYOUT_DATEANDTIME;
37 external_datefield_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
39 const Elm_Params_Datefield *p;
41 if (to_params) p = to_params;
42 else if (from_params) p = from_params;
47 Elm_Datefield_Layout layout = _datefield_layout_setting_get(p->layout);
48 elm_datefield_layout_set(obj, layout);
51 elm_datefield_date_format_set(obj, p->format);
53 elm_datefield_time_mode_set(obj, p->mode);
54 if ((p->year_exists) || (p->mon_exists) || (p->day_exists) || (p->hour_exists) || (p->min_exists))
56 int year, mon, day, hour, min;
57 elm_datefield_date_get(obj, &year, &mon, &day, &hour, &min);
59 if (p->year_exists) year = p->year;
60 if (p->mon_exists) mon = p->mon;
61 if (p->day_exists) day = p->day;
62 if (p->hour_exists) hour = p->hour;
63 if (p->min_exists) min = p->min;
64 elm_datefield_date_set(obj, year, mon, day, hour, min);
69 external_datefield_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
71 if (!strcmp(param->name, "layout"))
73 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
75 Elm_Datefield_Layout layout = _datefield_layout_setting_get(param->s);
76 elm_datefield_layout_set(obj, layout);
80 else if (!strcmp(param->name, "date_format"))
82 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
84 elm_datefield_date_format_set(obj, param->s);
88 else if (!strcmp(param->name, "time_mode"))
90 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
92 elm_datefield_time_mode_set(obj, param->i);
96 else if (!strcmp(param->name, "years"))
98 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
100 int mon, day, hour, min;
101 elm_datefield_date_get(obj, NULL, &mon, &day, &hour, &min);
102 elm_datefield_date_set(obj, param->i, mon, day, hour, min);
106 else if (!strcmp(param->name, "months"))
108 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
110 int year, day, hour, min;
111 elm_datefield_date_get(obj, &year, NULL, &day, &hour, &min);
112 elm_datefield_date_set(obj, year, param->i, day, hour, min);
116 else if (!strcmp(param->name, "days"))
118 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
120 int year, mon, hour, min;
121 elm_datefield_date_get(obj, &year, &mon, NULL, &hour, &min);
122 elm_datefield_date_set(obj, year, mon, param->i, hour, min);
126 else if (!strcmp(param->name, "hours"))
128 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
130 int year, mon, day, min;
131 elm_datefield_date_get(obj, &year, &mon, &day, NULL, &min);
132 elm_datefield_date_set(obj, year, mon, day, param->i, min);
136 else if (!strcmp(param->name, "days"))
138 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
140 int year, mon, day, hour;
141 elm_datefield_date_get(obj, &year, &mon, &day, &hour, NULL);
142 elm_datefield_date_set(obj, year, mon, day, hour, param->i);
147 ERR("unknown parameter '%s' of type '%s'",
148 param->name, edje_external_param_type_str(param->type));
154 external_datefield_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
156 if (!strcmp(param->name, "layout"))
158 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
160 Elm_Datefield_Layout layout = elm_datefield_layout_get(obj);
161 if (layout > ELM_DATEFIELD_LAYOUT_DATEANDTIME)
164 param->s = datefield_layout_choices[layout];
168 else if (!strcmp(param->name, "date_format"))
170 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
172 param->s = elm_datefield_date_format_get(obj);
176 else if (!strcmp(param->name, "time_mode"))
178 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
180 param->i = elm_datefield_time_mode_get(obj);
184 else if (!strcmp(param->name, "years"))
186 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
188 elm_datefield_date_get(obj, &(param->i), NULL, NULL, NULL, NULL);
192 else if (!strcmp(param->name, "months"))
194 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
196 elm_datefield_date_get(obj, NULL, &(param->i), NULL, NULL, NULL);
200 else if (!strcmp(param->name, "days"))
202 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
204 elm_datefield_date_get(obj, NULL, NULL, &(param->i),NULL, NULL);
208 else if (!strcmp(param->name, "hours"))
210 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
212 elm_datefield_date_get(obj, NULL, NULL, NULL, &(param->i), NULL);
216 else if (!strcmp(param->name, "minutes"))
218 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
220 elm_datefield_date_get(obj, NULL, NULL, NULL, NULL, &(param->i));
225 ERR("unknown parameter '%s' of type '%s'",
226 param->name, edje_external_param_type_str(param->type));
232 external_datefield_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
234 Elm_Params_Datefield *mem;
235 Edje_External_Param *param;
238 mem = calloc(1, sizeof(Elm_Params_Datefield));
242 EINA_LIST_FOREACH(params, l, param)
244 if (!strcmp(param->name, "layout"))
245 mem->layout = eina_stringshare_add(param->s);
246 else if (!strcmp(param->name, "date_format"))
247 mem->format = eina_stringshare_add(param->s);
248 else if (!strcmp(param->name, "time_mode"))
250 mem->mode = !!param->i;
251 mem->mode_exists = EINA_TRUE;
253 else if (!strcmp(param->name, "years"))
255 mem->year = param->i;
256 mem->year_exists = EINA_TRUE;
258 else if (!strcmp(param->name, "months"))
261 mem->mon_exists = EINA_TRUE;
263 else if (!strcmp(param->name, "days"))
266 mem->day_exists = EINA_TRUE;
268 else if (!strcmp(param->name, "hours"))
270 mem->hour = param->i;
271 mem->hour_exists = EINA_TRUE;
273 else if (!strcmp(param->name, "minutes"))
276 mem->min_exists = EINA_TRUE;
283 static Evas_Object *external_datefield_content_get(void *data __UNUSED__,
284 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
291 external_datefield_params_free(void *params)
293 Elm_Params_Datefield *mem = params;
296 eina_stringshare_del(mem->layout);
298 eina_stringshare_del(mem->format);
303 static Edje_External_Param_Info external_datefield_params[] = {
304 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("layout", "dateandtime", datefield_layout_choices),
305 EDJE_EXTERNAL_PARAM_INFO_STRING("date_format"),
306 EDJE_EXTERNAL_PARAM_INFO_BOOL("time_mode"),
307 EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT("years", 1900),
308 EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT("months", 1),
309 EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT("days", 1),
310 EDJE_EXTERNAL_PARAM_INFO_INT("hours"),
311 EDJE_EXTERNAL_PARAM_INFO_INT("minutes"),
312 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
315 DEFINE_EXTERNAL_ICON_ADD(datefield, "datefield");
316 DEFINE_EXTERNAL_TYPE_SIMPLE(datefield, "Datefield");