2010-10-19 11:25:22 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2019-03-07 07:39:06 -08:00
|
|
|
#include <Efl_Ui.h>
|
2012-03-29 12:27:13 -07:00
|
|
|
#include <Elementary.h>
|
2013-11-04 00:54:31 -08:00
|
|
|
|
2012-02-23 05:58:14 -08:00
|
|
|
struct _api_data
|
|
|
|
{
|
|
|
|
unsigned int state; /* What state we are testing */
|
|
|
|
void *box; /* box used in set_api_state */
|
|
|
|
};
|
|
|
|
typedef struct _api_data api_data;
|
|
|
|
|
|
|
|
enum _api_state
|
|
|
|
{
|
|
|
|
STATE_MARK_MONTHLY,
|
|
|
|
STATE_MARK_WEEKLY,
|
|
|
|
STATE_SUNDAY_HIGHLIGHT,
|
|
|
|
STATE_SELECT_DATE_DISABLED_WITH_MARKS,
|
|
|
|
STATE_SELECT_DATE_DISABLED_NO_MARKS,
|
|
|
|
API_STATE_LAST
|
|
|
|
};
|
|
|
|
typedef enum _api_state api_state;
|
|
|
|
|
2013-09-30 03:39:34 -07:00
|
|
|
#define SEC_PER_DAY 24 * 60 * 60
|
|
|
|
#define SEC_PER_YEAR 365 * SEC_PER_DAY
|
|
|
|
|
2012-02-23 05:58:14 -08:00
|
|
|
static void
|
|
|
|
set_api_state(api_data *api)
|
|
|
|
{
|
|
|
|
const Eina_List *items = elm_box_children_get(api->box);
|
|
|
|
static Elm_Calendar_Mark *m = NULL;
|
2012-03-29 04:09:45 -07:00
|
|
|
if (!eina_list_count(items))
|
2012-02-23 05:58:14 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch(api->state)
|
|
|
|
{ /* Put all api-changes under switch */
|
|
|
|
case STATE_MARK_MONTHLY:
|
|
|
|
{
|
|
|
|
Evas_Object *cal = eina_list_nth(items, 0);
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
|
2012-02-23 05:58:14 -08:00
|
|
|
m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY);
|
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STATE_MARK_WEEKLY:
|
|
|
|
{
|
|
|
|
Evas_Object *cal = eina_list_nth(items, 0);
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 4); /* Set date to DEC 26, 2010 */
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_calendar_mark_del(m);
|
|
|
|
m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
|
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STATE_SUNDAY_HIGHLIGHT:
|
|
|
|
{
|
|
|
|
Evas_Object *cal = eina_list_nth(items, 0);
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 3); /* Set date to DEC 25, 2010 */
|
2012-02-23 05:58:14 -08:00
|
|
|
/* elm_calendar_mark_del(m); */
|
|
|
|
m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
|
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STATE_SELECT_DATE_DISABLED_WITH_MARKS:
|
|
|
|
{
|
|
|
|
Evas_Object *cal = eina_list_nth(items, 0);
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 10); /* Set date to JAN 01, 2011 */
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STATE_SELECT_DATE_DISABLED_NO_MARKS:
|
|
|
|
{
|
|
|
|
Evas_Object *cal = eina_list_nth(items, 0);
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 40); /* Set date to FEB 01, 2011 */
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_calendar_marks_clear(cal);
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case API_STATE_LAST:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
_api_bt_clicked(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2012-02-23 05:58:14 -08:00
|
|
|
{ /* Will add here a SWITCH command containing code to modify test-object */
|
|
|
|
/* in accordance a->state value. */
|
|
|
|
api_data *a = data;
|
|
|
|
char str[128];
|
|
|
|
|
|
|
|
printf("clicked event on API Button: api_state=<%d>\n", a->state);
|
|
|
|
set_api_state(a);
|
|
|
|
a->state++;
|
|
|
|
sprintf(str, "Next API function (%u)", a->state);
|
|
|
|
elm_object_text_set(obj, str);
|
|
|
|
elm_object_disabled_set(obj, a->state == API_STATE_LAST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2012-02-23 05:58:14 -08:00
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
}
|
2010-08-23 11:46:43 -07:00
|
|
|
|
|
|
|
/* A simple test, just displaying calendar in it's default state */
|
|
|
|
void
|
2013-08-31 18:18:03 -07:00
|
|
|
test_calendar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2010-08-23 11:46:43 -07:00
|
|
|
{
|
2012-04-01 23:20:28 -07:00
|
|
|
Evas_Object *win, *cal, *bx, *bxx, *bt;
|
2012-02-23 05:58:14 -08:00
|
|
|
api_data *api = calloc(1, sizeof(api_data));
|
2010-08-23 11:46:43 -07:00
|
|
|
|
2012-04-01 23:20:28 -07:00
|
|
|
win = elm_win_util_standard_add("calendar", "Calendar");
|
2011-07-25 07:22:19 -07:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2012-02-23 05:58:14 -08:00
|
|
|
evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
|
2010-08-23 11:46:43 -07:00
|
|
|
|
2012-02-23 05:58:14 -08:00
|
|
|
bxx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-11-14 02:49:45 -08:00
|
|
|
elm_win_resize_object_add(win, bxx);
|
2012-02-23 05:58:14 -08:00
|
|
|
evas_object_show(bxx);
|
|
|
|
|
|
|
|
bx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
api->box = bx;
|
|
|
|
evas_object_show(bx);
|
|
|
|
|
|
|
|
bt = elm_button_add(win);
|
|
|
|
elm_object_text_set(bt, "Next API function");
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
|
|
|
|
elm_box_pack_end(bxx, bt);
|
|
|
|
elm_object_disabled_set(bt, api->state == API_STATE_LAST);
|
|
|
|
evas_object_show(bt);
|
|
|
|
|
|
|
|
elm_box_pack_end(bxx, bx);
|
|
|
|
|
2010-08-23 11:46:43 -07:00
|
|
|
cal = elm_calendar_add(win);
|
2012-03-29 15:59:11 -07:00
|
|
|
elm_calendar_first_day_of_week_set(cal, ELM_DAY_MONDAY);
|
2010-08-23 11:46:43 -07:00
|
|
|
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_box_pack_end(bx, cal);
|
|
|
|
|
2013-09-30 03:39:34 -07:00
|
|
|
time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
|
2012-02-23 05:58:14 -08:00
|
|
|
elm_calendar_selected_time_set(cal, gmtime(&the_time));
|
|
|
|
|
2010-08-23 11:46:43 -07:00
|
|
|
evas_object_show(cal);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_print_cal_info(Evas_Object *cal, Evas_Object *en)
|
|
|
|
{
|
|
|
|
char info[1024];
|
|
|
|
double interval;
|
|
|
|
Eina_Bool sel_enabled;
|
|
|
|
const char **wds;
|
2012-02-23 05:58:49 -08:00
|
|
|
struct tm stm;
|
2016-11-17 16:39:42 -08:00
|
|
|
const struct tm *mintm, *maxtm;
|
2010-08-23 11:46:43 -07:00
|
|
|
|
2012-02-23 05:58:49 -08:00
|
|
|
if (!elm_calendar_selected_time_get(cal, &stm))
|
2010-08-23 11:46:43 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
interval = elm_calendar_interval_get(cal);
|
2016-11-17 16:39:42 -08:00
|
|
|
mintm = elm_calendar_date_min_get(cal);
|
|
|
|
maxtm = elm_calendar_date_max_get(cal);
|
2012-04-19 02:03:59 -07:00
|
|
|
sel_enabled = !!(elm_calendar_select_mode_get(cal) != ELM_CALENDAR_SELECT_MODE_NONE);
|
2010-08-23 11:46:43 -07:00
|
|
|
wds = elm_calendar_weekdays_names_get(cal);
|
|
|
|
|
|
|
|
snprintf(info, sizeof(info),
|
2012-02-15 21:03:57 -08:00
|
|
|
" Day: %i, Mon: %i, Year %i, WeekDay: %i<br/>"
|
2016-11-17 16:39:42 -08:00
|
|
|
" Interval: %0.2f, Sel Enabled : %i<br/>"
|
|
|
|
" Day_Min : %i, Mon_Min : %i, Year_Min : %i<br/>"
|
|
|
|
" Day_Max : %i, Mon_Max : %i, Year_Max : %i<br/>"
|
2012-02-15 21:03:57 -08:00
|
|
|
" Weekdays: %s, %s, %s, %s, %s, %s, %s<br/>",
|
2012-02-23 05:58:49 -08:00
|
|
|
stm.tm_mday, stm.tm_mon, stm.tm_year + 1900, stm.tm_wday,
|
2016-11-17 16:39:42 -08:00
|
|
|
interval, sel_enabled,
|
|
|
|
mintm->tm_mday, mintm->tm_mon + 1, mintm->tm_year + 1900,
|
|
|
|
maxtm->tm_mday, maxtm->tm_mon + 1, maxtm->tm_year + 1900,
|
2012-02-15 21:03:57 -08:00
|
|
|
wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]);
|
2010-08-23 11:46:43 -07:00
|
|
|
|
2011-12-30 02:02:19 -08:00
|
|
|
elm_object_text_set(en, info);
|
2010-08-23 11:46:43 -07:00
|
|
|
}
|
|
|
|
|
2012-10-03 03:02:27 -07:00
|
|
|
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
|
2013-08-31 18:18:03 -07:00
|
|
|
_print_cal_shown_info_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2012-10-03 03:02:27 -07:00
|
|
|
{
|
|
|
|
_print_cal_shown_info(obj, data);
|
|
|
|
}
|
|
|
|
|
2010-08-23 11:46:43 -07:00
|
|
|
static void
|
2013-08-31 18:18:03 -07:00
|
|
|
_print_cal_info_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2010-08-23 11:46:43 -07:00
|
|
|
{
|
|
|
|
_print_cal_info(obj, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2012-02-23 05:58:49 -08:00
|
|
|
_format_month_year(struct tm *stm)
|
2010-08-23 11:46:43 -07:00
|
|
|
{
|
|
|
|
char buf[32];
|
2012-02-23 05:58:49 -08:00
|
|
|
if (!strftime(buf, sizeof(buf), "%b %y", stm)) return NULL;
|
2010-08-23 11:46:43 -07:00
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
2013-12-14 14:20:47 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_calendar_create(Evas_Object *parent)
|
2010-08-23 11:46:43 -07:00
|
|
|
{
|
2013-12-14 14:20:47 -08:00
|
|
|
Evas_Object *cal;
|
2010-08-23 11:46:43 -07:00
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
struct tm selected_time;
|
|
|
|
time_t current_time;
|
|
|
|
const char *weekdays[] =
|
|
|
|
{
|
|
|
|
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
|
|
"Thursday", "Friday", "Saturday"
|
|
|
|
};
|
|
|
|
|
2013-12-14 14:20:47 -08:00
|
|
|
cal = elm_calendar_add(parent);
|
|
|
|
elm_calendar_weekdays_names_set(cal, weekdays); // FIXME: this causes smart cal recalc loop error
|
|
|
|
elm_calendar_first_day_of_week_set(cal, ELM_DAY_SATURDAY);
|
|
|
|
elm_calendar_interval_set(cal, 0.4);
|
|
|
|
elm_calendar_format_function_set(cal, _format_month_year);
|
2016-11-17 16:39:42 -08:00
|
|
|
|
|
|
|
time_t the_time = (SEC_PER_YEAR * 40) + (SEC_PER_DAY * 24); /* Set min date to JAN 15, 2010 */
|
|
|
|
elm_calendar_date_min_set(cal, gmtime(&the_time));
|
|
|
|
the_time = (SEC_PER_YEAR * 42) + (SEC_PER_DAY * 3); /* Set max date to DEC 25, 2011 */
|
|
|
|
elm_calendar_date_max_set(cal, gmtime(&the_time));
|
2013-12-14 14:20:47 -08:00
|
|
|
|
|
|
|
current_time = time(NULL) + 4 * SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_ANNUALLY);
|
|
|
|
|
|
|
|
current_time = time(NULL) + 1 * SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
|
|
|
|
|
|
|
|
current_time = time(NULL) - 363 * SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_MONTHLY);
|
|
|
|
|
|
|
|
current_time = time(NULL) - 5 * SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
mark = elm_calendar_mark_add(cal, "holiday", &selected_time,
|
|
|
|
ELM_CALENDAR_WEEKLY);
|
|
|
|
|
|
|
|
current_time = time(NULL) + 1 * SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_WEEKLY);
|
|
|
|
|
|
|
|
elm_calendar_mark_del(mark);
|
|
|
|
elm_calendar_marks_draw(cal);
|
|
|
|
|
|
|
|
return cal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A test intended to cover all the calendar api and much use cases as
|
|
|
|
possible */
|
|
|
|
void
|
|
|
|
test_calendar2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *bx, *bxh, *cal, *cal2, *cal3, *en;
|
|
|
|
struct tm selected_time;
|
|
|
|
time_t current_time;
|
|
|
|
|
2012-04-01 23:20:28 -07:00
|
|
|
win = elm_win_util_standard_add("calendar2", "Calendar 2");
|
2011-07-25 07:22:19 -07:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2010-08-23 11:46:43 -07:00
|
|
|
|
|
|
|
bx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(win, bx);
|
|
|
|
evas_object_show(bx);
|
|
|
|
|
|
|
|
bxh = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(bxh, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(bxh, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bxh, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(bxh);
|
|
|
|
elm_box_pack_end(bx, bxh);
|
|
|
|
|
2013-12-14 14:20:47 -08:00
|
|
|
// calendar 1
|
|
|
|
cal = _calendar_create(win);
|
2010-08-23 11:46:43 -07:00
|
|
|
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(cal);
|
|
|
|
elm_box_pack_end(bx, cal);
|
|
|
|
|
2013-12-14 14:20:47 -08:00
|
|
|
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);
|
|
|
|
|
|
|
|
_print_cal_info(cal, en);
|
|
|
|
evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, en);
|
|
|
|
|
|
|
|
// calendar 2
|
2010-08-23 11:46:43 -07:00
|
|
|
cal2 = elm_calendar_add(win);
|
|
|
|
evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(cal2, ELM_CALENDAR_SELECT_MODE_NONE);
|
2010-08-23 11:46:43 -07:00
|
|
|
evas_object_show(cal2);
|
|
|
|
elm_box_pack_end(bxh, cal2);
|
|
|
|
|
2013-12-14 14:20:47 -08:00
|
|
|
// calendar 3
|
2010-08-23 11:46:43 -07:00
|
|
|
cal3 = elm_calendar_add(win);
|
|
|
|
evas_object_size_hint_weight_set(cal3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(cal3, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2013-09-30 03:39:34 -07:00
|
|
|
current_time = time(NULL) + 34 * SEC_PER_DAY;
|
2010-08-23 11:46:43 -07:00
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_selected_time_set(cal3, &selected_time);
|
2013-09-30 03:39:34 -07:00
|
|
|
current_time = time(NULL) + 1 * SEC_PER_DAY;
|
2010-08-23 11:46:43 -07:00
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
|
|
|
|
elm_calendar_marks_clear(cal3);
|
|
|
|
current_time = time(NULL);
|
|
|
|
localtime_r(¤t_time, &selected_time);
|
|
|
|
elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_DAILY);
|
|
|
|
elm_calendar_mark_add(cal3, "holiday", &selected_time, ELM_CALENDAR_DAILY);
|
|
|
|
elm_calendar_marks_draw(cal3);
|
|
|
|
evas_object_show(cal3);
|
|
|
|
elm_box_pack_end(bxh, cal3);
|
2011-05-14 12:47:54 -07:00
|
|
|
|
2013-12-14 12:45:57 -08:00
|
|
|
evas_object_show(win);
|
2010-08-23 11:46:43 -07:00
|
|
|
}
|
|
|
|
|
2012-04-19 01:46:22 -07:00
|
|
|
void
|
2013-08-31 18:18:03 -07:00
|
|
|
test_calendar3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2012-04-19 01:46:22 -07:00
|
|
|
{
|
2012-10-03 03:02:27 -07:00
|
|
|
Evas_Object *win, *cal, *en, *bx;
|
2012-04-25 15:51:46 -07:00
|
|
|
struct tm selected_time;
|
|
|
|
time_t current_time;
|
2012-04-19 01:46:22 -07:00
|
|
|
|
|
|
|
win = elm_win_util_standard_add("calendar", "Calendar");
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
|
2012-10-03 03:02:27 -07:00
|
|
|
bx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-11-14 02:49:45 -08:00
|
|
|
elm_win_resize_object_add(win, bx);
|
2012-10-03 03:02:27 -07:00
|
|
|
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);
|
2012-04-19 01:46:22 -07:00
|
|
|
|
2012-10-03 03:02:27 -07:00
|
|
|
elm_entry_editable_set(en, EINA_FALSE);
|
2012-04-19 01:46:22 -07:00
|
|
|
cal = elm_calendar_add(win);
|
2013-01-22 08:37:45 -08:00
|
|
|
elm_object_style_set(cal, "double_spinners");
|
2012-04-19 01:46:22 -07:00
|
|
|
elm_calendar_first_day_of_week_set(cal, ELM_DAY_THURSDAY);
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_ONDEMAND);
|
2012-09-11 14:33:54 -07:00
|
|
|
elm_calendar_selectable_set(cal,
|
|
|
|
(ELM_CALENDAR_SELECTABLE_YEAR
|
|
|
|
| ELM_CALENDAR_SELECTABLE_MONTH));
|
2013-09-30 03:39:34 -07:00
|
|
|
current_time = time(NULL) + 34 * SEC_PER_DAY;
|
2012-04-25 15:51:46 -07:00
|
|
|
localtime_r(¤t_time, &selected_time);
|
2012-04-19 01:46:22 -07:00
|
|
|
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-10-03 03:02:27 -07:00
|
|
|
elm_box_pack_end(bx, cal);
|
2012-04-19 02:03:59 -07:00
|
|
|
|
2012-04-19 01:46:22 -07:00
|
|
|
evas_object_show(cal);
|
2012-10-03 03:02:27 -07:00
|
|
|
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);
|
2012-04-19 01:46:22 -07:00
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
2017-10-25 00:42:39 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_cal_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
struct tm selected_date;
|
|
|
|
struct tm max_date;
|
|
|
|
struct tm min_date;
|
|
|
|
|
|
|
|
selected_date = efl_ui_calendar_date_get(ev->object);
|
|
|
|
min_date = efl_ui_calendar_date_min_get(ev->object);
|
|
|
|
max_date = efl_ui_calendar_date_max_get(ev->object);
|
|
|
|
printf("Selected Date is %i/%i/%i\n",
|
|
|
|
selected_date.tm_mday,
|
|
|
|
selected_date.tm_mon + 1,
|
|
|
|
selected_date.tm_year + 1900);
|
|
|
|
printf("Minimum Date is %i/%i/%i\n",
|
|
|
|
min_date.tm_mday,
|
|
|
|
min_date.tm_mon + 1,
|
|
|
|
min_date.tm_year + 1900);
|
|
|
|
printf("Max Date is %i/%i/%i\n",
|
|
|
|
max_date.tm_mday,
|
|
|
|
max_date.tm_mon + 1,
|
|
|
|
max_date.tm_year + 1900);
|
|
|
|
}
|
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
static Eina_Bool
|
2017-10-27 02:31:59 -07:00
|
|
|
_cal_format_cb(void *data EINA_UNUSED, Eina_Strbuf *str, const Eina_Value value)
|
|
|
|
{
|
|
|
|
struct tm current_time;
|
|
|
|
|
2017-11-13 17:30:55 -08:00
|
|
|
//return if the value type is other than EINA_VALUE_TYPE_TM
|
|
|
|
if (eina_value_type_get(&value) != EINA_VALUE_TYPE_TM)
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
return EINA_FALSE;
|
2017-11-13 17:30:55 -08:00
|
|
|
|
|
|
|
eina_value_get(&value, ¤t_time);
|
|
|
|
eina_strbuf_append_strftime(str, "<< %b %y >>", ¤t_time);
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
return EINA_TRUE;
|
2017-10-27 02:31:59 -07:00
|
|
|
}
|
|
|
|
|
2017-10-25 00:42:39 -07:00
|
|
|
void
|
|
|
|
test_efl_ui_calendar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2017-11-13 18:08:17 -08:00
|
|
|
Evas_Object *win, *box;
|
2017-10-25 00:42:39 -07:00
|
|
|
struct tm selected_date, min_date, max_date;
|
|
|
|
time_t current_date;
|
|
|
|
|
|
|
|
current_date = time(NULL) + SEC_PER_DAY;
|
|
|
|
localtime_r(¤t_date, &selected_date);
|
|
|
|
current_date = time(NULL) - SEC_PER_YEAR;
|
|
|
|
localtime_r(¤t_date, &min_date);
|
|
|
|
current_date = time(NULL) + SEC_PER_YEAR;
|
|
|
|
localtime_r(¤t_date, &max_date);
|
|
|
|
|
2019-12-11 23:29:19 -08:00
|
|
|
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
2017-10-25 00:42:39 -07:00
|
|
|
efl_text_set(efl_added, "Efl Ui Calendar"),
|
2017-11-13 18:08:17 -08:00
|
|
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
2017-10-25 00:42:39 -07:00
|
|
|
|
|
|
|
box = efl_add(EFL_UI_BOX_CLASS, win,
|
|
|
|
efl_content_set(win, efl_added));
|
|
|
|
|
2017-11-13 18:08:17 -08:00
|
|
|
efl_add(EFL_UI_CALENDAR_CLASS, win,
|
|
|
|
efl_ui_calendar_date_min_set(efl_added, min_date),
|
|
|
|
efl_ui_calendar_date_max_set(efl_added, max_date),
|
|
|
|
efl_ui_calendar_date_set(efl_added, selected_date),
|
|
|
|
efl_event_callback_add(efl_added, EFL_UI_CALENDAR_EVENT_CHANGED, _cal_changed_cb, NULL),
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_string_set(efl_added, "%b", EFL_UI_FORMAT_STRING_TYPE_TIME),
|
2017-11-13 18:08:17 -08:00
|
|
|
efl_pack(box, efl_added));
|
|
|
|
|
|
|
|
efl_add(EFL_UI_CALENDAR_CLASS, win,
|
|
|
|
efl_ui_calendar_date_min_set(efl_added, min_date),
|
|
|
|
efl_ui_calendar_date_max_set(efl_added, max_date),
|
|
|
|
efl_ui_calendar_date_set(efl_added, selected_date),
|
|
|
|
efl_event_callback_add(efl_added, EFL_UI_CALENDAR_EVENT_CHANGED, _cal_changed_cb, NULL),
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_func_set(efl_added, NULL, _cal_format_cb, NULL),
|
2017-11-13 18:08:17 -08:00
|
|
|
efl_pack(box, efl_added));
|
2017-10-25 00:42:39 -07:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 300));
|
2017-10-25 00:42:39 -07:00
|
|
|
}
|