summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-04-19 08:46:22 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-04-19 08:46:22 +0000
commite1f626acd08287ab9d32aff71d45b87ab9cbea3d (patch)
treeb4279050a1c113781c955bac99e93907e0471eaf
parent9266750afed2c2df3bf51ac926b377834285584a (diff)
elementary: elm_calendar deprecate elm_calendar_day_selection_disabled_set/get, instead now use elm_calendar_select_mode_set/get. ELM_CALENDAR_SELECT_MODE_ONDEMAND is present but not supported yet
SVN revision: 70319
-rw-r--r--src/bin/test_calendar.c57
-rw-r--r--src/lib/elm_calendar.c56
-rw-r--r--src/lib/elm_calendar.h51
-rw-r--r--src/lib/elm_deprecated.h11
4 files changed, 135 insertions, 40 deletions
diff --git a/src/bin/test_calendar.c b/src/bin/test_calendar.c
index 71107fd92..d7995f413 100644
--- a/src/bin/test_calendar.c
+++ b/src/bin/test_calendar.c
@@ -70,7 +70,7 @@ set_api_state(api_data *api)
70 time_t sec_per_day = (60*60*24); 70 time_t sec_per_day = (60*60*24);
71 time_t sec_per_year = sec_per_day * 365; 71 time_t sec_per_year = sec_per_day * 365;
72 time_t the_time = (sec_per_year * 41) + (sec_per_day * 10); /* Set date to JAN 01, 2011 */ 72 time_t the_time = (sec_per_year * 41) + (sec_per_day * 10); /* Set date to JAN 01, 2011 */
73 elm_calendar_day_selection_disabled_set(cal, EINA_TRUE); 73 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_NONE);
74 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 74 elm_calendar_selected_time_set(cal, gmtime(&the_time));
75 } 75 }
76 break; 76 break;
@@ -81,7 +81,7 @@ set_api_state(api_data *api)
81 time_t sec_per_year = sec_per_day * 365; 81 time_t sec_per_year = sec_per_day * 365;
82 time_t the_time = (sec_per_year * 41) + (sec_per_day * 40); /* Set date to FEB 01, 2011 */ 82 time_t the_time = (sec_per_year * 41) + (sec_per_day * 40); /* Set date to FEB 01, 2011 */
83 elm_calendar_marks_clear(cal); 83 elm_calendar_marks_clear(cal);
84 elm_calendar_day_selection_disabled_set(cal, EINA_TRUE); 84 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_NONE);
85 elm_calendar_selected_time_set(cal, gmtime(&the_time)); 85 elm_calendar_selected_time_set(cal, gmtime(&the_time));
86 } 86 }
87 break; 87 break;
@@ -174,7 +174,7 @@ _print_cal_info(Evas_Object *cal, Evas_Object *en)
174 174
175 interval = elm_calendar_interval_get(cal); 175 interval = elm_calendar_interval_get(cal);
176 elm_calendar_min_max_year_get(cal, &year_min, &year_max); 176 elm_calendar_min_max_year_get(cal, &year_min, &year_max);
177 sel_enabled = !elm_calendar_day_selection_disabled_get(cal); 177 sel_enabled = !!(elm_calendar_select_mode_get(cal) != ELM_CALENDAR_SELECT_NONE);
178 wds = elm_calendar_weekdays_names_get(cal); 178 wds = elm_calendar_weekdays_names_get(cal);
179 179
180 snprintf(info, sizeof(info), 180 snprintf(info, sizeof(info),
@@ -241,7 +241,7 @@ test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
241 cal2 = elm_calendar_add(win); 241 cal2 = elm_calendar_add(win);
242 evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 242 evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
243 evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL); 243 evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL);
244 elm_calendar_day_selection_disabled_set(cal2, EINA_TRUE); 244 elm_calendar_select_mode_set(cal2, ELM_CALENDAR_SELECT_NONE);
245 evas_object_show(cal2); 245 evas_object_show(cal2);
246 elm_box_pack_end(bxh, cal2); 246 elm_box_pack_end(bxh, cal2);
247 247
@@ -307,4 +307,53 @@ test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
307 evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, en); 307 evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, en);
308} 308}
309 309
310
311void
312test_calendar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
313{
314 Evas_Object *win, *cal, *bxx;
315 api_data *api = calloc(1, sizeof(api_data));
316
317 win = elm_win_util_standard_add("calendar", "Calendar");
318 elm_win_autodel_set(win, EINA_TRUE);
319 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
320
321 bxx = elm_box_add(win);
322 elm_win_resize_object_add(win, bxx);
323 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
324 evas_object_show(bxx);
325 /*
326
327 bx = elm_box_add(win);
328 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
329 api->box = bx;
330 evas_object_show(bx);
331
332 bt = elm_button_add(win);
333 elm_object_text_set(bt, "Next API function");
334 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
335 elm_box_pack_end(bxx, bt);
336 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
337 evas_object_show(bt);
338
339 elm_box_pack_end(bxx, bx);
340 */
341
342 cal = elm_calendar_add(win);
343 elm_calendar_first_day_of_week_set(cal, ELM_DAY_THURSDAY);
344 elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_ONDEMAND);
345 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
346 elm_box_pack_end(bxx, cal);
347//
348// time_t sec_per_day = (60*60*24);
349// time_t sec_per_year = sec_per_day * 365;
350// time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */
351// elm_calendar_selected_time_set(cal, gmtime(&the_time));
352// elm_calendar_min_max_year_set(cal, 2010, 2012);
353//
354 evas_object_show(cal);
355
356 evas_object_show(win);
357}
358
310#endif 359#endif
diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c
index 21c6a631f..3b65ce0f1 100644
--- a/src/lib/elm_calendar.c
+++ b/src/lib/elm_calendar.c
@@ -31,7 +31,7 @@ struct _Widget_Data
31 const char *weekdays[ELM_DAY_LAST]; 31 const char *weekdays[ELM_DAY_LAST];
32 struct tm current_time, selected_time; 32 struct tm current_time, selected_time;
33 Day_Color day_color[42]; // EINA_DEPRECATED 33 Day_Color day_color[42]; // EINA_DEPRECATED
34 Eina_Bool selection_enabled : 1; 34 Elm_Calendar_Select_Mode select_mode;
35}; 35};
36 36
37struct _Elm_Calendar_Mark 37struct _Elm_Calendar_Mark
@@ -302,7 +302,7 @@ _populate(Evas_Object *obj)
302 if ((wd->selected_it > -1) && (wd->selected_it != i)) 302 if ((wd->selected_it > -1) && (wd->selected_it != i))
303 _unselect(wd, wd->selected_it); 303 _unselect(wd, wd->selected_it);
304 304
305 if (wd->selection_enabled) _select(wd, i); 305 if (wd->select_mode != ELM_CALENDAR_SELECT_NONE) _select(wd, i);
306 306
307 wd->selected_it = i; 307 wd->selected_it = i;
308 } 308 }
@@ -600,7 +600,7 @@ _update_sel_it(Evas_Object *obj, int sel_it)
600{ 600{
601 int day; 601 int day;
602 Widget_Data *wd = elm_widget_data_get(obj); 602 Widget_Data *wd = elm_widget_data_get(obj);
603 if ((!wd) || (!wd->selection_enabled)) 603 if ((!wd) || (wd->select_mode == ELM_CALENDAR_SELECT_NONE))
604 return; 604 return;
605 605
606 day = _get_item_day(obj, sel_it); 606 day = _get_item_day(obj, sel_it);
@@ -621,7 +621,7 @@ _day_selected(void *data, Evas_Object *obj __UNUSED__, const char *emission __UN
621{ 621{
622 int sel_it; 622 int sel_it;
623 Widget_Data *wd = elm_widget_data_get(data); 623 Widget_Data *wd = elm_widget_data_get(data);
624 if ((!wd) || (!wd->selection_enabled)) 624 if ((!wd) || (wd->select_mode == ELM_CALENDAR_SELECT_NONE))
625 return; 625 return;
626 sel_it = atoi(source); 626 sel_it = atoi(source);
627 627
@@ -668,7 +668,7 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
668 668
669 if (!wd) return EINA_FALSE; 669 if (!wd) return EINA_FALSE;
670 if (elm_widget_disabled_get(obj)) return EINA_FALSE; 670 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
671 if (!wd->selection_enabled) return EINA_FALSE; 671 if (wd->select_mode == ELM_CALENDAR_SELECT_NONE) return EINA_FALSE;
672 672
673 if ((!strcmp(ev->keyname, "Left")) || 673 if ((!strcmp(ev->keyname, "Left")) ||
674 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string))) 674 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
@@ -736,7 +736,6 @@ elm_calendar_add(Evas_Object *parent)
736 wd->today_it = -1; 736 wd->today_it = -1;
737 wd->selected_it = -1; 737 wd->selected_it = -1;
738 wd->first_day_it = -1; 738 wd->first_day_it = -1;
739 wd->selection_enabled = EINA_TRUE;
740 wd->format_func = _format_month_year; 739 wd->format_func = _format_month_year;
741 wd->marks = NULL; 740 wd->marks = NULL;
742 741
@@ -864,26 +863,22 @@ elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max)
864 if (max) *max = wd->year_max + 1900; 863 if (max) *max = wd->year_max + 1900;
865} 864}
866 865
867EAPI void 866EINA_DEPRECATED EAPI void
868elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled) 867elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled)
869{ 868{
870 ELM_CHECK_WIDTYPE(obj, widtype); 869 if (disabled)
871 Widget_Data *wd = elm_widget_data_get(obj); 870 elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_NONE);
872 if (!wd) return;
873 wd->selection_enabled = (!disabled);
874 if (!disabled)
875 _select(wd, wd->selected_it);
876 else 871 else
877 _unselect(wd, wd->selected_it); 872 elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_DEFAULT);
878} 873}
879 874
880EAPI Eina_Bool 875EINA_DEPRECATED EAPI Eina_Bool
881elm_calendar_day_selection_disabled_get(const Evas_Object *obj) 876elm_calendar_day_selection_disabled_get(const Evas_Object *obj)
882{ 877{
883 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; 878 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
884 Widget_Data *wd = elm_widget_data_get(obj); 879 Widget_Data *wd = elm_widget_data_get(obj);
885 if (!wd) return EINA_FALSE; 880 if (!wd) return EINA_FALSE;
886 return (!wd->selection_enabled); 881 return !!(wd->select_mode == ELM_CALENDAR_SELECT_NONE);
887} 882}
888 883
889EAPI void 884EAPI void
@@ -1003,3 +998,32 @@ elm_calendar_first_day_of_week_get(const Evas_Object *obj)
1003 if (!wd) return -1; 998 if (!wd) return -1;
1004 return wd->first_week_day; 999 return wd->first_week_day;
1005} 1000}
1001
1002EAPI void
1003elm_calendar_select_mode_set(Evas_Object *obj, Elm_Calendar_Select_Mode mode)
1004{
1005 ELM_CHECK_WIDTYPE(obj, widtype);
1006 Widget_Data *wd = elm_widget_data_get(obj);
1007 if (!wd) return;
1008 if ((mode >= ELM_CALENDAR_SELECT_DEFAULT)
1009 && (mode <= ELM_CALENDAR_SELECT_ONDEMAND)
1010 && (wd->select_mode != mode))
1011 {
1012 wd->select_mode = mode;
1013 if (wd->select_mode == ELM_CALENDAR_SELECT_ALWAYS)
1014 _select(wd, wd->selected_it);
1015 else
1016 _unselect(wd, wd->selected_it);
1017 }
1018}
1019
1020EAPI Elm_Calendar_Select_Mode
1021elm_calendar_select_mode_get(const Evas_Object *obj)
1022{
1023 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1024 Widget_Data *wd = elm_widget_data_get(obj);
1025 if (!wd) return -1;
1026 return wd->select_mode;
1027}
1028
1029
diff --git a/src/lib/elm_calendar.h b/src/lib/elm_calendar.h
index 9f71b9b8e..c33d0500e 100644
--- a/src/lib/elm_calendar.h
+++ b/src/lib/elm_calendar.h
@@ -86,6 +86,27 @@ typedef enum
86 */ 86 */
87typedef _Elm_Calendar_Weekday Elm_Calendar_Weekday; 87typedef _Elm_Calendar_Weekday Elm_Calendar_Weekday;
88 88
89
90typedef enum
91{
92 ELM_CALENDAR_SELECT_DEFAULT = 0, /**< Default value. a day is always selected. */
93 ELM_CALENDAR_SELECT_ALWAYS, /**< a day is always selected. */
94 ELM_CALENDAR_SELECT_NONE, /**< None of the days can be selected. */
95 ELM_CALENDAR_SELECT_ONDEMAND /**< User may have selected a day or not. (not supported yet)*/
96} _Elm_Calendar_Select_Mode;
97
98/**
99 * @enum _Elm_Calendar_Select_Mode
100 * @typedef Elm_Calendar_Select_Mode
101 *
102 * the mode, who determine how user could select a day
103 *
104 * @see elm_calendar_select_mode_set()
105 *
106 * @ingroup Calendar
107 */
108typedef _Elm_Calendar_Select_Mode Elm_Calendar_Select_Mode;
109
89typedef struct _Elm_Calendar_Mark Elm_Calendar_Mark; /**< Item handle for a calendar mark. Created with elm_calendar_mark_add() and deleted with elm_calendar_mark_del(). */ 110typedef struct _Elm_Calendar_Mark Elm_Calendar_Mark; /**< Item handle for a calendar mark. Created with elm_calendar_mark_add() and deleted with elm_calendar_mark_del(). */
90 111
91/** 112/**
@@ -207,41 +228,31 @@ EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int mi
207EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max); 228EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
208 229
209/** 230/**
210 * Enable or disable day selection 231 * Set select day mode to use.
211 * 232 *
212 * @param obj The calendar object. 233 * @param obj The calendar object.
213 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to 234 * @param select_mdoe The select mode to use.
214 * enable it.
215 *
216 * Enabled by default. If disabled, the user still can select months,
217 * but not days. Selected days are highlighted on calendar.
218 * It should be used if you won't need such selection for the widget usage.
219 *
220 * When a day is selected, or month is changed, smart callbacks for
221 * signal "changed" will be called.
222 * 235 *
223 * @see elm_calendar_day_selection_disabled_get() 236 * Set the day selection mode used.
224 *
225 * @ref calendar_example_04
226 * 237 *
227 * @ingroup Calendar 238 * @ingroup Calendar
228 */ 239 */
229EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled); 240EAPI void elm_calendar_select_mode_set(Evas_Object *obj, Elm_Calendar_Select_Mode mode);
230 241
231/** 242/**
232 * Get a value whether day selection is disabled or not. 243 * Get the select day mode used.
233 * 244 *
234 * @param obj The calendar object. 245 * @param obj The calendar object.
235 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
236 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
237 * 246 *
238 * @see elm_calendar_day_selection_disabled_set() for details. 247 * @return the selected mode
239 * 248 *
240 * @ref calendar_example_05 249 * Get the day selection mode used.
250 *
251 * @see elm_calendar_select_mode_set() for more details
241 * 252 *
242 * @ingroup Calendar 253 * @ingroup Calendar
243 */ 254 */
244EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj); 255EAPI Elm_Calendar_Select_Mode elm_calendar_select_mode_get(const Evas_Object *obj);
245 256
246/** 257/**
247 * Set selected date to be highlighted on calendar. 258 * Set selected date to be highlighted on calendar.
diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h
index ba5206bc1..49f88c2a7 100644
--- a/src/lib/elm_deprecated.h
+++ b/src/lib/elm_deprecated.h
@@ -410,3 +410,14 @@ EINA_DEPRECATED EAPI void * elm_multibuttonentry_item_data_get(const Elm_Object_
410 * @deprecated Use elm_object_item_data_set instead. 410 * @deprecated Use elm_object_item_data_set instead.
411 */ 411 */
412EINA_DEPRECATED EAPI void elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data); 412EINA_DEPRECATED EAPI void elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data);
413
414/**
415 * @deprecated Use elm_calendar_select_mode_set instead.
416 */
417EINA_DEPRECATED EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
418
419/**
420 * @deprecated Use elm_calendar_select_mode_get instead.
421 */
422EINA_DEPRECATED EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
423