3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.1 (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 *conformant;
37 Evas_Object *naviframe;
38 Evas_Object *ly; // self
41 cal_radio_group_h freq_radio_group;
42 cal_radio_group_h range_radio_group;
44 Evas_Object *day_selector;
45 Evas_Object *repeat_occurrence_entry;
46 Evas_Object *end_date;
48 struct tm *start_date_time;
53 int selected_freq_radio;
54 int prev_selected_freq_radio;
55 int selected_range_radio;
57 cal_edit_repeat_destroy_callback callback_func;
60 cal_save_cancel_h save_cancel;
62 } cal_edit_repeat_data;
64 static int __cal_edit_repeat_get_radio_index(int freq)
67 case CALENDAR_RECURRENCE_NONE:
68 return CAL_EDIT_REPEAT_FREQ_OFF;
69 case CALENDAR_RECURRENCE_DAILY:
70 return CAL_EDIT_REPEAT_FREQ_EVERY_DAY;
71 case CAL_REPEAT_EVERY_3_DAY:
72 return CAL_EDIT_REPEAT_FREQ_EVERY_3_DAY;
73 case CALENDAR_RECURRENCE_WEEKLY:
74 return CAL_EDIT_REPEAT_FREQ_EVERY_WEEK;
75 case CAL_REPEAT_EVERY_2_WEEK:
76 return CAL_EDIT_REPEAT_FREQ_EVERY_2_WEEK;
77 case CALENDAR_RECURRENCE_MONTHLY:
78 return CAL_EDIT_REPEAT_FREQ_EVERY_MONTH;
79 case CALENDAR_RECURRENCE_YEARLY:
80 return CAL_EDIT_REPEAT_FREQ_EVERY_YEAR;
82 ERR("Invalid value : %d", freq);
87 static int __cal_edit_repeat_get_freq(int radio_index)
89 switch (radio_index) {
90 case CAL_EDIT_REPEAT_FREQ_OFF:
91 return CALENDAR_RECURRENCE_NONE;
92 case CAL_EDIT_REPEAT_FREQ_EVERY_DAY:
93 return CALENDAR_RECURRENCE_DAILY;
94 case CAL_EDIT_REPEAT_FREQ_EVERY_3_DAY:
95 return CAL_REPEAT_EVERY_3_DAY;
96 case CAL_EDIT_REPEAT_FREQ_EVERY_WEEK:
97 return CALENDAR_RECURRENCE_WEEKLY;
98 case CAL_EDIT_REPEAT_FREQ_EVERY_2_WEEK:
99 return CAL_REPEAT_EVERY_2_WEEK;
100 case CAL_EDIT_REPEAT_FREQ_EVERY_MONTH:
101 return CALENDAR_RECURRENCE_MONTHLY;
102 case CAL_EDIT_REPEAT_FREQ_EVERY_YEAR:
103 return CALENDAR_RECURRENCE_YEARLY;
105 ERR("Invalid value : %d", radio_index);
106 return CALENDAR_RECURRENCE_NONE;
110 static int __cal_edit_repeat_range_index[] = {
112 CALENDAR_RANGE_COUNT,
113 CALENDAR_RANGE_UNTIL,
117 CAL_EDIT_REPEAT_SEPARATOR_FREQ,
118 CAL_EDIT_REPEAT_ITEM_FREQ,
119 CAL_EDIT_REPEAT_SEPARATOR_RANGE,
120 CAL_EDIT_REPEAT_ITEM_RANGE,
121 }cal_edit_repeat_item_type;
123 static Elm_Entry_Filter_Limit_Size _limit_2char = {
126 static Elm_Entry_Filter_Accept_Set _digit_only = {
127 .accepted = "0123456789",
130 static Elm_Genlist_Item_Class itc_seperator, itc_1icon_1text, itc_1icon, itc_2icon_1text;
132 typedef struct __cal_edit_repeat_item_data cal_edit_repeat_item_data;
133 struct __cal_edit_repeat_item_data
135 cal_edit_repeat_data *p;
137 cal_edit_repeat_item_type type;
142 #define is_leap_year_tm(y) (((y+1900)%4 == 0 && ((y+1900)%100 != 0 || (y+1900)%400 == 0))? 1 : 0)
144 static void __cal_edit_repeat_delete_layout(void *data, Evas *e, Evas_Object *obj, void *ei)
148 cal_edit_repeat_data *p = data;
150 cal_radio_group_destroy(p->freq_radio_group);
151 cal_radio_group_destroy(p->range_radio_group);
154 cal_save_cancel_destroy(p->save_cancel);
159 static void __cal_edit_repeat_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
161 cal_edit_repeat_data *p;
162 Evas_Event_Mouse_Up *ev = ei;
165 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
168 p = CAL_UTIL_GET_PRIV_DATA(obj);
169 cal_radio_group_select_radio(p->freq_radio_group, val);
170 p->prev_selected_freq_radio = p->selected_freq_radio;
171 p->selected_freq_radio = val;
174 static void __cal_edit_repeat_entry_clicked_callback(void *data, Evas *e, Evas_Object *obj, void *ei)
179 Evas_Event_Mouse_Up *ev = ei;
182 if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
185 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(obj);
186 cal_radio_group_select_radio(p->range_radio_group, val);
188 if (CALENDAR_RANGE_COUNT == val) {
189 elm_object_focus_set(p->repeat_occurrence_entry, EINA_TRUE);
190 elm_entry_cursor_end_set(p->repeat_occurrence_entry);
193 p->selected_range_radio = val;
195 const char* str = elm_entry_entry_get(p->repeat_occurrence_entry);
196 c_ret_if(!CAL_STRLEN(str));
198 p->count = atoi(str);
201 int cal_edit_repeat_get_repeat(Evas_Object *ly, calendar_range_type_e *range, struct tm *until, int *count)
203 c_retvm_if(!ly, CALENDAR_RECURRENCE_NONE, "ly is null");
205 const char* text = NULL;
207 cal_edit_repeat_data *p = CAL_UTIL_GET_PRIV_DATA(ly);
208 c_retvm_if(!p, CALENDAR_RECURRENCE_NONE, "p is null");
210 c_retvm_if(!p->freq_radio_group, CALENDAR_RECURRENCE_NONE, "p->freq_radio_group is null");
211 c_retvm_if(!p->range_radio_group, CALENDAR_RECURRENCE_NONE, "p->range_radio_group is null");
213 *range = __cal_edit_repeat_range_index[p->selected_range_radio];
216 case CALENDAR_RANGE_NONE:
219 *until = *p->start_date_time;
220 cal_util_update_tm_month(until, 1);
223 case CALENDAR_RANGE_COUNT:
224 text = elm_entry_entry_get(p->repeat_occurrence_entry);
225 c_retvm_if(!text, CALENDAR_RECURRENCE_NONE, "text is null");
229 *until = *p->start_date_time;
230 cal_util_update_tm_month(until, 1);
234 case CALENDAR_RANGE_UNTIL:
244 return __cal_edit_repeat_get_freq(p->selected_freq_radio);
247 void _cal_edit_repeat_get_freq_str(int freq, char *buf, int size)
255 case CALENDAR_RECURRENCE_DAILY:
257 snprintf(buf, size, "%s", C_("IDS_KC_BODY_EVERY_DAY"));
260 case CAL_REPEAT_EVERY_3_DAY:
262 format = C_("IDS_CLD_BODY_EVERY_PD_DAYS");
263 snprintf(buf, size, format, 3);
266 case CALENDAR_RECURRENCE_WEEKLY:
268 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_WEEK"));
271 case CAL_REPEAT_EVERY_2_WEEK:
273 format = C_("IDS_CLD_BODY_EVERY_PD_WEEKS");
274 snprintf(buf, size, format, 2);
277 case CALENDAR_RECURRENCE_MONTHLY:
279 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_MONTH"));
282 case CALENDAR_RECURRENCE_YEARLY:
284 snprintf(buf, size, "%s", C_("IDS_CLD_BODY_EVERY_YEAR"));
289 snprintf(buf, size, "%s", S_("IDS_COM_BODY_OFF"));
297 static char *__cal_edit_repeat_get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
301 c_retv_if(!data, NULL);
303 cal_edit_repeat_item_data *item_data = data;
305 char string[32] = {0};
307 if (!CAL_STRCMP(part, "elm.text")) {
308 switch (item_data->type) {
309 case CAL_EDIT_REPEAT_SEPARATOR_FREQ:
310 return strdup(C_("IDS_CLD_BODY_REPEAT"));
312 case CAL_EDIT_REPEAT_ITEM_FREQ:
313 _cal_edit_repeat_get_freq_str(__cal_edit_repeat_get_freq(item_data->index), string, sizeof(string));
314 return strdup(string);
316 case CAL_EDIT_REPEAT_SEPARATOR_RANGE:
317 return strdup(C_("IDS_CLD_BODY_REPEAT_UNTIL"));
319 case CAL_EDIT_REPEAT_ITEM_RANGE:
320 if (__cal_edit_repeat_range_index[item_data->index] == CALENDAR_RANGE_NONE)
321 return strdup(S_("IDS_COM_BODY_NONE"));
326 } else if (!CAL_STRCMP(part, "text")) {
327 return strdup(C_("IDS_COM_POP_TIMES_LC"));
333 static void __cal_edit_repeat_genlist_item_delete_callback(void *data, Evas_Object *obj)
338 cal_edit_repeat_item_data *item_data = data;
343 static Eina_Bool __cal_edit_repeat_get_genlist_item_state(void *data, Evas_Object *obj, const char *part)
348 static Evas_Object* __cal_edit_repeat_add_radio(Evas_Object *obj, cal_edit_repeat_item_data *item_data)
350 c_retvm_if(!obj, NULL, "dg is NULL.");
351 c_retvm_if(!item_data, NULL, "item_data is NULL.");
353 cal_edit_repeat_data *p = item_data->p;
356 Evas_Object *rd = elm_radio_add(obj);
357 c_retv_if(!rd, NULL);
359 evas_object_propagate_events_set(rd, EINA_TRUE);
361 cal_edit_repeat_item_type type = item_data->type;
363 if (type == CAL_EDIT_REPEAT_ITEM_FREQ)
364 cal_radio_group_set_radio_object(p->freq_radio_group, item_data->index, rd);
365 else if (type == CAL_EDIT_REPEAT_ITEM_RANGE)
366 cal_radio_group_set_radio_object(p->range_radio_group, item_data->index, rd);
368 item_data->radio = rd;
370 evas_object_show(rd);
371 evas_object_data_set(rd, "priv", p);
373 if (item_data->type == CAL_EDIT_REPEAT_ITEM_FREQ)
374 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_clicked_callback, (void *)item_data->index);
375 else if (0 == item_data->index || 1 == item_data->index)
376 evas_object_event_callback_add(rd, EVAS_CALLBACK_MOUSE_UP, __cal_edit_repeat_entry_clicked_callback, (void *)item_data->index);
381 static void __cal_edit_repeat_entry_unfocused(void *data, Evas_Object *obj, void *event_info)
383 cal_edit_repeat_data *p = (cal_edit_repeat_data *)data;
385 char times[8] = {0,};
386 snprintf(times, 7, "%d", p->count);
387 elm_entry_entry_set(p->repeat_occurrence_entry, times);
391 static void __cal_edit_repeat_entry_changed_callback(void *data, Evas_Object *obj, void *event_info)
394 cal_edit_repeat_data *p = data;
396 const char *s = elm_entry_entry_get(p->repeat_occurrence_entry);
401 static Evas_Object* __cal_edit_repeat_add_entry(Evas_Object *parent, cal_edit_repeat_data *p)
404 Ecore_IMF_Context *ic;
406 e = elm_entry_add(parent);
410 elm_object_style_set(e, "font_color_black");
411 elm_entry_single_line_set(e, EINA_TRUE);
412 elm_entry_markup_filter_append(e, elm_entry_filter_limit_size, &_limit_2char);
413 elm_entry_markup_filter_append(e, elm_entry_filter_accept_set, &_digit_only);
414 elm_entry_input_panel_layout_set(e, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
415 elm_entry_context_menu_disabled_set(e, EINA_TRUE);
417 ic = elm_entry_imf_context_get(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->naviframe);
789 static void __cal_edit_repeat_cancel_button_callback(void *data, Evas_Object *obj, void *ei)
793 c_retm_if(!data, "data is null");
795 cal_edit_repeat_data *p = data;
797 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get((Evas_Object *)p->repeat_occurrence_entry);
798 c_retm_if(!imf_context, "elm_entry_imf_context_get returned null");
800 Ecore_IMF_Input_Panel_State state = ecore_imf_context_input_panel_state_get(imf_context);
802 if(state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
803 ecore_imf_context_input_panel_hide(imf_context);
806 elm_naviframe_item_pop(p->naviframe);
809 Evas_Object *cal_edit_repeat_create_view(Evas_Object *window, Evas_Object *conformant, Evas_Object *naviframe,
810 int freq, calendar_range_type_e range, struct tm* start_date_time, struct tm* until, int* count,
811 cal_edit_repeat_destroy_callback callback_func, void *callback_data)
815 c_retv_if(!window, NULL);
816 c_retv_if(!conformant, NULL);
817 c_retv_if(!naviframe, NULL);
819 cal_edit_repeat_data *p = calloc(1, sizeof(cal_edit_repeat_data));
820 c_retvm_if(!p, NULL, "p is null");
823 p->conformant = conformant;
824 p->naviframe = naviframe;
826 Evas_Object *ly = cal_util_add_layout(naviframe, "edit");
835 p->start_date_time = start_date_time;
837 p->callback_func = callback_func;
838 p->callback_data = callback_data;
840 p->freq_radio_group = cal_radio_group_create(CAL_EDIT_REPEAT_FREQ_MAX, ly);
841 p->range_radio_group = cal_radio_group_create(3, ly);;
843 evas_object_data_set(ly, "priv", p);
845 Elm_Object_Item *navi_item = NULL;
846 navi_item = elm_naviframe_item_push(p->naviframe, C_("IDS_CLD_BODY_REPEAT"), NULL, NULL, ly, NULL);
847 c_retv_if(!navi_item, NULL);
849 p->save_cancel = cal_save_cancel_create(p->window, p->conformant, p->naviframe, __cal_edit_repeat_save_button_callback, __cal_edit_repeat_cancel_button_callback, p);
851 __cal_edit_repeat_set_state(p, freq, range, until, count);
853 int r = __cal_edit_repeat_add_content(p);
860 evas_object_event_callback_add(ly, EVAS_CALLBACK_DEL, __cal_edit_repeat_delete_layout, p);