3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include "edit-repeat.h"
20 #include "radio-group.h"
21 #include "save-cancel.h"
23 enum __cal_edit_repeat_freq {
24 CAL_EDIT_REPEAT_FREQ_OFF = 0,
25 CAL_EDIT_REPEAT_FREQ_EVERY_DAY,
26 CAL_EDIT_REPEAT_FREQ_EVERY_3_DAY,
27 CAL_EDIT_REPEAT_FREQ_EVERY_WEEK,
28 CAL_EDIT_REPEAT_FREQ_EVERY_2_WEEK,
29 CAL_EDIT_REPEAT_FREQ_EVERY_MONTH,
30 CAL_EDIT_REPEAT_FREQ_EVERY_YEAR,
31 CAL_EDIT_REPEAT_FREQ_MAX
36 Evas_Object *ly; // self
39 cal_radio_group_h freq_radio_group;
40 cal_radio_group_h range_radio_group;
42 Evas_Object *day_selector;
43 Evas_Object *repeat_occurrence_entry;
44 Evas_Object *end_date;
46 struct tm *start_date_time;
51 int selected_freq_radio;
52 int prev_selected_freq_radio;
53 int selected_range_radio;
55 cal_edit_repeat_destroy_callback callback_func;
58 cal_save_cancel_h save_cancel;
60 } cal_edit_repeat_data;
62 static int __cal_edit_repeat_get_radio_index(int freq)
65 case CALENDAR_RECURRENCE_NONE:
66 return CAL_EDIT_REPEAT_FREQ_OFF;
67 case CALENDAR_RECURRENCE_DAILY:
68 return CAL_EDIT_REPEAT_FREQ_EVERY_DAY;
69 case CAL_REPEAT_EVERY_3_DAY:
70 return CAL_EDIT_REPEAT_FREQ_EVERY_3_DAY;
71 case CALENDAR_RECURRENCE_WEEKLY:
72 return CAL_EDIT_REPEAT_FREQ_EVERY_WEEK;
73 case CAL_REPEAT_EVERY_2_WEEK:
74 return CAL_EDIT_REPEAT_FREQ_EVERY_2_WEEK;
75 case CALENDAR_RECURRENCE_MONTHLY:
76 return CAL_EDIT_REPEAT_FREQ_EVERY_MONTH;
77 case CALENDAR_RECURRENCE_YEARLY:
78 return CAL_EDIT_REPEAT_FREQ_EVERY_YEAR;
80 ERR("Invalid value : %d", freq);
85 static int __cal_edit_repeat_get_freq(int radio_index)
87 switch (radio_index) {
88 case CAL_EDIT_REPEAT_FREQ_OFF:
89 return CALENDAR_RECURRENCE_NONE;
90 case CAL_EDIT_REPEAT_FREQ_EVERY_DAY:
91 return CALENDAR_RECURRENCE_DAILY;
92 case CAL_EDIT_REPEAT_FREQ_EVERY_3_DAY:
93 return CAL_REPEAT_EVERY_3_DAY;
94 case CAL_EDIT_REPEAT_FREQ_EVERY_WEEK:
95 return CALENDAR_RECURRENCE_WEEKLY;
96 case CAL_EDIT_REPEAT_FREQ_EVERY_2_WEEK:
97 return CAL_REPEAT_EVERY_2_WEEK;
98 case CAL_EDIT_REPEAT_FREQ_EVERY_MONTH:
99 return CALENDAR_RECURRENCE_MONTHLY;
100 case CAL_EDIT_REPEAT_FREQ_EVERY_YEAR:
101 return CALENDAR_RECURRENCE_YEARLY;
103 ERR("Invalid value : %d", radio_index);
104 return CALENDAR_RECURRENCE_NONE;
108 static int __cal_edit_repeat_range_index[] = {
110 CALENDAR_RANGE_COUNT,
111 CALENDAR_RANGE_UNTIL,
115 CAL_EDIT_REPEAT_SEPARATOR_FREQ,
116 CAL_EDIT_REPEAT_ITEM_FREQ,
117 CAL_EDIT_REPEAT_SEPARATOR_RANGE,
118 CAL_EDIT_REPEAT_ITEM_RANGE,
119 }cal_edit_repeat_item_type;
121 static Elm_Entry_Filter_Limit_Size _limit_2char = {
124 static Elm_Entry_Filter_Accept_Set _digit_only = {
125 .accepted = "0123456789",
128 static Elm_Genlist_Item_Class itc_seperator, itc_1icon_1text, itc_1icon, itc_2icon_1text;
130 typedef struct __cal_edit_repeat_item_data cal_edit_repeat_item_data;
131 struct __cal_edit_repeat_item_data
133 cal_edit_repeat_data *p;
135 cal_edit_repeat_item_type type;
140 #define is_leap_year_tm(y) (((y+1900)%4 == 0 && ((y+1900)%100 != 0 || (y+1900)%400 == 0))? 1 : 0)
142 static void __cal_edit_repeat_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
146 cal_edit_repeat_data *p = data;
148 cal_radio_group_destroy(p->freq_radio_group);
149 cal_radio_group_destroy(p->range_radio_group);
152 cal_save_cancel_destroy(p->save_cancel);
157 static void __cal_edit_repeat_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
159 cal_edit_repeat_data *p;
160 Evas_Event_Mouse_Up *ev = ei;
163 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
166 p = CAL_UTIL_GET_PRIV_DATA(obj);
167 cal_radio_group_select_radio(p->freq_radio_group, val);
168 p->prev_selected_freq_radio = p->selected_freq_radio;
169 p->selected_freq_radio = val;
172 static void __cal_edit_repeat_entry_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
177 Evas_Event_Mouse_Up *ev = ei;
180 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
183 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
184 cal_radio_group_select_radio(p->range_radio_group, val);
186 if (CALENDAR_RANGE_COUNT == val) {
187 elm_object_focus_set(p->repeat_occurrence_entry, EINA_TRUE);
188 elm_entry_cursor_end_set(p->repeat_occurrence_entry);
191 p->selected_range_radio = val;
193 const char* str = elm_entry_entry_get(p->repeat_occurrence_entry);
194 c_ret_if(!CAL_STRLEN(str));
196 p->count = atoi(str);
199 int cal_edit_repeat_get_repeat(Evas_Object *ly, calendar_range_type_e *range, struct tm *until, int *count)
201 c_retvm_if(!ly, CALENDAR_RECURRENCE_NONE, "ly is null");
203 const char* text = NULL;
205 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
206 c_retvm_if(!p, CALENDAR_RECURRENCE_NONE, "p is null");
208 c_retvm_if(!p->freq_radio_group, CALENDAR_RECURRENCE_NONE, "p->freq_radio_group is null");
209 c_retvm_if(!p->range_radio_group, CALENDAR_RECURRENCE_NONE, "p->range_radio_group is null");
211 *range = __cal_edit_repeat_range_index[p->selected_range_radio];
214 case CALENDAR_RANGE_NONE:
217 *until = *p->start_date_time;
218 cal_util_update_tm_month(until, 1);
221 case CALENDAR_RANGE_COUNT:
222 text = elm_entry_entry_get(p->repeat_occurrence_entry);
223 c_retvm_if(!text, CALENDAR_RECURRENCE_NONE, "text is null");
227 *until = *p->start_date_time;
228 cal_util_update_tm_month(until, 1);
232 case CALENDAR_RANGE_UNTIL:
242 return __cal_edit_repeat_get_freq(p->selected_freq_radio);
245 void _cal_edit_repeat_get_freq_str(int freq, char *buf, int size)
253 case CALENDAR_RECURRENCE_DAILY:
255 snprintf(buf, size, "%s", C_("IDS_KC_BODY_EVERY_DAY"));
258 case CAL_REPEAT_EVERY_3_DAY:
260 format = C_("IDS_CLD_BODY_EVERY_PD_DAYS");
261 snprintf(buf, size, format, 3);
264 case CALENDAR_RECURRENCE_WEEKLY:
266 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_WEEK"));
269 case CAL_REPEAT_EVERY_2_WEEK:
271 format = C_("IDS_CLD_BODY_EVERY_PD_WEEKS");
272 snprintf(buf, size, format, 2);
275 case CALENDAR_RECURRENCE_MONTHLY:
277 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_MONTH"));
280 case CALENDAR_RECURRENCE_YEARLY:
282 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_YEAR"));
287 snprintf(buf, size, "%s", S_("IDS_COM_BODY_OFF"));
295 static char *__cal_edit_repeat_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
299 c_retv_if(!data, NULL);
301 cal_edit_repeat_item_data *item_data = data;
303 char string[32] = {0};
305 if (!CAL_STRCMP(part, "elm.text")) {
306 switch (item_data->type) {
307 case CAL_EDIT_REPEAT_SEPARATOR_FREQ:
308 return strdup(C_("IDS_CLD_BODY_REPEAT"));
310 case CAL_EDIT_REPEAT_ITEM_FREQ:
311 _cal_edit_repeat_get_freq_str(__cal_edit_repeat_get_freq(item_data->index), string, sizeof(string));
312 return strdup(string);
314 case CAL_EDIT_REPEAT_SEPARATOR_RANGE:
315 return strdup(C_("IDS_CLD_BODY_REPEAT_UNTIL"));
317 case CAL_EDIT_REPEAT_ITEM_RANGE:
318 if (__cal_edit_repeat_range_index[item_data->index] == CALENDAR_RANGE_NONE)
319 return strdup(S_("IDS_COM_BODY_NONE"));
324 } else if (!CAL_STRCMP(part, "text")) {
325 return strdup(C_("IDS_COM_POP_TIMES_LC"));
331 static void __cal_edit_repeat_genlist_item_delete_callback(void *data, Evas_Object *obj)
336 cal_edit_repeat_item_data *item_data = data;
341 static Eina_Bool __cal_edit_repeat_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
346 static Evas_Object* __cal_edit_repeat_add_radio(Evas_Object *obj, cal_edit_repeat_item_data *item_data)
348 c_retvm_if(!obj, NULL, "dg is NULL.");
349 c_retvm_if(!item_data, NULL, "item_data is NULL.");
351 cal_edit_repeat_data *p = item_data->p;
354 Evas_Object *rd = elm_radio_add(obj);
355 c_retv_if(!rd, NULL);
357 evas_object_propagate_events_set(rd, EINA_TRUE);
359 cal_edit_repeat_item_type type = item_data->type;
361 if (type == CAL_EDIT_REPEAT_ITEM_FREQ)
362 cal_radio_group_set_radio_object(p->freq_radio_group, item_data->index, rd);
363 else if (type == CAL_EDIT_REPEAT_ITEM_RANGE)
364 cal_radio_group_set_radio_object(p->range_radio_group, item_data->index, rd);
366 item_data->radio = rd;
368 evas_object_show(rd);
369 evas_object_data_set(rd, "priv", p);
371 if (item_data->type == CAL_EDIT_REPEAT_ITEM_FREQ)
372 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_clicked_callback, (void *)item_data->index);
373 else if (0 == item_data->index || 1 == item_data->index)
374 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)item_data->index);
379 static void __cal_edit_repeat_entry_unfocused(void *data, Evas_Object *obj, void *event_info)
381 cal_edit_repeat_data *p = (cal_edit_repeat_data *)data;
383 char times[8] = {0,};
384 snprintf(times, 7, "%d", p->count);
385 elm_entry_entry_set(p->repeat_occurrence_entry, times);
389 static void __cal_edit_repeat_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
392 cal_edit_repeat_data *p = data;
394 const char *s = elm_entry_entry_get(p->repeat_occurrence_entry);
399 static Evas_Object* __cal_edit_repeat_add_entry(Evas_Object *parent, cal_edit_repeat_data *p)
402 Ecore_IMF_Context *ic;
404 e = elm_entry_add(parent);
408 elm_object_style_set(e, "font_color_black");
409 elm_entry_single_line_set(e, EINA_TRUE);
410 elm_entry_markup_filter_append(e, elm_entry_filter_limit_size, &_limit_2char);
411 elm_entry_markup_filter_append(e, elm_entry_filter_accept_set, &_digit_only);
412 elm_entry_input_panel_layout_set(e, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
413 elm_entry_context_menu_disabled_set(e, EINA_TRUE);
415 ic = elm_entry_imf_context_get(e);
419 cal_save_cancel_set_input_panel_callback_for_ug(p->save_cancel, e);
421 evas_object_smart_callback_add(e, "unfocused", __cal_edit_repeat_entry_unfocused, p);
422 evas_object_smart_callback_add(e, "changed", __cal_edit_repeat_entry_changed_callback, p);
424 elm_entry_text_style_user_push(e, "DEFAULT='align=center'");
429 static void __cal_edit_repeat_end_date_changed_callback(void *data, Evas_Object *obj, void *ei)
431 cal_edit_repeat_data *p = data;
433 elm_datetime_value_get(obj, &p->until);
436 static Evas_Object* __cal_edit_repeat_add_radio_tm(Evas_Object *obj, cal_edit_repeat_item_data *item_data)
438 c_retv_if(!obj, NULL);
439 c_retv_if(!item_data, NULL);
441 cal_edit_repeat_data *p = item_data->p;
444 Evas_Object *ly = cal_util_add_layout(obj, "dialoguegroup/tm");
445 c_retvm_if(!ly, NULL, "ly is null");
447 evas_object_show(ly);
448 evas_object_data_set(ly, "priv", p);
450 Evas_Object *rd = elm_radio_add(obj);
456 evas_object_propagate_events_set(rd, EINA_TRUE);
458 elm_object_part_content_set(ly, "content", rd);
459 item_data->radio = rd;
461 cal_radio_group_set_radio_object(p->range_radio_group, item_data->index, rd);
463 Evas_Object *datetime = cal_util_add_datetime(ly, NULL, &p->until);
464 c_retvm_if(!datetime, NULL, "datetime is null");
466 evas_object_propagate_events_set(datetime, EINA_TRUE);
468 elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
469 elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
470 elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
472 elm_datetime_field_limit_set(datetime, ELM_DATETIME_YEAR, 70, 137);
474 evas_object_smart_callback_add(datetime,"changed", __cal_edit_repeat_end_date_changed_callback, p);
476 elm_object_part_content_set(ly, "datefield", datetime);
481 static Evas_Object* __cal_edit_repeat_add_radio_group(Evas_Object *obj, cal_edit_repeat_item_data *item_data)
485 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
488 if (item_data->type == CAL_EDIT_REPEAT_ITEM_FREQ) {
490 return __cal_edit_repeat_add_radio(obj, item_data);
492 } else if (item_data->type == CAL_EDIT_REPEAT_ITEM_RANGE){
494 switch (__cal_edit_repeat_range_index[item_data->index]) {
496 case CALENDAR_RANGE_NONE:
497 return __cal_edit_repeat_add_radio(obj, item_data);
499 case CALENDAR_RANGE_UNTIL:
500 return __cal_edit_repeat_add_radio_tm(obj, item_data);
515 static void __cal_edit_repeat_set_selected_freq_state(cal_edit_repeat_data *p)
517 cal_radio_group_select_radio(p->freq_radio_group, p->selected_freq_radio);
520 static void __cal_edit_repeat_set_selected_range_state(cal_edit_repeat_data *p)
526 char times[10] = {0};
528 snprintf(times,sizeof(times),"%d", p->count);
529 elm_entry_entry_set(p->repeat_occurrence_entry, times);
530 cal_radio_group_select_radio(p->range_radio_group, p->selected_range_radio);
535 static Evas_Object *__cal_edit_repeat_get_genlist_times_content(void *data, Evas_Object *obj, const char *part)
537 c_retv_if(!data, NULL);
538 c_retv_if(!obj, NULL);
539 c_retv_if(!part, NULL);
541 cal_edit_repeat_item_data *item_data = data;
543 cal_edit_repeat_data *p = item_data->p;
546 if (!CAL_STRCMP(part, "radio")) {
548 Evas_Object* radio = elm_radio_add(obj);
549 c_retv_if(!radio, NULL);
551 if (item_data->type == CAL_EDIT_REPEAT_ITEM_FREQ)
552 cal_radio_group_set_radio_object(p->freq_radio_group, item_data->index, radio);
553 else if (item_data->type == CAL_EDIT_REPEAT_ITEM_RANGE)
554 cal_radio_group_set_radio_object(p->range_radio_group, item_data->index, radio);
556 item_data->radio = radio;
559 } else if (!CAL_STRCMP(part, "input_sw")) {
561 Evas_Object* entry = __cal_edit_repeat_add_entry(obj, p);
562 c_retv_if(!entry, NULL);
565 snprintf(times, sizeof(times), "%d", p->count);
566 elm_entry_entry_set(entry, times);
568 p->repeat_occurrence_entry = entry;
575 static Evas_Object *__cal_edit_repeat_get_genlist_item_icon(void *data, Evas_Object *obj, const char *part)
579 c_retv_if(!data, NULL);
580 c_retv_if(!obj, NULL);
582 Evas_Object *e_obj = NULL;
584 if (!CAL_STRCMP(part, "elm.icon")) {
585 cal_edit_repeat_item_data *item_data = data;
587 cal_edit_repeat_data *p = item_data->p;
588 cal_edit_repeat_item_type type = item_data->type;
590 if (type == CAL_EDIT_REPEAT_ITEM_FREQ) {
592 e_obj = __cal_edit_repeat_add_radio_group(obj, item_data);
594 __cal_edit_repeat_set_selected_freq_state(p);
596 } else if (type == CAL_EDIT_REPEAT_ITEM_RANGE){
598 e_obj = __cal_edit_repeat_add_radio_group(obj, item_data);
600 __cal_edit_repeat_set_selected_range_state(p);
616 static void __cal_edit_repeat_genlist_item_select_callback(void *data, Evas_Object *obj, void *event_info)
622 Elm_Object_Item *it = elm_genlist_selected_item_get(obj);
625 elm_genlist_item_selected_set(it, EINA_FALSE);
627 cal_edit_repeat_item_data *item_data = elm_object_item_data_get(it);
628 c_ret_if(!item_data);
630 cal_edit_repeat_data *p = item_data->p;
633 cal_edit_repeat_item_type type = item_data->type;
634 int index = item_data->index;
636 if (type == CAL_EDIT_REPEAT_ITEM_FREQ) {
638 p->selected_freq_radio = index;
639 cal_radio_group_select_radio(p->freq_radio_group, index);
640 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
642 } else if (type == CAL_EDIT_REPEAT_ITEM_RANGE){
644 cal_radio_group_select_radio(p->range_radio_group, index);
645 p->selected_range_radio = index;
647 if (index != __cal_edit_repeat_range_index[CALENDAR_RANGE_COUNT])
648 elm_object_focus_set(p->repeat_occurrence_entry, EINA_FALSE);
659 static void __cal_edit_repeat_add_separator(Evas_Object *genlist, cal_edit_repeat_data *p, cal_edit_repeat_item_type type)
663 cal_edit_repeat_item_data *item_data = calloc(1, sizeof(cal_edit_repeat_item_data));
664 c_ret_if(!item_data);
666 item_data->type = type;
669 item_data->it = elm_genlist_item_append(genlist, &itc_seperator, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, NULL);
671 elm_genlist_item_select_mode_set(item_data->it, ELM_OBJECT_SELECT_MODE_NONE);
676 static void __cal_edit_repeat_add_freq(Evas_Object *genlist, cal_edit_repeat_data *p)
681 for (i = 0; i < CAL_EDIT_REPEAT_FREQ_MAX; i++) {
682 cal_edit_repeat_item_data *item_data = calloc(1, sizeof(cal_edit_repeat_item_data));
683 c_ret_if(!item_data);
686 item_data->index = i;
687 item_data->type = CAL_EDIT_REPEAT_ITEM_FREQ;
689 item_data->it = elm_genlist_item_append(genlist, &itc_1icon_1text, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, item_data);
695 static void __cal_edit_repeat_add_range(Evas_Object *genlist, cal_edit_repeat_data *p)
700 for (i = 0; i < sizeof(__cal_edit_repeat_range_index)/sizeof(__cal_edit_repeat_range_index[0]); i++) {
701 cal_edit_repeat_item_data *item_data = calloc(1, sizeof(cal_edit_repeat_item_data));
702 c_ret_if(!item_data);
705 item_data->index = i;
706 item_data->type = CAL_EDIT_REPEAT_ITEM_RANGE;
708 if (__cal_edit_repeat_range_index[item_data->index] == CALENDAR_RANGE_COUNT)
709 item_data->it = elm_genlist_item_append(genlist, &itc_2icon_1text, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, item_data);
711 item_data->it = elm_genlist_item_append(genlist, &itc_1icon_1text, (void*)item_data, NULL, ELM_GENLIST_ITEM_NONE, __cal_edit_repeat_genlist_item_select_callback, item_data);
717 static void __cal_edit_repeat_add_genlist_item(Evas_Object *genlist, cal_edit_repeat_data *p)
721 __cal_edit_repeat_add_separator(genlist, p, CAL_EDIT_REPEAT_SEPARATOR_FREQ);
723 __cal_edit_repeat_add_freq(genlist, p);
725 __cal_edit_repeat_add_separator(genlist, p, CAL_EDIT_REPEAT_SEPARATOR_RANGE);
727 __cal_edit_repeat_add_range(genlist, p);
732 static int __cal_edit_repeat_add_content(cal_edit_repeat_data *p)
736 p->genlist = elm_genlist_add(p->ly);
737 c_retv_if(!p->genlist, -1);
739 evas_object_data_set(p->genlist, "priv", p);
741 itc_seperator.item_style = "dialogue/title";
742 itc_seperator.func.text_get = __cal_edit_repeat_get_genlist_item_label;
743 itc_seperator.func.state_get = __cal_edit_repeat_get_genlist_item_state;
744 itc_seperator.func.del = __cal_edit_repeat_genlist_item_delete_callback;
746 itc_1icon_1text.item_style = "dialogue/1text.1icon.2";
747 itc_1icon_1text.func.text_get = __cal_edit_repeat_get_genlist_item_label;
748 itc_1icon_1text.func.del = __cal_edit_repeat_genlist_item_delete_callback;
749 itc_1icon_1text.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
751 itc_2icon_1text.item_style = "dialogue/2icon.1text.custom";
752 itc_2icon_1text.func.text_get = __cal_edit_repeat_get_genlist_item_label;
753 itc_2icon_1text.func.del = __cal_edit_repeat_genlist_item_delete_callback;
754 itc_2icon_1text.func.content_get = __cal_edit_repeat_get_genlist_times_content;
756 itc_1icon.item_style = "dialogue/1icon";
757 itc_1icon.func.text_get = __cal_edit_repeat_get_genlist_item_label;
758 itc_1icon.func.del = __cal_edit_repeat_genlist_item_delete_callback;
759 itc_1icon.func.content_get = __cal_edit_repeat_get_genlist_item_icon;
761 __cal_edit_repeat_add_genlist_item(p->genlist, p);
763 elm_object_part_content_set(p->ly, "sw", p->genlist);
770 static void __cal_edit_repeat_set_state(cal_edit_repeat_data *p, int freq, calendar_range_type_e range, struct tm* until, int* occurrency)
772 p->selected_freq_radio = __cal_edit_repeat_get_radio_index(freq);
773 p->prev_selected_freq_radio = __cal_edit_repeat_get_radio_index(freq);
774 p->selected_range_radio = __cal_edit_repeat_range_index[range];
777 static void __cal_edit_repeat_save_button_callback(void *data, Evas_Object *obj, void *ei)
781 c_retm_if(!data, "data is null");
783 cal_edit_repeat_data *p = data;
785 p->callback_func(p->callback_data);
786 elm_naviframe_item_pop(p->parent);
789 static void __cal_edit_repeat_cancel_button_callback(void *data, Evas_Object *obj, void *ei)
795 Evas_Object *cal_edit_repeat_create_view(Evas_Object *parent, int freq, calendar_range_type_e range, struct tm* start_date_time, struct tm* until, int* count,
796 cal_edit_repeat_destroy_callback callback_func, void *callback_data)
800 c_retvm_if(!parent, NULL, "parent is null");
802 cal_edit_repeat_data *p = calloc(1, sizeof(cal_edit_repeat_data));
803 c_retvm_if(!p, NULL, "p is null");
807 Evas_Object *ly = cal_util_add_layout(parent, "edit");
816 p->start_date_time = start_date_time;
818 p->callback_func = callback_func;
819 p->callback_data = callback_data;
821 p->freq_radio_group = cal_radio_group_create(CAL_EDIT_REPEAT_FREQ_MAX, ly);
822 p->range_radio_group = cal_radio_group_create(3, ly);;
824 evas_object_data_set(ly, "priv", p);
826 Elm_Object_Item *navi_item = NULL;
827 navi_item = elm_naviframe_item_push(p->parent, C_("IDS_CLD_BODY_REPEAT"), NULL, NULL, ly, NULL);
828 c_retv_if(!navi_item, NULL);
830 p->save_cancel = cal_save_cancel_create(p->parent, NULL, __cal_edit_repeat_save_button_callback, __cal_edit_repeat_cancel_button_callback, p);
832 __cal_edit_repeat_set_state(p, freq, range, until, count);
834 int r = __cal_edit_repeat_add_content(p);
841 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_edit_repeat_delete_layout, p);