forked from enlightenment/efl
elementary: add an enum for the weekdays, with magic numbers fixes
SVN revision: 69772
This commit is contained in:
parent
92c1745e90
commit
6e92d78cf3
|
@ -150,7 +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);
|
||||
elm_calendar_first_day_of_week_set(cal, ELM_DAY_MONDAY);
|
||||
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_box_pack_end(bx, cal);
|
||||
|
||||
|
@ -286,7 +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_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);
|
||||
elm_calendar_min_max_year_set(cal, 2010, 2020);
|
||||
|
|
|
@ -24,10 +24,11 @@ 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, first_week_day;
|
||||
int today_it, selected_it, first_day_it;
|
||||
Elm_Calendar_Weekday first_week_day;
|
||||
Ecore_Timer *spin, *update_timer;
|
||||
Elm_Calendar_Format_Cb format_func;
|
||||
const char *weekdays[7];
|
||||
const char *weekdays[ELM_DAY_LAST];
|
||||
struct tm current_time, selected_time;
|
||||
Day_Color day_color[42]; // EINA_DEPRECATED
|
||||
Eina_Bool selection_enabled : 1;
|
||||
|
@ -97,7 +98,7 @@ _sizing_eval(Evas_Object *obj)
|
|||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1;
|
||||
if (!wd) return;
|
||||
elm_coords_finger_size_adjust(8, &minw, 7, &minh);
|
||||
elm_coords_finger_size_adjust(8, &minw, ELM_DAY_LAST, &minh);
|
||||
edje_object_size_min_restricted_calc(wd->calendar, &minw, &minh, minw, minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, -1, -1);
|
||||
|
@ -170,7 +171,7 @@ _cit_mark(Evas_Object *cal, int cit, const char *mtype)
|
|||
static inline int
|
||||
_weekday_get(int first_week_day, int day)
|
||||
{
|
||||
return (day + first_week_day - 1) % 7;
|
||||
return (day + first_week_day - 1) % ELM_DAY_LAST;
|
||||
}
|
||||
|
||||
// EINA_DEPRECATED
|
||||
|
@ -241,8 +242,8 @@ _populate(Evas_Object *obj)
|
|||
mktime(&first_day);
|
||||
|
||||
// Layout of the calendar is changed for removing the unfilled last row.
|
||||
if (first_day.tm_wday < wd->first_week_day)
|
||||
wd->first_day_it = first_day.tm_wday + 7 - wd->first_week_day;
|
||||
if (first_day.tm_wday < (int)wd->first_week_day)
|
||||
wd->first_day_it = first_day.tm_wday + ELM_DAY_LAST - wd->first_week_day;
|
||||
else
|
||||
wd->first_day_it = first_day.tm_wday - wd->first_week_day;
|
||||
|
||||
|
@ -379,10 +380,12 @@ _set_headers(Evas_Object *obj)
|
|||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < ELM_DAY_LAST; i++)
|
||||
{
|
||||
part[3] = i + '0';
|
||||
edje_object_part_text_set(wd->calendar, part, wd->weekdays[(i + wd->first_week_day) % 7]);
|
||||
edje_object_part_text_set(
|
||||
wd->calendar, part,
|
||||
wd->weekdays[(i + wd->first_week_day) % ELM_DAY_LAST]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +409,7 @@ _del_hook(Evas_Object *obj)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < ELM_DAY_LAST; i++)
|
||||
eina_stringshare_del(wd->weekdays[i]);
|
||||
|
||||
free(wd);
|
||||
|
@ -680,12 +683,12 @@ _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type ty
|
|||
else if ((!strcmp(ev->keyname, "Up")) ||
|
||||
(!strcmp(ev->keyname, "KP_Up")))
|
||||
{
|
||||
_update_sel_it(obj, wd->selected_it-7);
|
||||
_update_sel_it(obj, wd->selected_it-ELM_DAY_LAST);
|
||||
}
|
||||
else if ((!strcmp(ev->keyname, "Down")) ||
|
||||
(!strcmp(ev->keyname, "KP_Down")))
|
||||
{
|
||||
_update_sel_it(obj, wd->selected_it+7);
|
||||
_update_sel_it(obj, wd->selected_it+ELM_DAY_LAST);
|
||||
}
|
||||
else if ((!strcmp(ev->keyname, "Prior")) ||
|
||||
(!strcmp(ev->keyname, "KP_Prior")))
|
||||
|
@ -752,7 +755,7 @@ elm_calendar_add(Evas_Object *parent)
|
|||
|
||||
evas_object_smart_callbacks_descriptions_set(obj, _signals);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < ELM_DAY_LAST; i++)
|
||||
{
|
||||
/* FIXME: I'm not aware of a known max, so if it fails,
|
||||
* just make it larger. :| */
|
||||
|
@ -795,7 +798,7 @@ elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[])
|
|||
|
||||
EINA_SAFETY_ON_NULL_RETURN(weekdays);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < ELM_DAY_LAST; i++)
|
||||
{
|
||||
eina_stringshare_replace(&wd->weekdays[i], weekdays[i]);
|
||||
}
|
||||
|
@ -978,12 +981,12 @@ elm_calendar_marks_draw(Evas_Object *obj)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
elm_calendar_first_day_of_week_set(Evas_Object *obj, int day)
|
||||
elm_calendar_first_day_of_week_set(Evas_Object *obj, Elm_Calendar_Weekday day)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if ((day > 6) || (day < 0)) return;
|
||||
if (day >= ELM_DAY_LAST) return;
|
||||
if (wd->first_week_day != day)
|
||||
{
|
||||
wd->first_week_day = day;
|
||||
|
@ -992,7 +995,7 @@ elm_calendar_first_day_of_week_set(Evas_Object *obj, int day)
|
|||
}
|
||||
}
|
||||
|
||||
EAPI int
|
||||
EAPI Elm_Calendar_Weekday
|
||||
elm_calendar_first_day_of_week_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) -1;
|
||||
|
|
|
@ -61,6 +61,30 @@ typedef enum
|
|||
*/
|
||||
typedef _Elm_Calendar_Mark_Repeat_Type Elm_Calendar_Mark_Repeat_Type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ELM_DAY_SUNDAY,
|
||||
ELM_DAY_MONDAY,
|
||||
ELM_DAY_TUESDAY,
|
||||
ELM_DAY_WEDNESDAY,
|
||||
ELM_DAY_THURSDAY,
|
||||
ELM_DAY_FRIDAY,
|
||||
ELM_DAY_SATURDAY,
|
||||
ELM_DAY_LAST
|
||||
} _Elm_Calendar_Weekday;
|
||||
|
||||
/**
|
||||
* @enum _Elm_Calendar_Weekday
|
||||
* @typedef Elm_Calendar_Weekday
|
||||
*
|
||||
* a weekday
|
||||
*
|
||||
* @see elm_calendar_first_day_of_week_set()
|
||||
*
|
||||
* @ingroup Calendar
|
||||
*/
|
||||
typedef _Elm_Calendar_Weekday Elm_Calendar_Weekday;
|
||||
|
||||
typedef 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(). */
|
||||
|
||||
/**
|
||||
|
@ -452,7 +476,7 @@ EAPI double elm_calendar_interval_get(const Evas_Object *obj);
|
|||
*
|
||||
* @ingroup Calendar
|
||||
*/
|
||||
EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, int day);
|
||||
EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, Elm_Calendar_Weekday day);
|
||||
|
||||
/**
|
||||
* Get the first day of week, who are used on calendar widgets'.
|
||||
|
@ -465,7 +489,7 @@ EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, i
|
|||
*
|
||||
* @ingroup Calendar
|
||||
*/
|
||||
EAPI int elm_calendar_first_day_of_week_get(const Evas_Object *obj);
|
||||
EAPI Elm_Calendar_Weekday elm_calendar_first_day_of_week_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
Loading…
Reference in New Issue