2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-10-17 08:56:11 -07:00
|
|
|
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
|
|
|
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
|
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-07-31 15:06:52 -07:00
|
|
|
#include "elm_widget_calendar.h"
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_CALENDAR_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Calendar"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_calendar"
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2011-04-15 10:01:39 -07:00
|
|
|
static const char SIG_CHANGED[] = "changed";
|
2012-10-03 03:02:27 -07:00
|
|
|
static const char SIG_DISPLAY_CHANGED[] = "display,changed";
|
2011-04-15 10:01:39 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
2011-04-15 10:01:39 -07:00
|
|
|
{SIG_CHANGED, ""},
|
2012-10-03 03:02:27 -07:00
|
|
|
{SIG_DISPLAY_CHANGED, ""},
|
2014-01-23 03:07:20 -08:00
|
|
|
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-07 21:05:06 -08:00
|
|
|
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2011-04-15 10:01:39 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2014-03-31 19:10:25 -07:00
|
|
|
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
|
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"move", _key_action_move},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2011-02-15 05:37:28 -08:00
|
|
|
/* Should not be translated, it's used if we failed
|
|
|
|
* getting from locale. */
|
2010-08-23 11:45:36 -07:00
|
|
|
static const char *_days_abbrev[] =
|
|
|
|
{
|
|
|
|
"Sun", "Mon", "Tue", "Wed",
|
|
|
|
"Thu", "Fri", "Sat"
|
|
|
|
};
|
|
|
|
|
|
|
|
static int _days_in_month[2][12] =
|
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
|
|
|
|
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
|
2010-08-23 11:45:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static Elm_Calendar_Mark *
|
2012-05-03 15:41:58 -07:00
|
|
|
_mark_new(Evas_Object *obj,
|
|
|
|
const char *mark_type,
|
|
|
|
struct tm *mark_time,
|
|
|
|
Elm_Calendar_Mark_Repeat_Type repeat)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
|
|
|
|
mark = calloc(1, sizeof(Elm_Calendar_Mark));
|
|
|
|
if (!mark) return NULL;
|
|
|
|
mark->obj = obj;
|
|
|
|
mark->mark_type = eina_stringshare_add(mark_type);
|
|
|
|
mark->mark_time = *mark_time;
|
|
|
|
mark->repeat = repeat;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
return mark;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_mark_free(Elm_Calendar_Mark *mark)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(mark->mark_type);
|
|
|
|
free(mark);
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_elm_layout_sizing_eval(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2014-02-19 02:25:32 -08:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2013-10-05 01:13:43 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2013-09-30 03:21:31 -07:00
|
|
|
|
2014-02-19 02:25:32 -08:00
|
|
|
if (sd->filling) return;
|
2013-08-07 00:49:23 -07:00
|
|
|
// 7x8 (1 month+year, days, 6 dates.)
|
|
|
|
elm_coords_finger_size_adjust(7, &minw, 8, &minh);
|
2012-05-03 15:41:58 -07:00
|
|
|
edje_object_size_min_restricted_calc
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
2010-08-23 11:45:36 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2011-05-24 05:57:44 -07:00
|
|
|
_maxdays_get(struct tm *selected_time)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
int month, year;
|
|
|
|
|
2011-05-24 05:57:44 -07:00
|
|
|
month = selected_time->tm_mon;
|
|
|
|
year = selected_time->tm_year + 1900;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
return _days_in_month
|
|
|
|
[((!(year % 4)) && ((!(year % 400)) || (year % 100)))][month];
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2012-05-03 15:41:58 -07:00
|
|
|
_unselect(Evas_Object *obj,
|
|
|
|
int selected)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2010-12-02 23:58:43 -08:00
|
|
|
char emission[32];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,unselected", selected);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2012-05-03 15:41:58 -07:00
|
|
|
_select(Evas_Object *obj,
|
|
|
|
int selected)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2010-12-02 23:58:43 -08:00
|
|
|
char emission[32];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
sd->selected_it = selected;
|
2010-08-23 11:45:36 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,selected", selected);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-03-20 00:44:34 -07:00
|
|
|
_not_today(Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2010-12-02 23:58:43 -08:00
|
|
|
char emission[32];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,not_today", sd->today_it);
|
2012-11-25 22:32:53 -08:00
|
|
|
elm_layout_signal_emit(sd->obj, emission, "elm");
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->today_it = -1;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-03-20 00:44:34 -07:00
|
|
|
_today(Elm_Calendar_Data *sd,
|
2012-05-03 15:41:58 -07:00
|
|
|
int it)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2010-12-02 23:58:43 -08:00
|
|
|
char emission[32];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,today", it);
|
2012-11-25 22:32:53 -08:00
|
|
|
elm_layout_signal_emit(sd->obj, emission, "elm");
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->today_it = it;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2011-05-24 05:57:44 -07:00
|
|
|
_format_month_year(struct tm *selected_time)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
char buf[32];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2011-09-13 09:58:10 -07:00
|
|
|
if (!strftime(buf, sizeof(buf), E_("%B %Y"), selected_time)) return NULL;
|
2010-08-23 11:45:36 -07:00
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
static char *
|
|
|
|
_format_month(struct tm *selected_time)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (!strftime(buf, sizeof(buf), E_("%B"), selected_time)) return NULL;
|
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_format_year(struct tm *selected_time)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (!strftime(buf, sizeof(buf), E_("%Y"), selected_time)) return NULL;
|
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
static inline void
|
2012-05-03 15:41:58 -07:00
|
|
|
_cit_mark(Evas_Object *cal,
|
|
|
|
int cit,
|
|
|
|
const char *mtype)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
char sign[64];
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
snprintf(sign, sizeof(sign), "cit_%i,%s", cit, mtype);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(cal, sign, "elm");
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2012-05-03 15:41:58 -07:00
|
|
|
_weekday_get(int first_week_day,
|
|
|
|
int day)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-03-29 15:59:11 -07:00
|
|
|
return (day + first_week_day - 1) % ELM_DAY_LAST;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2010-12-06 16:56:21 -08:00
|
|
|
// EINA_DEPRECATED
|
2010-12-02 23:58:43 -08:00
|
|
|
static void
|
2014-03-20 00:44:34 -07:00
|
|
|
_text_day_color_update(Elm_Calendar_Data *sd,
|
2012-05-03 15:41:58 -07:00
|
|
|
int pos)
|
2010-12-02 23:58:43 -08:00
|
|
|
{
|
|
|
|
char emission[32];
|
2011-04-01 04:35:07 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
switch (sd->day_color[pos])
|
2011-04-01 04:35:07 -07:00
|
|
|
{
|
|
|
|
case DAY_WEEKDAY:
|
2012-05-03 15:41:58 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,weekday", pos);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case DAY_SATURDAY:
|
2012-05-03 15:41:58 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,saturday", pos);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case DAY_SUNDAY:
|
2012-05-03 15:41:58 -07:00
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,sunday", pos);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
default:
|
2012-05-03 15:41:58 -07:00
|
|
|
return;
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
elm_layout_signal_emit(sd->obj, emission, "elm");
|
2010-12-02 23:58:43 -08:00
|
|
|
}
|
|
|
|
|
2011-07-14 08:46:26 -07:00
|
|
|
static void
|
2014-03-20 00:44:34 -07:00
|
|
|
_set_month_year(Elm_Calendar_Data *sd)
|
2011-07-14 08:46:26 -07:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_TRUE;
|
2013-10-13 22:40:35 -07:00
|
|
|
if (sd->double_spinners) /* theme has spinner for year */
|
|
|
|
{
|
|
|
|
buf = _format_year(&sd->shown_time);
|
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
elm_layout_text_set(sd->obj, "year_text", buf);
|
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
else elm_layout_text_set(sd->obj, "year_text", "");
|
|
|
|
|
|
|
|
buf = _format_month(&sd->shown_time);
|
|
|
|
}
|
2013-01-22 08:37:45 -08:00
|
|
|
else
|
|
|
|
buf = sd->format_func(&sd->shown_time);
|
2013-01-03 12:50:10 -08:00
|
|
|
|
2011-07-14 08:46:26 -07:00
|
|
|
if (buf)
|
|
|
|
{
|
2013-01-22 08:37:45 -08:00
|
|
|
elm_layout_text_set(sd->obj, "month_text", buf);
|
2011-07-14 08:46:26 -07:00
|
|
|
free(buf);
|
|
|
|
}
|
2013-01-22 08:37:45 -08:00
|
|
|
else elm_layout_text_set(sd->obj, "month_text", "");
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_FALSE;
|
2011-07-14 08:46:26 -07:00
|
|
|
}
|
|
|
|
|
2012-09-12 01:25:10 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2012-09-12 01:25:10 -07:00
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
|
|
|
|
eina_strbuf_append_printf(buf, "day %s", elm_widget_access_info_get(obj));
|
|
|
|
|
|
|
|
ret = eina_strbuf_string_steal(buf);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_access_calendar_item_register(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
int maxdays, day, i;
|
|
|
|
char day_s[3], pname[14];
|
|
|
|
Evas_Object *ao;
|
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
day = 0;
|
|
|
|
maxdays = _maxdays_get(&sd->shown_time);
|
|
|
|
for (i = 0; i < 42; i++)
|
|
|
|
{
|
|
|
|
if ((!day) && (i == sd->first_day_it)) day = 1;
|
|
|
|
if ((day) && (day <= maxdays))
|
|
|
|
{
|
|
|
|
snprintf(pname, sizeof(pname), "cit_%i.access", i);
|
|
|
|
|
|
|
|
ao = _elm_access_edje_object_part_object_register
|
|
|
|
(obj, elm_layout_edje_get(obj), pname);
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2012-09-12 01:25:10 -07:00
|
|
|
ELM_ACCESS_TYPE, E_("calendar item"));
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_callback_set(_elm_access_info_get(ao),
|
2012-09-12 01:25:10 -07:00
|
|
|
ELM_ACCESS_INFO, _access_info_cb, NULL);
|
|
|
|
|
|
|
|
snprintf(day_s, sizeof(day_s), "%i", day++);
|
|
|
|
elm_widget_access_info_set(ao, (const char*)day_s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(pname, sizeof(pname), "cit_%i.access", i);
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
|
|
|
(obj, elm_layout_edje_get(obj), pname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_access_calendar_spinner_register(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *po;
|
|
|
|
Elm_Access_Info *ai;
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->dec_btn_month_access = _elm_access_edje_object_part_object_register
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "left_bt");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->dec_btn_month_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement month button"));
|
|
|
|
|
|
|
|
sd->dec_btn_year_access = _elm_access_edje_object_part_object_register
|
|
|
|
(obj, elm_layout_edje_get(obj), "left_bt_year");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->dec_btn_year_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar decrement year button"));
|
2012-09-12 01:25:10 -07:00
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->inc_btn_month_access = _elm_access_edje_object_part_object_register
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "right_bt");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->inc_btn_month_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment month button"));
|
|
|
|
|
|
|
|
sd->inc_btn_year_access = _elm_access_edje_object_part_object_register
|
|
|
|
(obj, elm_layout_edje_get(obj), "right_bt_year");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->inc_btn_year_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar increment year button"));
|
2012-09-12 01:25:10 -07:00
|
|
|
|
|
|
|
sd->month_access = _elm_access_edje_object_part_object_register
|
2013-01-03 12:50:10 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "text_month");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->month_access);
|
2012-09-12 01:25:10 -07:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar month"));
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->year_access = _elm_access_edje_object_part_object_register
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "year_text");
|
2013-07-30 20:53:04 -07:00
|
|
|
ai = _elm_access_info_get(sd->year_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("calendar year"));
|
|
|
|
|
2012-09-12 01:25:10 -07:00
|
|
|
po = (Evas_Object *)edje_object_part_object_get
|
2013-01-22 08:37:45 -08:00
|
|
|
(elm_layout_edje_get(obj), "month_text");
|
2012-09-12 01:25:10 -07:00
|
|
|
evas_object_pass_events_set(po, EINA_FALSE);
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
po = (Evas_Object *)edje_object_part_object_get
|
2013-01-22 08:37:45 -08:00
|
|
|
(elm_layout_edje_get(obj), "year_text");
|
2013-01-03 12:50:10 -08:00
|
|
|
evas_object_pass_events_set(po, EINA_FALSE);
|
2012-09-12 01:25:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_access_calendar_register(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
_access_calendar_spinner_register(obj);
|
|
|
|
_access_calendar_item_register(obj);
|
|
|
|
}
|
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
static void
|
|
|
|
_populate(Evas_Object *obj)
|
|
|
|
{
|
2012-03-06 23:59:51 -08:00
|
|
|
int maxdays, day, mon, yr, i;
|
2010-08-23 11:45:36 -07:00
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
char part[12], day_s[3];
|
|
|
|
struct tm first_day;
|
|
|
|
Eina_List *l;
|
2010-12-02 23:58:43 -08:00
|
|
|
Eina_Bool last_row = EINA_TRUE;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-07-30 00:14:33 -07:00
|
|
|
elm_layout_freeze(obj);
|
|
|
|
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_FALSE;
|
2012-05-03 15:41:58 -07:00
|
|
|
if (sd->today_it > 0) _not_today(sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
maxdays = _maxdays_get(&sd->shown_time);
|
|
|
|
mon = sd->shown_time.tm_mon;
|
|
|
|
yr = sd->shown_time.tm_year;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
_set_month_year(sd);
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_TRUE;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
/* Set days */
|
|
|
|
day = 0;
|
2012-05-03 15:41:58 -07:00
|
|
|
first_day = sd->shown_time;
|
2010-08-23 11:45:36 -07:00
|
|
|
first_day.tm_mday = 1;
|
|
|
|
mktime(&first_day);
|
|
|
|
|
2010-12-02 23:58:43 -08:00
|
|
|
// Layout of the calendar is changed for removing the unfilled last row.
|
2012-05-03 15:41:58 -07:00
|
|
|
if (first_day.tm_wday < (int)sd->first_week_day)
|
|
|
|
sd->first_day_it = first_day.tm_wday + ELM_DAY_LAST - sd->first_week_day;
|
2012-03-29 15:14:30 -07:00
|
|
|
else
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->first_day_it = first_day.tm_wday - sd->first_week_day;
|
2011-04-01 04:35:07 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((35 - sd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
|
2011-04-01 04:35:07 -07:00
|
|
|
|
|
|
|
if (!last_row)
|
|
|
|
{
|
|
|
|
char emission[32];
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
snprintf(emission, sizeof(emission), "cseph_%i,row_hide", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
snprintf(emission, sizeof(emission), "cseph_%i,row_invisible", 5);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
for (i = 0; i < 35; i++)
|
|
|
|
{
|
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,cell_expanded", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
for (i = 35; i < 42; i++)
|
|
|
|
{
|
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,cell_invisible", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char emission[32];
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
snprintf(emission, sizeof(emission), "cseph_%i,row_show", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
for (i = 0; i < 42; i++)
|
|
|
|
{
|
|
|
|
snprintf(emission, sizeof(emission), "cit_%i,cell_default", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_signal_emit(obj, emission, "elm");
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
for (i = 0; i < 42; i++)
|
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
_text_day_color_update(sd, i); // EINA_DEPRECATED
|
|
|
|
if ((!day) && (i == sd->first_day_it)) day = 1;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((day == sd->current_time.tm_mday)
|
|
|
|
&& (mon == sd->current_time.tm_mon)
|
|
|
|
&& (yr == sd->current_time.tm_year))
|
|
|
|
_today(sd, i);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if (day == sd->selected_time.tm_mday)
|
2011-04-01 04:35:07 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->selected_it > -1) && (sd->selected_it != i))
|
|
|
|
_unselect(obj, sd->selected_it);
|
|
|
|
|
|
|
|
if (sd->select_mode == ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((mon == sd->selected_time.tm_mon)
|
|
|
|
&& (yr == sd->selected_time.tm_year)
|
|
|
|
&& (sd->selected))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
_select(obj, i);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
else if (sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE)
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
_select(obj, i);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
if ((day) && (day <= maxdays))
|
|
|
|
snprintf(day_s, sizeof(day_s), "%i", day++);
|
|
|
|
else
|
2010-12-02 23:58:43 -08:00
|
|
|
day_s[0] = 0;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
snprintf(part, sizeof(part), "cit_%i.text", i);
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_text_set(obj, part, day_s);
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
/* Clear previous marks */
|
2012-05-03 15:41:58 -07:00
|
|
|
_cit_mark(obj, i, "clear");
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2012-09-12 01:25:10 -07:00
|
|
|
// ACCESS
|
|
|
|
if ((_elm_config->access_mode != ELM_ACCESS_MODE_OFF))
|
|
|
|
_access_calendar_item_register(obj);
|
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
/* Set marks */
|
2012-10-01 00:36:27 -07:00
|
|
|
EINA_LIST_FOREACH(sd->marks, l, mark)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2011-04-01 04:35:07 -07:00
|
|
|
struct tm *mtime = &mark->mark_time;
|
2012-05-03 15:41:58 -07:00
|
|
|
int month = sd->shown_time.tm_mon;
|
|
|
|
int year = sd->shown_time.tm_year;
|
|
|
|
int mday_it = mtime->tm_mday + sd->first_day_it - 1;
|
2011-04-01 04:35:07 -07:00
|
|
|
|
|
|
|
switch (mark->repeat)
|
|
|
|
{
|
|
|
|
case ELM_CALENDAR_UNIQUE:
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((mtime->tm_mon == month) && (mtime->tm_year == year))
|
|
|
|
_cit_mark(obj, mday_it, mark->mark_type);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case ELM_CALENDAR_DAILY:
|
2012-05-03 15:41:58 -07:00
|
|
|
if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
|
|
|
|
(mtime->tm_year < year))
|
|
|
|
day = 1;
|
|
|
|
else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
|
|
|
|
day = mtime->tm_mday;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
for (; day <= maxdays; day++)
|
|
|
|
_cit_mark(obj, day + sd->first_day_it - 1,
|
|
|
|
mark->mark_type);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case ELM_CALENDAR_WEEKLY:
|
2012-05-03 15:41:58 -07:00
|
|
|
if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
|
|
|
|
(mtime->tm_year < year))
|
|
|
|
day = 1;
|
|
|
|
else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
|
|
|
|
day = mtime->tm_mday;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
for (; day <= maxdays; day++)
|
|
|
|
if (mtime->tm_wday == _weekday_get(sd->first_day_it, day))
|
|
|
|
_cit_mark(obj, day + sd->first_day_it - 1,
|
|
|
|
mark->mark_type);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case ELM_CALENDAR_MONTHLY:
|
2012-05-03 15:41:58 -07:00
|
|
|
if (((mtime->tm_year < year) ||
|
|
|
|
((mtime->tm_year == year) && (mtime->tm_mon <= month))) &&
|
|
|
|
(mtime->tm_mday <= maxdays))
|
|
|
|
_cit_mark(obj, mday_it, mark->mark_type);
|
|
|
|
break;
|
|
|
|
|
2011-04-01 04:35:07 -07:00
|
|
|
case ELM_CALENDAR_ANNUALLY:
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((mtime->tm_year <= year) && (mtime->tm_mon == month) &&
|
|
|
|
(mtime->tm_mday <= maxdays))
|
|
|
|
_cit_mark(obj, mday_it, mark->mark_type);
|
|
|
|
break;
|
2012-06-14 10:10:31 -07:00
|
|
|
|
|
|
|
case ELM_CALENDAR_LAST_DAY_OF_MONTH:
|
|
|
|
if (((mtime->tm_year < year) ||
|
|
|
|
((mtime->tm_year == year) && (mtime->tm_mon <= month))))
|
|
|
|
_cit_mark(obj, maxdays + sd->first_day_it - 1, mark->mark_type);
|
|
|
|
break;
|
2011-04-01 04:35:07 -07:00
|
|
|
}
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_FALSE;
|
2012-07-30 00:14:33 -07:00
|
|
|
|
|
|
|
elm_layout_thaw(obj);
|
2014-02-19 02:25:32 -08:00
|
|
|
elm_layout_sizing_eval(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_set_headers(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
static char part[] = "ch_0.text";
|
|
|
|
int i;
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-07-30 00:14:33 -07:00
|
|
|
elm_layout_freeze(obj);
|
|
|
|
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_TRUE;
|
2012-03-29 15:59:11 -07:00
|
|
|
for (i = 0; i < ELM_DAY_LAST; i++)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2011-04-01 04:35:07 -07:00
|
|
|
part[3] = i + '0';
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_layout_text_set
|
|
|
|
(obj, part, sd->weekdays[(i + sd->first_week_day) % ELM_DAY_LAST]);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
2014-02-19 02:25:32 -08:00
|
|
|
sd->filling = EINA_FALSE;
|
2012-07-30 00:14:33 -07:00
|
|
|
|
|
|
|
elm_layout_thaw(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_elm_widget_theme_apply(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2014-04-03 06:49:09 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
|
2014-03-20 00:44:34 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
evas_object_smart_changed(obj);
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_TRUE;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set correct tm_wday and tm_yday after other fields changes*/
|
|
|
|
static inline void
|
2014-03-20 00:44:34 -07:00
|
|
|
_fix_selected_time(Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if (sd->selected_time.tm_mon != sd->shown_time.tm_mon)
|
|
|
|
sd->selected_time.tm_mon = sd->shown_time.tm_mon;
|
|
|
|
if (sd->selected_time.tm_year != sd->shown_time.tm_year)
|
|
|
|
sd->selected_time.tm_year = sd->shown_time.tm_year;
|
|
|
|
mktime(&sd->selected_time);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-01-03 12:50:10 -08:00
|
|
|
_update_data(Evas_Object *obj, Eina_Bool month,
|
2012-05-03 15:41:58 -07:00
|
|
|
int delta)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
struct tm time_check;
|
2013-01-07 05:50:19 -08:00
|
|
|
int maxdays, years;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
/* check if it's a valid time. for 32 bits, year greater than 2037 is not */
|
2012-05-03 15:41:58 -07:00
|
|
|
time_check = sd->shown_time;
|
2013-01-03 12:50:10 -08:00
|
|
|
if (month)
|
|
|
|
time_check.tm_mon += delta;
|
|
|
|
else
|
|
|
|
time_check.tm_year += delta;
|
2010-08-23 11:45:36 -07:00
|
|
|
if (mktime(&time_check) == -1)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
if (month)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2013-10-13 22:40:35 -07:00
|
|
|
sd->shown_time.tm_mon += delta;
|
|
|
|
if (sd->shown_time.tm_mon < 0)
|
|
|
|
{
|
|
|
|
if (sd->shown_time.tm_year == sd->year_min)
|
|
|
|
{
|
|
|
|
sd->shown_time.tm_mon++;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
sd->shown_time.tm_mon = 11;
|
|
|
|
sd->shown_time.tm_year--;
|
|
|
|
}
|
|
|
|
else if (sd->shown_time.tm_mon > 11)
|
|
|
|
{
|
|
|
|
if (sd->shown_time.tm_year == sd->year_max)
|
|
|
|
{
|
|
|
|
sd->shown_time.tm_mon--;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
sd->shown_time.tm_mon = 0;
|
|
|
|
sd->shown_time.tm_year++;
|
|
|
|
}
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
2013-01-03 12:50:10 -08:00
|
|
|
else
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2013-10-13 22:40:35 -07:00
|
|
|
years = sd->shown_time.tm_year + delta;
|
|
|
|
if (((years > sd->year_max) && (sd->year_max != -1)) ||
|
|
|
|
years < sd->year_min)
|
|
|
|
return EINA_FALSE;
|
2013-01-07 05:50:19 -08:00
|
|
|
|
2013-10-13 22:40:35 -07:00
|
|
|
sd->shown_time.tm_year = years;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
&& (sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
maxdays = _maxdays_get(&sd->shown_time);
|
|
|
|
if (sd->selected_time.tm_mday > maxdays)
|
|
|
|
sd->selected_time.tm_mday = maxdays;
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
_fix_selected_time(sd);
|
2012-04-24 16:07:36 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
|
|
|
|
}
|
2012-10-03 03:02:27 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DISPLAY_CHANGED, NULL);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-01-03 12:50:10 -08:00
|
|
|
_spin_month_value(void *data)
|
|
|
|
{
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (_update_data(data, EINA_TRUE, sd->spin_speed))
|
|
|
|
evas_object_smart_changed(data);
|
|
|
|
|
|
|
|
sd->interval = sd->interval / 1.05;
|
|
|
|
ecore_timer_interval_set(sd->spin_month, sd->interval);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_spin_year_value(void *data)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
if (_update_data(data, EINA_FALSE, sd->spin_speed))
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(data);
|
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->interval = sd->interval / 1.05;
|
2013-01-03 12:50:10 -08:00
|
|
|
ecore_timer_interval_set(sd->spin_year, sd->interval);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-08-23 11:45:36 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_month_inc_start(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2013-01-03 12:50:10 -08:00
|
|
|
{
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->interval = sd->first_interval;
|
|
|
|
sd->spin_speed = 1;
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->spin_month);
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->spin_month = ecore_timer_add(sd->interval, _spin_month_value, data);
|
|
|
|
|
|
|
|
_spin_month_value(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_month_dec_start(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->interval = sd->first_interval;
|
|
|
|
sd->spin_speed = -1;
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->spin_month);
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->spin_month = ecore_timer_add(sd->interval, _spin_month_value, data);
|
|
|
|
|
|
|
|
_spin_month_value(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_month_stop(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2013-01-03 12:50:10 -08:00
|
|
|
{
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->interval = sd->first_interval;
|
2013-05-29 04:41:37 -07:00
|
|
|
ELM_SAFE_FREE(sd->spin_month, ecore_timer_del);
|
2013-01-03 12:50:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_year_inc_start(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2013-01-03 12:50:10 -08:00
|
|
|
{
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->interval = sd->first_interval;
|
|
|
|
sd->spin_speed = 1;
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->spin_year);
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->spin_year = ecore_timer_add(sd->interval, _spin_year_value, data);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
_spin_year_value(data);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_year_dec_start(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->interval = sd->first_interval;
|
|
|
|
sd->spin_speed = -1;
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->spin_year);
|
2013-01-03 12:50:10 -08:00
|
|
|
sd->spin_year = ecore_timer_add(sd->interval, _spin_year_value, data);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
_spin_year_value(data);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_year_stop(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->interval = sd->first_interval;
|
2013-05-29 04:41:37 -07:00
|
|
|
ELM_SAFE_FREE(sd->spin_year, ecore_timer_del);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-05-03 15:41:58 -07:00
|
|
|
_get_item_day(Evas_Object *obj,
|
|
|
|
int selected_it)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
int day;
|
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
day = selected_it - sd->first_day_it + 1;
|
|
|
|
if ((day < 0) || (day > _maxdays_get(&sd->shown_time)))
|
2010-08-23 11:45:36 -07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return day;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:58 -07:00
|
|
|
_update_sel_it(Evas_Object *obj,
|
|
|
|
int sel_it)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2010-11-22 07:57:26 -08:00
|
|
|
int day;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->select_mode == ELM_CALENDAR_SELECT_MODE_NONE)
|
2011-04-01 04:35:07 -07:00
|
|
|
return;
|
2010-11-22 07:57:26 -08:00
|
|
|
|
|
|
|
day = _get_item_day(obj, sel_it);
|
2010-08-23 11:45:36 -07:00
|
|
|
if (!day)
|
|
|
|
return;
|
2010-11-22 07:57:26 -08:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
_unselect(obj, sd->selected_it);
|
|
|
|
if (!sd->selected)
|
|
|
|
sd->selected = EINA_TRUE;
|
2010-11-22 07:57:26 -08:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->selected_time.tm_mday = day;
|
|
|
|
_fix_selected_time(sd);
|
|
|
|
_select(obj, sel_it);
|
2011-04-15 10:01:39 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
|
2010-11-22 07:57:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:58 -07:00
|
|
|
_day_selected(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
2012-05-03 15:41:58 -07:00
|
|
|
const char *source)
|
2010-11-22 07:57:26 -08:00
|
|
|
{
|
|
|
|
int sel_it;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (sd->select_mode == ELM_CALENDAR_SELECT_MODE_NONE)
|
2011-04-01 04:35:07 -07:00
|
|
|
return;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2010-11-22 07:57:26 -08:00
|
|
|
sel_it = atoi(source);
|
|
|
|
|
|
|
|
_update_sel_it(data, sel_it);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
_time_to_next_day(struct tm *t)
|
|
|
|
{
|
2011-04-01 04:35:07 -07:00
|
|
|
return ((((24 - t->tm_hour) * 60) - t->tm_min) * 60) - t->tm_sec;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_update_cur_date(void *data)
|
|
|
|
{
|
|
|
|
time_t current_time;
|
|
|
|
int t, day;
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if (sd->today_it > 0) _not_today(sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
current_time = time(NULL);
|
2012-05-03 15:41:58 -07:00
|
|
|
localtime_r(¤t_time, &sd->current_time);
|
|
|
|
t = _time_to_next_day(&sd->current_time);
|
|
|
|
ecore_timer_interval_set(sd->update_timer, t);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->current_time.tm_mon != sd->shown_time.tm_mon) ||
|
|
|
|
(sd->current_time.tm_year != sd->shown_time.tm_year))
|
2010-08-23 11:45:36 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
day = sd->current_time.tm_mday + sd->first_day_it - 1;
|
|
|
|
_today(sd, day);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2014-03-31 19:10:25 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_move(Evas_Object *obj, const char *params)
|
2010-11-22 07:57:26 -08:00
|
|
|
{
|
2014-03-31 19:10:25 -07:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2014-04-01 06:20:58 -07:00
|
|
|
const char *dir = params;
|
2010-11-22 07:57:26 -08:00
|
|
|
|
2014-03-31 19:10:25 -07:00
|
|
|
if (!strcmp(dir, "prior"))
|
2010-11-22 07:57:26 -08:00
|
|
|
{
|
2013-01-03 12:50:10 -08:00
|
|
|
if (_update_data(obj, EINA_TRUE, -1)) _populate(obj);
|
2010-11-22 07:57:26 -08:00
|
|
|
}
|
2014-03-31 19:10:25 -07:00
|
|
|
else if (!strcmp(dir, "next"))
|
2010-11-22 07:57:26 -08:00
|
|
|
{
|
2013-01-03 12:50:10 -08:00
|
|
|
if (_update_data(obj, EINA_TRUE, 1)) _populate(obj);
|
2010-11-22 07:57:26 -08:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
else if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_NONE)
|
|
|
|
&& ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
|| (sd->selected)))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2014-03-31 19:10:25 -07:00
|
|
|
if (!strcmp(dir, "left"))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
|| ((sd->shown_time.tm_year == sd->selected_time.tm_year)
|
|
|
|
&& (sd->shown_time.tm_mon == sd->selected_time.tm_mon)))
|
|
|
|
_update_sel_it(obj, sd->selected_it - 1);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2014-03-31 19:10:25 -07:00
|
|
|
else if (!strcmp(dir, "right"))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
|| ((sd->shown_time.tm_year == sd->selected_time.tm_year)
|
|
|
|
&& (sd->shown_time.tm_mon == sd->selected_time.tm_mon)))
|
|
|
|
_update_sel_it(obj, sd->selected_it + 1);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2014-03-31 19:10:25 -07:00
|
|
|
else if (!strcmp(dir, "up"))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
|| ((sd->shown_time.tm_year == sd->selected_time.tm_year)
|
|
|
|
&& (sd->shown_time.tm_mon == sd->selected_time.tm_mon)))
|
|
|
|
_update_sel_it(obj, sd->selected_it - ELM_DAY_LAST);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2014-03-31 19:10:25 -07:00
|
|
|
else if (!strcmp(dir, "down"))
|
2012-04-24 16:07:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
|| ((sd->shown_time.tm_year == sd->selected_time.tm_year)
|
|
|
|
&& (sd->shown_time.tm_mon == sd->selected_time.tm_mon)))
|
|
|
|
_update_sel_it(obj, sd->selected_it + ELM_DAY_LAST);
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2014-03-20 00:44:34 -07:00
|
|
|
else return EINA_FALSE;
|
2012-04-24 16:07:36 -07:00
|
|
|
}
|
2014-03-20 00:44:34 -07:00
|
|
|
else return EINA_FALSE;
|
2010-11-22 07:57:26 -08:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_TRUE;
|
2010-11-22 07:57:26 -08:00
|
|
|
}
|
|
|
|
|
2014-03-31 19:10:25 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-01 06:20:58 -07:00
|
|
|
_elm_calendar_elm_widget_event(Eo *obj, Elm_Calendar_Data *sd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
2014-03-31 19:10:25 -07:00
|
|
|
{
|
|
|
|
(void) src;
|
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
|
|
|
|
|
|
|
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!_elm_config_key_binding_call(obj, ev, key_actions))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_calendar_evas_object_smart_calculate(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2012-07-30 02:02:23 -07:00
|
|
|
{
|
|
|
|
elm_layout_freeze(obj);
|
|
|
|
|
|
|
|
_set_headers(obj);
|
|
|
|
_populate(obj);
|
|
|
|
|
2013-09-30 03:21:31 -07:00
|
|
|
elm_layout_thaw(obj);
|
2012-07-30 02:02:23 -07:00
|
|
|
}
|
|
|
|
|
2013-01-22 08:37:45 -08:00
|
|
|
static void
|
|
|
|
_style_changed(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2013-01-22 08:37:45 -08:00
|
|
|
{
|
|
|
|
ELM_CALENDAR_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!strcmp("double_spinners", elm_object_style_get(sd->obj)))
|
|
|
|
sd->double_spinners = EINA_TRUE;
|
|
|
|
else
|
|
|
|
sd->double_spinners = EINA_FALSE;
|
|
|
|
|
|
|
|
_set_month_year(sd);
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_calendar_evas_object_smart_add(Eo *obj, Elm_Calendar_Data *priv)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-02 18:19:05 -07:00
|
|
|
time_t weekday = 259200; /* Just the first sunday since epoch */
|
2012-05-03 15:41:58 -07:00
|
|
|
time_t current_time;
|
2010-08-23 11:45:36 -07:00
|
|
|
int i, t;
|
|
|
|
|
2013-10-05 01:13:43 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2013-03-18 09:07:38 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
|
2013-09-24 21:33:39 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2013-08-26 08:29:45 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
priv->first_interval = 0.85;
|
|
|
|
priv->year_min = 2;
|
|
|
|
priv->year_max = -1;
|
|
|
|
priv->today_it = -1;
|
|
|
|
priv->selected_it = -1;
|
|
|
|
priv->first_day_it = -1;
|
|
|
|
priv->format_func = _format_month_year;
|
2012-09-11 14:33:54 -07:00
|
|
|
priv->selectable = (~(ELM_CALENDAR_SELECTABLE_NONE));
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,increment,start", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_month_inc_start, obj);
|
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,decrement,start", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_month_dec_start, obj);
|
2012-05-03 15:41:58 -07:00
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,increment,startyear", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_year_inc_start, obj);
|
2012-05-03 15:41:58 -07:00
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,decrement,startyear", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_year_dec_start, obj);
|
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,stop", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_month_stop, obj);
|
|
|
|
edje_object_signal_callback_add
|
2013-01-22 08:37:45 -08:00
|
|
|
(wd->resize_obj, "elm,action,stopyear", "*",
|
2013-01-03 12:50:10 -08:00
|
|
|
_button_year_stop, obj);
|
2012-05-03 15:41:58 -07:00
|
|
|
edje_object_signal_callback_add
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, "elm,action,selected", "*",
|
2012-05-03 15:41:58 -07:00
|
|
|
_day_selected, obj);
|
2013-01-22 08:37:45 -08:00
|
|
|
edje_object_signal_callback_add
|
2013-10-13 22:40:35 -07:00
|
|
|
(wd->resize_obj, "load", "*",
|
|
|
|
_style_changed, obj);
|
2011-04-15 10:01:39 -07:00
|
|
|
|
2012-03-29 15:59:11 -07:00
|
|
|
for (i = 0; i < ELM_DAY_LAST; i++)
|
2011-02-15 05:37:28 -08:00
|
|
|
{
|
|
|
|
/* FIXME: I'm not aware of a known max, so if it fails,
|
|
|
|
* just make it larger. :| */
|
|
|
|
char buf[20];
|
|
|
|
/* I don't know of a better way of doing it */
|
|
|
|
if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
|
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
priv->weekdays[i] = eina_stringshare_add(buf);
|
2011-02-15 05:37:28 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If we failed getting day, get a default value */
|
2012-05-03 15:41:58 -07:00
|
|
|
priv->weekdays[i] = _days_abbrev[i];
|
2011-02-15 05:37:28 -08:00
|
|
|
WRN("Failed getting weekday name for '%s' from locale.",
|
2011-04-01 04:35:07 -07:00
|
|
|
_days_abbrev[i]);
|
2011-02-15 05:37:28 -08:00
|
|
|
}
|
|
|
|
weekday += 86400; /* Advance by a day */
|
|
|
|
}
|
2010-08-23 11:45:36 -07:00
|
|
|
|
|
|
|
current_time = time(NULL);
|
2012-05-03 15:41:58 -07:00
|
|
|
localtime_r(¤t_time, &priv->shown_time);
|
|
|
|
priv->current_time = priv->shown_time;
|
|
|
|
priv->selected_time = priv->shown_time;
|
|
|
|
t = _time_to_next_day(&priv->current_time);
|
|
|
|
priv->update_timer = ecore_timer_add(t, _update_cur_date, obj);
|
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2012-07-17 11:44:16 -07:00
|
|
|
|
2013-03-01 18:04:31 -08:00
|
|
|
if (!elm_layout_theme_set(obj, "calendar", "base",
|
|
|
|
elm_object_style_get(obj)))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2013-01-22 08:37:45 -08:00
|
|
|
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2012-09-12 01:25:10 -07:00
|
|
|
|
|
|
|
// ACCESS
|
|
|
|
if ((_elm_config->access_mode != ELM_ACCESS_MODE_OFF))
|
|
|
|
_access_calendar_spinner_register(obj);
|
2012-05-03 15:41:58 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_calendar_evas_object_smart_del(Eo *obj, Elm_Calendar_Data *sd)
|
2012-05-03 15:41:58 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->spin_month);
|
|
|
|
ecore_timer_del(sd->spin_year);
|
|
|
|
ecore_timer_del(sd->update_timer);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
if (sd->marks)
|
|
|
|
{
|
2013-03-08 20:23:42 -08:00
|
|
|
EINA_LIST_FREE(sd->marks, mark)
|
2012-05-03 15:41:58 -07:00
|
|
|
{
|
|
|
|
_mark_free(mark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ELM_DAY_LAST; i++)
|
|
|
|
eina_stringshare_del(sd->weekdays[i]);
|
|
|
|
|
2013-03-18 09:07:38 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
2012-05-03 15:41:58 -07:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static Eina_Bool _elm_calendar_smart_focus_next_enable = EINA_FALSE;
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2012-09-12 01:25:10 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return _elm_calendar_smart_focus_next_enable;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_elm_widget_focus_next(Eo *obj, Elm_Calendar_Data *sd, Elm_Focus_Direction dir, Evas_Object **next)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-09-12 01:25:10 -07:00
|
|
|
int maxdays, day, i;
|
|
|
|
Eina_List *items = NULL;
|
|
|
|
Evas_Object *ao;
|
|
|
|
Evas_Object *po;
|
|
|
|
|
|
|
|
items = eina_list_append(items, sd->month_access);
|
2013-01-03 12:50:10 -08:00
|
|
|
items = eina_list_append(items, sd->dec_btn_month_access);
|
|
|
|
items = eina_list_append(items, sd->inc_btn_month_access);
|
|
|
|
|
|
|
|
items = eina_list_append(items, sd->year_access);
|
|
|
|
items = eina_list_append(items, sd->dec_btn_year_access);
|
|
|
|
items = eina_list_append(items, sd->inc_btn_year_access);
|
2012-09-12 01:25:10 -07:00
|
|
|
|
|
|
|
day = 0;
|
|
|
|
maxdays = _maxdays_get(&sd->shown_time);
|
|
|
|
for (i = 0; i < 42; i++)
|
|
|
|
{
|
|
|
|
if ((!day) && (i == sd->first_day_it)) day = 1;
|
|
|
|
if ((day) && (day <= maxdays))
|
|
|
|
{
|
|
|
|
char pname[14];
|
|
|
|
snprintf(pname, sizeof(pname), "cit_%i.access", i);
|
|
|
|
|
|
|
|
po = (Evas_Object *)edje_object_part_object_get
|
|
|
|
(elm_layout_edje_get(obj), pname);
|
|
|
|
ao = evas_object_data_get(po, "_part_access_obj");
|
|
|
|
items = eina_list_append(items, ao);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
return elm_widget_focus_list_next_get
|
2012-09-12 01:25:10 -07:00
|
|
|
(obj, items, eina_list_data_get, dir, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_access_obj_process(Evas_Object *obj, Eina_Bool is_access)
|
|
|
|
{
|
|
|
|
int maxdays, day, i;
|
|
|
|
|
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (is_access)
|
|
|
|
_access_calendar_register(obj);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
day = 0;
|
|
|
|
maxdays = _maxdays_get(&sd->shown_time);
|
|
|
|
for (i = 0; i < 42; i++)
|
|
|
|
{
|
|
|
|
if ((!day) && (i == sd->first_day_it)) day = 1;
|
|
|
|
if ((day) && (day <= maxdays))
|
|
|
|
{
|
|
|
|
char pname[14];
|
|
|
|
snprintf(pname, sizeof(pname), "cit_%i.access", i);
|
|
|
|
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
|
|
|
(obj, elm_layout_edje_get(obj), pname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 12:50:10 -08:00
|
|
|
if (sd->dec_btn_month_access)
|
2012-09-12 01:25:10 -07:00
|
|
|
_elm_access_edje_object_part_object_unregister
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "left_bt");
|
2013-01-03 12:50:10 -08:00
|
|
|
if (sd->inc_btn_month_access)
|
2012-09-12 01:25:10 -07:00
|
|
|
_elm_access_edje_object_part_object_unregister
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "right_bt");
|
2012-09-12 01:25:10 -07:00
|
|
|
if (sd->month_access)
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "month_text");
|
2013-01-03 12:50:10 -08:00
|
|
|
|
|
|
|
if (sd->dec_btn_year_access)
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
|
|
|
(obj, elm_layout_edje_get(obj), "left_bt_year");
|
|
|
|
if (sd->inc_btn_year_access)
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
|
|
|
(obj, elm_layout_edje_get(obj), "right_bt_year");
|
|
|
|
if (sd->year_access)
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
2013-01-22 08:37:45 -08:00
|
|
|
(obj, elm_layout_edje_get(obj), "year_text");
|
2012-09-12 01:25:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
2014-03-22 10:05:16 -07:00
|
|
|
_elm_calendar_elm_widget_access(Eo *obj EINA_UNUSED, Elm_Calendar_Data *_pd EINA_UNUSED, Eina_Bool acs)
|
2012-07-31 15:06:52 -07:00
|
|
|
{
|
2014-03-22 10:05:16 -07:00
|
|
|
_elm_calendar_smart_focus_next_enable = acs;
|
2012-11-25 22:32:53 -08:00
|
|
|
_access_obj_process(obj, _elm_calendar_smart_focus_next_enable);
|
2012-05-03 15:41:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_calendar_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2012-11-25 22:32:53 -08:00
|
|
|
Evas_Object *obj = eo_add(MY_CLASS, parent);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2014-03-20 00:44:34 -07:00
|
|
|
_elm_calendar_eo_base_constructor(Eo *obj, Elm_Calendar_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2015-05-19 05:34:07 -07:00
|
|
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
2012-11-25 22:32:53 -08:00
|
|
|
sd->obj = obj;
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
eo_do(obj,
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_obj_type_set(MY_CLASS_NAME_LEGACY),
|
2014-06-10 19:07:15 -07:00
|
|
|
evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
|
|
|
|
elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_CALENDAR));
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_weekdays_names_set(Eo *obj, Elm_Calendar_Data *sd, const char **weekdays)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2010-08-23 11:45:36 -07:00
|
|
|
int i;
|
|
|
|
|
2010-12-03 06:08:33 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(weekdays);
|
|
|
|
|
2012-03-29 15:59:11 -07:00
|
|
|
for (i = 0; i < ELM_DAY_LAST; i++)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
eina_stringshare_replace(&sd->weekdays[i], weekdays[i]);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static const char**
|
|
|
|
_elm_calendar_weekdays_names_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->weekdays;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_interval_set(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, double interval)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->first_interval = interval;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static double
|
|
|
|
_elm_calendar_interval_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->first_interval;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_min_max_year_set(Eo *obj, Elm_Calendar_Data *sd, int min, int max)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2010-08-23 11:45:36 -07:00
|
|
|
min -= 1900;
|
|
|
|
max -= 1900;
|
2012-05-03 15:41:58 -07:00
|
|
|
if ((sd->year_min == min) && (sd->year_max == max)) return;
|
|
|
|
sd->year_min = min > 2 ? min : 2;
|
|
|
|
if (max > sd->year_min)
|
|
|
|
sd->year_max = max;
|
2011-10-10 01:33:04 -07:00
|
|
|
else
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->year_max = sd->year_min;
|
|
|
|
if (sd->shown_time.tm_year > sd->year_max)
|
|
|
|
sd->shown_time.tm_year = sd->year_max;
|
|
|
|
if (sd->shown_time.tm_year < sd->year_min)
|
|
|
|
sd->shown_time.tm_year = sd->year_min;
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_min_max_year_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, int *min, int *max)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
if (min) *min = sd->year_min + 1900;
|
|
|
|
if (max) *max = sd->year_max + 1900;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2012-04-19 01:46:22 -07:00
|
|
|
EINA_DEPRECATED EAPI void
|
2012-05-03 15:41:58 -07:00
|
|
|
elm_calendar_day_selection_disabled_set(Evas_Object *obj,
|
|
|
|
Eina_Bool disabled)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_CHECK(obj);
|
|
|
|
|
2012-04-19 01:46:22 -07:00
|
|
|
if (disabled)
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_MODE_NONE);
|
2010-08-23 11:45:36 -07:00
|
|
|
else
|
2012-04-19 02:03:59 -07:00
|
|
|
elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_MODE_DEFAULT);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2012-04-19 01:46:22 -07:00
|
|
|
EINA_DEPRECATED EAPI Eina_Bool
|
2012-02-28 23:54:57 -08:00
|
|
|
elm_calendar_day_selection_disabled_get(const Evas_Object *obj)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_CHECK(obj) EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
ELM_CALENDAR_DATA_GET(obj, sd);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
return !!(sd->select_mode == ELM_CALENDAR_SELECT_MODE_NONE);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_selected_time_set(Eo *obj, Elm_Calendar_Data *sd, struct tm *selected_time)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2012-05-02 18:19:05 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(selected_time);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2012-09-11 14:33:54 -07:00
|
|
|
if (sd->selectable & ELM_CALENDAR_SELECTABLE_YEAR)
|
|
|
|
sd->selected_time.tm_year = selected_time->tm_year;
|
|
|
|
if (sd->selectable & ELM_CALENDAR_SELECTABLE_MONTH)
|
|
|
|
sd->selected_time.tm_mon = selected_time->tm_mon;
|
|
|
|
if (sd->selectable & ELM_CALENDAR_SELECTABLE_DAY)
|
|
|
|
{
|
|
|
|
sd->selected_time.tm_mday = selected_time->tm_mday;
|
|
|
|
if (!sd->selected)
|
|
|
|
sd->selected = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (sd->select_mode != ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
{
|
|
|
|
if (!sd->selected)
|
|
|
|
sd->selected = EINA_TRUE;
|
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
if (sd->selected_time.tm_year != sd->shown_time.tm_year)
|
|
|
|
sd->shown_time.tm_year = sd->selected_time.tm_year;
|
|
|
|
if (sd->selected_time.tm_mon != sd->shown_time.tm_mon)
|
|
|
|
sd->shown_time.tm_mon = sd->selected_time.tm_mon;
|
|
|
|
|
|
|
|
_fix_selected_time(sd);
|
|
|
|
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_selected_time_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, struct tm *selected_time)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(selected_time, EINA_FALSE);
|
2012-05-03 15:41:58 -07:00
|
|
|
|
|
|
|
if ((sd->select_mode == ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
&& (!sd->selected))
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_FALSE;
|
2012-05-03 15:41:58 -07:00
|
|
|
*selected_time = sd->selected_time;
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_format_function_set(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, Elm_Calendar_Format_Cb format_function)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->format_func = format_function;
|
2013-10-13 22:40:35 -07:00
|
|
|
if (sd->double_spinners) /* theme has spinner for year */
|
2013-01-22 08:37:45 -08:00
|
|
|
_set_month_year(sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Elm_Calendar_Mark*
|
|
|
|
_elm_calendar_mark_add(Eo *obj, Elm_Calendar_Data *sd, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat_Type repeat)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2010-08-23 11:45:36 -07:00
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
|
|
|
|
mark = _mark_new(obj, mark_type, mark_time, repeat);
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->marks = eina_list_append(sd->marks, mark);
|
|
|
|
mark->node = eina_list_last(sd->marks);
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
return mark;
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_calendar_mark_del(Elm_Calendar_Mark *mark)
|
|
|
|
{
|
2010-12-03 06:08:33 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(mark);
|
2012-05-03 15:41:58 -07:00
|
|
|
ELM_CALENDAR_CHECK(mark->obj);
|
|
|
|
ELM_CALENDAR_DATA_GET(mark->obj, sd);
|
2010-08-23 11:45:36 -07:00
|
|
|
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->marks = eina_list_remove_list(sd->marks, mark->node);
|
2010-08-23 11:45:36 -07:00
|
|
|
_mark_free(mark);
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_marks_clear(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
|
|
|
Elm_Calendar_Mark *mark;
|
|
|
|
|
2013-03-08 20:23:42 -08:00
|
|
|
EINA_LIST_FREE(sd->marks, mark)
|
2012-05-03 15:41:58 -07:00
|
|
|
_mark_free(mark);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static const Eina_List*
|
|
|
|
_elm_calendar_marks_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2010-08-23 11:45:36 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->marks;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_marks_draw(Eo *obj, Elm_Calendar_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2010-08-23 11:45:36 -07:00
|
|
|
}
|
2012-03-29 15:14:30 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_first_day_of_week_set(Eo *obj, Elm_Calendar_Data *sd, Elm_Calendar_Weekday day)
|
2012-03-29 15:14:30 -07:00
|
|
|
{
|
2012-03-29 15:59:11 -07:00
|
|
|
if (day >= ELM_DAY_LAST) return;
|
2012-05-03 15:41:58 -07:00
|
|
|
if (sd->first_week_day != day)
|
2012-03-29 15:14:30 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->first_week_day = day;
|
2012-07-30 02:02:23 -07:00
|
|
|
evas_object_smart_changed(obj);
|
2012-03-29 15:14:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Elm_Calendar_Weekday
|
|
|
|
_elm_calendar_first_day_of_week_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2012-03-29 15:14:30 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->first_week_day;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_select_mode_set(Eo *obj, Elm_Calendar_Data *sd, Elm_Calendar_Select_Mode mode)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
|
2012-04-19 15:47:53 -07:00
|
|
|
if ((mode <= ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
2012-05-03 15:41:58 -07:00
|
|
|
&& (sd->select_mode != mode))
|
2012-04-19 01:46:22 -07:00
|
|
|
{
|
2012-05-03 15:41:58 -07:00
|
|
|
sd->select_mode = mode;
|
|
|
|
if (sd->select_mode == ELM_CALENDAR_SELECT_MODE_ONDEMAND)
|
|
|
|
sd->selected = EINA_FALSE;
|
|
|
|
if ((sd->select_mode == ELM_CALENDAR_SELECT_MODE_ALWAYS)
|
|
|
|
|| (sd->select_mode == ELM_CALENDAR_SELECT_MODE_DEFAULT))
|
|
|
|
_select(obj, sd->selected_it);
|
2012-04-19 01:46:22 -07:00
|
|
|
else
|
2012-05-03 15:41:58 -07:00
|
|
|
_unselect(obj, sd->selected_it);
|
2012-04-19 01:46:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Elm_Calendar_Select_Mode
|
|
|
|
_elm_calendar_select_mode_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2012-04-19 01:46:22 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->select_mode;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_calendar_selectable_set(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, Elm_Calendar_Selectable selectable)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-09-11 14:33:54 -07:00
|
|
|
sd->selectable = selectable;
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Elm_Calendar_Selectable
|
|
|
|
_elm_calendar_selectable_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd)
|
2012-09-11 14:33:54 -07:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
return sd->selectable;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-10-03 03:02:27 -07:00
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_calendar_displayed_time_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd, struct tm *displayed_time)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-20 00:44:34 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(displayed_time, EINA_FALSE);
|
2012-10-03 03:02:27 -07:00
|
|
|
*displayed_time = sd->shown_time;
|
2014-03-20 00:44:34 -07:00
|
|
|
return EINA_TRUE;
|
2012-10-03 03:02:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static void
|
2014-03-20 00:44:34 -07:00
|
|
|
_elm_calendar_class_constructor(Eo_Class *klass)
|
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2013-02-09 23:52:31 -08:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
|
|
|
|
_elm_calendar_smart_focus_next_enable = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-07-25 01:33:19 -07:00
|
|
|
EOLIAN static const Elm_Atspi_Action*
|
|
|
|
_elm_calendar_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Calendar_Data *sd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
static Elm_Atspi_Action atspi_actions[] = {
|
|
|
|
{ "move,prior", "move", "prior", _key_action_move},
|
|
|
|
{ "move,next", "move", "next", _key_action_move},
|
|
|
|
{ "move,left", "move", "left", _key_action_move},
|
|
|
|
{ "move,right", "move", "right", _key_action_move},
|
|
|
|
{ "move,up", "move", "up", _key_action_move},
|
|
|
|
{ "move,down", "move", "down", _key_action_move},
|
|
|
|
{ NULL, NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
|
|
|
}
|
|
|
|
|
2014-03-20 00:44:34 -07:00
|
|
|
#include "elm_calendar.eo.c"
|