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_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)
667 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
668 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
669 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
670 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
671 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
672 if (sd->theme_func) sd->theme_func(obj);
676 elm_widget_theme_specific(Evas_Object *obj,
684 Elm_Theme *th2, *thdef;
687 thdef = elm_theme_default_get();
692 if (!th2) th2 = thdef;
700 if (th2 == thdef) break;
701 th2 = th2->ref_theme;
702 if (!th2) th2 = thdef;
706 EINA_LIST_FOREACH(sd->subobjs, l, child)
707 elm_widget_theme_specific(child, th, force);
708 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
709 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
710 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
711 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
712 if (sd->theme_func) sd->theme_func(obj);
718 * Set hook to get next object in object focus chain.
720 * @param obj The widget object.
721 * @param func The hook to be used with this widget.
726 elm_widget_focus_next_hook_set(Evas_Object *obj,
727 Eina_Bool (*func)(const Evas_Object *obj,
728 Elm_Focus_Direction dir,
732 sd->focus_next_func = func;
736 * Returns the widget's mirrored mode.
738 * @param obj The widget.
739 * @return mirrored mode of the object.
743 elm_widget_mirrored_get(const Evas_Object *obj)
745 API_ENTRY return EINA_FALSE;
746 return sd->is_mirrored;
750 * Sets the widget's mirrored mode.
752 * @param obj The widget.
753 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
756 elm_widget_mirrored_set(Evas_Object *obj,
760 if (sd->is_mirrored != mirrored)
762 sd->is_mirrored = mirrored;
763 elm_widget_theme(obj);
769 * Resets the mirrored mode from the system mirror mode for widgets that are in
770 * automatic mirroring mode. This function does not call elm_widget_theme.
772 * @param obj The widget.
773 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
776 _elm_widget_mirrored_reload(Evas_Object *obj)
779 Eina_Bool mirrored = elm_mirrored_get();
780 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
782 sd->is_mirrored = mirrored;
787 * Returns the widget's mirrored mode setting.
789 * @param obj The widget.
790 * @return mirrored mode setting of the object.
794 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
796 API_ENTRY return EINA_FALSE;
797 return sd->mirrored_auto_mode;
801 * Sets the widget's mirrored mode setting.
802 * When widget in automatic mode, it follows the system mirrored mode set by
803 * elm_mirrored_set().
804 * @param obj The widget.
805 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
808 elm_widget_mirrored_automatic_set(Evas_Object *obj,
812 if (sd->mirrored_auto_mode != automatic)
814 sd->mirrored_auto_mode = automatic;
818 elm_widget_mirrored_set(obj, elm_mirrored_get());
824 elm_widget_on_focus_hook_set(Evas_Object *obj,
825 void (*func)(void *data,
830 sd->on_focus_func = func;
831 sd->on_focus_data = data;
835 elm_widget_on_change_hook_set(Evas_Object *obj,
836 void (*func)(void *data,
841 sd->on_change_func = func;
842 sd->on_change_data = data;
846 elm_widget_on_show_region_hook_set(Evas_Object *obj,
847 void (*func)(void *data,
852 sd->on_show_region_func = func;
853 sd->on_show_region_data = data;
859 * Set the hook to use to show the focused region.
861 * Whenever a new widget gets focused or it's needed to show the focused
862 * area of the current one, this hook will be called on objects that may
863 * want to move their children into their visible area.
864 * The area given in the hook function is relative to the @p obj widget.
866 * @param obj The widget object
867 * @param func The function to call to show the specified area.
872 elm_widget_focus_region_hook_set(Evas_Object *obj,
873 void (*func)(Evas_Object *obj,
880 sd->focus_region_func = func;
886 * Set the hook to retrieve the focused region of a widget.
888 * This hook will be called by elm_widget_focus_region_get() whenever
889 * it's needed to get the focused area of a widget. The area must be relative
890 * to the widget itself and if no hook is set, it will default to the entire
893 * @param obj The widget object
894 * @param func The function used to retrieve the focus region.
899 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
900 void (*func)(const Evas_Object *obj,
907 sd->on_focus_region_func = func;
911 elm_widget_data_set(Evas_Object *obj,
919 elm_widget_data_get(const Evas_Object *obj)
921 API_ENTRY return NULL;
926 elm_widget_sub_object_add(Evas_Object *obj,
930 double scale, pscale = elm_widget_scale_get(sobj);
931 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
932 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
934 if (sobj == sd->parent_obj)
936 elm_widget_sub_object_del(sobj, obj);
937 WRN("You passed a parent object of obj = %p as the sub object = %p!", obj, sobj);
940 if (_elm_widget_is(sobj))
942 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
945 if (sd2->parent_obj == obj)
948 elm_widget_sub_object_del(sd2->parent_obj, sobj);
949 sd2->parent_obj = obj;
950 sd2->top_win_focused = sd->top_win_focused;
951 if (!sd->child_can_focus && (_is_focusable(sobj)))
952 sd->child_can_focus = EINA_TRUE;
957 void *data = evas_object_data_get(sobj, "elm-parent");
960 if (data == obj) return;
961 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
965 sd->subobjs = eina_list_append(sd->subobjs, sobj);
966 evas_object_data_set(sobj, "elm-parent", obj);
967 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
968 if (_elm_widget_is(sobj))
969 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
970 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
971 scale = elm_widget_scale_get(sobj);
972 th = elm_widget_theme_get(sobj);
973 mirrored = elm_widget_mirrored_get(sobj);
974 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
975 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
979 elm_widget_sub_object_del(Evas_Object *obj,
982 Evas_Object *sobj_parent;
986 sobj_parent = evas_object_data_del(sobj, "elm-parent");
987 if (sobj_parent != obj)
989 static int abort_on_warn = -1;
990 ERR("removing sub object %p (%s) from parent %p (%s), "
991 "but elm-parent is different %p (%s)!",
992 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
993 sobj_parent, elm_widget_type_get(sobj_parent));
994 if (EINA_UNLIKELY(abort_on_warn == -1))
996 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
997 else abort_on_warn = 0;
999 if (abort_on_warn == 1) abort();
1001 if (_elm_widget_is(sobj))
1003 if (elm_widget_focus_get(sobj))
1005 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1006 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1008 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1010 Evas_Object *subobj;
1012 sd->child_can_focus = EINA_FALSE;
1013 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1015 if (_is_focusable(subobj))
1017 sd->child_can_focus = EINA_TRUE;
1022 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1025 sd2->parent_obj = NULL;
1026 if (sd2->resize_obj == sobj)
1027 sd2->resize_obj = NULL;
1029 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1032 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1035 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1036 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1038 if (_elm_widget_is(sobj))
1039 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1041 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1045 elm_widget_resize_object_set(Evas_Object *obj,
1049 // orphan previous resize obj
1052 evas_object_clip_unset(sd->resize_obj);
1053 evas_object_data_del(sd->resize_obj, "elm-parent");
1054 if (_elm_widget_is(sd->resize_obj))
1056 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1057 if (sd2) sd2->parent_obj = NULL;
1058 evas_object_event_callback_del_full(sd->resize_obj,
1062 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1064 evas_object_event_callback_del_full(sd->resize_obj,
1065 EVAS_CALLBACK_MOUSE_DOWN,
1066 _sub_obj_mouse_down, sd);
1067 evas_object_event_callback_del_full(sd->resize_obj,
1068 EVAS_CALLBACK_MOUSE_MOVE,
1069 _sub_obj_mouse_move, sd);
1070 evas_object_event_callback_del_full(sd->resize_obj,
1071 EVAS_CALLBACK_MOUSE_UP,
1072 _sub_obj_mouse_up, sd);
1073 evas_object_smart_member_del(sd->resize_obj);
1075 if (_elm_widget_is(sd->resize_obj))
1077 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1081 sd->resize_obj = sobj;
1084 // orphan new resize obj
1085 evas_object_data_del(sobj, "elm-parent");
1086 if (_elm_widget_is(sobj))
1088 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1089 if (sd2) sd2->parent_obj = NULL;
1090 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1093 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1095 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1096 _sub_obj_mouse_down, sd);
1097 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1098 _sub_obj_mouse_move, sd);
1099 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1100 _sub_obj_mouse_up, sd);
1101 evas_object_smart_member_del(sobj);
1102 if (_elm_widget_is(sobj))
1104 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1107 // set the resize obj up
1108 if (_elm_widget_is(sobj))
1110 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1113 sd2->parent_obj = obj;
1114 sd2->top_win_focused = sd->top_win_focused;
1116 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1119 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1120 evas_object_smart_member_add(sobj, obj);
1121 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1123 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1124 _sub_obj_mouse_down, sd);
1125 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1126 _sub_obj_mouse_move, sd);
1127 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1128 _sub_obj_mouse_up, sd);
1129 _smart_reconfigure(sd);
1130 evas_object_data_set(sobj, "elm-parent", obj);
1131 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1132 if (_elm_widget_is(sobj))
1134 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1139 elm_widget_hover_object_set(Evas_Object *obj,
1145 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1148 sd->hover_obj = sobj;
1151 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1153 _smart_reconfigure(sd);
1158 elm_widget_can_focus_set(Evas_Object *obj,
1159 Eina_Bool can_focus)
1163 can_focus = !!can_focus;
1165 if (sd->can_focus == can_focus) return;
1166 sd->can_focus = can_focus;
1169 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1171 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1172 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1174 (void *)(long)EVAS_CALLBACK_KEY_UP);
1175 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1177 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1181 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1183 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1185 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1191 elm_widget_can_focus_get(const Evas_Object *obj)
1193 API_ENTRY return EINA_FALSE;
1194 return sd->can_focus;
1198 elm_widget_child_can_focus_get(const Evas_Object *obj)
1200 API_ENTRY return EINA_FALSE;
1201 return sd->child_can_focus;
1207 * This API makes the widget object and its children to be unfocusable.
1209 * This API can be helpful for an object to be deleted.
1210 * When an object will be deleted soon, it and its children may not
1211 * want to get focus (by focus reverting or by other focus controls).
1212 * Then, just use this API before deleting.
1214 * @param obj The widget root of sub-tree
1215 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1220 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1221 Eina_Bool tree_unfocusable)
1225 tree_unfocusable = !!tree_unfocusable;
1226 if (sd->tree_unfocusable == tree_unfocusable) return;
1227 sd->tree_unfocusable = tree_unfocusable;
1228 elm_widget_focus_tree_unfocusable_handle(obj);
1234 * This returns true, if the object sub-tree is unfocusable.
1236 * @param obj The widget root of sub-tree
1237 * @return EINA_TRUE if the object sub-tree is unfocusable
1242 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1244 API_ENTRY return EINA_FALSE;
1245 return sd->tree_unfocusable;
1251 * Get the list of focusable child objects.
1253 * This function retruns list of child objects which can get focus.
1255 * @param obj The parent widget
1256 * @retrun list of focusable child objects.
1261 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1263 API_ENTRY return NULL;
1266 Eina_List *child_list = NULL;
1271 EINA_LIST_FOREACH(sd->subobjs, l, child)
1273 if ((elm_widget_can_focus_get(child)) &&
1274 (evas_object_visible_get(child)) &&
1275 (!elm_widget_disabled_get(child)))
1276 child_list = eina_list_append(child_list, child);
1277 else if (elm_widget_is(child))
1279 Eina_List *can_focus_list;
1280 can_focus_list = elm_widget_can_focus_child_list_get(child);
1282 child_list = eina_list_merge(child_list, can_focus_list);
1290 elm_widget_highlight_ignore_set(Evas_Object *obj,
1294 sd->highlight_ignore = !!ignore;
1298 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1300 API_ENTRY return EINA_FALSE;
1301 return sd->highlight_ignore;
1305 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1306 Eina_Bool highlight)
1309 sd->highlight_in_theme = !!highlight;
1310 /* FIXME: if focused, it should switch from one mode to the other */
1314 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1316 API_ENTRY return EINA_FALSE;
1317 return sd->highlight_in_theme;
1321 elm_widget_focus_get(const Evas_Object *obj)
1323 API_ENTRY return EINA_FALSE;
1328 elm_widget_focused_object_get(const Evas_Object *obj)
1330 const Evas_Object *subobj;
1332 API_ENTRY return NULL;
1334 if (!sd->focused) return NULL;
1335 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1337 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1338 if (fobj) return fobj;
1340 return (Evas_Object *)obj;
1344 elm_widget_top_get(const Evas_Object *obj)
1346 API_ENTRY return NULL;
1347 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1348 return (Evas_Object *)obj;
1352 elm_widget_is(const Evas_Object *obj)
1354 return _elm_widget_is(obj);
1358 elm_widget_parent_widget_get(const Evas_Object *obj)
1360 Evas_Object *parent;
1362 if (_elm_widget_is(obj))
1364 Smart_Data *sd = evas_object_smart_data_get(obj);
1365 if (!sd) return NULL;
1366 parent = sd->parent_obj;
1370 parent = evas_object_data_get(obj, "elm-parent");
1371 if (!parent) parent = evas_object_smart_parent_get(obj);
1376 Evas_Object *elm_parent;
1377 if (_elm_widget_is(parent)) break;
1378 elm_parent = evas_object_data_get(parent, "elm-parent");
1379 if (elm_parent) parent = elm_parent;
1380 else parent = evas_object_smart_parent_get(parent);
1386 elm_widget_parent2_get(const Evas_Object *obj)
1388 if (_elm_widget_is(obj))
1390 Smart_Data *sd = evas_object_smart_data_get(obj);
1391 if (sd) return sd->parent2;
1397 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1400 sd->parent2 = parent;
1404 elm_widget_event_callback_add(Evas_Object *obj,
1409 EINA_SAFETY_ON_NULL_RETURN(func);
1410 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1413 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1417 elm_widget_event_callback_del(Evas_Object *obj,
1421 API_ENTRY return NULL;
1422 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1424 Elm_Event_Cb_Data *ecd;
1425 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1426 if ((ecd->func == func) && (ecd->data == data))
1429 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1430 return (void *)data;
1436 elm_widget_event_propagate(Evas_Object *obj,
1437 Evas_Callback_Type type,
1439 Evas_Event_Flags *event_flags)
1441 API_ENTRY return EINA_FALSE; //TODO reduce.
1442 if (!_elm_widget_is(obj)) return EINA_FALSE;
1443 Evas_Object *parent = obj;
1444 Elm_Event_Cb_Data *ecd;
1445 Eina_List *l, *l_prev;
1448 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1450 sd = evas_object_smart_data_get(parent);
1451 if ((!sd) || (!_elm_widget_is(obj)))
1452 return EINA_FALSE; //Not Elm Widget
1454 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1457 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1459 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1460 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1463 parent = sd->parent_obj;
1472 * Set custom focus chain.
1474 * This function i set one new and overwrite any previous custom focus chain
1475 * with the list of objects. The previous list will be deleted and this list
1476 * will be managed. After setted, don't modity it.
1478 * @note On focus cycle, only will be evaluated children of this container.
1480 * @param obj The container widget
1481 * @param objs Chain of objects to pass focus
1485 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1489 if (!sd->focus_next_func)
1492 elm_widget_focus_custom_chain_unset(obj);
1497 EINA_LIST_FOREACH(objs, l, o)
1499 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1500 _elm_object_focus_chain_del_cb, sd);
1503 sd->focus_chain = objs;
1509 * Get custom focus chain
1511 * @param obj The container widget
1514 EAPI const Eina_List *
1515 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1517 API_ENTRY return NULL;
1518 return (const Eina_List *)sd->focus_chain;
1524 * Unset custom focus chain
1526 * @param obj The container widget
1530 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1533 Eina_List *l, *l_next;
1536 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1538 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1539 _elm_object_focus_chain_del_cb, sd);
1540 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1547 * Append object to custom focus chain.
1549 * @note If relative_child equal to NULL or not in custom chain, the object
1550 * will be added in end.
1552 * @note On focus cycle, only will be evaluated children of this container.
1554 * @param obj The container widget
1555 * @param child The child to be added in custom chain
1556 * @param relative_child The relative object to position the child
1560 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1562 Evas_Object *relative_child)
1565 EINA_SAFETY_ON_NULL_RETURN(child);
1566 if (!sd->focus_next_func) return;
1568 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1569 _elm_object_focus_chain_del_cb, sd);
1571 if (!relative_child)
1572 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1574 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1575 child, relative_child);
1581 * Prepend object to custom focus chain.
1583 * @note If relative_child equal to NULL or not in custom chain, the object
1584 * will be added in begin.
1586 * @note On focus cycle, only will be evaluated children of this container.
1588 * @param obj The container widget
1589 * @param child The child to be added in custom chain
1590 * @param relative_child The relative object to position the child
1594 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1596 Evas_Object *relative_child)
1599 EINA_SAFETY_ON_NULL_RETURN(child);
1601 if (!sd->focus_next_func) return;
1603 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1604 _elm_object_focus_chain_del_cb, sd);
1606 if (!relative_child)
1607 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1609 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1610 child, relative_child);
1616 * Give focus to next object in object tree.
1618 * Give focus to next object in focus chain of one object sub-tree.
1619 * If the last object of chain already have focus, the focus will go to the
1620 * first object of chain.
1622 * @param obj The widget root of sub-tree
1623 * @param dir Direction to cycle the focus
1628 elm_widget_focus_cycle(Evas_Object *obj,
1629 Elm_Focus_Direction dir)
1631 Evas_Object *target = NULL;
1632 if (!_elm_widget_is(obj))
1634 elm_widget_focus_next_get(obj, dir, &target);
1636 elm_widget_focus_steal(target);
1642 * Give focus to near object in one direction.
1644 * Give focus to near object in direction of one object.
1645 * If none focusable object in given direction, the focus will not change.
1647 * @param obj The reference widget
1648 * @param x Horizontal component of direction to focus
1649 * @param y Vertical component of direction to focus
1653 //XXX: If x, y indicates the elements of the directional vector,
1654 //It would be better if these values are the normalized value(float x, float y)
1656 EINA_DEPRECATED EAPI void
1657 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1667 * Get next object in focus chain of object tree.
1669 * Get next object in focus chain of one object sub-tree.
1670 * Return the next object by reference. If don't have any candidate to receive
1671 * focus before chain end, the first candidate will be returned.
1673 * @param obj The widget root of sub-tree
1674 * @param dir Direction os focus chain
1675 * @param next The next object in focus chain
1676 * @return EINA_TRUE if don't need focus chain restart/loop back
1677 * to use 'next' obj.
1682 elm_widget_focus_next_get(const Evas_Object *obj,
1683 Elm_Focus_Direction dir,
1690 API_ENTRY return EINA_FALSE;
1692 /* Ignore if disabled */
1693 if ((!evas_object_visible_get(obj))
1694 || (elm_widget_disabled_get(obj))
1695 || (elm_widget_tree_unfocusable_get(obj)))
1699 if (sd->focus_next_func)
1700 return sd->focus_next_func(obj, dir, next);
1702 if (!elm_widget_can_focus_get(obj))
1706 *next = (Evas_Object *)obj;
1707 return !elm_widget_focus_get(obj);
1713 * Get next object in focus chain of object tree in list.
1715 * Get next object in focus chain of one object sub-tree ordered by one list.
1716 * Return the next object by reference. If don't have any candidate to receive
1717 * focus before list end, the first candidate will be returned.
1719 * @param obj The widget root of sub-tree
1720 * @param dir Direction os focus chain
1721 * @param items list with ordered objects
1722 * @param list_data_get function to get the object from one item of list
1723 * @param next The next object in focus chain
1724 * @return EINA_TRUE if don't need focus chain restart/loop back
1725 * to use 'next' obj.
1730 elm_widget_focus_list_next_get(const Evas_Object *obj,
1731 const Eina_List *items,
1732 void *(*list_data_get)(const Eina_List * list),
1733 Elm_Focus_Direction dir,
1736 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1742 if (!_elm_widget_is(obj))
1749 if (dir == ELM_FOCUS_PREVIOUS)
1751 items = eina_list_last(items);
1752 list_next = eina_list_prev;
1754 else if (dir == ELM_FOCUS_NEXT)
1755 list_next = eina_list_next;
1759 const Eina_List *l = items;
1761 /* Recovery last focused sub item */
1762 if (elm_widget_focus_get(obj))
1763 for (; l; l = list_next(l))
1765 Evas_Object *cur = list_data_get(l);
1766 if (elm_widget_focus_get(cur)) break;
1769 const Eina_List *start = l;
1770 Evas_Object *to_focus = NULL;
1772 /* Interate sub items */
1773 /* Go to end of list */
1774 for (; l; l = list_next(l))
1776 Evas_Object *tmp = NULL;
1777 Evas_Object *cur = list_data_get(l);
1779 if (elm_widget_parent_get(cur) != obj)
1782 /* Try Focus cycle in subitem */
1783 if (elm_widget_focus_next_get(cur, dir, &tmp))
1788 else if ((tmp) && (!to_focus))
1794 /* Get First possible */
1795 for (; l != start; l = list_next(l))
1797 Evas_Object *tmp = NULL;
1798 Evas_Object *cur = list_data_get(l);
1800 if (elm_widget_parent_get(cur) != obj)
1803 /* Try Focus cycle in subitem */
1804 elm_widget_focus_next_get(cur, dir, &tmp);
1817 elm_widget_signal_emit(Evas_Object *obj,
1818 const char *emission,
1822 if (!sd->signal_func) return;
1823 sd->signal_func(obj, emission, source);
1827 _edje_signal_callback(void *data,
1828 Evas_Object *obj __UNUSED__,
1829 const char *emission,
1832 Edje_Signal_Data *esd = data;
1833 esd->func(esd->data, esd->obj, emission, source);
1837 elm_widget_signal_callback_add(Evas_Object *obj,
1838 const char *emission,
1840 Edje_Signal_Cb func,
1843 Edje_Signal_Data *esd;
1845 if (!sd->callback_add_func) return;
1846 EINA_SAFETY_ON_NULL_RETURN(func);
1848 esd = ELM_NEW(Edje_Signal_Data);
1853 esd->emission = eina_stringshare_add(emission);
1854 esd->source = eina_stringshare_add(source);
1856 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1857 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1861 elm_widget_signal_callback_del(Evas_Object *obj,
1862 const char *emission,
1864 Edje_Signal_Cb func)
1866 Edje_Signal_Data *esd;
1869 API_ENTRY return NULL;
1870 if (!sd->callback_del_func) return NULL;
1872 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1874 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1875 (!strcmp(esd->source, source)))
1877 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1878 eina_stringshare_del(esd->emission);
1879 eina_stringshare_del(esd->source);
1885 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1890 elm_widget_focus_set(Evas_Object *obj,
1897 sd->focus_order = focus_order;
1898 sd->focused = EINA_TRUE;
1899 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1903 sd->focus_func(obj);
1910 if ((_is_focusable(sd->resize_obj)) &&
1911 (!elm_widget_disabled_get(sd->resize_obj)))
1913 elm_widget_focus_set(sd->resize_obj, first);
1919 EINA_LIST_FOREACH(sd->subobjs, l, child)
1921 if ((_is_focusable(child)) &&
1922 (!elm_widget_disabled_get(child)))
1924 elm_widget_focus_set(child, first);
1934 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1936 if ((_is_focusable(child)) &&
1937 (!elm_widget_disabled_get(child)))
1939 elm_widget_focus_set(child, first);
1945 if ((_is_focusable(sd->resize_obj)) &&
1946 (!elm_widget_disabled_get(sd->resize_obj)))
1948 elm_widget_focus_set(sd->resize_obj, first);
1956 elm_widget_parent_get(const Evas_Object *obj)
1958 API_ENTRY return NULL;
1959 return sd->parent_obj;
1963 elm_widget_focused_object_clear(Evas_Object *obj)
1966 if (!sd->focused) return;
1967 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
1968 elm_widget_focused_object_clear(sd->resize_obj);
1973 EINA_LIST_FOREACH(sd->subobjs, l, child)
1975 if (elm_widget_focus_get(child))
1977 elm_widget_focused_object_clear(child);
1982 sd->focused = EINA_FALSE;
1983 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1984 if (sd->focus_func) sd->focus_func(obj);
1988 elm_widget_focus_steal(Evas_Object *obj)
1990 Evas_Object *parent, *parent2, *o;
1993 if (sd->focused) return;
1994 if (sd->disabled) return;
1995 if (!sd->can_focus) return;
1996 if (sd->tree_unfocusable) return;
2000 o = elm_widget_parent_get(parent);
2002 sd = evas_object_smart_data_get(o);
2003 if (sd->disabled || sd->tree_unfocusable) return;
2004 if (sd->focused) break;
2007 if ((!elm_widget_parent_get(parent)) &&
2008 (!elm_widget_parent2_get(parent)))
2009 elm_widget_focused_object_clear(parent);
2012 parent2 = elm_widget_parent_get(parent);
2013 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2015 sd = evas_object_smart_data_get(parent);
2018 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2019 elm_widget_focused_object_clear(sd->resize_obj);
2024 EINA_LIST_FOREACH(sd->subobjs, l, child)
2026 if (elm_widget_focus_get(child))
2028 elm_widget_focused_object_clear(child);
2040 elm_widget_focus_restore(Evas_Object *obj)
2042 Evas_Object *newest = NULL;
2043 unsigned int newest_focus_order = 0;
2046 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2049 elm_object_focus_set(newest, EINA_FALSE);
2050 elm_object_focus_set(newest, EINA_TRUE);
2055 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
2061 if (sd->top_win_focused == top_win_focused) return;
2063 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2064 EINA_LIST_FOREACH(sd->subobjs, l, child)
2066 _elm_widget_top_win_focused_set(child, top_win_focused);
2068 sd->top_win_focused = top_win_focused;
2072 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2074 API_ENTRY return EINA_FALSE;
2075 return sd->top_win_focused;
2079 elm_widget_activate(Evas_Object *obj)
2082 elm_widget_change(obj);
2083 if (sd->activate_func) sd->activate_func(obj);
2087 elm_widget_change(Evas_Object *obj)
2090 elm_widget_change(elm_widget_parent_get(obj));
2091 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2095 elm_widget_disabled_set(Evas_Object *obj,
2100 if (sd->disabled == disabled) return;
2101 sd->disabled = !!disabled;
2102 elm_widget_focus_disabled_handle(obj);
2103 if (sd->disable_func) sd->disable_func(obj);
2107 elm_widget_disabled_get(const Evas_Object *obj)
2110 return sd->disabled;
2114 elm_widget_show_region_set(Evas_Object *obj,
2119 Eina_Bool forceshow)
2121 Evas_Object *parent_obj, *child_obj;
2122 Evas_Coord px, py, cx, cy;
2126 evas_smart_objects_calculate(evas_object_evas_get(obj));
2128 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2129 (w == sd->rw) && (h == sd->rh)) return;
2134 if (sd->on_show_region_func)
2135 sd->on_show_region_func(sd->on_show_region_data, obj);
2139 parent_obj = sd->parent_obj;
2140 child_obj = sd->obj;
2141 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2142 sd = evas_object_smart_data_get(parent_obj);
2145 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2146 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2155 if (sd->on_show_region_func)
2157 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2164 elm_widget_show_region_get(const Evas_Object *obj,
2180 * Get the focus region of the given widget.
2182 * The focus region is the area of a widget that should brought into the
2183 * visible area when the widget is focused. Mostly used to show the part of
2184 * an entry where the cursor is, for example. The area returned is relative
2185 * to the object @p obj.
2186 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2187 * function will return the full size of the object.
2189 * @param obj The widget object
2190 * @param x Where to store the x coordinate of the area
2191 * @param y Where to store the y coordinate of the area
2192 * @param w Where to store the width of the area
2193 * @param h Where to store the height of the area
2198 elm_widget_focus_region_get(const Evas_Object *obj,
2208 sd = evas_object_smart_data_get(obj);
2209 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2211 evas_object_geometry_get(obj, NULL, NULL, w, h);
2216 sd->on_focus_region_func(obj, x, y, w, h);
2220 elm_widget_scroll_hold_push(Evas_Object *obj)
2224 if (sd->scroll_hold == 1)
2225 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2226 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2227 // FIXME: on delete/reparent hold pop
2231 elm_widget_scroll_hold_pop(Evas_Object *obj)
2235 if (!sd->scroll_hold)
2236 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2237 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2238 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2242 elm_widget_scroll_hold_get(const Evas_Object *obj)
2245 return sd->scroll_hold;
2249 elm_widget_scroll_freeze_push(Evas_Object *obj)
2252 sd->scroll_freeze++;
2253 if (sd->scroll_freeze == 1)
2254 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2255 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2256 // FIXME: on delete/reparent freeze pop
2260 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2263 sd->scroll_freeze--;
2264 if (!sd->scroll_freeze)
2265 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2266 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2267 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2271 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2274 return sd->scroll_freeze;
2278 elm_widget_scale_set(Evas_Object *obj,
2282 if (scale <= 0.0) scale = 0.0;
2283 if (sd->scale != scale)
2286 elm_widget_theme(obj);
2291 elm_widget_scale_get(const Evas_Object *obj)
2293 API_ENTRY return 1.0;
2294 // FIXME: save walking up the tree by storing/caching parent scale
2295 if (sd->scale == 0.0)
2298 return elm_widget_scale_get(sd->parent_obj);
2306 elm_widget_theme_set(Evas_Object *obj,
2310 if (sd->theme != th)
2312 if (sd->theme) elm_theme_free(sd->theme);
2315 elm_widget_theme(obj);
2320 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2324 if (!sd->text_set_func)
2327 sd->text_set_func(obj, part, label);
2331 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2333 API_ENTRY return NULL;
2335 if (!sd->text_get_func)
2338 return sd->text_get_func(obj, part);
2342 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2346 Elm_Translate_String_Data *ts = NULL;
2349 str = eina_stringshare_add(part);
2350 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2357 eina_stringshare_del(str);
2360 ts = malloc(sizeof(Elm_Translate_String_Data));
2364 ts->domain = eina_stringshare_add(domain);
2365 ts->string = eina_stringshare_add(label);
2366 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2372 eina_stringshare_replace(&ts->domain, domain);
2373 eina_stringshare_replace(&ts->string, label);
2377 sd->translate_strings = eina_list_remove_list(
2378 sd->translate_strings, l);
2379 eina_stringshare_del(ts->id);
2380 eina_stringshare_del(ts->domain);
2381 eina_stringshare_del(ts->string);
2384 eina_stringshare_del(str);
2388 if (label && label[0])
2389 label = dgettext(domain, label);
2391 elm_widget_text_part_set(obj, part, label);
2395 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2397 const char *str, *ret = NULL;
2399 Elm_Translate_String_Data *ts;
2400 API_ENTRY return NULL;
2402 str = eina_stringshare_add(part);
2403 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2409 eina_stringshare_del(str);
2414 elm_widget_translate(Evas_Object *obj)
2419 Elm_Translate_String_Data *ts;
2423 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2424 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2425 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2426 if (sd->translate_func) sd->translate_func(obj);
2429 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2431 const char *s = dgettext(ts->domain, ts->string);
2432 elm_widget_text_part_set(obj, ts->id, s);
2438 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2442 if (!sd->content_set_func) return;
2443 sd->content_set_func(obj, part, content);
2447 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2449 API_ENTRY return NULL;
2451 if (!sd->content_get_func) return NULL;
2452 return sd->content_get_func(obj, part);
2456 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2458 API_ENTRY return NULL;
2460 if (!sd->content_unset_func) return NULL;
2461 return sd->content_unset_func(obj, part);
2465 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2468 if (sd->access_info) eina_stringshare_del(sd->access_info);
2469 if (!txt) sd->access_info = NULL;
2470 else sd->access_info = eina_stringshare_add(txt);
2474 elm_widget_access_info_get(const Evas_Object *obj)
2476 API_ENTRY return NULL;
2477 return sd->access_info;
2481 elm_widget_theme_get(const Evas_Object *obj)
2483 API_ENTRY return NULL;
2487 return elm_widget_theme_get(sd->parent_obj);
2495 elm_widget_style_set(Evas_Object *obj,
2500 if (eina_stringshare_replace(&sd->style, style))
2501 elm_widget_theme(obj);
2505 elm_widget_style_get(const Evas_Object *obj)
2507 API_ENTRY return NULL;
2508 if (sd->style) return sd->style;
2513 elm_widget_type_set(Evas_Object *obj,
2517 eina_stringshare_replace(&sd->type, type);
2521 elm_widget_type_get(const Evas_Object *obj)
2523 API_ENTRY return NULL;
2524 if (sd->type) return sd->type;
2529 elm_widget_tooltip_add(Evas_Object *obj,
2533 sd->tooltips = eina_list_append(sd->tooltips, tt);
2537 elm_widget_tooltip_del(Evas_Object *obj,
2541 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2545 elm_widget_cursor_add(Evas_Object *obj,
2549 sd->cursors = eina_list_append(sd->cursors, cur);
2553 elm_widget_cursor_del(Evas_Object *obj,
2557 sd->cursors = eina_list_remove(sd->cursors, cur);
2561 elm_widget_drag_lock_x_set(Evas_Object *obj,
2565 if (sd->drag_x_locked == lock) return;
2566 sd->drag_x_locked = lock;
2567 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2568 else _propagate_x_drag_lock(obj, -1);
2572 elm_widget_drag_lock_y_set(Evas_Object *obj,
2576 if (sd->drag_y_locked == lock) return;
2577 sd->drag_y_locked = lock;
2578 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2579 else _propagate_y_drag_lock(obj, -1);
2583 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2585 API_ENTRY return EINA_FALSE;
2586 return sd->drag_x_locked;
2590 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2592 API_ENTRY return EINA_FALSE;
2593 return sd->drag_y_locked;
2597 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2600 return sd->child_drag_x_locked;
2604 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2607 return sd->child_drag_y_locked;
2611 elm_widget_theme_object_set(Evas_Object *obj,
2614 const char *welement,
2617 API_ENTRY return EINA_FALSE;
2618 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2622 elm_widget_is_check(const Evas_Object *obj)
2624 static int abort_on_warn = -1;
2625 if (elm_widget_is(obj))
2628 ERR("Passing Object: %p.", obj);
2629 if (abort_on_warn == -1)
2631 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2632 else abort_on_warn = 0;
2634 if (abort_on_warn == 1) abort();
2639 elm_widget_type_check(const Evas_Object *obj,
2643 const char *provided, *expected = "(unknown)";
2644 static int abort_on_warn = -1;
2645 provided = elm_widget_type_get(obj);
2646 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2647 if (type) expected = type;
2648 if ((!provided) || (!provided[0]))
2650 provided = evas_object_type_get(obj);
2651 if ((!provided) || (!provided[0]))
2652 provided = "(unknown)";
2654 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2655 if (abort_on_warn == -1)
2657 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2658 else abort_on_warn = 0;
2660 if (abort_on_warn == 1) abort();
2664 static Evas_Object *
2665 _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2670 INTERNAL_ENTRY NULL;
2672 if (!_elm_widget_is(obj)) return NULL;
2675 s = evas_object_name_get(sd->resize_obj);
2676 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
2677 if ((recurse != 0) &&
2678 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
2681 EINA_LIST_FOREACH(sd->subobjs, l, child)
2683 s = evas_object_name_get(child);
2684 if ((s) && (!strcmp(s, name))) return child;
2685 if ((recurse != 0) &&
2686 ((child = _widget_name_find(child, name, recurse - 1))))
2691 s = evas_object_name_get(sd->hover_obj);
2692 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
2693 if ((recurse != 0) &&
2694 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
2701 elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2703 API_ENTRY return NULL;
2704 if (!name) return NULL;
2705 return _widget_name_find(obj, name, recurse);
2711 * Split string in words
2713 * @param str Source string
2714 * @return List of const words
2716 * @see elm_widget_stringlist_free()
2720 elm_widget_stringlist_get(const char *str)
2722 Eina_List *list = NULL;
2724 if (!str) return NULL;
2725 for (b = s = str; 1; s++)
2727 if ((*s == ' ') || (!*s))
2729 char *t = malloc(s - b + 1);
2732 strncpy(t, b, s - b);
2734 list = eina_list_append(list, eina_stringshare_add(t));
2745 elm_widget_stringlist_free(Eina_List *list)
2748 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2752 elm_widget_focus_hide_handle(Evas_Object *obj)
2754 if (!_elm_widget_is(obj))
2756 _if_focused_revert(obj, EINA_TRUE);
2760 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2762 Evas_Object *o = obj;
2765 if (_elm_widget_is(o)) break;
2766 o = evas_object_smart_parent_get(o);
2770 if (!_is_focusable(o)) return;
2771 elm_widget_focus_steal(o);
2775 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2779 //FIXME: Need to check whether the object is unfocusable or not.
2781 if (!elm_widget_parent_get(obj))
2782 elm_widget_focused_object_clear(obj);
2784 _if_focused_revert(obj, EINA_TRUE);
2788 elm_widget_focus_disabled_handle(Evas_Object *obj)
2792 elm_widget_focus_tree_unfocusable_handle(obj);
2796 elm_widget_focus_order_get(const Evas_Object *obj)
2799 return sd->focus_order;
2805 * Allocate a new Elm_Widget_Item-derived structure.
2807 * The goal of this structure is to provide common ground for actions
2808 * that a widget item have, such as the owner widget, callback to
2809 * notify deletion, data pointer and maybe more.
2811 * @param widget the owner widget that holds this item, must be an elm_widget!
2812 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2813 * be used to allocate memory.
2815 * @return allocated memory that is already zeroed out, or NULL on errors.
2817 * @see elm_widget_item_new() convenience macro.
2818 * @see elm_widget_item_del() to release memory.
2821 EAPI Elm_Widget_Item *
2822 _elm_widget_item_new(Evas_Object *widget,
2825 if (!_elm_widget_is(widget))
2828 Elm_Widget_Item *item;
2830 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2831 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2833 item = calloc(1, alloc_size);
2834 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2836 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2837 item->widget = widget;
2842 _elm_widget_item_free(Elm_Widget_Item *item)
2844 ELM_WIDGET_ITEM_FREE_OR_RETURN(item);
2845 Elm_Object_Item_Smart_Cb cb;
2847 if (item->walking > 0)
2849 item->delete_me = EINA_TRUE;
2853 EINA_LIST_FREE(item->callbacks, cb) free(cb);
2856 item->del_func((void *)item->data, item->widget, item);
2859 evas_object_del(item->view);
2863 _elm_access_clear(item->access);
2867 if (item->access_info)
2868 eina_stringshare_del(item->access_info);
2870 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2877 * Releases widget item memory, calling back del_cb() if it exists.
2879 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2880 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2881 * this function and then unset it, thus being useful for 2 step
2882 * cleanup whenever the del_cb may use any of the data that must be
2883 * deleted from item.
2885 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2888 * @param item a valid #Elm_Widget_Item to be deleted.
2889 * @see elm_widget_item_del() convenience macro.
2893 _elm_widget_item_del(Elm_Widget_Item *item)
2895 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2897 //Widget item delete callback
2898 if (item->del_pre_func)
2900 if (item->del_pre_func((Elm_Object_Item *) item))
2901 _elm_widget_item_free(item);
2904 _elm_widget_item_free(item);
2910 * Set the function to notify to widgets when item is being deleted by user.
2912 * @param item a valid #Elm_Widget_Item to be notified
2913 * @see elm_widget_item_del_pre_hook_set() convenience macro.
2917 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func)
2919 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2920 item->del_pre_func = func;
2926 * Notify object will be deleted without actually deleting it.
2928 * This function will callback Elm_Widget_Item::del_cb if it is set
2929 * and then unset it so it is not called twice (ie: from
2930 * elm_widget_item_del()).
2932 * @param item a valid #Elm_Widget_Item to be notified
2933 * @see elm_widget_item_pre_notify_del() convenience macro.
2937 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2939 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2940 if (!item->del_func) return;
2941 item->del_func((void *)item->data, item->widget, item);
2942 item->del_func = NULL;
2948 * Set the function to notify when item is being deleted.
2950 * This function will complain if there was a callback set already,
2951 * however it will set the new one.
2953 * The callback will be called from elm_widget_item_pre_notify_del()
2954 * or elm_widget_item_del() will be called with:
2955 * - data: the Elm_Widget_Item::data value.
2956 * - obj: the Elm_Widget_Item::widget evas object.
2957 * - event_info: the item being deleted.
2959 * @param item a valid #Elm_Widget_Item to be notified
2960 * @see elm_widget_item_del_cb_set() convenience macro.
2964 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2967 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2969 if ((item->del_func) && (item->del_func != func))
2970 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2971 item->del_func, item, func);
2973 item->del_func = func;
2979 * Set user-data in this item.
2981 * User data may be used to identify this item or just store any
2982 * application data. It is automatically given as the first parameter
2983 * of the deletion notify callback.
2985 * @param item a valid #Elm_Widget_Item to store data in.
2986 * @param data user data to store.
2987 * @see elm_widget_item_del_cb_set() convenience macro.
2991 _elm_widget_item_data_set(Elm_Widget_Item *item,
2994 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2995 if ((item->data) && (item->data != data))
2996 DBG("Replacing item %p data %p with %p", item, item->data, data);
3003 * Retrieves user-data of this item.
3005 * @param item a valid #Elm_Widget_Item to get data from.
3006 * @see elm_widget_item_data_set()
3010 _elm_widget_item_data_get(const Elm_Widget_Item *item)
3012 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3013 return (void *)item->data;
3017 _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
3019 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3021 if (item->disabled == disabled) return;
3022 item->disabled = !!disabled;
3023 if (item->disable_func) item->disable_func(item);
3027 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3029 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3030 return item->disabled;
3034 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3035 Elm_Widget_Disable_Cb func)
3037 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3038 item->disable_func = func;
3041 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3043 struct _Elm_Widget_Item_Tooltip
3045 Elm_Widget_Item *item;
3046 Elm_Tooltip_Item_Content_Cb func;
3047 Evas_Smart_Cb del_cb;
3051 static Evas_Object *
3052 _elm_widget_item_tooltip_label_create(void *data,
3053 Evas_Object *obj __UNUSED__,
3054 Evas_Object *tooltip,
3055 void *item __UNUSED__)
3057 Evas_Object *label = elm_label_add(tooltip);
3060 elm_object_style_set(label, "tooltip");
3061 elm_object_text_set(label, data);
3065 static Evas_Object *
3066 _elm_widget_item_tooltip_trans_label_create(void *data,
3067 Evas_Object *obj __UNUSED__,
3068 Evas_Object *tooltip,
3069 void *item __UNUSED__)
3071 Evas_Object *label = elm_label_add(tooltip);
3074 elm_object_style_set(label, "tooltip");
3075 elm_object_translatable_text_set(label, data);
3080 _elm_widget_item_tooltip_label_del_cb(void *data,
3081 Evas_Object *obj __UNUSED__,
3082 void *event_info __UNUSED__)
3084 eina_stringshare_del(data);
3090 * Set the text to be shown in the widget item.
3092 * @param item Target item
3093 * @param text The text to set in the content
3095 * Setup the text as tooltip to object. The item can have only one tooltip,
3096 * so any previous tooltip data is removed.
3101 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3104 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3105 EINA_SAFETY_ON_NULL_RETURN(text);
3107 text = eina_stringshare_add(text);
3108 _elm_widget_item_tooltip_content_cb_set
3109 (item, _elm_widget_item_tooltip_label_create, text,
3110 _elm_widget_item_tooltip_label_del_cb);
3114 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3117 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3118 EINA_SAFETY_ON_NULL_RETURN(text);
3120 text = eina_stringshare_add(text);
3121 _elm_widget_item_tooltip_content_cb_set
3122 (item, _elm_widget_item_tooltip_trans_label_create, text,
3123 _elm_widget_item_tooltip_label_del_cb);
3126 static Evas_Object *
3127 _elm_widget_item_tooltip_create(void *data,
3129 Evas_Object *tooltip)
3131 Elm_Widget_Item_Tooltip *wit = data;
3132 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3136 _elm_widget_item_tooltip_del_cb(void *data,
3138 void *event_info __UNUSED__)
3140 Elm_Widget_Item_Tooltip *wit = data;
3141 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3148 * Set the content to be shown in the tooltip item
3150 * Setup the tooltip to item. The item can have only one tooltip,
3151 * so any previous tooltip data is removed. @p func(with @p data) will
3152 * be called every time that need show the tooltip and it should
3153 * return a valid Evas_Object. This object is then managed fully by
3154 * tooltip system and is deleted when the tooltip is gone.
3156 * @param item the widget item being attached a tooltip.
3157 * @param func the function used to create the tooltip contents.
3158 * @param data what to provide to @a func as callback data/context.
3159 * @param del_cb called when data is not needed anymore, either when
3160 * another callback replaces @func, the tooltip is unset with
3161 * elm_widget_item_tooltip_unset() or the owner @a item
3162 * dies. This callback receives as the first parameter the
3163 * given @a data, and @c event_info is the item.
3168 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3169 Elm_Tooltip_Item_Content_Cb func,
3171 Evas_Smart_Cb del_cb)
3173 Elm_Widget_Item_Tooltip *wit;
3175 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3179 _elm_widget_item_tooltip_unset(item);
3183 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3184 if (!wit) goto error;
3188 wit->del_cb = del_cb;
3190 elm_object_sub_tooltip_content_cb_set
3191 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3192 _elm_widget_item_tooltip_del_cb);
3197 if (del_cb) del_cb((void *)data, NULL, item);
3200 if (del_cb) del_cb((void *)data, item->widget, item);
3206 * Unset tooltip from item
3208 * @param item widget item to remove previously set tooltip.
3210 * Remove tooltip from item. The callback provided as del_cb to
3211 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3212 * it is not used anymore.
3214 * @see elm_widget_item_tooltip_content_cb_set()
3219 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3221 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3222 elm_object_tooltip_unset(item->view);
3228 * Sets a different style for this item tooltip.
3230 * @note before you set a style you should define a tooltip with
3231 * elm_widget_item_tooltip_content_cb_set() or
3232 * elm_widget_item_tooltip_text_set()
3234 * @param item widget item with tooltip already set.
3235 * @param style the theme style to use (default, transparent, ...)
3240 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3243 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3244 elm_object_tooltip_style_set(item->view, style);
3248 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
3250 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3251 return elm_object_tooltip_window_mode_set(item->view, disable);
3255 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
3257 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3258 return elm_object_tooltip_window_mode_get(item->view);
3264 * Get the style for this item tooltip.
3266 * @param item widget item with tooltip already set.
3267 * @return style the theme style in use, defaults to "default". If the
3268 * object does not have a tooltip set, then NULL is returned.
3273 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3275 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3276 return elm_object_tooltip_style_get(item->view);
3280 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3283 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3284 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3288 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3290 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3291 return elm_object_cursor_get(item->view);
3295 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3297 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3298 elm_object_cursor_unset(item->view);
3304 * Sets a different style for this item cursor.
3306 * @note before you set a style you should define a cursor with
3307 * elm_widget_item_cursor_set()
3309 * @param item widget item with cursor already set.
3310 * @param style the theme style to use (default, transparent, ...)
3315 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3318 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3319 elm_object_cursor_style_set(item->view, style);
3325 * Get the style for this item cursor.
3327 * @param item widget item with cursor already set.
3328 * @return style the theme style in use, defaults to "default". If the
3329 * object does not have a cursor set, then NULL is returned.
3334 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3336 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3337 return elm_object_cursor_style_get(item->view);
3343 * Set if the cursor set should be searched on the theme or should use
3344 * the provided by the engine, only.
3346 * @note before you set if should look on theme you should define a cursor
3347 * with elm_object_cursor_set(). By default it will only look for cursors
3348 * provided by the engine.
3350 * @param item widget item with cursor already set.
3351 * @param engine_only boolean to define it cursors should be looked only
3352 * between the provided by the engine or searched on widget's theme as well.
3357 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3358 Eina_Bool engine_only)
3360 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3361 elm_object_cursor_engine_only_set(item->view, engine_only);
3367 * Get the cursor engine only usage for this item cursor.
3369 * @param item widget item with cursor already set.
3370 * @return engine_only boolean to define it cursors should be looked only
3371 * between the provided by the engine or searched on widget's theme as well. If
3372 * the object does not have a cursor set, then EINA_FALSE is returned.
3377 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3379 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3380 return elm_object_cursor_engine_only_get(item->view);
3383 // smart object funcs
3385 _smart_reconfigure(Smart_Data *sd)
3389 evas_object_move(sd->resize_obj, sd->x, sd->y);
3390 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3394 evas_object_move(sd->hover_obj, sd->x, sd->y);
3395 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3400 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3402 Evas_Object *content)
3404 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3405 if (!item->content_set_func) return;
3406 item->content_set_func((Elm_Object_Item *) item, part, content);
3410 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3413 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3414 if (!item->content_get_func) return NULL;
3415 return item->content_get_func((Elm_Object_Item *) item, part);
3419 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3422 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3423 if (!item->content_unset_func) return NULL;
3424 return item->content_unset_func((Elm_Object_Item *) item, part);
3428 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3432 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3433 if (!item->text_set_func) return;
3434 item->text_set_func((Elm_Object_Item *) item, part, label);
3438 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3439 const char *emission,
3442 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3443 if (item->signal_emit_func)
3444 item->signal_emit_func((Elm_Object_Item *) item, emission, source);
3448 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3451 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3452 if (!item->text_get_func) return NULL;
3453 return item->text_get_func((Elm_Object_Item *) item, part);
3457 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3458 Elm_Widget_Content_Set_Cb func)
3460 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3461 item->content_set_func = func;
3465 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3466 Elm_Widget_Content_Get_Cb func)
3468 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3469 item->content_get_func = func;
3473 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3474 Elm_Widget_Content_Unset_Cb func)
3476 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3477 item->content_unset_func = func;
3481 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3482 Elm_Widget_Text_Set_Cb func)
3484 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3485 item->text_set_func = func;
3489 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3490 Elm_Widget_Text_Get_Cb func)
3492 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3493 item->text_get_func = func;
3497 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3498 Elm_Widget_Signal_Emit_Cb func)
3500 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3501 item->signal_emit_func = func;
3505 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3507 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3508 if (item->access_info) eina_stringshare_del(item->access_info);
3509 if (!txt) item->access_info = NULL;
3510 else item->access_info = eina_stringshare_add(txt);
3514 elm_widget_item_smart_callback_add(Elm_Widget_Item *item, const char *event, Elm_Object_Item_Smart_Cb func, const void *data)
3516 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3517 if ((!event) || (!func)) return;
3519 Elm_Widget_Item_Callback *cb = ELM_NEW(Elm_Widget_Item_Callback);
3522 //TODO: apply MEMPOOL?
3523 cb->event = eina_stringshare_add(event);
3525 cb->data = (void *)data;
3526 item->callbacks = eina_list_append(item->callbacks, cb);
3530 elm_widget_item_smart_callback_del(Elm_Widget_Item *item, const char *event, Elm_Object_Item_Smart_Cb func)
3532 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3534 Eina_List *l, *l_next;
3535 Elm_Widget_Item_Callback *cb;
3537 if ((!event) || (!func)) return NULL;
3539 EINA_LIST_FOREACH_SAFE(item->callbacks, l, l_next, cb)
3541 if ((!strcmp(cb->event, event)) && (cb->func == func))
3543 void *data = cb->data;
3546 item->callbacks = eina_list_remove_list(item->callbacks, l);
3550 cb->delete_me = EINA_TRUE;
3558 _elm_widget_item_smart_callback_call(Elm_Widget_Item *item, const char *event, void *event_info)
3560 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3562 Eina_List *l, *l_next;
3563 Elm_Widget_Item_Callback *cb;
3564 const char *strshare;
3568 strshare = eina_stringshare_add(event);
3570 EINA_LIST_FOREACH(item->callbacks, l, cb)
3572 if (strcmp(cb->event, strshare)) continue;
3573 if (cb->delete_me) continue;
3576 cb->func(cb->data, (Elm_Object_Item *) item, event_info);
3579 if (item->delete_me) break;
3583 EINA_LIST_FOREACH_SAFE(item->callbacks, l, l_next, cb)
3585 if (!cb->delete_me) continue;
3586 item->callbacks = eina_list_remove_list(item->callbacks, l);
3590 if (item->delete_me && !item->walking)
3591 elm_widget_item_free(item);
3595 _smart_add(Evas_Object *obj)
3599 sd = calloc(1, sizeof(Smart_Data));
3602 sd->x = sd->y = sd->w = sd->h = 0;
3603 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3604 evas_object_smart_data_set(obj, sd);
3605 elm_widget_can_focus_set(obj, EINA_TRUE);
3608 static Evas_Object *
3609 _newest_focus_order_get(Evas_Object *obj,
3610 unsigned int *newest_focus_order,
3611 Eina_Bool can_focus_only)
3614 Evas_Object *child, *ret, *best;
3616 API_ENTRY return NULL;
3618 if (!evas_object_visible_get(obj)
3619 || (elm_widget_disabled_get(obj))
3620 || (elm_widget_tree_unfocusable_get(obj)))
3624 if (*newest_focus_order < sd->focus_order)
3626 *newest_focus_order = sd->focus_order;
3629 EINA_LIST_FOREACH(sd->subobjs, l, child)
3631 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3637 if ((!best) || (!elm_widget_can_focus_get(best)))
3644 _if_focused_revert(Evas_Object *obj,
3645 Eina_Bool can_focus_only)
3648 Evas_Object *newest = NULL;
3649 unsigned int newest_focus_order = 0;
3653 if (!sd->focused) return;
3654 if (!sd->parent_obj) return;
3656 top = elm_widget_top_get(sd->parent_obj);
3659 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3662 elm_object_focus_set(newest, EINA_FALSE);
3663 elm_object_focus_set(newest, EINA_TRUE);
3669 _smart_del(Evas_Object *obj)
3672 Edje_Signal_Data *esd;
3673 Elm_Translate_String_Data *ts;
3677 if (sd->del_pre_func) sd->del_pre_func(obj);
3680 sobj = sd->resize_obj;
3681 sd->resize_obj = NULL;
3682 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3683 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3684 evas_object_del(sobj);
3685 sd->resize_obj = NULL;
3689 sobj = sd->hover_obj;
3690 sd->hover_obj = NULL;
3691 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3692 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3693 evas_object_del(sobj);
3694 sd->hover_obj = NULL;
3696 EINA_LIST_FREE(sd->subobjs, sobj)
3698 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3699 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3700 evas_object_del(sobj);
3702 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3703 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3704 EINA_LIST_FREE(sd->edje_signals, esd)
3706 eina_stringshare_del(esd->emission);
3707 eina_stringshare_del(esd->source);
3710 EINA_LIST_FREE(sd->translate_strings, ts)
3712 eina_stringshare_del(ts->id);
3713 eina_stringshare_del(ts->domain);
3714 eina_stringshare_del(ts->string);
3717 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3718 if (sd->del_func) sd->del_func(obj);
3719 if (sd->style) eina_stringshare_del(sd->style);
3720 if (sd->type) eina_stringshare_del(sd->type);
3721 if (sd->theme) elm_theme_free(sd->theme);
3723 _if_focused_revert(obj, EINA_TRUE);
3724 if (sd->access_info) eina_stringshare_del(sd->access_info);
3726 evas_object_smart_data_set(obj, NULL);
3730 _smart_move(Evas_Object *obj,
3737 _smart_reconfigure(sd);
3741 _smart_resize(Evas_Object *obj,
3748 _smart_reconfigure(sd);
3752 _smart_show(Evas_Object *obj)
3757 if ((list = evas_object_smart_members_get(obj)))
3759 EINA_LIST_FREE(list, o)
3761 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3762 evas_object_show(o);
3768 _smart_hide(Evas_Object *obj)
3774 list = evas_object_smart_members_get(obj);
3775 EINA_LIST_FREE(list, o)
3777 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3778 evas_object_hide(o);
3783 _smart_color_set(Evas_Object *obj,
3792 if ((list = evas_object_smart_members_get(obj)))
3794 EINA_LIST_FREE(list, o)
3796 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3797 evas_object_color_set(o, r, g, b, a);
3803 _smart_clip_set(Evas_Object *obj,
3809 if ((list = evas_object_smart_members_get(obj)))
3811 EINA_LIST_FREE(list, o)
3813 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3814 evas_object_clip_set(o, clip);
3820 _smart_clip_unset(Evas_Object *obj)
3825 if ((list = evas_object_smart_members_get(obj)))
3827 EINA_LIST_FREE(list, o)
3829 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3830 evas_object_clip_unset(o);
3836 _smart_calculate(Evas_Object *obj)
3839 if (sd->changed_func) sd->changed_func(obj);
3842 /* never need to touch this */
3846 if (_e_smart) return;
3848 static const Evas_Smart_Class sc =
3851 EVAS_SMART_CLASS_VERSION,
3869 _e_smart = evas_smart_class_new(&sc);
3873 /* happy debug functions */
3876 _sub_obj_tree_dump(const Evas_Object *obj,
3881 for (i = 0; i < lvl * 3; i++)
3884 if (_elm_widget_is(obj))
3888 printf("+ %s(%p)\n",
3892 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3893 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3895 if (obj != sd->resize_obj)
3896 _sub_obj_tree_dump(obj, lvl + 1);
3900 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3904 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3907 if (!_elm_widget_is(obj))
3911 Eina_Bool visible = evas_object_visible_get(obj);
3912 Eina_Bool disabled = elm_widget_disabled_get(obj);
3913 Eina_Bool focused = elm_widget_focus_get(obj);
3914 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3918 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3921 fprintf(output, ", style=bold");
3924 fprintf(output, ", color=gray28");
3926 fprintf(output, " ];\n");
3929 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3930 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3931 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3935 fprintf(output, ", style=bold");
3938 fprintf(output, ", fontcolor=gray28");
3940 if ((disabled) || (!visible))
3941 fprintf(output, ", color=gray");
3943 fprintf(output, " ];\n");
3947 EINA_LIST_FOREACH(sd->subobjs, l, o)
3948 _sub_obj_tree_dot_dump(o, output);
3953 elm_widget_tree_dump(const Evas_Object *top)
3956 if (!_elm_widget_is(top))
3958 _sub_obj_tree_dump(top, 0);
3966 elm_widget_tree_dot_dump(const Evas_Object *top,
3970 if (!_elm_widget_is(top))
3972 fprintf(output, "graph " " { node [shape=record];\n");
3973 _sub_obj_tree_dot_dump(top, output);
3974 fprintf(output, "}\n");