static void _sizing_eval(Evas_Object *obj);
static void _on_focus_hook(void *data, Evas_Object *obj);
+static void _signal_rect_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _signal_ampm_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _signal_ampm_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info);
static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
static int _imf_event_commit_cb(void *data, int type, void *event);
+static void _datefield_show_cb(void *data, Evas_Object * obj, void *event_info);
static void _date_entry_add(Evas_Object *obj);
static void _time_entry_add(Evas_Object *obj);
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return ;
-
+
ecore_event_handler_del(wd->handler);
+
free(wd);
}
int i;
if (!wd || !wd->base) return;
- _elm_theme_object_set(obj, wd->base, "datefield", "base", elm_widget_style_get(obj));
-
- for (i = 0; i < DATE_MAX; i++)
- _elm_theme_object_set(obj, wd->date[i], "entry", "base", "datefield");
+ if (wd->layout == ELM_DATEFIELD_LAYOUT_DATEANDTIME)
+ {
+ _elm_theme_object_set(obj, wd->base, "datefield", "base", elm_widget_style_get(obj));
- for (i = 0; i < TIME_MAX; i++)
- _elm_theme_object_set(obj, wd->time[i], "entry", "base", "datefield");
+ for (i = 0; i < DATE_MAX; i++)
+ elm_object_style_set(wd->date[i], "datefield/hybrid");
+ for (i = 0; i < TIME_MAX; i++)
+ elm_object_style_set(wd->time[i], "datefield/hybrid");
+ }
+ else if (wd->layout == ELM_DATEFIELD_LAYOUT_DATE)
+ {
+ _elm_theme_object_set(obj, wd->base, "datefield", "date", elm_widget_style_get(obj));
- edje_object_part_swallow(wd->base, "elm.swallow.date.year", wd->date[DATE_YEAR]);
- edje_object_part_swallow(wd->base, "elm.swallow.date.month", wd->date[DATE_MON]);
- edje_object_part_swallow(wd->base, "elm.swallow.date.day", wd->date[DATE_DAY]);
- edje_object_part_text_set(wd->base, "elm.text.date.comma", ",");
+ for (i = 0; i < DATE_MAX; i++)
+ elm_object_style_set(wd->date[i], "datefield");
+ }
+ else if (wd->layout == ELM_DATEFIELD_LAYOUT_TIME)
+ {
+ _elm_theme_object_set(obj, wd->base, "datefield", "time", elm_widget_style_get(obj));
- edje_object_part_swallow(wd->base, "elm.swallow.time.hour", wd->time[TIME_HOUR]);
- edje_object_part_swallow(wd->base, "elm.swallow.time.min", wd->time[TIME_MIN]);
- edje_object_part_text_set(wd->base, "elm.text.colon", ":");
+ for (i = 0; i < TIME_MAX; i++)
+ elm_object_style_set(wd->time[i], "datefield");
+ }
+ if (wd->layout == ELM_DATEFIELD_LAYOUT_DATEANDTIME || wd->layout == ELM_DATEFIELD_LAYOUT_DATE)
+ {
+ edje_object_part_swallow(wd->base, "elm.swallow.date.year", wd->date[DATE_YEAR]);
+ edje_object_part_swallow(wd->base, "elm.swallow.date.month", wd->date[DATE_MON]);
+ edje_object_part_swallow(wd->base, "elm.swallow.date.day", wd->date[DATE_DAY]);
+ edje_object_part_text_set(wd->base, "elm.text.date.comma", ",");
+
+ edje_object_signal_callback_add(wd->base, "mouse, down,1", "elm.rect.date.left.pad", _signal_rect_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.date.year.over", _signal_rect_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.date.month.over", _signal_rect_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.date.day.over", _signal_rect_mouse_down, obj);
+ }
+
+ if (wd->layout == ELM_DATEFIELD_LAYOUT_DATEANDTIME || wd->layout == ELM_DATEFIELD_LAYOUT_TIME)
+ {
+ edje_object_part_swallow(wd->base, "elm.swallow.time.hour", wd->time[TIME_HOUR]);
+ edje_object_part_swallow(wd->base, "elm.swallow.time.min", wd->time[TIME_MIN]);
+ edje_object_part_text_set(wd->base, "elm.text.colon", ":");
+
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.time.hour.over", _signal_rect_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.time.min.over", _signal_rect_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.time.ampm.over", _signal_ampm_mouse_down, obj);
+ edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "elm.rect.time.ampm.over", _signal_ampm_clicked, obj);
+ }
+
_date_update(obj);
_sizing_eval(obj);
}
}
static void
+_datefield_show_cb(void *data, Evas_Object * obj, void *event_info)
+{
+ _theme_hook(data);
+}
+
+static void
_signal_ampm_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source)
{
ELM_CHECK_WIDTYPE(data, widtype);
}
static void
+_signal_rect_mouse_down(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ ELM_CHECK_WIDTYPE(data, widtype);
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd || !wd->base) return ;
+
+ if (!strcmp(source, "elm.rect.date.year.over") || !strcmp(source, "elm.rect.date.left.pad"))
+ elm_object_focus(wd->date[DATE_YEAR]);
+ else if (!strcmp(source, "elm.rect.date.month.over"))
+ elm_object_focus(wd->date[DATE_MON]);
+ else if (!strcmp(source, "elm.rect.date.day.over"))
+ elm_object_focus(wd->date[DATE_DAY]);
+ else if (!strcmp(source, "elm.rect.time.hour.over"))
+ elm_object_focus(wd->time[TIME_HOUR]);
+ else if (!strcmp(source, "elm.rect.time.min.over"))
+ elm_object_focus(wd->time[TIME_MIN]);
+}
+
+static void
_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
{
ELM_CHECK_WIDTYPE(data, widtype);
if (!wd || !wd->base) return ;
if (focus_obj == wd->date[DATE_YEAR])
- elm_object_focus(wd->time[TIME_HOUR]);
+ {
+ if (wd->layout == ELM_DATEFIELD_LAYOUT_DATEANDTIME)
+ elm_object_focus(wd->time[TIME_HOUR]);
+ else if (wd->layout == ELM_DATEFIELD_LAYOUT_DATE)
+ elm_object_unfocus(wd->date[DATE_YEAR]);
+ }
else if (focus_obj == wd->date[DATE_MON])
elm_object_focus(wd->date[DATE_DAY]);
else if (focus_obj == wd->date[DATE_DAY])
Widget_Data *wd = elm_widget_data_get(obj);
int i;
- if (!wd || !wd->base) return ;
+ if (!wd) return ;
for (i = 0; i < DATE_MAX; i++)
{
wd->date[i] = elm_entry_add(obj);
- elm_object_style_set(wd->date[i], "datefield");
+ elm_object_style_set(wd->date[i], "datefield/hybrid");
elm_entry_context_menu_disabled_set(wd->date[i], EINA_TRUE);
elm_entry_input_panel_layout_set(wd->date[i], ELM_INPUT_PANEL_LAYOUT_NUMBER);
evas_object_size_hint_weight_set(wd->date[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_entry_maximum_bytes_set(wd->date[DATE_YEAR], YEAR_MAX_LENGTH);
elm_entry_maximum_bytes_set(wd->date[DATE_MON], MONTH_MAX_LENGTH);
elm_entry_maximum_bytes_set(wd->date[DATE_DAY], DAY_MAX_LENGTH);
-
- edje_object_part_swallow(wd->base, "elm.swallow.date.year", wd->date[DATE_YEAR]);
- edje_object_part_swallow(wd->base, "elm.swallow.date.month", wd->date[DATE_MON]);
- edje_object_part_swallow(wd->base, "elm.swallow.date.day", wd->date[DATE_DAY]);
- edje_object_part_text_set(wd->base, "elm.text.date.comma", ",");
}
static void
Widget_Data *wd = elm_widget_data_get(obj);
int i;
- if (!wd || !wd->base) return ;
+ if (!wd) return ;
for (i = 0; i < TIME_MAX; i++)
{
wd->time[i] = elm_entry_add(obj);
- elm_object_style_set(wd->time[i], "datefield");
+ elm_object_style_set(wd->time[i], "datefield/hybrid");
elm_entry_context_menu_disabled_set(wd->time[i], EINA_TRUE);
elm_entry_input_panel_layout_set(wd->time[i], ELM_INPUT_PANEL_LAYOUT_NUMBER);
elm_entry_maximum_bytes_set(wd->time[i], TIME_MAX_LENGTH);
evas_object_smart_callback_add(wd->time[i], "unfocused", _entry_unfocused_cb, obj);
elm_widget_sub_object_add(obj, wd->time[i]);
}
-
- edje_object_part_swallow(wd->base, "elm.swallow.time.hour", wd->time[TIME_HOUR]);
- edje_object_part_swallow(wd->base, "elm.swallow.time.min", wd->time[TIME_MIN]);
- edje_object_part_text_set(wd->base, "elm.text.colon", ":");
- edje_object_part_text_set(wd->base, "elm.text.ampm", "AM");
- edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "elm.rect.ampm.over", _signal_ampm_clicked, obj);
- edje_object_signal_callback_add(wd->base, "mouse,down,1", "elm.rect.ampm.over", _signal_ampm_mouse_down, obj);
}
/**
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_on_focus_hook_set( obj, _on_focus_hook, NULL );
elm_widget_can_focus_set(obj, EINA_TRUE);
-
+
wd->base = edje_object_add(e);
- _elm_theme_object_set(obj, wd->base, "datefield", "base", "default");
elm_widget_resize_object_set(obj, wd->base);
wd->handler = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _imf_event_commit_cb, obj);
_date_entry_add(obj);
_time_entry_add(obj);
-
+
+ wd->year = YEAR_MINIMUM;
+ wd->month = 1;
+ wd->day = 1;
+ wd->hour = 0;
+ wd->min = 0;
+ wd->layout = ELM_DATEFIELD_LAYOUT_DATEANDTIME;
wd->editing = EINA_FALSE;
wd->time_mode = EINA_TRUE;
- elm_datefield_date_set(obj, 1900, 1, 1, 0, 0);
+ evas_object_event_callback_add(wd->base, EVAS_CALLBACK_SHOW, _datefield_show_cb, obj);
_sizing_eval(obj);
* Add a new datefield object
*
* @param parent The parent object
- * @param layout set layout for date/time/dateandtime
+ * @param layout set layout for date/time/dateandtime (default: ELM_DATEFIELD_LAYOUT_DATEANDTIME)
*
* @ingroup Datefield
*/
if (!wd) return ;
- wd->layout = layout;
+ if (wd->layout != layout)
+ {
+ wd->layout = layout;
+ if (evas_object_visible_get(obj)) _datefield_show_cb(wd->base, obj, NULL);
+ }
}
/**
wd->hour = hour;
wd->min = min;
- _date_update(obj);
+ if (evas_object_visible_get(obj)) _date_update(obj);
}
/**