5 typedef struct _Elm_Params_Calendar
10 const char *select_mode;
12 } Elm_Params_Calendar;
14 #define SELECT_MODE_GET(CHOICES, STR) \
16 for (i = 0; i < (sizeof(CHOICES) / sizeof(CHOICES[0])); ++i) \
17 if (!strcmp(STR, CHOICES[i])) \
21 static const char *_calendar_select_modes[] = {"default", "always", "none",
24 static Elm_Calendar_Select_Mode
25 _calendar_select_mode_get(const char *select_mode)
27 assert(sizeof(_calendar_select_modes) /
28 sizeof(_calendar_select_modes[0])
29 == ELM_CALENDAR_SELECT_MODE_ONDEMAND + 2);
30 SELECT_MODE_GET(_calendar_select_modes, select_mode);
35 external_calendar_state_set(void *data __UNUSED__, Evas_Object *obj,
36 const void *from_params, const void *to_params,
39 const Elm_Params_Calendar *p;
40 Elm_Calendar_Select_Mode select_mode;
43 if (to_params) p = to_params;
44 else if (from_params) p = from_params;
49 elm_calendar_min_max_year_get(obj, NULL, &max);
50 elm_calendar_min_max_year_set(obj, p->year_min, max);
54 elm_calendar_min_max_year_get(obj, &min, NULL);
55 elm_calendar_min_max_year_set(obj, min, p->year_max);
59 select_mode = _calendar_select_mode_get(p->select_mode);
60 elm_calendar_select_mode_set(obj, select_mode);
65 external_calendar_param_set(void *data __UNUSED__, Evas_Object *obj,
66 const Edje_External_Param *param)
70 if (!strcmp(param->name, "year_min"))
72 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
74 elm_calendar_min_max_year_get(obj, NULL, &max);
75 elm_calendar_min_max_year_set(obj, param->i, max);
79 else if (!strcmp(param->name, "year_max"))
81 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
83 elm_calendar_min_max_year_get(obj, &min, NULL);
84 elm_calendar_min_max_year_set(obj, min,param->i);
88 else if (!strcmp(param->name, "select_mode"))
90 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
92 Elm_Calendar_Select_Mode select_mode;
93 select_mode = _calendar_select_mode_get(param->s);
94 elm_calendar_select_mode_set(obj, select_mode);
99 ERR("unknown parameter '%s' of type '%s'",
100 param->name, edje_external_param_type_str(param->type));
106 external_calendar_param_get(void *data __UNUSED__, const Evas_Object *obj,
107 Edje_External_Param *param)
111 if (!strcmp(param->name, "year_min"))
113 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
115 elm_calendar_min_max_year_get(obj, &(param->i) ,&max);
119 else if (!strcmp(param->name, "year_max"))
121 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
123 elm_calendar_min_max_year_get(obj, &min,&(param->i));
127 else if (!strcmp(param->name, "select_mode"))
129 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
131 Elm_Calendar_Select_Mode mode;
132 mode = elm_calendar_select_mode_get(obj);
133 param->s = _calendar_select_modes[mode];
139 ERR("unknown parameter '%s' of type '%s'",
140 param->name, edje_external_param_type_str(param->type));
146 external_calendar_params_parse(void *data __UNUSED__,
147 Evas_Object *obj __UNUSED__,
148 const Eina_List *params)
150 Elm_Params_Calendar *mem;
151 Edje_External_Param *param;
154 mem = calloc(1, sizeof(Elm_Params_Calendar));
158 EINA_LIST_FOREACH(params, l, param)
160 if (!strcmp(param->name, "year_min"))
161 mem->year_min = param->i;
163 else if (!strcmp(param->name, "year_max"))
164 mem->year_max = param->i;
166 else if (!strcmp(param->name, "select_mode"))
167 mem->select_mode = eina_stringshare_add(param->s);
174 external_calendar_content_get(void *data __UNUSED__,
175 const Evas_Object *obj __UNUSED__,
176 const char *content __UNUSED__)
183 external_calendar_params_free(void *params)
185 Elm_Params_Calendar *mem = params;
186 if (mem->select_mode)
187 eina_stringshare_del(mem->select_mode);
191 static Edje_External_Param_Info external_calendar_params[] = {
192 DEFINE_EXTERNAL_COMMON_PARAMS,
193 EDJE_EXTERNAL_PARAM_INFO_INT("year_min"),
194 EDJE_EXTERNAL_PARAM_INFO_INT("year_max"),
195 EDJE_EXTERNAL_PARAM_INFO_STRING("select_mode"),
196 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
199 DEFINE_EXTERNAL_ICON_ADD(calendar, "calendar");
200 DEFINE_EXTERNAL_TYPE_SIMPLE(calendar, "Calendar");