#define API_ENTRY \
Smart_Data * sd = evas_object_smart_data_get(obj); \
- if ((!obj) || (!sd) || (!_elm_widget_is(obj)))
+ if ((!sd) || (!_elm_widget_is(obj)))
#define INTERNAL_ENTRY \
Smart_Data * sd = evas_object_smart_data_get(obj); \
- if (!sd) return;
+ if (!sd) return
+
+#undef elm_widget_text_set_hook_set
+#undef elm_widget_text_get_hook_set
+#undef elm_widget_content_set_hook_set
+#undef elm_widget_content_get_hook_set
+#undef elm_widget_content_unset_hook_set
typedef struct _Smart_Data Smart_Data;
typedef struct _Edje_Signal_Data Edje_Signal_Data;
typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
+typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
struct _Smart_Data
{
void (*activate_func)(Evas_Object *obj);
void (*disable_func)(Evas_Object *obj);
void (*theme_func)(Evas_Object *obj);
+ void (*translate_func)(Evas_Object *obj);
Eina_Bool (*event_func)(Evas_Object *obj,
Evas_Object *source,
Evas_Callback_Type type,
Evas_Coord *y,
Evas_Coord *w,
Evas_Coord *h);
- void (*on_text_set_func)(Evas_Object *obj,
- const char *item,
- const char *text);
- const char *(*on_text_get_func)(const Evas_Object *obj,
- const char *item);
- void (*on_content_set_func)(Evas_Object *obj,
- const char *item,
- Evas_Object *content);
- Evas_Object *(*on_content_get_func)(const Evas_Object *obj,
- const char *item);
- Evas_Object *(*on_content_unset_func)(Evas_Object *obj,
- const char *item);
+ Elm_Widget_Text_Set_Cb text_set_func;
+ Elm_Widget_Text_Get_Cb text_get_func;
+ Elm_Widget_Content_Set_Cb content_set_func;
+ Elm_Widget_Content_Get_Cb content_get_func;
+ Elm_Widget_Content_Unset_Cb content_unset_func;
void *data;
Evas_Coord rx, ry, rw, rh;
int scroll_hold;
double scale;
Elm_Theme *theme;
const char *style;
+ const char *access_info;
unsigned int focus_order;
Eina_Bool focus_order_on_calc;
int child_drag_y_locked;
Eina_List *edje_signals;
+ Eina_List *translate_strings;
Eina_Bool drag_x_locked : 1;
Eina_Bool drag_y_locked : 1;
Eina_Bool can_focus : 1;
Eina_Bool child_can_focus : 1;
Eina_Bool focused : 1;
+ Eina_Bool top_win_focused : 1;
Eina_Bool tree_unfocusable : 1;
Eina_Bool highlight_ignore : 1;
Eina_Bool highlight_in_theme : 1;
Eina_Bool disabled : 1;
Eina_Bool is_mirrored : 1;
Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
+ Eina_Bool still_in : 1;
Eina_List *focus_chain;
Eina_List *event_cb;
const void *data;
};
+struct _Elm_Translate_String_Data
+{
+ const char *id;
+ const char *domain;
+ const char *string;
+};
+
/* local subsystem functions */
static void _smart_reconfigure(Smart_Data *sd);
static void _smart_add(Evas_Object *obj);
{
for (; obj; obj = elm_widget_parent_get(obj))
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (!sd->focused) return;
sd->focused = 0;
}
{
for (; obj; obj = elm_widget_parent_get(obj))
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (sd->focused) return;
sd->focused = 1;
}
}
static void
-_sub_obj_mouse_down(void *data __UNUSED__,
+_sub_obj_mouse_down(void *data,
+ Evas *e __UNUSED__,
+ Evas_Object *obj __UNUSED__,
+ void *event_info)
+{
+ Smart_Data *sd = data;
+ Evas_Event_Mouse_Down *ev = event_info;
+ if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
+ sd->still_in = EINA_TRUE;
+}
+
+static void
+_sub_obj_mouse_move(void *data,
Evas *e __UNUSED__,
Evas_Object *obj,
- void *event_info __UNUSED__)
+ void *event_info)
{
- elm_widget_focus_mouse_down_handle(obj);
+ Smart_Data *sd = data;
+ Evas_Event_Mouse_Move *ev = event_info;
+ if (sd->still_in)
+ {
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ sd->still_in = EINA_FALSE;
+ else
+ {
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
+ (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
+ sd->still_in = EINA_FALSE;
+ }
+ }
+}
+
+static void
+_sub_obj_mouse_up(void *data,
+ Evas *e __UNUSED__,
+ Evas_Object *obj,
+ void *event_info __UNUSED__)
+{
+ Smart_Data *sd = data;
+ if (sd->still_in)
+ elm_widget_focus_mouse_up_handle(obj);
+ sd->still_in = EINA_FALSE;
}
static void
_propagate_x_drag_lock(Evas_Object *obj,
int dir)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (sd->parent_obj)
{
Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
_propagate_y_drag_lock(Evas_Object *obj,
int dir)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (sd->parent_obj)
{
Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
Evas_Object *obj,
void *event_info)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
Evas_Event_Flags *event_flags = NULL;
focus_order++;
sd->focus_order = focus_order;
- sd->focused = EINA_TRUE;
- if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
- if (sd->focus_func) sd->focus_func(obj);
-
- _elm_widget_focus_region_show(obj);
-
+ if (sd->top_win_focused)
+ {
+ sd->focused = EINA_TRUE;
+ if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
+ if (sd->focus_func) sd->focus_func(obj);
+ _elm_widget_focus_region_show(obj);
+ }
sd->focus_order_on_calc = EINA_FALSE;
}
widtypes = eina_list_append(widtypes, (void *)ptr);
}
+/**
+ * @defgroup Widget Widget
+ *
+ * @internal
+ * Disposed api for making widgets
+ */
+EAPI void
+elm_widget_type_unregister(const char **ptr)
+{
+ widtypes = eina_list_remove(widtypes, (void *)ptr);
+}
+
EAPI Eina_Bool
elm_widget_api_check(int ver)
{
}
EAPI void
+elm_widget_translate_hook_set(Evas_Object *obj,
+ void (*func)(Evas_Object *obj))
+{
+ API_ENTRY return;
+ sd->translate_func = func;
+}
+
+EAPI void
elm_widget_event_hook_set(Evas_Object *obj,
Eina_Bool (*func)(Evas_Object *obj,
Evas_Object *source,
EAPI void
elm_widget_text_set_hook_set(Evas_Object *obj,
- void (*func)(Evas_Object *obj,
- const char *part,
- const char *text))
+ Elm_Widget_Text_Set_Cb func)
{
API_ENTRY return;
- sd->on_text_set_func = func;
+ sd->text_set_func = func;
}
EAPI void
elm_widget_text_get_hook_set(Evas_Object *obj,
- const char *(*func)(const Evas_Object *obj,
- const char *part))
+ Elm_Widget_Text_Get_Cb func)
{
API_ENTRY return;
- sd->on_text_get_func = func;
+ sd->text_get_func = func;
}
EAPI void
elm_widget_content_set_hook_set(Evas_Object *obj,
- void (*func)(Evas_Object *obj,
- const char *part,
- Evas_Object *content))
+ Elm_Widget_Content_Set_Cb func)
{
API_ENTRY return;
- sd->on_content_set_func = func;
+ sd->content_set_func = func;
}
EAPI void
elm_widget_content_get_hook_set(Evas_Object *obj,
- Evas_Object *(*func)(const Evas_Object *obj,
- const char *part))
+ Elm_Widget_Content_Get_Cb func)
{
API_ENTRY return;
- sd->on_content_get_func = func;
+ sd->content_get_func = func;
}
EAPI void
elm_widget_content_unset_hook_set(Evas_Object *obj,
- Evas_Object *(*func)(Evas_Object *obj,
- const char *part))
+ Elm_Widget_Content_Unset_Cb func)
{
API_ENTRY return;
- sd->on_content_unset_func = func;
+ sd->content_unset_func = func;
}
EAPI void
if (sd2->parent_obj)
elm_widget_sub_object_del(sd2->parent_obj, sobj);
sd2->parent_obj = obj;
+ sd2->top_win_focused = sd->top_win_focused;
if (!sd->child_can_focus && (_is_focusable(sobj)))
sd->child_can_focus = EINA_TRUE;
}
_sub_obj_del);
}
}
-
sd->subobjs = eina_list_append(sd->subobjs, sobj);
evas_object_data_set(sobj, "elm-parent", obj);
evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
if (sobj_parent != obj)
{
static int abort_on_warn = -1;
- ERR("removing sub object %p from parent %p, "
- "but elm-parent is different %p!",
- sobj, obj, sobj_parent);
+ ERR("removing sub object %p (%s) from parent %p (%s), "
+ "but elm-parent is different %p (%s)!",
+ sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
+ sobj_parent, elm_widget_type_get(sobj_parent));
if (EINA_UNLIKELY(abort_on_warn == -1))
{
if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
}
if (_elm_widget_is(sobj))
{
- Smart_Data *sd2 = evas_object_smart_data_get(sobj);
- if (sd2)
+ if (elm_widget_focus_get(sobj))
{
- sd2->parent_obj = NULL;
- if (sd2->resize_obj == sobj)
- sd2->resize_obj = NULL;
- else
- sd->subobjs = eina_list_remove(sd->subobjs, sobj);
+ elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
+ elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
}
- else
- sd->subobjs = eina_list_remove(sd->subobjs, sobj);
- if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
if ((sd->child_can_focus) && (_is_focusable(sobj)))
{
Evas_Object *subobj;
}
}
}
+ Smart_Data *sd2 = evas_object_smart_data_get(sobj);
+ if (sd2)
+ {
+ sd2->parent_obj = NULL;
+ if (sd2->resize_obj == sobj)
+ sd2->resize_obj = NULL;
+ else
+ sd->subobjs = eina_list_remove(sd->subobjs, sobj);
+ }
+ else
+ sd->subobjs = eina_list_remove(sd->subobjs, sobj);
}
else
sd->subobjs = eina_list_remove(sd->subobjs, sobj);
_sub_obj_del, sd);
evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
_sub_obj_mouse_down, sd);
+ evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
+ _sub_obj_mouse_move, sd);
+ evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
+ _sub_obj_mouse_up, sd);
evas_object_smart_member_del(sd->resize_obj);
if (_elm_widget_is(sd->resize_obj))
{
if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
}
}
- // orphan new resize obj
- if (sobj)
- {
- evas_object_data_del(sobj, "elm-parent");
- if (_elm_widget_is(sobj))
- {
- Smart_Data *sd2 = evas_object_smart_data_get(sobj);
- if (sd2) sd2->parent_obj = NULL;
- evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
- _sub_obj_hide, sd);
- }
- evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
- _sub_obj_del, sd);
- evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
- _sub_obj_mouse_down, sd);
- evas_object_smart_member_del(sobj);
- if (_elm_widget_is(sobj))
- {
- if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
- }
- }
- // set the resize obj up
+
sd->resize_obj = sobj;
- if (sd->resize_obj)
+ if (!sobj) return;
+
+ // orphan new resize obj
+ evas_object_data_del(sobj, "elm-parent");
+ if (_elm_widget_is(sobj))
{
- if (_elm_widget_is(sd->resize_obj))
- {
- Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
- if (sd2) sd2->parent_obj = obj;
- evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
+ Smart_Data *sd2 = evas_object_smart_data_get(sobj);
+ if (sd2) sd2->parent_obj = NULL;
+ evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
_sub_obj_hide, sd);
- }
- evas_object_clip_set(sobj, evas_object_clip_get(obj));
- evas_object_smart_member_add(sobj, obj);
- evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
+ }
+ evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
_sub_obj_del, sd);
- evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
+ evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
_sub_obj_mouse_down, sd);
- _smart_reconfigure(sd);
- evas_object_data_set(sobj, "elm-parent", obj);
- evas_object_smart_callback_call(obj, "sub-object-add", sobj);
- if (_elm_widget_is(sobj))
+ evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
+ _sub_obj_mouse_move, sd);
+ evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
+ _sub_obj_mouse_up, sd);
+ evas_object_smart_member_del(sobj);
+ if (_elm_widget_is(sobj))
+ {
+ if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
+ }
+
+ // set the resize obj up
+ if (_elm_widget_is(sobj))
+ {
+ Smart_Data *sd2 = evas_object_smart_data_get(sobj);
+ if (sd2)
{
- if (elm_widget_focus_get(sobj)) _focus_parents(obj);
+ sd2->parent_obj = obj;
+ sd2->top_win_focused = sd->top_win_focused;
}
+ evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
+ _sub_obj_hide, sd);
+ }
+ evas_object_clip_set(sobj, evas_object_clip_get(obj));
+ evas_object_smart_member_add(sobj, obj);
+ evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
+ _sub_obj_del, sd);
+ evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
+ _sub_obj_mouse_down, sd);
+ evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
+ _sub_obj_mouse_move, sd);
+ evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
+ _sub_obj_mouse_up, sd);
+ _smart_reconfigure(sd);
+ evas_object_data_set(sobj, "elm-parent", obj);
+ evas_object_smart_callback_call(obj, "sub-object-add", sobj);
+ if (_elm_widget_is(sobj))
+ {
+ if (elm_widget_focus_get(sobj)) _focus_parents(obj);
}
}
return sd->tree_unfocusable;
}
+/**
+ * @internal
+ *
+ * Get the list of focusable child objects.
+ *
+ * This function retruns list of child objects which can get focus.
+ *
+ * @param obj The parent widget
+ * @retrun list of focusable child objects.
+ *
+ * @ingroup Widget
+ */
+EAPI Eina_List *
+elm_widget_can_focus_child_list_get(const Evas_Object *obj)
+{
+ API_ENTRY return NULL;
+
+ const Eina_List *l;
+ Eina_List *child_list = NULL;
+ Evas_Object *child;
+
+ if (sd->subobjs)
+ {
+ EINA_LIST_FOREACH(sd->subobjs, l, child)
+ {
+ if ((elm_widget_can_focus_get(child)) &&
+ (evas_object_visible_get(child)) &&
+ (!elm_widget_disabled_get(child)))
+ child_list = eina_list_append(child_list, child);
+ else if (elm_widget_is(child))
+ {
+ Eina_List *can_focus_list;
+ can_focus_list = elm_widget_can_focus_child_list_get(child);
+ if (can_focus_list)
+ child_list = eina_list_merge(child_list, can_focus_list);
+ }
+ }
+ }
+ return child_list;
+}
+
EAPI void
elm_widget_highlight_ignore_set(Evas_Object *obj,
Eina_Bool ignore)
Elm_Focus_Direction dir,
Evas_Object **next)
{
- Eina_List *(*list_next)(const Eina_List * list);
+ Eina_List *(*list_next)(const Eina_List * list) = NULL;
if (!next)
return EINA_FALSE;
{
API_ENTRY return;
if (!sd->focused) return;
- if (elm_widget_focus_get(sd->resize_obj))
+ if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
elm_widget_focused_object_clear(sd->resize_obj);
else
{
}
EAPI void
+elm_widget_focus_restore(Evas_Object *obj)
+{
+ Evas_Object *newest = NULL;
+ unsigned int newest_focus_order = 0;
+ API_ENTRY return;
+
+ newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
+ if (newest)
+ {
+ elm_object_focus_set(newest, EINA_FALSE);
+ elm_object_focus_set(newest, EINA_TRUE);
+ }
+}
+
+void
+_elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
+{
+ const Eina_List *l;
+ Evas_Object *child;
+ API_ENTRY return;
+
+ if (sd->top_win_focused == top_win_focused) return;
+ if (sd->resize_obj)
+ _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
+ EINA_LIST_FOREACH(sd->subobjs, l, child)
+ {
+ _elm_widget_top_win_focused_set(child, top_win_focused);
+ }
+ sd->top_win_focused = top_win_focused;
+}
+
+Eina_Bool
+_elm_widget_top_win_focused_get(const Evas_Object *obj)
+{
+ API_ENTRY return EINA_FALSE;
+ return sd->top_win_focused;
+}
+
+EAPI void
elm_widget_activate(Evas_Object *obj)
{
API_ENTRY return;
Evas_Object *parent_obj, *child_obj;
Evas_Coord px, py, cx, cy;
+ evas_smart_objects_calculate(evas_object_evas_get(obj));
+
API_ENTRY return;
if (!forceshow && (x == sd->rx) && (y == sd->ry)
&& (w == sd->rw) && (h == sd->rh)) return;
{
API_ENTRY return;
sd->scroll_hold--;
- if (sd->scroll_hold < 0) sd->scroll_hold = 0;
if (!sd->scroll_hold)
evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
+ if (sd->scroll_hold < 0) sd->scroll_hold = 0;
}
EAPI int
{
API_ENTRY return;
sd->scroll_freeze--;
- if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
if (!sd->scroll_freeze)
evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
+ if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
}
EAPI int
{
API_ENTRY return;
- if (!sd->on_text_set_func)
+ if (!sd->text_set_func)
return;
- sd->on_text_set_func(obj, part, label);
+ sd->text_set_func(obj, part, label);
}
EAPI const char *
{
API_ENTRY return NULL;
- if (!sd->on_text_get_func)
+ if (!sd->text_get_func)
return NULL;
- return sd->on_text_get_func(obj, part);
+ return sd->text_get_func(obj, part);
+}
+
+EAPI void
+elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
+{
+ const char *str;
+ Eina_List *l;
+ Elm_Translate_String_Data *ts = NULL;
+ API_ENTRY return;
+
+ str = eina_stringshare_add(part);
+ EINA_LIST_FOREACH(sd->translate_strings, l, ts)
+ if (ts->id == str)
+ break;
+ else
+ ts = NULL;
+
+ if (!ts && !label)
+ eina_stringshare_del(str);
+ else if (!ts)
+ {
+ ts = malloc(sizeof(Elm_Translate_String_Data));
+ if (!ts) return;
+
+ ts->id = str;
+ ts->domain = eina_stringshare_add(domain);
+ ts->string = eina_stringshare_add(label);
+ sd->translate_strings = eina_list_append(sd->translate_strings, ts);
+ }
+ else
+ {
+ if (label)
+ {
+ eina_stringshare_replace(&ts->domain, domain);
+ eina_stringshare_replace(&ts->string, label);
+ }
+ else
+ {
+ sd->translate_strings = eina_list_remove_list(
+ sd->translate_strings, l);
+ eina_stringshare_del(ts->id);
+ eina_stringshare_del(ts->domain);
+ eina_stringshare_del(ts->string);
+ free(ts);
+ }
+ eina_stringshare_del(str);
+ }
+
+#ifdef HAVE_GETTEXT
+ if (label && label[0])
+ label = dgettext(domain, label);
+#endif
+ elm_widget_text_part_set(obj, part, label);
+}
+
+EAPI const char *
+elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
+{
+ const char *str, *ret = NULL;
+ Eina_List *l;
+ Elm_Translate_String_Data *ts;
+ API_ENTRY return NULL;
+
+ str = eina_stringshare_add(part);
+ EINA_LIST_FOREACH(sd->translate_strings, l, ts)
+ if (ts->id == str)
+ {
+ ret = ts->string;
+ break;
+ }
+ eina_stringshare_del(str);
+ return ret;
+}
+
+EAPI void
+elm_widget_translate(Evas_Object *obj)
+{
+ const Eina_List *l;
+ Evas_Object *child;
+#ifdef HAVE_GETTEXT
+ Elm_Translate_String_Data *ts;
+#endif
+
+ API_ENTRY return;
+ EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
+ if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
+ if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
+ if (sd->translate_func) sd->translate_func(obj);
+
+#ifdef HAVE_GETTEXT
+ EINA_LIST_FOREACH(sd->translate_strings, l, ts)
+ {
+ const char *s = dgettext(ts->domain, ts->string);
+ elm_widget_text_part_set(obj, ts->id, s);
+ }
+#endif
}
EAPI void
{
API_ENTRY return;
- if (!sd->on_content_set_func) return;
- sd->on_content_set_func(obj, part, content);
+ if (!sd->content_set_func) return;
+ sd->content_set_func(obj, part, content);
}
EAPI Evas_Object *
{
API_ENTRY return NULL;
- if (!sd->on_content_get_func) return NULL;
- return sd->on_content_get_func(obj, part);
+ if (!sd->content_get_func) return NULL;
+ return sd->content_get_func(obj, part);
}
EAPI Evas_Object *
{
API_ENTRY return NULL;
- if (!sd->on_content_unset_func) return NULL;
- return sd->on_content_unset_func(obj, part);
+ if (!sd->content_unset_func) return NULL;
+ return sd->content_unset_func(obj, part);
+}
+
+EAPI void
+elm_widget_access_info_set(Evas_Object *obj, const char *txt)
+{
+ API_ENTRY return;
+ if (sd->access_info) eina_stringshare_del(sd->access_info);
+ if (!txt) sd->access_info = NULL;
+ else sd->access_info = eina_stringshare_add(txt);
+}
+
+EAPI const char *
+elm_widget_access_info_get(Evas_Object *obj)
+{
+ API_ENTRY return NULL;
+ return sd->access_info;
}
EAPI Elm_Theme *
}
EAPI Eina_Bool
+elm_widget_is_check(const Evas_Object *obj)
+{
+ static int abort_on_warn = -1;
+ if (elm_widget_is(obj))
+ return EINA_TRUE;
+
+ ERR("Passing Object: %p.", obj);
+ if (abort_on_warn == -1)
+ {
+ if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
+ else abort_on_warn = 0;
+ }
+ if (abort_on_warn == 1) abort();
+ return EINA_FALSE;
+}
+
+EAPI Eina_Bool
elm_widget_type_check(const Evas_Object *obj,
- const char *type)
+ const char *type,
+ const char *func)
{
const char *provided, *expected = "(unknown)";
static int abort_on_warn = -1;
if ((!provided) || (!provided[0]))
provided = "(unknown)";
}
- ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
+ ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
if (abort_on_warn == -1)
{
if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
return EINA_FALSE;
}
+static Evas_Object *
+_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
+{
+ Eina_List *l;
+ Evas_Object *child;
+ const char *s;
+ INTERNAL_ENTRY NULL;
+
+ if (!_elm_widget_is(obj)) return NULL;
+ if (sd->resize_obj)
+ {
+ s = evas_object_name_get(sd->resize_obj);
+ if ((s) && (!strcmp(s, name))) return sd->resize_obj;
+ if ((recurse != 0) &&
+ ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
+ return child;
+ }
+ EINA_LIST_FOREACH(sd->subobjs, l, child)
+ {
+ s = evas_object_name_get(child);
+ if ((s) && (!strcmp(s, name))) return child;
+ if ((recurse != 0) &&
+ ((child = _widget_name_find(child, name, recurse - 1))))
+ return child;
+ }
+ if (sd->hover_obj)
+ {
+ s = evas_object_name_get(sd->hover_obj);
+ if ((s) && (!strcmp(s, name))) return sd->hover_obj;
+ if ((recurse != 0) &&
+ ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
+ return child;
+ }
+ return NULL;
+}
+
+EAPI Evas_Object *
+elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
+{
+ API_ENTRY return NULL;
+ if (!name) return NULL;
+ return _widget_name_find(obj, name, recurse);
+}
+
/**
* @internal
*
}
EAPI void
-elm_widget_focus_mouse_down_handle(Evas_Object *obj)
+elm_widget_focus_mouse_up_handle(Evas_Object *obj)
{
Evas_Object *o = obj;
do
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if (item->del_cb)
- item->del_cb((void *)item->data, item->widget, item);
+ if (item->del_func)
+ item->del_func((void *)item->data, item->widget, item);
+
+ if (item->del_pre_func)
+ item->del_pre_func((Elm_Object_Item *) item);
if (item->view)
evas_object_del(item->view);
+ if (item->access)
+ {
+ _elm_access_clear(item->access);
+ free(item->access);
+ item->access = NULL;
+ }
+ if (item->access_info)
+ {
+ eina_stringshare_del(item->access_info);
+ item->access_info = NULL;
+ }
+
EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
free(item);
}
/**
* @internal
*
+ * Set the function to notify to widgets when item is being deleted by user.
+ *
+ * This function will complain if there was a callback set already,
+ * however it will set the new one.
+ *
+ * @param item a valid #Elm_Widget_Item to be notified
+ * @see elm_widget_item_del_pre_hook_set() convenience macro.
+ * @ingroup Widget
+ */
+EAPI void
+_elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Item_Del_Pre_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ if ((item->del_pre_func) && (item->del_pre_func != func))
+ WRN("You're replacing a previously set del_pre_cb %p of item %p with %p", item->del_pre_func, item, func);
+ item->del_pre_func = func;
+}
+
+/**
+ * @internal
+ *
* Notify object will be deleted without actually deleting it.
*
* This function will callback Elm_Widget_Item::del_cb if it is set
_elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if (!item->del_cb) return;
- item->del_cb((void *)item->data, item->widget, item);
- item->del_cb = NULL;
+ if (!item->del_func) return;
+ item->del_func((void *)item->data, item->widget, item);
+ item->del_func = NULL;
}
/**
*/
EAPI void
_elm_widget_item_del_cb_set(Elm_Widget_Item *item,
- Evas_Smart_Cb del_cb)
+ Evas_Smart_Cb func)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if ((item->del_cb) && (item->del_cb != del_cb))
+ if ((item->del_func) && (item->del_func != func))
WRN("You're replacing a previously set del_cb %p of item %p with %p",
- item->del_cb, item, del_cb);
+ item->del_func, item, func);
- item->del_cb = del_cb;
+ item->del_func = func;
}
/**
return (void *)item->data;
}
+EAPI void
+_elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+
+ if (item->disabled == disabled) return;
+ item->disabled = !!disabled;
+ if (item->disable_func) item->disable_func(item);
+}
+
+EAPI Eina_Bool
+_elm_widget_item_disabled_get(const Elm_Widget_Item *item)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
+ return item->disabled;
+}
+
+EAPI void
+_elm_widget_item_disable_set_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Disable_Set_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->disable_func = func;
+}
+
typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
struct _Elm_Widget_Item_Tooltip
return label;
}
+static Evas_Object *
+_elm_widget_item_tooltip_trans_label_create(void *data,
+ Evas_Object *obj __UNUSED__,
+ Evas_Object *tooltip,
+ void *item __UNUSED__)
+{
+ Evas_Object *label = elm_label_add(tooltip);
+ if (!label)
+ return NULL;
+ elm_object_style_set(label, "tooltip");
+ elm_object_translatable_text_set(label, data);
+ return label;
+}
+
static void
_elm_widget_item_tooltip_label_del_cb(void *data,
Evas_Object *obj __UNUSED__,
_elm_widget_item_tooltip_label_del_cb);
}
+EAPI void
+_elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
+ const char *text)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ EINA_SAFETY_ON_NULL_RETURN(text);
+
+ text = eina_stringshare_add(text);
+ _elm_widget_item_tooltip_content_cb_set
+ (item, _elm_widget_item_tooltip_trans_label_create, text,
+ _elm_widget_item_tooltip_label_del_cb);
+}
+
static Evas_Object *
_elm_widget_item_tooltip_create(void *data,
Evas_Object *obj,
}
EAPI Eina_Bool
-_elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
+_elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
- return elm_tooltip_size_restrict_disable(item->view, disable);
+ return elm_object_tooltip_window_mode_set(item->view, disable);
}
EAPI Eina_Bool
-_elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
+_elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
- return elm_tooltip_size_restrict_disabled_get(item->view);
+ return elm_object_tooltip_window_mode_get(item->view);
}
/**
Evas_Object *content)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if (!item->on_content_set_func) return;
- item->on_content_set_func(item, part, content);
+ if (!item->content_set_func) return;
+ item->content_set_func((Elm_Object_Item *) item, part, content);
}
EAPI Evas_Object *
_elm_widget_item_content_part_get(const Elm_Widget_Item *item,
- const char *part)
+ const char *part)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
- if (!item->on_content_get_func) return NULL;
- return item->on_content_get_func(item, part);
+ if (!item->content_get_func) return NULL;
+ return item->content_get_func((Elm_Object_Item *) item, part);
}
EAPI Evas_Object *
_elm_widget_item_content_part_unset(Elm_Widget_Item *item,
- const char *part)
+ const char *part)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
- if (!item->on_content_unset_func) return NULL;
- return item->on_content_unset_func(item, part);
+ if (!item->content_unset_func) return NULL;
+ return item->content_unset_func((Elm_Object_Item *) item, part);
}
EAPI void
const char *label)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if (!item->on_text_set_func) return;
- item->on_text_set_func(item, part, label);
+ if (!item->text_set_func) return;
+ item->text_set_func((Elm_Object_Item *) item, part, label);
+}
+
+EAPI void
+_elm_widget_item_signal_emit(Elm_Widget_Item *item,
+ const char *emission,
+ const char *source)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ if (item->signal_emit_func)
+ item->signal_emit_func((Elm_Object_Item *) item, emission, source);
}
EAPI const char *
_elm_widget_item_text_part_get(const Elm_Widget_Item *item,
- const char *part)
+ const char *part)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
- if (!item->on_text_get_func) return NULL;
- return item->on_text_get_func(item, part);
+ if (!item->text_get_func) return NULL;
+ return item->text_get_func((Elm_Object_Item *) item, part);
+}
+
+EAPI void
+_elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Content_Set_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->content_set_func = func;
+}
+
+EAPI void
+_elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Content_Get_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->content_get_func = func;
+}
+
+EAPI void
+_elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Content_Unset_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->content_unset_func = func;
+}
+
+EAPI void
+_elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Text_Set_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->text_set_func = func;
+}
+
+EAPI void
+_elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Text_Get_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->text_get_func = func;
+}
+
+EAPI void
+_elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
+ Elm_Widget_Signal_Emit_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ item->signal_emit_func = func;
+}
+
+EAPI void
+_elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ if (item->access_info) eina_stringshare_del(item->access_info);
+ if (!txt) item->access_info = NULL;
+ else item->access_info = eina_stringshare_add(txt);
}
+
static void
_smart_add(Evas_Object *obj)
{
Evas_Object *newest = NULL;
unsigned int newest_focus_order = 0;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (!sd->focused) return;
if (!sd->parent_obj) return;
{
Evas_Object *sobj;
Edje_Signal_Data *esd;
+ Elm_Translate_String_Data *ts;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (sd->del_pre_func) sd->del_pre_func(obj);
if (sd->resize_obj)
evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
evas_object_del(sobj);
+ sd->resize_obj = NULL;
}
if (sd->hover_obj)
{
evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
evas_object_del(sobj);
+ sd->hover_obj = NULL;
}
EINA_LIST_FREE(sd->subobjs, sobj)
{
evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
evas_object_del(sobj);
}
- eina_list_free(sd->tooltips); /* should be empty anyway */
- eina_list_free(sd->cursors); /* should be empty anyway */
+ sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
+ sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
EINA_LIST_FREE(sd->edje_signals, esd)
{
eina_stringshare_del(esd->emission);
eina_stringshare_del(esd->source);
free(esd);
}
- eina_list_free(sd->event_cb); /* should be empty anyway */
+ EINA_LIST_FREE(sd->translate_strings, ts)
+ {
+ eina_stringshare_del(ts->id);
+ eina_stringshare_del(ts->domain);
+ eina_stringshare_del(ts->string);
+ free(ts);
+ }
+ sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
if (sd->del_func) sd->del_func(obj);
if (sd->style) eina_stringshare_del(sd->style);
if (sd->type) eina_stringshare_del(sd->type);
if (sd->theme) elm_theme_free(sd->theme);
+ sd->data = NULL;
_if_focused_revert(obj, EINA_TRUE);
+ if (sd->access_info) eina_stringshare_del(sd->access_info);
free(sd);
+ evas_object_smart_data_set(obj, NULL);
}
static void
Evas_Coord x,
Evas_Coord y)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
sd->x = x;
sd->y = y;
_smart_reconfigure(sd);
Evas_Coord w,
Evas_Coord h)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
sd->w = w;
sd->h = h;
_smart_reconfigure(sd);
{
Eina_List *list;
Evas_Object *o;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if ((list = evas_object_smart_members_get(obj)))
{
EINA_LIST_FREE(list, o)
{
Eina_List *list;
Evas_Object *o;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
list = evas_object_smart_members_get(obj);
EINA_LIST_FREE(list, o)
{
Eina_List *list;
Evas_Object *o;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if ((list = evas_object_smart_members_get(obj)))
{
EINA_LIST_FREE(list, o)
{
Eina_List *list;
Evas_Object *o;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if ((list = evas_object_smart_members_get(obj)))
{
EINA_LIST_FREE(list, o)
{
Eina_List *list;
Evas_Object *o;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if ((list = evas_object_smart_members_get(obj)))
{
EINA_LIST_FREE(list, o)
static void
_smart_calculate(Evas_Object *obj)
{
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
if (sd->changed_func) sd->changed_func(obj);
}
_smart_init(void)
{
if (_e_smart) return;
- {
- static const Evas_Smart_Class sc =
- {
- SMART_NAME,
- EVAS_SMART_CLASS_VERSION,
- _smart_add,
- _smart_del,
- _smart_move,
- _smart_resize,
- _smart_show,
- _smart_hide,
- _smart_color_set,
- _smart_clip_set,
- _smart_clip_unset,
- _smart_calculate,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- };
- _e_smart = evas_smart_class_new(&sc);
- }
+ {
+ static const Evas_Smart_Class sc =
+ {
+ SMART_NAME,
+ EVAS_SMART_CLASS_VERSION,
+ _smart_add,
+ _smart_del,
+ _smart_move,
+ _smart_resize,
+ _smart_show,
+ _smart_hide,
+ _smart_color_set,
+ _smart_clip_set,
+ _smart_clip_unset,
+ _smart_calculate,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+ _e_smart = evas_smart_class_new(&sc);
+ }
}
/* happy debug functions */
if (_elm_widget_is(obj))
{
Eina_List *l;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
printf("+ %s(%p)\n",
sd->type,
obj);
{
if (!_elm_widget_is(obj))
return;
- INTERNAL_ENTRY
+ INTERNAL_ENTRY;
Eina_Bool visible = evas_object_visible_get(obj);
Eina_Bool disabled = elm_widget_disabled_get(obj);