elementary: add 2 API, the first one is to set the first day of week in elm_calendar, and the second to get the info. I use a more trivial way to set headers ^^

SVN revision: 69771
This commit is contained in:
Michael BOUCHAUD 2012-03-29 22:14:30 +00:00
parent 147c0a2980
commit 92c1745e90
3 changed files with 57 additions and 4 deletions

View File

@ -150,6 +150,7 @@ test_calendar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
elm_box_pack_end(bxx, bx);
cal = elm_calendar_add(win);
elm_calendar_first_day_of_week_set(cal, 1);
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, cal);
@ -285,6 +286,7 @@ test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
elm_calendar_min_max_year_set(cal3, -1, -1);
elm_calendar_weekdays_names_set(cal, weekdays);
elm_calendar_first_day_of_week_set(cal, 6);
elm_calendar_interval_set(cal, 0.4);
elm_calendar_format_function_set(cal, _format_month_year);
elm_calendar_min_max_year_set(cal, 2010, 2020);

View File

@ -24,7 +24,7 @@ struct _Widget_Data
Eina_List *marks;
double interval, first_interval;
int year_min, year_max, spin_speed;
int today_it, selected_it, first_day_it;
int today_it, selected_it, first_day_it, first_week_day;
Ecore_Timer *spin, *update_timer;
Elm_Calendar_Format_Cb format_func;
const char *weekdays[7];
@ -241,7 +241,10 @@ _populate(Evas_Object *obj)
mktime(&first_day);
// Layout of the calendar is changed for removing the unfilled last row.
wd->first_day_it = first_day.tm_wday;
if (first_day.tm_wday < wd->first_week_day)
wd->first_day_it = first_day.tm_wday + 7 - wd->first_week_day;
else
wd->first_day_it = first_day.tm_wday - wd->first_week_day;
if ((35 - wd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
@ -286,7 +289,7 @@ _populate(Evas_Object *obj)
for (i = 0; i < 42; i++)
{
_text_day_color_update(wd, i); // EINA_DEPRECATED
if ((!day) && (i == first_day.tm_wday)) day = 1;
if ((!day) && (i == wd->first_day_it)) day = 1;
if ((day == wd->current_time.tm_mday)
&& (mon == wd->current_time.tm_mon)
@ -379,7 +382,7 @@ _set_headers(Evas_Object *obj)
for (i = 0; i < 7; i++)
{
part[3] = i + '0';
edje_object_part_text_set(wd->calendar, part, wd->weekdays[i]);
edje_object_part_text_set(wd->calendar, part, wd->weekdays[(i + wd->first_week_day) % 7]);
}
}
@ -973,3 +976,27 @@ elm_calendar_marks_draw(Evas_Object *obj)
if (!wd) return;
_populate(obj);
}
EAPI void
elm_calendar_first_day_of_week_set(Evas_Object *obj, int day)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if ((day > 6) || (day < 0)) return;
if (wd->first_week_day != day)
{
wd->first_week_day = day;
_set_headers(obj);
_populate(obj);
}
}
EAPI int
elm_calendar_first_day_of_week_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) -1;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return -1;
return wd->first_week_day;
}

View File

@ -443,6 +443,30 @@ EAPI void elm_calendar_interval_set(Evas_Object *obj, double int
*/
EAPI double elm_calendar_interval_get(const Evas_Object *obj);
/**
* Set the first day of week to use on calendar widgets'.
*
* @param obj The calendar object
* @param day An int which correspond to the first day of the week (Sunday = 0, monday = 1,
* ..., saturday = 6)
*
* @ingroup Calendar
*/
EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, int day);
/**
* Get the first day of week, who are used on calendar widgets'.
*
* @param obj The calendar object
* @return An int which correspond to the first day of the week (Sunday = 0, monday = 1,
* ..., saturday = 6)
*
* @see elm_calendar_first_day_of_week_set() for more details
*
* @ingroup Calendar
*/
EAPI int elm_calendar_first_day_of_week_get(const Evas_Object *obj);
/**
* @}
*/