forked from enlightenment/efl
elementary: add elm_calendar_displayed_time_get to know which month is displayed. And add a signal display,changed
SVN revision: 77362
This commit is contained in:
parent
fe71040979
commit
14e4e7dfbe
|
@ -551,3 +551,7 @@
|
|||
|
||||
* Fix list corruption issue in multibuttonentry.
|
||||
|
||||
2012-10-03 Michael Bouchaud (yoz)
|
||||
|
||||
* add elm_calendar_displayed_time_get
|
||||
* add a signal display,changed to elm_calendar
|
||||
|
|
|
@ -8,6 +8,7 @@ Additions:
|
|||
* Add window floating mode api's
|
||||
* Add reorder mode set/get API in Toolbar.
|
||||
* Add the toolbar API which expand the transverse length.
|
||||
* Add a way to know which month is displayed in elm_calendar
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
|
@ -188,6 +188,26 @@ _print_cal_info(Evas_Object *cal, Evas_Object *en)
|
|||
elm_object_text_set(en, info);
|
||||
}
|
||||
|
||||
void
|
||||
_print_cal_shown_info(Evas_Object *cal, Evas_Object *en)
|
||||
{
|
||||
char info[1024];
|
||||
struct tm stm;
|
||||
|
||||
elm_calendar_displayed_time_get(cal, &stm);
|
||||
snprintf(info, sizeof(info),
|
||||
" Mon: %i, Year %i",
|
||||
stm.tm_mon, stm.tm_year + 1900);
|
||||
|
||||
elm_object_text_set(en, info);
|
||||
}
|
||||
|
||||
void
|
||||
_print_cal_shown_info_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
||||
{
|
||||
_print_cal_shown_info(obj, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_print_cal_info_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
||||
{
|
||||
|
@ -311,18 +331,25 @@ test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
|
|||
void
|
||||
test_calendar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *win, *cal, *bxx;
|
||||
Evas_Object *win, *cal, *en, *bx;
|
||||
struct tm selected_time;
|
||||
time_t current_time;
|
||||
|
||||
win = elm_win_util_standard_add("calendar", "Calendar");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
bxx = elm_box_add(win);
|
||||
elm_win_resize_object_add(win, bxx);
|
||||
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(bxx);
|
||||
bx = elm_box_add(win);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(bx);
|
||||
|
||||
en = elm_entry_add(win);
|
||||
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(en);
|
||||
elm_box_pack_end(bx, en);
|
||||
|
||||
elm_entry_editable_set(en, EINA_FALSE);
|
||||
cal = elm_calendar_add(win);
|
||||
elm_calendar_first_day_of_week_set(cal, ELM_DAY_THURSDAY);
|
||||
elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_ONDEMAND);
|
||||
|
@ -331,11 +358,13 @@ test_calendar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
|
|||
| ELM_CALENDAR_SELECTABLE_MONTH));
|
||||
current_time = time(NULL) + 34 * 84600;
|
||||
localtime_r(¤t_time, &selected_time);
|
||||
elm_calendar_selected_time_set(cal, &selected_time);
|
||||
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_pack_end(bxx, cal);
|
||||
elm_box_pack_end(bx, cal);
|
||||
|
||||
evas_object_show(cal);
|
||||
elm_calendar_selected_time_set(cal, &selected_time);
|
||||
_print_cal_shown_info(cal, en);
|
||||
evas_object_smart_callback_add(cal, "display,changed", _print_cal_shown_info_cb, en);
|
||||
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
EAPI const char ELM_CALENDAR_SMART_NAME[] = "elm_calendar";
|
||||
|
||||
static const char SIG_CHANGED[] = "changed";
|
||||
static const char SIG_DISPLAY_CHANGED[] = "display,changed";
|
||||
|
||||
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
||||
{SIG_CHANGED, ""},
|
||||
{SIG_DISPLAY_CHANGED, ""},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -559,6 +561,7 @@ _update_month(Evas_Object *obj,
|
|||
_fix_selected_time(sd);
|
||||
evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
|
||||
}
|
||||
evas_object_smart_callback_call(obj, SIG_DISPLAY_CHANGED, NULL);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -1321,3 +1324,14 @@ elm_calendar_selectable_get(const Evas_Object *obj)
|
|||
return sd->selectable;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
elm_calendar_displayed_time_get(const Evas_Object *obj, struct tm *displayed_time)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(displayed_time, EINA_FALSE);
|
||||
ELM_CALENDAR_CHECK(obj) EINA_FALSE;
|
||||
ELM_CALENDAR_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
|
||||
|
||||
*displayed_time = sd->shown_time;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
* This widget emits the following signals, besides the ones sent from
|
||||
* @ref Layout:
|
||||
* - @c "changed" - emitted when the date in the calendar is changed.
|
||||
* - @c "display,changed" - emitted when the current month displayed in the
|
||||
* calendar is changed.
|
||||
*
|
||||
* Supported elm_object common APIs.
|
||||
* @li @ref elm_object_signal_emit
|
||||
|
@ -567,6 +569,19 @@ EAPI void elm_calendar_selectable_set(Evas_Object *obj, Elm_Cale
|
|||
*/
|
||||
EAPI Elm_Calendar_Selectable elm_calendar_selectable_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Get the current time displayed in the widget
|
||||
*
|
||||
* @param obj The calendar object
|
||||
* @param selected_time A @b tm struct to point to displayed date
|
||||
* @return EINA_FALSE means an error occurred. If it's an error the returned
|
||||
* time is zero filled.
|
||||
*
|
||||
* @ingroup Calendar
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI Eina_Bool elm_calendar_displayed_time_get(const Evas_Object *obj, struct tm *displayed_time);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue