1 #include <Elementary.h>
4 static const char SMART_NAME[] = "elm_widget";
7 Smart_Data * sd = evas_object_smart_data_get(obj); \
8 if ((!sd) || (!_elm_widget_is(obj)))
9 #define INTERNAL_ENTRY \
10 Smart_Data * sd = evas_object_smart_data_get(obj); \
13 #undef elm_widget_text_set_hook_set
14 #undef elm_widget_text_get_hook_set
15 #undef elm_widget_content_set_hook_set
16 #undef elm_widget_content_get_hook_set
17 #undef elm_widget_content_unset_hook_set
19 typedef struct _Smart_Data Smart_Data;
20 typedef struct _Edje_Signal_Data Edje_Signal_Data;
21 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
22 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
23 typedef struct _Elm_Widget_Item_Callback Elm_Widget_Item_Callback;
29 Evas_Object *parent_obj;
31 Evas_Coord x, y, w, h;
33 Evas_Object *resize_obj;
34 Evas_Object *hover_obj;
35 Eina_List *tooltips, *cursors;
36 void (*del_func)(Evas_Object *obj);
37 void (*del_pre_func)(Evas_Object *obj);
38 void (*focus_func)(Evas_Object *obj);
39 void (*activate_func)(Evas_Object *obj);
40 void (*disable_func)(Evas_Object *obj);
41 void (*theme_func)(Evas_Object *obj);
42 void (*translate_func)(Evas_Object *obj);
43 Eina_Bool (*event_func)(Evas_Object *obj,
45 Evas_Callback_Type type,
47 void (*signal_func)(Evas_Object *obj,
50 void (*callback_add_func)(Evas_Object *obj,
55 void (*callback_del_func)(Evas_Object *obj,
60 void (*changed_func)(Evas_Object *obj);
61 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
62 Elm_Focus_Direction dir,
64 void (*on_focus_func)(void *data,
67 void (*on_change_func)(void *data,
70 void (*on_show_region_func)(void *data,
72 void *on_show_region_data;
73 void (*focus_region_func)(Evas_Object *obj,
78 void (*on_focus_region_func)(const Evas_Object *obj,
83 Elm_Widget_Text_Set_Cb text_set_func;
84 Elm_Widget_Text_Get_Cb text_get_func;
85 Elm_Widget_Content_Set_Cb content_set_func;
86 Elm_Widget_Content_Get_Cb content_get_func;
87 Elm_Widget_Content_Unset_Cb content_unset_func;
89 Evas_Coord rx, ry, rw, rh;
95 const char *access_info;
96 unsigned int focus_order;
97 Eina_Bool focus_order_on_calc;
99 int child_drag_x_locked;
100 int child_drag_y_locked;
102 Eina_List *edje_signals;
103 Eina_List *translate_strings;
105 Eina_Bool drag_x_locked : 1;
106 Eina_Bool drag_y_locked : 1;
108 Eina_Bool can_focus : 1;
109 Eina_Bool child_can_focus : 1;
110 Eina_Bool focused : 1;
111 Eina_Bool top_win_focused : 1;
112 Eina_Bool tree_unfocusable : 1;
113 Eina_Bool highlight_ignore : 1;
114 Eina_Bool highlight_in_theme : 1;
115 Eina_Bool disabled : 1;
116 Eina_Bool is_mirrored : 1;
117 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
118 Eina_Bool still_in : 1;
120 Eina_List *focus_chain;
124 struct _Edje_Signal_Data
128 const char *emission;
133 struct _Elm_Event_Cb_Data
139 struct _Elm_Translate_String_Data
146 struct _Elm_Widget_Item_Callback
149 Elm_Object_Item_Smart_Cb func;
152 Eina_Bool delete_me : 1;
156 /* local subsystem functions */
157 static void _smart_reconfigure(Smart_Data *sd);
158 static void _smart_add(Evas_Object *obj);
159 static void _smart_del(Evas_Object *obj);
160 static void _smart_move(Evas_Object *obj,
163 static void _smart_resize(Evas_Object *obj,
166 static void _smart_show(Evas_Object *obj);
167 static void _smart_hide(Evas_Object *obj);
168 static void _smart_color_set(Evas_Object *obj,
173 static void _smart_clip_set(Evas_Object *obj,
175 static void _smart_clip_unset(Evas_Object *obj);
176 static void _smart_calculate(Evas_Object *obj);
177 static void _smart_init(void);
179 static void _if_focused_revert(Evas_Object *obj,
180 Eina_Bool can_focus_only);
181 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
182 unsigned int *newest_focus_order,
183 Eina_Bool can_focus_only);
185 /* local subsystem globals */
186 static Evas_Smart *_e_smart = NULL;
187 static Eina_List *widtypes = NULL;
189 static unsigned int focus_order = 0;
192 static inline Eina_Bool
193 _elm_widget_is(const Evas_Object *obj)
195 const char *type = evas_object_type_get(obj);
196 return type == SMART_NAME;
199 static inline Eina_Bool
200 _is_focusable(Evas_Object *obj)
202 API_ENTRY return EINA_FALSE;
203 return sd->can_focus || (sd->child_can_focus);
207 _unfocus_parents(Evas_Object *obj)
209 for (; obj; obj = elm_widget_parent_get(obj))
212 if (!sd->focused) return;
218 _focus_parents(Evas_Object *obj)
220 for (; obj; obj = elm_widget_parent_get(obj))
223 if (sd->focused) return;
229 _sub_obj_del(void *data,
232 void *event_info __UNUSED__)
234 Smart_Data *sd = data;
236 if (_elm_widget_is(obj))
238 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
240 if (obj == sd->resize_obj)
241 sd->resize_obj = NULL;
242 else if (obj == sd->hover_obj)
243 sd->hover_obj = NULL;
245 sd->subobjs = eina_list_remove(sd->subobjs, obj);
246 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
250 _sub_obj_hide(void *data __UNUSED__,
253 void *event_info __UNUSED__)
255 elm_widget_focus_hide_handle(obj);
259 _sub_obj_mouse_down(void *data,
261 Evas_Object *obj __UNUSED__,
264 Smart_Data *sd = data;
265 Evas_Event_Mouse_Down *ev = event_info;
266 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
267 sd->still_in = EINA_TRUE;
271 _sub_obj_mouse_move(void *data,
276 Smart_Data *sd = data;
277 Evas_Event_Mouse_Move *ev = event_info;
280 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
281 sd->still_in = EINA_FALSE;
284 Evas_Coord x, y, w, h;
285 evas_object_geometry_get(obj, &x, &y, &w, &h);
286 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
287 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
288 sd->still_in = EINA_FALSE;
294 _sub_obj_mouse_up(void *data,
297 void *event_info __UNUSED__)
299 Smart_Data *sd = data;
301 elm_widget_focus_mouse_up_handle(obj);
302 sd->still_in = EINA_FALSE;
306 _propagate_x_drag_lock(Evas_Object *obj,
312 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
315 sd2->child_drag_x_locked += dir;
316 _propagate_x_drag_lock(sd->parent_obj, dir);
322 _propagate_y_drag_lock(Evas_Object *obj,
328 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
331 sd2->child_drag_y_locked += dir;
332 _propagate_y_drag_lock(sd->parent_obj, dir);
338 _propagate_event(void *data,
344 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
345 Evas_Event_Flags *event_flags = NULL;
349 case EVAS_CALLBACK_KEY_DOWN:
351 Evas_Event_Key_Down *ev = event_info;
352 event_flags = &(ev->event_flags);
356 case EVAS_CALLBACK_KEY_UP:
358 Evas_Event_Key_Up *ev = event_info;
359 event_flags = &(ev->event_flags);
363 case EVAS_CALLBACK_MOUSE_WHEEL:
365 Evas_Event_Mouse_Wheel *ev = event_info;
366 event_flags = &(ev->event_flags);
374 elm_widget_event_propagate(obj, type, event_info, event_flags);
378 _parent_focus(Evas_Object *obj)
381 if (sd->focused) return;
383 Evas_Object *o = elm_widget_parent_get(obj);
384 sd->focus_order_on_calc = EINA_TRUE;
386 if (o) _parent_focus(o);
388 if (!sd->focus_order_on_calc)
389 return; /* we don't want to override it if by means of any of the
390 callbacks below one gets to calculate our order
394 sd->focus_order = focus_order;
395 if (sd->top_win_focused)
397 sd->focused = EINA_TRUE;
398 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
399 if (sd->focus_func) sd->focus_func(obj);
400 _elm_widget_focus_region_show(obj);
402 sd->focus_order_on_calc = EINA_FALSE;
406 _elm_object_focus_chain_del_cb(void *data,
409 void *event_info __UNUSED__)
411 Smart_Data *sd = data;
413 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
416 // exposed util funcs to elm
418 _elm_widget_type_clear(void)
422 EINA_LIST_FREE(widtypes, ptr)
424 eina_stringshare_del(*ptr);
430 _elm_widget_focus_region_show(const Evas_Object *obj)
432 Evas_Coord x, y, w, h, ox, oy;
438 o = elm_widget_parent_get(obj);
441 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
442 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
446 sd2 = evas_object_smart_data_get(o);
447 if (sd2->focus_region_func)
449 sd2->focus_region_func(o, x, y, w, h);
450 elm_widget_focus_region_get(o, &x, &y, &w, &h);
454 evas_object_geometry_get(o, &px, &py, NULL, NULL);
460 o = elm_widget_parent_get(o);
465 * @defgroup Widget Widget
468 * Exposed api for making widgets
471 elm_widget_type_register(const char **ptr)
473 widtypes = eina_list_append(widtypes, (void *)ptr);
477 * @defgroup Widget Widget
480 * Disposed api for making widgets
483 elm_widget_type_unregister(const char **ptr)
485 widtypes = eina_list_remove(widtypes, (void *)ptr);
489 elm_widget_api_check(int ver)
491 if (ver != ELM_INTERNAL_API_VERSION)
493 CRITICAL("Elementary widget api versions do not match");
500 elm_widget_add(Evas *evas)
504 obj = evas_object_smart_add(evas, _e_smart);
505 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
510 elm_widget_del_hook_set(Evas_Object *obj,
511 void (*func)(Evas_Object *obj))
518 elm_widget_del_pre_hook_set(Evas_Object *obj,
519 void (*func)(Evas_Object *obj))
522 sd->del_pre_func = func;
526 elm_widget_focus_hook_set(Evas_Object *obj,
527 void (*func)(Evas_Object *obj))
530 sd->focus_func = func;
534 elm_widget_activate_hook_set(Evas_Object *obj,
535 void (*func)(Evas_Object *obj))
538 sd->activate_func = func;
542 elm_widget_disable_hook_set(Evas_Object *obj,
543 void (*func)(Evas_Object *obj))
546 sd->disable_func = func;
550 elm_widget_theme_hook_set(Evas_Object *obj,
551 void (*func)(Evas_Object *obj))
554 sd->theme_func = func;
558 elm_widget_translate_hook_set(Evas_Object *obj,
559 void (*func)(Evas_Object *obj))
562 sd->translate_func = func;
566 elm_widget_event_hook_set(Evas_Object *obj,
567 Eina_Bool (*func)(Evas_Object *obj,
569 Evas_Callback_Type type,
573 sd->event_func = func;
577 elm_widget_text_set_hook_set(Evas_Object *obj,
578 Elm_Widget_Text_Set_Cb func)
581 sd->text_set_func = func;
585 elm_widget_text_get_hook_set(Evas_Object *obj,
586 Elm_Widget_Text_Get_Cb func)
589 sd->text_get_func = func;
593 elm_widget_content_set_hook_set(Evas_Object *obj,
594 Elm_Widget_Content_Set_Cb func)
597 sd->content_set_func = func;
601 elm_widget_content_get_hook_set(Evas_Object *obj,
602 Elm_Widget_Content_Get_Cb func)
605 sd->content_get_func = func;
609 elm_widget_content_unset_hook_set(Evas_Object *obj,
610 Elm_Widget_Content_Unset_Cb func)
613 sd->content_unset_func = func;
617 elm_widget_changed_hook_set(Evas_Object *obj,
618 void (*func)(Evas_Object *obj))
621 sd->changed_func = func;
625 elm_widget_signal_emit_hook_set(Evas_Object *obj,
626 void (*func)(Evas_Object *obj,
627 const char *emission,
631 sd->signal_func = func;
635 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
636 void (*func)(Evas_Object *obj,
637 const char *emission,
639 Edje_Signal_Cb func_cb,
643 sd->callback_add_func = func;
647 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
648 void (*func)(Evas_Object *obj,
649 const char *emission,
651 Edje_Signal_Cb func_cb,
655 sd->callback_del_func = func;
659 elm_widget_theme(Evas_Object *obj)
665 Eina_Bool ret = EINA_TRUE;
667 API_ENTRY return EINA_FALSE;
668 EINA_LIST_FOREACH(sd->subobjs, l, child) ret &= elm_widget_theme(child);
669 if (sd->resize_obj) ret &= elm_widget_theme(sd->resize_obj);
670 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
671 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
672 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
673 if (sd->theme_func) sd->theme_func(obj);
679 elm_widget_theme_specific(Evas_Object *obj,
687 Elm_Theme *th2, *thdef;
690 thdef = elm_theme_default_get();
695 if (!th2) th2 = thdef;
703 if (th2 == thdef) break;
704 th2 = th2->ref_theme;
705 if (!th2) th2 = thdef;
709 EINA_LIST_FOREACH(sd->subobjs, l, child)
710 elm_widget_theme_specific(child, th, force);
711 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
712 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
713 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
714 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
715 if (sd->theme_func) sd->theme_func(obj);
721 * Set hook to get next object in object focus chain.
723 * @param obj The widget object.
724 * @param func The hook to be used with this widget.
729 elm_widget_focus_next_hook_set(Evas_Object *obj,
730 Eina_Bool (*func)(const Evas_Object *obj,
731 Elm_Focus_Direction dir,
735 sd->focus_next_func = func;
739 * Returns the widget's mirrored mode.
741 * @param obj The widget.
742 * @return mirrored mode of the object.
746 elm_widget_mirrored_get(const Evas_Object *obj)
748 API_ENTRY return EINA_FALSE;
749 return sd->is_mirrored;
753 * Sets the widget's mirrored mode.
755 * @param obj The widget.
756 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
759 elm_widget_mirrored_set(Evas_Object *obj,
763 if (sd->is_mirrored != mirrored)
765 sd->is_mirrored = mirrored;
766 elm_widget_theme(obj);
772 * Resets the mirrored mode from the system mirror mode for widgets that are in
773 * automatic mirroring mode. This function does not call elm_widget_theme.
775 * @param obj The widget.
776 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
779 _elm_widget_mirrored_reload(Evas_Object *obj)
782 Eina_Bool mirrored = elm_config_mirrored_get();
783 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
785 sd->is_mirrored = mirrored;
790 * Returns the widget's mirrored mode setting.
792 * @param obj The widget.
793 * @return mirrored mode setting of the object.
797 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
799 API_ENTRY return EINA_FALSE;
800 return sd->mirrored_auto_mode;
804 * Sets the widget's mirrored mode setting.
805 * When widget in automatic mode, it follows the system mirrored mode set by
806 * elm_mirrored_set().
807 * @param obj The widget.
808 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
811 elm_widget_mirrored_automatic_set(Evas_Object *obj,
815 if (sd->mirrored_auto_mode != automatic)
817 sd->mirrored_auto_mode = automatic;
821 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
827 elm_widget_on_focus_hook_set(Evas_Object *obj,
828 void (*func)(void *data,
833 sd->on_focus_func = func;
834 sd->on_focus_data = data;
838 elm_widget_on_change_hook_set(Evas_Object *obj,
839 void (*func)(void *data,
844 sd->on_change_func = func;
845 sd->on_change_data = data;
849 elm_widget_on_show_region_hook_set(Evas_Object *obj,
850 void (*func)(void *data,
855 sd->on_show_region_func = func;
856 sd->on_show_region_data = data;
862 * Set the hook to use to show the focused region.
864 * Whenever a new widget gets focused or it's needed to show the focused
865 * area of the current one, this hook will be called on objects that may
866 * want to move their children into their visible area.
867 * The area given in the hook function is relative to the @p obj widget.
869 * @param obj The widget object
870 * @param func The function to call to show the specified area.
875 elm_widget_focus_region_hook_set(Evas_Object *obj,
876 void (*func)(Evas_Object *obj,
883 sd->focus_region_func = func;
889 * Set the hook to retrieve the focused region of a widget.
891 * This hook will be called by elm_widget_focus_region_get() whenever
892 * it's needed to get the focused area of a widget. The area must be relative
893 * to the widget itself and if no hook is set, it will default to the entire
896 * @param obj The widget object
897 * @param func The function used to retrieve the focus region.
902 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
903 void (*func)(const Evas_Object *obj,
910 sd->on_focus_region_func = func;
914 elm_widget_data_set(Evas_Object *obj,
922 elm_widget_data_get(const Evas_Object *obj)
924 API_ENTRY return NULL;
929 elm_widget_sub_object_add(Evas_Object *obj,
933 double scale, pscale = elm_widget_scale_get(sobj);
934 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
935 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
937 if (sobj == sd->parent_obj)
939 elm_widget_sub_object_del(sobj, obj);
940 WRN("You passed a parent object of obj = %p as the sub object = %p!", obj, sobj);
943 if (_elm_widget_is(sobj))
945 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
948 if (sd2->parent_obj == obj)
951 elm_widget_sub_object_del(sd2->parent_obj, sobj);
952 sd2->parent_obj = obj;
953 sd2->top_win_focused = sd->top_win_focused;
954 if (!sd->child_can_focus && (_is_focusable(sobj)))
955 sd->child_can_focus = EINA_TRUE;
960 void *data = evas_object_data_get(sobj, "elm-parent");
963 if (data == obj) return;
964 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
968 sd->subobjs = eina_list_append(sd->subobjs, sobj);
969 evas_object_data_set(sobj, "elm-parent", obj);
970 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
971 if (_elm_widget_is(sobj))
972 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
973 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
974 scale = elm_widget_scale_get(sobj);
975 th = elm_widget_theme_get(sobj);
976 mirrored = elm_widget_mirrored_get(sobj);
977 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
978 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
982 elm_widget_sub_object_del(Evas_Object *obj,
985 Evas_Object *sobj_parent;
989 sobj_parent = evas_object_data_del(sobj, "elm-parent");
990 if (sobj_parent != obj)
992 static int abort_on_warn = -1;
993 ERR("removing sub object %p (%s) from parent %p (%s), "
994 "but elm-parent is different %p (%s)!",
995 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
996 sobj_parent, elm_widget_type_get(sobj_parent));
997 if (EINA_UNLIKELY(abort_on_warn == -1))
999 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
1000 else abort_on_warn = 0;
1002 if (abort_on_warn == 1) abort();
1004 if (_elm_widget_is(sobj))
1006 if (elm_widget_focus_get(sobj))
1008 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1009 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1011 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1013 Evas_Object *subobj;
1015 sd->child_can_focus = EINA_FALSE;
1016 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1018 if (_is_focusable(subobj))
1020 sd->child_can_focus = EINA_TRUE;
1025 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1028 sd2->parent_obj = NULL;
1029 if (sd2->resize_obj == sobj)
1030 sd2->resize_obj = NULL;
1032 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1035 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1038 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1039 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1041 if (_elm_widget_is(sobj))
1042 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1044 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1048 elm_widget_resize_object_set(Evas_Object *obj,
1052 // orphan previous resize obj
1055 evas_object_clip_unset(sd->resize_obj);
1056 evas_object_data_del(sd->resize_obj, "elm-parent");
1057 if (_elm_widget_is(sd->resize_obj))
1059 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1060 if (sd2) sd2->parent_obj = NULL;
1061 evas_object_event_callback_del_full(sd->resize_obj,
1065 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1067 evas_object_event_callback_del_full(sd->resize_obj,
1068 EVAS_CALLBACK_MOUSE_DOWN,
1069 _sub_obj_mouse_down, sd);
1070 evas_object_event_callback_del_full(sd->resize_obj,
1071 EVAS_CALLBACK_MOUSE_MOVE,
1072 _sub_obj_mouse_move, sd);
1073 evas_object_event_callback_del_full(sd->resize_obj,
1074 EVAS_CALLBACK_MOUSE_UP,
1075 _sub_obj_mouse_up, sd);
1076 evas_object_smart_member_del(sd->resize_obj);
1078 if (_elm_widget_is(sd->resize_obj))
1080 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1084 sd->resize_obj = sobj;
1087 // orphan new resize obj
1088 evas_object_data_del(sobj, "elm-parent");
1089 if (_elm_widget_is(sobj))
1091 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1092 if (sd2) sd2->parent_obj = NULL;
1093 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1096 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1098 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1099 _sub_obj_mouse_down, sd);
1100 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1101 _sub_obj_mouse_move, sd);
1102 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1103 _sub_obj_mouse_up, sd);
1104 evas_object_smart_member_del(sobj);
1105 if (_elm_widget_is(sobj))
1107 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1110 // set the resize obj up
1111 if (_elm_widget_is(sobj))
1113 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1116 sd2->parent_obj = obj;
1117 sd2->top_win_focused = sd->top_win_focused;
1119 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1122 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1123 evas_object_smart_member_add(sobj, obj);
1124 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1126 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1127 _sub_obj_mouse_down, sd);
1128 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1129 _sub_obj_mouse_move, sd);
1130 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1131 _sub_obj_mouse_up, sd);
1132 _smart_reconfigure(sd);
1133 evas_object_data_set(sobj, "elm-parent", obj);
1134 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1135 if (_elm_widget_is(sobj))
1137 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1142 elm_widget_hover_object_set(Evas_Object *obj,
1148 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1151 sd->hover_obj = sobj;
1154 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1156 _smart_reconfigure(sd);
1161 elm_widget_can_focus_set(Evas_Object *obj,
1162 Eina_Bool can_focus)
1166 can_focus = !!can_focus;
1168 if (sd->can_focus == can_focus) return;
1169 sd->can_focus = can_focus;
1172 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1174 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1175 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1177 (void *)(long)EVAS_CALLBACK_KEY_UP);
1178 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1180 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1184 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1186 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1188 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1194 elm_widget_can_focus_get(const Evas_Object *obj)
1196 API_ENTRY return EINA_FALSE;
1197 return sd->can_focus;
1201 elm_widget_child_can_focus_get(const Evas_Object *obj)
1203 API_ENTRY return EINA_FALSE;
1204 return sd->child_can_focus;
1210 * This API makes the widget object and its children to be unfocusable.
1212 * This API can be helpful for an object to be deleted.
1213 * When an object will be deleted soon, it and its children may not
1214 * want to get focus (by focus reverting or by other focus controls).
1215 * Then, just use this API before deleting.
1217 * @param obj The widget root of sub-tree
1218 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1223 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1224 Eina_Bool tree_unfocusable)
1228 tree_unfocusable = !!tree_unfocusable;
1229 if (sd->tree_unfocusable == tree_unfocusable) return;
1230 sd->tree_unfocusable = tree_unfocusable;
1231 elm_widget_focus_tree_unfocusable_handle(obj);
1237 * This returns true, if the object sub-tree is unfocusable.
1239 * @param obj The widget root of sub-tree
1240 * @return EINA_TRUE if the object sub-tree is unfocusable
1245 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1247 API_ENTRY return EINA_FALSE;
1248 return sd->tree_unfocusable;
1254 * Get the list of focusable child objects.
1256 * This function retruns list of child objects which can get focus.
1258 * @param obj The parent widget
1259 * @retrun list of focusable child objects.
1264 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1266 API_ENTRY return NULL;
1269 Eina_List *child_list = NULL;
1274 EINA_LIST_FOREACH(sd->subobjs, l, child)
1276 if ((elm_widget_can_focus_get(child)) &&
1277 (evas_object_visible_get(child)) &&
1278 (!elm_widget_disabled_get(child)))
1279 child_list = eina_list_append(child_list, child);
1280 else if (elm_widget_is(child))
1282 Eina_List *can_focus_list;
1283 can_focus_list = elm_widget_can_focus_child_list_get(child);
1285 child_list = eina_list_merge(child_list, can_focus_list);
1293 elm_widget_highlight_ignore_set(Evas_Object *obj,
1297 sd->highlight_ignore = !!ignore;
1301 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1303 API_ENTRY return EINA_FALSE;
1304 return sd->highlight_ignore;
1308 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1309 Eina_Bool highlight)
1312 sd->highlight_in_theme = !!highlight;
1313 /* FIXME: if focused, it should switch from one mode to the other */
1317 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1319 API_ENTRY return EINA_FALSE;
1320 return sd->highlight_in_theme;
1324 elm_widget_focus_get(const Evas_Object *obj)
1326 API_ENTRY return EINA_FALSE;
1331 elm_widget_focused_object_get(const Evas_Object *obj)
1333 const Evas_Object *subobj;
1335 API_ENTRY return NULL;
1337 if (!sd->focused) return NULL;
1338 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1340 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1341 if (fobj) return fobj;
1343 return (Evas_Object *)obj;
1347 elm_widget_top_get(const Evas_Object *obj)
1349 API_ENTRY return NULL;
1350 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1351 return (Evas_Object *)obj;
1355 elm_widget_is(const Evas_Object *obj)
1357 return _elm_widget_is(obj);
1361 elm_widget_parent_widget_get(const Evas_Object *obj)
1363 Evas_Object *parent;
1365 if (_elm_widget_is(obj))
1367 Smart_Data *sd = evas_object_smart_data_get(obj);
1368 if (!sd) return NULL;
1369 parent = sd->parent_obj;
1373 parent = evas_object_data_get(obj, "elm-parent");
1374 if (!parent) parent = evas_object_smart_parent_get(obj);
1379 Evas_Object *elm_parent;
1380 if (_elm_widget_is(parent)) break;
1381 elm_parent = evas_object_data_get(parent, "elm-parent");
1382 if (elm_parent) parent = elm_parent;
1383 else parent = evas_object_smart_parent_get(parent);
1389 elm_widget_parent2_get(const Evas_Object *obj)
1391 if (_elm_widget_is(obj))
1393 Smart_Data *sd = evas_object_smart_data_get(obj);
1394 if (sd) return sd->parent2;
1400 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1403 sd->parent2 = parent;
1407 elm_widget_event_callback_add(Evas_Object *obj,
1412 EINA_SAFETY_ON_NULL_RETURN(func);
1413 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1416 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1420 elm_widget_event_callback_del(Evas_Object *obj,
1424 API_ENTRY return NULL;
1425 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1427 Elm_Event_Cb_Data *ecd;
1428 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1429 if ((ecd->func == func) && (ecd->data == data))
1432 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1433 return (void *)data;
1439 elm_widget_event_propagate(Evas_Object *obj,
1440 Evas_Callback_Type type,
1442 Evas_Event_Flags *event_flags)
1444 API_ENTRY return EINA_FALSE; //TODO reduce.
1445 if (!_elm_widget_is(obj)) return EINA_FALSE;
1446 Evas_Object *parent = obj;
1447 Elm_Event_Cb_Data *ecd;
1448 Eina_List *l, *l_prev;
1451 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1453 sd = evas_object_smart_data_get(parent);
1454 if ((!sd) || (!_elm_widget_is(obj)))
1455 return EINA_FALSE; //Not Elm Widget
1457 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1460 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1462 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1463 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1466 parent = sd->parent_obj;
1475 * Set custom focus chain.
1477 * This function i set one new and overwrite any previous custom focus chain
1478 * with the list of objects. The previous list will be deleted and this list
1479 * will be managed. After setted, don't modity it.
1481 * @note On focus cycle, only will be evaluated children of this container.
1483 * @param obj The container widget
1484 * @param objs Chain of objects to pass focus
1488 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1492 if (!sd->focus_next_func)
1495 elm_widget_focus_custom_chain_unset(obj);
1500 EINA_LIST_FOREACH(objs, l, o)
1502 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1503 _elm_object_focus_chain_del_cb, sd);
1506 sd->focus_chain = objs;
1512 * Get custom focus chain
1514 * @param obj The container widget
1517 EAPI const Eina_List *
1518 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1520 API_ENTRY return NULL;
1521 return (const Eina_List *)sd->focus_chain;
1527 * Unset custom focus chain
1529 * @param obj The container widget
1533 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1536 Eina_List *l, *l_next;
1539 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1541 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1542 _elm_object_focus_chain_del_cb, sd);
1543 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1550 * Append object to custom focus chain.
1552 * @note If relative_child equal to NULL or not in custom chain, the object
1553 * will be added in end.
1555 * @note On focus cycle, only will be evaluated children of this container.
1557 * @param obj The container widget
1558 * @param child The child to be added in custom chain
1559 * @param relative_child The relative object to position the child
1563 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1565 Evas_Object *relative_child)
1568 EINA_SAFETY_ON_NULL_RETURN(child);
1569 if (!sd->focus_next_func) return;
1571 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1572 _elm_object_focus_chain_del_cb, sd);
1574 if (!relative_child)
1575 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1577 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1578 child, relative_child);
1584 * Prepend object to custom focus chain.
1586 * @note If relative_child equal to NULL or not in custom chain, the object
1587 * will be added in begin.
1589 * @note On focus cycle, only will be evaluated children of this container.
1591 * @param obj The container widget
1592 * @param child The child to be added in custom chain
1593 * @param relative_child The relative object to position the child
1597 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1599 Evas_Object *relative_child)
1602 EINA_SAFETY_ON_NULL_RETURN(child);
1604 if (!sd->focus_next_func) return;
1606 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1607 _elm_object_focus_chain_del_cb, sd);
1609 if (!relative_child)
1610 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1612 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1613 child, relative_child);
1619 * Give focus to next object in object tree.
1621 * Give focus to next object in focus chain of one object sub-tree.
1622 * If the last object of chain already have focus, the focus will go to the
1623 * first object of chain.
1625 * @param obj The widget root of sub-tree
1626 * @param dir Direction to cycle the focus
1631 elm_widget_focus_cycle(Evas_Object *obj,
1632 Elm_Focus_Direction dir)
1634 Evas_Object *target = NULL;
1635 if (!_elm_widget_is(obj))
1637 elm_widget_focus_next_get(obj, dir, &target);
1639 elm_widget_focus_steal(target);
1645 * Give focus to near object in one direction.
1647 * Give focus to near object in direction of one object.
1648 * If none focusable object in given direction, the focus will not change.
1650 * @param obj The reference widget
1651 * @param x Horizontal component of direction to focus
1652 * @param y Vertical component of direction to focus
1656 //XXX: If x, y indicates the elements of the directional vector,
1657 //It would be better if these values are the normalized value(float x, float y)
1659 EINA_DEPRECATED EAPI void
1660 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1670 * Get next object in focus chain of object tree.
1672 * Get next object in focus chain of one object sub-tree.
1673 * Return the next object by reference. If don't have any candidate to receive
1674 * focus before chain end, the first candidate will be returned.
1676 * @param obj The widget root of sub-tree
1677 * @param dir Direction os focus chain
1678 * @param next The next object in focus chain
1679 * @return EINA_TRUE if don't need focus chain restart/loop back
1680 * to use 'next' obj.
1685 elm_widget_focus_next_get(const Evas_Object *obj,
1686 Elm_Focus_Direction dir,
1693 API_ENTRY return EINA_FALSE;
1695 /* Ignore if disabled */
1696 if ((!evas_object_visible_get(obj))
1697 || (elm_widget_disabled_get(obj))
1698 || (elm_widget_tree_unfocusable_get(obj)))
1702 if (sd->focus_next_func)
1703 return sd->focus_next_func(obj, dir, next);
1705 if (!elm_widget_can_focus_get(obj))
1709 *next = (Evas_Object *)obj;
1710 return !elm_widget_focus_get(obj);
1716 * Get next object in focus chain of object tree in list.
1718 * Get next object in focus chain of one object sub-tree ordered by one list.
1719 * Return the next object by reference. If don't have any candidate to receive
1720 * focus before list end, the first candidate will be returned.
1722 * @param obj The widget root of sub-tree
1723 * @param dir Direction os focus chain
1724 * @param items list with ordered objects
1725 * @param list_data_get function to get the object from one item of list
1726 * @param next The next object in focus chain
1727 * @return EINA_TRUE if don't need focus chain restart/loop back
1728 * to use 'next' obj.
1733 elm_widget_focus_list_next_get(const Evas_Object *obj,
1734 const Eina_List *items,
1735 void *(*list_data_get)(const Eina_List * list),
1736 Elm_Focus_Direction dir,
1739 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1745 if (!_elm_widget_is(obj))
1752 if (dir == ELM_FOCUS_PREVIOUS)
1754 items = eina_list_last(items);
1755 list_next = eina_list_prev;
1757 else if (dir == ELM_FOCUS_NEXT)
1758 list_next = eina_list_next;
1762 const Eina_List *l = items;
1764 /* Recovery last focused sub item */
1765 if (elm_widget_focus_get(obj))
1766 for (; l; l = list_next(l))
1768 Evas_Object *cur = list_data_get(l);
1769 if (elm_widget_focus_get(cur)) break;
1772 const Eina_List *start = l;
1773 Evas_Object *to_focus = NULL;
1775 /* Interate sub items */
1776 /* Go to end of list */
1777 for (; l; l = list_next(l))
1779 Evas_Object *tmp = NULL;
1780 Evas_Object *cur = list_data_get(l);
1782 if (elm_widget_parent_get(cur) != obj)
1785 /* Try Focus cycle in subitem */
1786 if (elm_widget_focus_next_get(cur, dir, &tmp))
1791 else if ((tmp) && (!to_focus))
1797 /* Get First possible */
1798 for (; l != start; l = list_next(l))
1800 Evas_Object *tmp = NULL;
1801 Evas_Object *cur = list_data_get(l);
1803 if (elm_widget_parent_get(cur) != obj)
1806 /* Try Focus cycle in subitem */
1807 elm_widget_focus_next_get(cur, dir, &tmp);
1820 elm_widget_signal_emit(Evas_Object *obj,
1821 const char *emission,
1825 if (!sd->signal_func) return;
1826 sd->signal_func(obj, emission, source);
1830 _edje_signal_callback(void *data,
1831 Evas_Object *obj __UNUSED__,
1832 const char *emission,
1835 Edje_Signal_Data *esd = data;
1836 esd->func(esd->data, esd->obj, emission, source);
1840 elm_widget_signal_callback_add(Evas_Object *obj,
1841 const char *emission,
1843 Edje_Signal_Cb func,
1846 Edje_Signal_Data *esd;
1848 if (!sd->callback_add_func) return;
1849 EINA_SAFETY_ON_NULL_RETURN(func);
1851 esd = ELM_NEW(Edje_Signal_Data);
1856 esd->emission = eina_stringshare_add(emission);
1857 esd->source = eina_stringshare_add(source);
1859 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1860 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1864 elm_widget_signal_callback_del(Evas_Object *obj,
1865 const char *emission,
1867 Edje_Signal_Cb func)
1869 Edje_Signal_Data *esd;
1872 API_ENTRY return NULL;
1873 if (!sd->callback_del_func) return NULL;
1875 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1877 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1878 (!strcmp(esd->source, source)))
1880 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1881 eina_stringshare_del(esd->emission);
1882 eina_stringshare_del(esd->source);
1888 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1893 elm_widget_focus_set(Evas_Object *obj,
1900 sd->focus_order = focus_order;
1901 sd->focused = EINA_TRUE;
1902 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1906 sd->focus_func(obj);
1913 if ((_is_focusable(sd->resize_obj)) &&
1914 (!elm_widget_disabled_get(sd->resize_obj)))
1916 elm_widget_focus_set(sd->resize_obj, first);
1922 EINA_LIST_FOREACH(sd->subobjs, l, child)
1924 if ((_is_focusable(child)) &&
1925 (!elm_widget_disabled_get(child)))
1927 elm_widget_focus_set(child, first);
1937 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1939 if ((_is_focusable(child)) &&
1940 (!elm_widget_disabled_get(child)))
1942 elm_widget_focus_set(child, first);
1948 if ((_is_focusable(sd->resize_obj)) &&
1949 (!elm_widget_disabled_get(sd->resize_obj)))
1951 elm_widget_focus_set(sd->resize_obj, first);
1959 elm_widget_parent_get(const Evas_Object *obj)
1961 API_ENTRY return NULL;
1962 return sd->parent_obj;
1966 elm_widget_focused_object_clear(Evas_Object *obj)
1969 if (!sd->focused) return;
1970 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
1971 elm_widget_focused_object_clear(sd->resize_obj);
1976 EINA_LIST_FOREACH(sd->subobjs, l, child)
1978 if (elm_widget_focus_get(child))
1980 elm_widget_focused_object_clear(child);
1985 sd->focused = EINA_FALSE;
1986 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1987 if (sd->focus_func) sd->focus_func(obj);
1991 elm_widget_focus_steal(Evas_Object *obj)
1993 Evas_Object *parent, *parent2, *o;
1996 if (sd->focused) return;
1997 if (sd->disabled) return;
1998 if (!sd->can_focus) return;
1999 if (sd->tree_unfocusable) return;
2003 o = elm_widget_parent_get(parent);
2005 sd = evas_object_smart_data_get(o);
2006 if (sd->disabled || sd->tree_unfocusable) return;
2007 if (sd->focused) break;
2010 if ((!elm_widget_parent_get(parent)) &&
2011 (!elm_widget_parent2_get(parent)))
2012 elm_widget_focused_object_clear(parent);
2015 parent2 = elm_widget_parent_get(parent);
2016 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2018 sd = evas_object_smart_data_get(parent);
2021 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2022 elm_widget_focused_object_clear(sd->resize_obj);
2027 EINA_LIST_FOREACH(sd->subobjs, l, child)
2029 if (elm_widget_focus_get(child))
2031 elm_widget_focused_object_clear(child);
2043 elm_widget_focus_restore(Evas_Object *obj)
2045 Evas_Object *newest = NULL;
2046 unsigned int newest_focus_order = 0;
2049 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2052 elm_object_focus_set(newest, EINA_FALSE);
2053 elm_object_focus_set(newest, EINA_TRUE);
2058 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
2064 if (sd->top_win_focused == top_win_focused) return;
2066 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2067 EINA_LIST_FOREACH(sd->subobjs, l, child)
2069 _elm_widget_top_win_focused_set(child, top_win_focused);
2071 sd->top_win_focused = top_win_focused;
2075 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2077 API_ENTRY return EINA_FALSE;
2078 return sd->top_win_focused;
2082 elm_widget_activate(Evas_Object *obj)
2085 elm_widget_change(obj);
2086 if (sd->activate_func) sd->activate_func(obj);
2090 elm_widget_change(Evas_Object *obj)
2093 elm_widget_change(elm_widget_parent_get(obj));
2094 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2098 elm_widget_disabled_set(Evas_Object *obj,
2103 if (sd->disabled == disabled) return;
2104 sd->disabled = !!disabled;
2105 elm_widget_focus_disabled_handle(obj);
2106 if (sd->disable_func) sd->disable_func(obj);
2110 elm_widget_disabled_get(const Evas_Object *obj)
2113 return sd->disabled;
2117 elm_widget_show_region_set(Evas_Object *obj,
2122 Eina_Bool forceshow)
2124 Evas_Object *parent_obj, *child_obj;
2125 Evas_Coord px, py, cx, cy;
2129 evas_smart_objects_calculate(evas_object_evas_get(obj));
2131 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2132 (w == sd->rw) && (h == sd->rh)) return;
2137 if (sd->on_show_region_func)
2138 sd->on_show_region_func(sd->on_show_region_data, obj);
2142 parent_obj = sd->parent_obj;
2143 child_obj = sd->obj;
2144 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2145 sd = evas_object_smart_data_get(parent_obj);
2148 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2149 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2158 if (sd->on_show_region_func)
2160 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2167 elm_widget_show_region_get(const Evas_Object *obj,
2183 * Get the focus region of the given widget.
2185 * The focus region is the area of a widget that should brought into the
2186 * visible area when the widget is focused. Mostly used to show the part of
2187 * an entry where the cursor is, for example. The area returned is relative
2188 * to the object @p obj.
2189 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2190 * function will return the full size of the object.
2192 * @param obj The widget object
2193 * @param x Where to store the x coordinate of the area
2194 * @param y Where to store the y coordinate of the area
2195 * @param w Where to store the width of the area
2196 * @param h Where to store the height of the area
2201 elm_widget_focus_region_get(const Evas_Object *obj,
2211 sd = evas_object_smart_data_get(obj);
2212 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2214 evas_object_geometry_get(obj, NULL, NULL, w, h);
2219 sd->on_focus_region_func(obj, x, y, w, h);
2223 elm_widget_scroll_hold_push(Evas_Object *obj)
2227 if (sd->scroll_hold == 1)
2228 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2229 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2230 // FIXME: on delete/reparent hold pop
2234 elm_widget_scroll_hold_pop(Evas_Object *obj)
2238 if (!sd->scroll_hold)
2239 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2240 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2241 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2245 elm_widget_scroll_hold_get(const Evas_Object *obj)
2248 return sd->scroll_hold;
2252 elm_widget_scroll_freeze_push(Evas_Object *obj)
2255 sd->scroll_freeze++;
2256 if (sd->scroll_freeze == 1)
2257 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2258 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2259 // FIXME: on delete/reparent freeze pop
2263 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2266 sd->scroll_freeze--;
2267 if (!sd->scroll_freeze)
2268 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2269 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2270 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2274 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2277 return sd->scroll_freeze;
2281 elm_widget_scale_set(Evas_Object *obj,
2285 if (scale <= 0.0) scale = 0.0;
2286 if (sd->scale != scale)
2289 elm_widget_theme(obj);
2294 elm_widget_scale_get(const Evas_Object *obj)
2296 API_ENTRY return 1.0;
2297 // FIXME: save walking up the tree by storing/caching parent scale
2298 if (sd->scale == 0.0)
2301 return elm_widget_scale_get(sd->parent_obj);
2309 elm_widget_theme_set(Evas_Object *obj,
2313 if (sd->theme != th)
2315 if (sd->theme) elm_theme_free(sd->theme);
2318 elm_widget_theme(obj);
2323 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2327 if (!sd->text_set_func)
2330 sd->text_set_func(obj, part, label);
2334 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2336 API_ENTRY return NULL;
2338 if (!sd->text_get_func)
2341 return sd->text_get_func(obj, part);
2345 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2349 Elm_Translate_String_Data *ts = NULL;
2352 str = eina_stringshare_add(part);
2353 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2360 eina_stringshare_del(str);
2363 ts = malloc(sizeof(Elm_Translate_String_Data));
2367 ts->domain = eina_stringshare_add(domain);
2368 ts->string = eina_stringshare_add(label);
2369 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2375 eina_stringshare_replace(&ts->domain, domain);
2376 eina_stringshare_replace(&ts->string, label);
2380 sd->translate_strings = eina_list_remove_list(
2381 sd->translate_strings, l);
2382 eina_stringshare_del(ts->id);
2383 eina_stringshare_del(ts->domain);
2384 eina_stringshare_del(ts->string);
2387 eina_stringshare_del(str);
2391 if (label && label[0])
2392 label = dgettext(domain, label);
2394 elm_widget_text_part_set(obj, part, label);
2398 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2400 const char *str, *ret = NULL;
2402 Elm_Translate_String_Data *ts;
2403 API_ENTRY return NULL;
2405 str = eina_stringshare_add(part);
2406 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2412 eina_stringshare_del(str);
2417 elm_widget_translate(Evas_Object *obj)
2422 Elm_Translate_String_Data *ts;
2426 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2427 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2428 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2429 if (sd->translate_func) sd->translate_func(obj);
2432 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2434 const char *s = dgettext(ts->domain, ts->string);
2435 elm_widget_text_part_set(obj, ts->id, s);
2441 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2445 if (!sd->content_set_func) return;
2446 sd->content_set_func(obj, part, content);
2450 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2452 API_ENTRY return NULL;
2454 if (!sd->content_get_func) return NULL;
2455 return sd->content_get_func(obj, part);
2459 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2461 API_ENTRY return NULL;
2463 if (!sd->content_unset_func) return NULL;
2464 return sd->content_unset_func(obj, part);
2468 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2471 if (sd->access_info) eina_stringshare_del(sd->access_info);
2472 if (!txt) sd->access_info = NULL;
2473 else sd->access_info = eina_stringshare_add(txt);
2477 elm_widget_access_info_get(const Evas_Object *obj)
2479 API_ENTRY return NULL;
2480 return sd->access_info;
2484 elm_widget_theme_get(const Evas_Object *obj)
2486 API_ENTRY return NULL;
2490 return elm_widget_theme_get(sd->parent_obj);
2498 elm_widget_style_set(Evas_Object *obj,
2501 API_ENTRY return EINA_FALSE;
2503 if (eina_stringshare_replace(&sd->style, style))
2504 return elm_widget_theme(obj);
2510 elm_widget_style_get(const Evas_Object *obj)
2512 API_ENTRY return NULL;
2513 if (sd->style) return sd->style;
2518 elm_widget_type_set(Evas_Object *obj,
2522 eina_stringshare_replace(&sd->type, type);
2526 elm_widget_type_get(const Evas_Object *obj)
2528 API_ENTRY return NULL;
2529 if (sd->type) return sd->type;
2534 elm_widget_tooltip_add(Evas_Object *obj,
2538 sd->tooltips = eina_list_append(sd->tooltips, tt);
2542 elm_widget_tooltip_del(Evas_Object *obj,
2546 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2550 elm_widget_cursor_add(Evas_Object *obj,
2554 sd->cursors = eina_list_append(sd->cursors, cur);
2558 elm_widget_cursor_del(Evas_Object *obj,
2562 sd->cursors = eina_list_remove(sd->cursors, cur);
2566 elm_widget_drag_lock_x_set(Evas_Object *obj,
2570 if (sd->drag_x_locked == lock) return;
2571 sd->drag_x_locked = lock;
2572 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2573 else _propagate_x_drag_lock(obj, -1);
2577 elm_widget_drag_lock_y_set(Evas_Object *obj,
2581 if (sd->drag_y_locked == lock) return;
2582 sd->drag_y_locked = lock;
2583 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2584 else _propagate_y_drag_lock(obj, -1);
2588 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2590 API_ENTRY return EINA_FALSE;
2591 return sd->drag_x_locked;
2595 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2597 API_ENTRY return EINA_FALSE;
2598 return sd->drag_y_locked;
2602 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2605 return sd->child_drag_x_locked;
2609 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2612 return sd->child_drag_y_locked;
2616 elm_widget_theme_object_set(Evas_Object *obj,
2619 const char *welement,
2622 API_ENTRY return EINA_FALSE;
2623 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2627 elm_widget_is_check(const Evas_Object *obj)
2629 static int abort_on_warn = -1;
2630 if (elm_widget_is(obj))
2633 ERR("Passing Object: %p.", obj);
2634 if (abort_on_warn == -1)
2636 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2637 else abort_on_warn = 0;
2639 if (abort_on_warn == 1) abort();
2644 elm_widget_type_check(const Evas_Object *obj,
2648 const char *provided, *expected = "(unknown)";
2649 static int abort_on_warn = -1;
2650 provided = elm_widget_type_get(obj);
2651 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2652 if (type) expected = type;
2653 if ((!provided) || (!provided[0]))
2655 provided = evas_object_type_get(obj);
2656 if ((!provided) || (!provided[0]))
2657 provided = "(unknown)";
2659 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2660 if (abort_on_warn == -1)
2662 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2663 else abort_on_warn = 0;
2665 if (abort_on_warn == 1) abort();
2669 static Evas_Object *
2670 _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2675 INTERNAL_ENTRY NULL;
2677 if (!_elm_widget_is(obj)) return NULL;
2680 s = evas_object_name_get(sd->resize_obj);
2681 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
2682 if ((recurse != 0) &&
2683 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
2686 EINA_LIST_FOREACH(sd->subobjs, l, child)
2688 s = evas_object_name_get(child);
2689 if ((s) && (!strcmp(s, name))) return child;
2690 if ((recurse != 0) &&
2691 ((child = _widget_name_find(child, name, recurse - 1))))
2696 s = evas_object_name_get(sd->hover_obj);
2697 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
2698 if ((recurse != 0) &&
2699 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
2706 elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2708 API_ENTRY return NULL;
2709 if (!name) return NULL;
2710 return _widget_name_find(obj, name, recurse);
2716 * Split string in words
2718 * @param str Source string
2719 * @return List of const words
2721 * @see elm_widget_stringlist_free()
2725 elm_widget_stringlist_get(const char *str)
2727 Eina_List *list = NULL;
2729 if (!str) return NULL;
2730 for (b = s = str; 1; s++)
2732 if ((*s == ' ') || (!*s))
2734 char *t = malloc(s - b + 1);
2737 strncpy(t, b, s - b);
2739 list = eina_list_append(list, eina_stringshare_add(t));
2750 elm_widget_stringlist_free(Eina_List *list)
2753 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2757 elm_widget_focus_hide_handle(Evas_Object *obj)
2759 if (!_elm_widget_is(obj))
2761 _if_focused_revert(obj, EINA_TRUE);
2765 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2767 Evas_Object *o = obj;
2770 if (_elm_widget_is(o)) break;
2771 o = evas_object_smart_parent_get(o);
2775 if (!_is_focusable(o)) return;
2776 elm_widget_focus_steal(o);
2780 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2784 //FIXME: Need to check whether the object is unfocusable or not.
2786 if (!elm_widget_parent_get(obj))
2787 elm_widget_focused_object_clear(obj);
2789 _if_focused_revert(obj, EINA_TRUE);
2793 elm_widget_focus_disabled_handle(Evas_Object *obj)
2797 elm_widget_focus_tree_unfocusable_handle(obj);
2801 elm_widget_focus_order_get(const Evas_Object *obj)
2804 return sd->focus_order;
2810 * Allocate a new Elm_Widget_Item-derived structure.
2812 * The goal of this structure is to provide common ground for actions
2813 * that a widget item have, such as the owner widget, callback to
2814 * notify deletion, data pointer and maybe more.
2816 * @param widget the owner widget that holds this item, must be an elm_widget!
2817 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2818 * be used to allocate memory.
2820 * @return allocated memory that is already zeroed out, or NULL on errors.
2822 * @see elm_widget_item_new() convenience macro.
2823 * @see elm_widget_item_del() to release memory.
2826 EAPI Elm_Widget_Item *
2827 _elm_widget_item_new(Evas_Object *widget,
2830 if (!_elm_widget_is(widget))
2833 Elm_Widget_Item *item;
2835 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2836 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2838 item = calloc(1, alloc_size);
2839 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2841 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2842 item->widget = widget;
2847 _elm_widget_item_free(Elm_Widget_Item *item)
2849 ELM_WIDGET_ITEM_FREE_OR_RETURN(item);
2850 Elm_Object_Item_Smart_Cb cb;
2852 if (item->walking > 0)
2854 item->delete_me = EINA_TRUE;
2858 EINA_LIST_FREE(item->callbacks, cb) free(cb);
2861 item->del_func((void *)item->data, item->widget, item);
2864 evas_object_del(item->view);
2868 _elm_access_clear(item->access);
2872 if (item->access_info)
2873 eina_stringshare_del(item->access_info);
2875 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2882 * Releases widget item memory, calling back del_cb() if it exists.
2884 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2885 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2886 * this function and then unset it, thus being useful for 2 step
2887 * cleanup whenever the del_cb may use any of the data that must be
2888 * deleted from item.
2890 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2893 * @param item a valid #Elm_Widget_Item to be deleted.
2894 * @see elm_widget_item_del() convenience macro.
2898 _elm_widget_item_del(Elm_Widget_Item *item)
2900 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2902 //Widget item delete callback
2903 if (item->del_pre_func)
2905 if (item->del_pre_func((Elm_Object_Item *)item))
2906 _elm_widget_item_free(item);
2909 _elm_widget_item_free(item);
2915 * Set the function to notify to widgets when item is being deleted by user.
2917 * @param item a valid #Elm_Widget_Item to be notified
2918 * @see elm_widget_item_del_pre_hook_set() convenience macro.
2922 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func)
2924 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2925 item->del_pre_func = func;
2931 * Notify object will be deleted without actually deleting it.
2933 * This function will callback Elm_Widget_Item::del_cb if it is set
2934 * and then unset it so it is not called twice (ie: from
2935 * elm_widget_item_del()).
2937 * @param item a valid #Elm_Widget_Item to be notified
2938 * @see elm_widget_item_pre_notify_del() convenience macro.
2942 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2944 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2945 if (!item->del_func) return;
2946 item->del_func((void *)item->data, item->widget, item);
2947 item->del_func = NULL;
2953 * Set the function to notify when item is being deleted.
2955 * This function will complain if there was a callback set already,
2956 * however it will set the new one.
2958 * The callback will be called from elm_widget_item_pre_notify_del()
2959 * or elm_widget_item_del() will be called with:
2960 * - data: the Elm_Widget_Item::data value.
2961 * - obj: the Elm_Widget_Item::widget evas object.
2962 * - event_info: the item being deleted.
2964 * @param item a valid #Elm_Widget_Item to be notified
2965 * @see elm_widget_item_del_cb_set() convenience macro.
2969 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2972 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2974 if ((item->del_func) && (item->del_func != func))
2975 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2976 item->del_func, item, func);
2978 item->del_func = func;
2984 * Set user-data in this item.
2986 * User data may be used to identify this item or just store any
2987 * application data. It is automatically given as the first parameter
2988 * of the deletion notify callback.
2990 * @param item a valid #Elm_Widget_Item to store data in.
2991 * @param data user data to store.
2992 * @see elm_widget_item_del_cb_set() convenience macro.
2996 _elm_widget_item_data_set(Elm_Widget_Item *item,
2999 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3000 if ((item->data) && (item->data != data))
3001 DBG("Replacing item %p data %p with %p", item, item->data, data);
3008 * Retrieves user-data of this item.
3010 * @param item a valid #Elm_Widget_Item to get data from.
3011 * @see elm_widget_item_data_set()
3015 _elm_widget_item_data_get(const Elm_Widget_Item *item)
3017 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3018 return (void *)item->data;
3022 _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
3024 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3026 if (item->disabled == disabled) return;
3027 item->disabled = !!disabled;
3028 if (item->disable_func) item->disable_func(item);
3032 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3034 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3035 return item->disabled;
3039 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3040 Elm_Widget_Disable_Cb func)
3042 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3043 item->disable_func = func;
3046 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3048 struct _Elm_Widget_Item_Tooltip
3050 Elm_Widget_Item *item;
3051 Elm_Tooltip_Item_Content_Cb func;
3052 Evas_Smart_Cb del_cb;
3056 static Evas_Object *
3057 _elm_widget_item_tooltip_label_create(void *data,
3058 Evas_Object *obj __UNUSED__,
3059 Evas_Object *tooltip,
3060 void *item __UNUSED__)
3062 Evas_Object *label = elm_label_add(tooltip);
3065 elm_object_style_set(label, "tooltip");
3066 elm_object_text_set(label, data);
3070 static Evas_Object *
3071 _elm_widget_item_tooltip_trans_label_create(void *data,
3072 Evas_Object *obj __UNUSED__,
3073 Evas_Object *tooltip,
3074 void *item __UNUSED__)
3076 Evas_Object *label = elm_label_add(tooltip);
3079 elm_object_style_set(label, "tooltip");
3080 elm_object_translatable_text_set(label, data);
3085 _elm_widget_item_tooltip_label_del_cb(void *data,
3086 Evas_Object *obj __UNUSED__,
3087 void *event_info __UNUSED__)
3089 eina_stringshare_del(data);
3095 * Set the text to be shown in the widget item.
3097 * @param item Target item
3098 * @param text The text to set in the content
3100 * Setup the text as tooltip to object. The item can have only one tooltip,
3101 * so any previous tooltip data is removed.
3106 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3109 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3110 EINA_SAFETY_ON_NULL_RETURN(text);
3112 text = eina_stringshare_add(text);
3113 _elm_widget_item_tooltip_content_cb_set
3114 (item, _elm_widget_item_tooltip_label_create, text,
3115 _elm_widget_item_tooltip_label_del_cb);
3119 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3122 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3123 EINA_SAFETY_ON_NULL_RETURN(text);
3125 text = eina_stringshare_add(text);
3126 _elm_widget_item_tooltip_content_cb_set
3127 (item, _elm_widget_item_tooltip_trans_label_create, text,
3128 _elm_widget_item_tooltip_label_del_cb);
3131 static Evas_Object *
3132 _elm_widget_item_tooltip_create(void *data,
3134 Evas_Object *tooltip)
3136 Elm_Widget_Item_Tooltip *wit = data;
3137 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3141 _elm_widget_item_tooltip_del_cb(void *data,
3143 void *event_info __UNUSED__)
3145 Elm_Widget_Item_Tooltip *wit = data;
3146 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3153 * Set the content to be shown in the tooltip item
3155 * Setup the tooltip to item. The item can have only one tooltip,
3156 * so any previous tooltip data is removed. @p func(with @p data) will
3157 * be called every time that need show the tooltip and it should
3158 * return a valid Evas_Object. This object is then managed fully by
3159 * tooltip system and is deleted when the tooltip is gone.
3161 * @param item the widget item being attached a tooltip.
3162 * @param func the function used to create the tooltip contents.
3163 * @param data what to provide to @a func as callback data/context.
3164 * @param del_cb called when data is not needed anymore, either when
3165 * another callback replaces @func, the tooltip is unset with
3166 * elm_widget_item_tooltip_unset() or the owner @a item
3167 * dies. This callback receives as the first parameter the
3168 * given @a data, and @c event_info is the item.
3173 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3174 Elm_Tooltip_Item_Content_Cb func,
3176 Evas_Smart_Cb del_cb)
3178 Elm_Widget_Item_Tooltip *wit;
3180 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3184 _elm_widget_item_tooltip_unset(item);
3188 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3189 if (!wit) goto error;
3193 wit->del_cb = del_cb;
3195 elm_object_sub_tooltip_content_cb_set
3196 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3197 _elm_widget_item_tooltip_del_cb);
3202 if (del_cb) del_cb((void *)data, NULL, item);
3205 if (del_cb) del_cb((void *)data, item->widget, item);
3211 * Unset tooltip from item
3213 * @param item widget item to remove previously set tooltip.
3215 * Remove tooltip from item. The callback provided as del_cb to
3216 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3217 * it is not used anymore.
3219 * @see elm_widget_item_tooltip_content_cb_set()
3224 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3226 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3227 elm_object_tooltip_unset(item->view);
3233 * Sets a different style for this item tooltip.
3235 * @note before you set a style you should define a tooltip with
3236 * elm_widget_item_tooltip_content_cb_set() or
3237 * elm_widget_item_tooltip_text_set()
3239 * @param item widget item with tooltip already set.
3240 * @param style the theme style to use (default, transparent, ...)
3245 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3248 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3249 elm_object_tooltip_style_set(item->view, style);
3253 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
3255 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3256 return elm_object_tooltip_window_mode_set(item->view, disable);
3260 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
3262 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3263 return elm_object_tooltip_window_mode_get(item->view);
3269 * Get the style for this item tooltip.
3271 * @param item widget item with tooltip already set.
3272 * @return style the theme style in use, defaults to "default". If the
3273 * object does not have a tooltip set, then NULL is returned.
3278 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3280 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3281 return elm_object_tooltip_style_get(item->view);
3285 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3288 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3289 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3293 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3295 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3296 return elm_object_cursor_get(item->view);
3300 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3302 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3303 elm_object_cursor_unset(item->view);
3309 * Sets a different style for this item cursor.
3311 * @note before you set a style you should define a cursor with
3312 * elm_widget_item_cursor_set()
3314 * @param item widget item with cursor already set.
3315 * @param style the theme style to use (default, transparent, ...)
3320 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3323 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3324 elm_object_cursor_style_set(item->view, style);
3330 * Get the style for this item cursor.
3332 * @param item widget item with cursor already set.
3333 * @return style the theme style in use, defaults to "default". If the
3334 * object does not have a cursor set, then NULL is returned.
3339 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3341 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3342 return elm_object_cursor_style_get(item->view);
3348 * Set if the cursor set should be searched on the theme or should use
3349 * the provided by the engine, only.
3351 * @note before you set if should look on theme you should define a cursor
3352 * with elm_object_cursor_set(). By default it will only look for cursors
3353 * provided by the engine.
3355 * @param item widget item with cursor already set.
3356 * @param engine_only boolean to define it cursors should be looked only
3357 * between the provided by the engine or searched on widget's theme as well.
3362 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3363 Eina_Bool engine_only)
3365 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3366 elm_object_cursor_theme_search_enabled_set(item->view, engine_only);
3372 * Get the cursor engine only usage for this item cursor.
3374 * @param item widget item with cursor already set.
3375 * @return engine_only boolean to define it cursors should be looked only
3376 * between the provided by the engine or searched on widget's theme as well. If
3377 * the object does not have a cursor set, then EINA_FALSE is returned.
3382 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3384 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3385 return elm_object_cursor_theme_search_enabled_get(item->view);
3388 // smart object funcs
3390 _smart_reconfigure(Smart_Data *sd)
3394 evas_object_move(sd->resize_obj, sd->x, sd->y);
3395 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3399 evas_object_move(sd->hover_obj, sd->x, sd->y);
3400 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3405 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3407 Evas_Object *content)
3409 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3410 if (!item->content_set_func) return;
3411 item->content_set_func((Elm_Object_Item *)item, part, content);
3415 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3418 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3419 if (!item->content_get_func) return NULL;
3420 return item->content_get_func((Elm_Object_Item *)item, part);
3424 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3427 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3428 if (!item->content_unset_func) return NULL;
3429 return item->content_unset_func((Elm_Object_Item *)item, part);
3433 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3437 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3438 if (!item->text_set_func) return;
3439 item->text_set_func((Elm_Object_Item *)item, part, label);
3443 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3444 const char *emission,
3447 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3448 if (item->signal_emit_func)
3449 item->signal_emit_func((Elm_Object_Item *)item, emission, source);
3453 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3456 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3457 if (!item->text_get_func) return NULL;
3458 return item->text_get_func((Elm_Object_Item *)item, part);
3462 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3463 Elm_Widget_Content_Set_Cb func)
3465 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3466 item->content_set_func = func;
3470 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3471 Elm_Widget_Content_Get_Cb func)
3473 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3474 item->content_get_func = func;
3478 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3479 Elm_Widget_Content_Unset_Cb func)
3481 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3482 item->content_unset_func = func;
3486 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3487 Elm_Widget_Text_Set_Cb func)
3489 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3490 item->text_set_func = func;
3494 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3495 Elm_Widget_Text_Get_Cb func)
3497 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3498 item->text_get_func = func;
3502 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3503 Elm_Widget_Signal_Emit_Cb func)
3505 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3506 item->signal_emit_func = func;
3510 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3512 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3513 if (item->access_info) eina_stringshare_del(item->access_info);
3514 if (!txt) item->access_info = NULL;
3515 else item->access_info = eina_stringshare_add(txt);
3519 elm_widget_item_smart_callback_add(Elm_Widget_Item *item, const char *event, Elm_Object_Item_Smart_Cb func, const void *data)
3521 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3522 if ((!event) || (!func)) return;
3524 Elm_Widget_Item_Callback *cb = ELM_NEW(Elm_Widget_Item_Callback);
3527 //TODO: apply MEMPOOL?
3528 cb->event = eina_stringshare_add(event);
3530 cb->data = (void *)data;
3531 item->callbacks = eina_list_append(item->callbacks, cb);
3535 elm_widget_item_smart_callback_del(Elm_Widget_Item *item, const char *event, Elm_Object_Item_Smart_Cb func)
3537 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3539 Eina_List *l, *l_next;
3540 Elm_Widget_Item_Callback *cb;
3542 if ((!event) || (!func)) return NULL;
3544 EINA_LIST_FOREACH_SAFE(item->callbacks, l, l_next, cb)
3546 if ((!strcmp(cb->event, event)) && (cb->func == func))
3548 void *data = cb->data;
3551 item->callbacks = eina_list_remove_list(item->callbacks, l);
3555 cb->delete_me = EINA_TRUE;
3563 _elm_widget_item_smart_callback_call(Elm_Widget_Item *item, const char *event, void *event_info)
3565 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3567 Eina_List *l, *l_next;
3568 Elm_Widget_Item_Callback *cb;
3569 const char *strshare;
3573 strshare = eina_stringshare_add(event);
3575 EINA_LIST_FOREACH(item->callbacks, l, cb)
3577 if (strcmp(cb->event, strshare)) continue;
3578 if (cb->delete_me) continue;
3581 cb->func(cb->data, (Elm_Object_Item *)item, event_info);
3584 if (item->delete_me) break;
3588 EINA_LIST_FOREACH_SAFE(item->callbacks, l, l_next, cb)
3590 if (!cb->delete_me) continue;
3591 item->callbacks = eina_list_remove_list(item->callbacks, l);
3595 if (item->delete_me && !item->walking)
3596 elm_widget_item_free(item);
3600 _smart_add(Evas_Object *obj)
3604 sd = calloc(1, sizeof(Smart_Data));
3607 sd->x = sd->y = sd->w = sd->h = 0;
3608 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3609 evas_object_smart_data_set(obj, sd);
3610 elm_widget_can_focus_set(obj, EINA_TRUE);
3613 static Evas_Object *
3614 _newest_focus_order_get(Evas_Object *obj,
3615 unsigned int *newest_focus_order,
3616 Eina_Bool can_focus_only)
3619 Evas_Object *child, *ret, *best;
3621 API_ENTRY return NULL;
3623 if (!evas_object_visible_get(obj)
3624 || (elm_widget_disabled_get(obj))
3625 || (elm_widget_tree_unfocusable_get(obj)))
3629 if (*newest_focus_order < sd->focus_order)
3631 *newest_focus_order = sd->focus_order;
3634 EINA_LIST_FOREACH(sd->subobjs, l, child)
3636 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3642 if ((!best) || (!elm_widget_can_focus_get(best)))
3649 _if_focused_revert(Evas_Object *obj,
3650 Eina_Bool can_focus_only)
3653 Evas_Object *newest = NULL;
3654 unsigned int newest_focus_order = 0;
3658 if (!sd->focused) return;
3659 if (!sd->parent_obj) return;
3661 top = elm_widget_top_get(sd->parent_obj);
3664 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3667 elm_object_focus_set(newest, EINA_FALSE);
3668 elm_object_focus_set(newest, EINA_TRUE);
3674 _smart_del(Evas_Object *obj)
3677 Edje_Signal_Data *esd;
3678 Elm_Translate_String_Data *ts;
3682 if (sd->del_pre_func) sd->del_pre_func(obj);
3685 sobj = sd->resize_obj;
3686 sd->resize_obj = NULL;
3687 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3688 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3689 evas_object_del(sobj);
3690 sd->resize_obj = NULL;
3694 sobj = sd->hover_obj;
3695 sd->hover_obj = NULL;
3696 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3697 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3698 evas_object_del(sobj);
3699 sd->hover_obj = NULL;
3701 EINA_LIST_FREE(sd->subobjs, sobj)
3703 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3704 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3705 evas_object_del(sobj);
3707 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3708 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3709 EINA_LIST_FREE(sd->edje_signals, esd)
3711 eina_stringshare_del(esd->emission);
3712 eina_stringshare_del(esd->source);
3715 EINA_LIST_FREE(sd->translate_strings, ts)
3717 eina_stringshare_del(ts->id);
3718 eina_stringshare_del(ts->domain);
3719 eina_stringshare_del(ts->string);
3722 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3723 if (sd->del_func) sd->del_func(obj);
3724 if (sd->style) eina_stringshare_del(sd->style);
3725 if (sd->type) eina_stringshare_del(sd->type);
3726 if (sd->theme) elm_theme_free(sd->theme);
3728 _if_focused_revert(obj, EINA_TRUE);
3729 if (sd->access_info) eina_stringshare_del(sd->access_info);
3731 evas_object_smart_data_set(obj, NULL);
3735 _smart_move(Evas_Object *obj,
3742 _smart_reconfigure(sd);
3746 _smart_resize(Evas_Object *obj,
3753 _smart_reconfigure(sd);
3757 _smart_show(Evas_Object *obj)
3762 if ((list = evas_object_smart_members_get(obj)))
3764 EINA_LIST_FREE(list, o)
3766 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3767 evas_object_show(o);
3773 _smart_hide(Evas_Object *obj)
3779 list = evas_object_smart_members_get(obj);
3780 EINA_LIST_FREE(list, o)
3782 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3783 evas_object_hide(o);
3788 _smart_color_set(Evas_Object *obj,
3797 if ((list = evas_object_smart_members_get(obj)))
3799 EINA_LIST_FREE(list, o)
3801 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3802 evas_object_color_set(o, r, g, b, a);
3808 _smart_clip_set(Evas_Object *obj,
3814 if ((list = evas_object_smart_members_get(obj)))
3816 EINA_LIST_FREE(list, o)
3818 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3819 evas_object_clip_set(o, clip);
3825 _smart_clip_unset(Evas_Object *obj)
3830 if ((list = evas_object_smart_members_get(obj)))
3832 EINA_LIST_FREE(list, o)
3834 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3835 evas_object_clip_unset(o);
3841 _smart_calculate(Evas_Object *obj)
3844 if (sd->changed_func) sd->changed_func(obj);
3847 /* never need to touch this */
3851 if (_e_smart) return;
3853 static const Evas_Smart_Class sc =
3856 EVAS_SMART_CLASS_VERSION,
3874 _e_smart = evas_smart_class_new(&sc);
3878 /* happy debug functions */
3881 _sub_obj_tree_dump(const Evas_Object *obj,
3886 for (i = 0; i < lvl * 3; i++)
3889 if (_elm_widget_is(obj))
3893 printf("+ %s(%p)\n",
3897 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3898 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3900 if (obj != sd->resize_obj)
3901 _sub_obj_tree_dump(obj, lvl + 1);
3905 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3909 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3912 if (!_elm_widget_is(obj))
3916 Eina_Bool visible = evas_object_visible_get(obj);
3917 Eina_Bool disabled = elm_widget_disabled_get(obj);
3918 Eina_Bool focused = elm_widget_focus_get(obj);
3919 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3923 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3926 fprintf(output, ", style=bold");
3929 fprintf(output, ", color=gray28");
3931 fprintf(output, " ];\n");
3934 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3935 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3936 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3940 fprintf(output, ", style=bold");
3943 fprintf(output, ", fontcolor=gray28");
3945 if ((disabled) || (!visible))
3946 fprintf(output, ", color=gray");
3948 fprintf(output, " ];\n");
3952 EINA_LIST_FOREACH(sd->subobjs, l, o)
3953 _sub_obj_tree_dot_dump(o, output);
3958 elm_widget_tree_dump(const Evas_Object *top)
3961 if (!_elm_widget_is(top))
3963 _sub_obj_tree_dump(top, 0);
3971 elm_widget_tree_dot_dump(const Evas_Object *top,
3975 if (!_elm_widget_is(top))
3977 fprintf(output, "graph " " { node [shape=record];\n");
3978 _sub_obj_tree_dot_dump(top, output);
3979 fprintf(output, "}\n");