1 #include <Elementary.h>
4 static const char SMART_NAME[] = "elm_widget";
7 Smart_Data * sd = evas_object_smart_data_get(obj); \
8 if ((!obj) || (!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;
27 Evas_Object *parent_obj;
29 Evas_Coord x, y, w, h;
31 Evas_Object *resize_obj;
32 Evas_Object *hover_obj;
33 Eina_List *tooltips, *cursors;
34 void (*del_func)(Evas_Object *obj);
35 void (*del_pre_func)(Evas_Object *obj);
36 void (*focus_func)(Evas_Object *obj);
37 void (*activate_func)(Evas_Object *obj);
38 void (*disable_func)(Evas_Object *obj);
39 void (*theme_func)(Evas_Object *obj);
40 Eina_Bool (*event_func)(Evas_Object *obj,
42 Evas_Callback_Type type,
44 void (*signal_func)(Evas_Object *obj,
47 void (*callback_add_func)(Evas_Object *obj,
52 void (*callback_del_func)(Evas_Object *obj,
57 void (*changed_func)(Evas_Object *obj);
58 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
59 Elm_Focus_Direction dir,
61 void (*on_focus_func)(void *data,
64 void (*on_change_func)(void *data,
67 void (*on_show_region_func)(void *data,
69 void *on_show_region_data;
70 void (*focus_region_func)(Evas_Object *obj,
75 void (*on_focus_region_func)(const Evas_Object *obj,
80 Elm_Widget_On_Text_Set_Cb on_text_set_func;
81 Elm_Widget_On_Text_Get_Cb on_text_get_func;
82 Elm_Widget_On_Content_Set_Cb on_content_set_func;
83 Elm_Widget_On_Content_Get_Cb on_content_get_func;
84 Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
86 Evas_Coord rx, ry, rw, rh;
92 const char *access_info;
93 unsigned int focus_order;
94 Eina_Bool focus_order_on_calc;
96 int child_drag_x_locked;
97 int child_drag_y_locked;
99 Eina_List *edje_signals;
101 Eina_Bool drag_x_locked : 1;
102 Eina_Bool drag_y_locked : 1;
104 Eina_Bool can_focus : 1;
105 Eina_Bool child_can_focus : 1;
106 Eina_Bool focused : 1;
107 Eina_Bool tree_unfocusable : 1;
108 Eina_Bool highlight_ignore : 1;
109 Eina_Bool highlight_in_theme : 1;
110 Eina_Bool disabled : 1;
111 Eina_Bool is_mirrored : 1;
112 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
114 Eina_List *focus_chain;
118 struct _Edje_Signal_Data
122 const char *emission;
127 struct _Elm_Event_Cb_Data
133 /* local subsystem functions */
134 static void _smart_reconfigure(Smart_Data *sd);
135 static void _smart_add(Evas_Object *obj);
136 static void _smart_del(Evas_Object *obj);
137 static void _smart_move(Evas_Object *obj,
140 static void _smart_resize(Evas_Object *obj,
143 static void _smart_show(Evas_Object *obj);
144 static void _smart_hide(Evas_Object *obj);
145 static void _smart_color_set(Evas_Object *obj,
150 static void _smart_clip_set(Evas_Object *obj,
152 static void _smart_clip_unset(Evas_Object *obj);
153 static void _smart_calculate(Evas_Object *obj);
154 static void _smart_init(void);
156 static void _if_focused_revert(Evas_Object *obj,
157 Eina_Bool can_focus_only);
158 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
159 unsigned int *newest_focus_order,
160 Eina_Bool can_focus_only);
162 /* local subsystem globals */
163 static Evas_Smart *_e_smart = NULL;
164 static Eina_List *widtypes = NULL;
166 static unsigned int focus_order = 0;
169 static inline Eina_Bool
170 _elm_widget_is(const Evas_Object *obj)
172 const char *type = evas_object_type_get(obj);
173 return type == SMART_NAME;
176 static inline Eina_Bool
177 _is_focusable(Evas_Object *obj)
179 API_ENTRY return EINA_FALSE;
180 return sd->can_focus || (sd->child_can_focus);
184 _unfocus_parents(Evas_Object *obj)
186 for (; obj; obj = elm_widget_parent_get(obj))
189 if (!sd->focused) return;
195 _focus_parents(Evas_Object *obj)
197 for (; obj; obj = elm_widget_parent_get(obj))
200 if (sd->focused) return;
206 _sub_obj_del(void *data,
209 void *event_info __UNUSED__)
211 Smart_Data *sd = data;
213 if (_elm_widget_is(obj))
215 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
217 if (obj == sd->resize_obj)
218 sd->resize_obj = NULL;
219 else if (obj == sd->hover_obj)
220 sd->hover_obj = NULL;
222 sd->subobjs = eina_list_remove(sd->subobjs, obj);
223 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
227 _sub_obj_hide(void *data __UNUSED__,
230 void *event_info __UNUSED__)
232 elm_widget_focus_hide_handle(obj);
236 _sub_obj_mouse_up(void *data __UNUSED__,
241 Evas_Event_Mouse_Up *ev = event_info;
242 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
243 elm_widget_focus_mouse_up_handle(obj);
247 _propagate_x_drag_lock(Evas_Object *obj,
253 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
256 sd2->child_drag_x_locked += dir;
257 _propagate_x_drag_lock(sd->parent_obj, dir);
263 _propagate_y_drag_lock(Evas_Object *obj,
269 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
272 sd2->child_drag_y_locked += dir;
273 _propagate_y_drag_lock(sd->parent_obj, dir);
279 _propagate_event(void *data,
285 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
286 Evas_Event_Flags *event_flags = NULL;
290 case EVAS_CALLBACK_KEY_DOWN:
292 Evas_Event_Key_Down *ev = event_info;
293 event_flags = &(ev->event_flags);
297 case EVAS_CALLBACK_KEY_UP:
299 Evas_Event_Key_Up *ev = event_info;
300 event_flags = &(ev->event_flags);
304 case EVAS_CALLBACK_MOUSE_WHEEL:
306 Evas_Event_Mouse_Wheel *ev = event_info;
307 event_flags = &(ev->event_flags);
315 elm_widget_event_propagate(obj, type, event_info, event_flags);
319 _parent_focus(Evas_Object *obj)
322 if (sd->focused) return;
324 Evas_Object *o = elm_widget_parent_get(obj);
325 sd->focus_order_on_calc = EINA_TRUE;
327 if (o) _parent_focus(o);
329 if (!sd->focus_order_on_calc)
330 return; /* we don't want to override it if by means of any of the
331 callbacks below one gets to calculate our order
335 sd->focus_order = focus_order;
336 sd->focused = EINA_TRUE;
337 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
338 if (sd->focus_func) sd->focus_func(obj);
340 _elm_widget_focus_region_show(obj);
342 sd->focus_order_on_calc = EINA_FALSE;
346 _elm_object_focus_chain_del_cb(void *data,
349 void *event_info __UNUSED__)
351 Smart_Data *sd = data;
353 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
356 // exposed util funcs to elm
358 _elm_widget_type_clear(void)
362 EINA_LIST_FREE(widtypes, ptr)
364 eina_stringshare_del(*ptr);
370 _elm_widget_focus_region_show(const Evas_Object *obj)
372 Evas_Coord x, y, w, h, ox, oy;
378 o = elm_widget_parent_get(obj);
381 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
382 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
386 sd2 = evas_object_smart_data_get(o);
387 if (sd2->focus_region_func)
389 sd2->focus_region_func(o, x, y, w, h);
390 elm_widget_focus_region_get(o, &x, &y, &w, &h);
394 evas_object_geometry_get(o, &px, &py, NULL, NULL);
400 o = elm_widget_parent_get(o);
405 * @defgroup Widget Widget
408 * Exposed api for making widgets
411 elm_widget_type_register(const char **ptr)
413 widtypes = eina_list_append(widtypes, (void *)ptr);
417 * @defgroup Widget Widget
420 * Disposed api for making widgets
423 elm_widget_type_unregister(const char **ptr)
425 widtypes = eina_list_remove(widtypes, (void *)ptr);
429 elm_widget_api_check(int ver)
431 if (ver != ELM_INTERNAL_API_VERSION)
433 CRITICAL("Elementary widget api versions do not match");
440 elm_widget_add(Evas *evas)
444 obj = evas_object_smart_add(evas, _e_smart);
445 elm_widget_mirrored_set(obj, elm_mirrored_get());
450 elm_widget_del_hook_set(Evas_Object *obj,
451 void (*func)(Evas_Object *obj))
458 elm_widget_del_pre_hook_set(Evas_Object *obj,
459 void (*func)(Evas_Object *obj))
462 sd->del_pre_func = func;
466 elm_widget_focus_hook_set(Evas_Object *obj,
467 void (*func)(Evas_Object *obj))
470 sd->focus_func = func;
474 elm_widget_activate_hook_set(Evas_Object *obj,
475 void (*func)(Evas_Object *obj))
478 sd->activate_func = func;
482 elm_widget_disable_hook_set(Evas_Object *obj,
483 void (*func)(Evas_Object *obj))
486 sd->disable_func = func;
490 elm_widget_theme_hook_set(Evas_Object *obj,
491 void (*func)(Evas_Object *obj))
494 sd->theme_func = func;
498 elm_widget_event_hook_set(Evas_Object *obj,
499 Eina_Bool (*func)(Evas_Object *obj,
501 Evas_Callback_Type type,
505 sd->event_func = func;
509 elm_widget_text_set_hook_set(Evas_Object *obj,
510 Elm_Widget_On_Text_Set_Cb func)
513 sd->on_text_set_func = func;
517 elm_widget_text_get_hook_set(Evas_Object *obj,
518 Elm_Widget_On_Text_Get_Cb func)
521 sd->on_text_get_func = func;
525 elm_widget_content_set_hook_set(Evas_Object *obj,
526 Elm_Widget_On_Content_Set_Cb func)
529 sd->on_content_set_func = func;
533 elm_widget_content_get_hook_set(Evas_Object *obj,
534 Elm_Widget_On_Content_Get_Cb func)
537 sd->on_content_get_func = func;
541 elm_widget_content_unset_hook_set(Evas_Object *obj,
542 Elm_Widget_On_Content_Unset_Cb func)
545 sd->on_content_unset_func = func;
549 elm_widget_changed_hook_set(Evas_Object *obj,
550 void (*func)(Evas_Object *obj))
553 sd->changed_func = func;
557 elm_widget_signal_emit_hook_set(Evas_Object *obj,
558 void (*func)(Evas_Object *obj,
559 const char *emission,
563 sd->signal_func = func;
567 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
568 void (*func)(Evas_Object *obj,
569 const char *emission,
571 Edje_Signal_Cb func_cb,
575 sd->callback_add_func = func;
579 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
580 void (*func)(Evas_Object *obj,
581 const char *emission,
583 Edje_Signal_Cb func_cb,
587 sd->callback_del_func = func;
591 elm_widget_theme(Evas_Object *obj)
599 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
600 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
601 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
602 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
603 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
604 if (sd->theme_func) sd->theme_func(obj);
608 elm_widget_theme_specific(Evas_Object *obj,
616 Elm_Theme *th2, *thdef;
619 thdef = elm_theme_default_get();
624 if (!th2) th2 = thdef;
632 if (th2 == thdef) break;
633 th2 = th2->ref_theme;
634 if (!th2) th2 = thdef;
638 EINA_LIST_FOREACH(sd->subobjs, l, child)
639 elm_widget_theme_specific(child, th, force);
640 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
641 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
642 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
643 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
644 if (sd->theme_func) sd->theme_func(obj);
650 * Set hook to get next object in object focus chain.
652 * @param obj The widget object.
653 * @param func The hook to be used with this widget.
658 elm_widget_focus_next_hook_set(Evas_Object *obj,
659 Eina_Bool (*func)(const Evas_Object *obj,
660 Elm_Focus_Direction dir,
664 sd->focus_next_func = func;
668 * Returns the widget's mirrored mode.
670 * @param obj The widget.
671 * @return mirrored mode of the object.
675 elm_widget_mirrored_get(const Evas_Object *obj)
677 API_ENTRY return EINA_FALSE;
678 return sd->is_mirrored;
682 * Sets the widget's mirrored mode.
684 * @param obj The widget.
685 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
688 elm_widget_mirrored_set(Evas_Object *obj,
692 if (sd->is_mirrored != mirrored)
694 sd->is_mirrored = mirrored;
695 elm_widget_theme(obj);
701 * Resets the mirrored mode from the system mirror mode for widgets that are in
702 * automatic mirroring mode. This function does not call elm_widget_theme.
704 * @param obj The widget.
705 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
708 _elm_widget_mirrored_reload(Evas_Object *obj)
711 Eina_Bool mirrored = elm_mirrored_get();
712 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
714 sd->is_mirrored = mirrored;
719 * Returns the widget's mirrored mode setting.
721 * @param obj The widget.
722 * @return mirrored mode setting of the object.
726 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
728 API_ENTRY return EINA_FALSE;
729 return sd->mirrored_auto_mode;
733 * Sets the widget's mirrored mode setting.
734 * When widget in automatic mode, it follows the system mirrored mode set by
735 * elm_mirrored_set().
736 * @param obj The widget.
737 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
740 elm_widget_mirrored_automatic_set(Evas_Object *obj,
744 if (sd->mirrored_auto_mode != automatic)
746 sd->mirrored_auto_mode = automatic;
750 elm_widget_mirrored_set(obj, elm_mirrored_get());
756 elm_widget_on_focus_hook_set(Evas_Object *obj,
757 void (*func)(void *data,
762 sd->on_focus_func = func;
763 sd->on_focus_data = data;
767 elm_widget_on_change_hook_set(Evas_Object *obj,
768 void (*func)(void *data,
773 sd->on_change_func = func;
774 sd->on_change_data = data;
778 elm_widget_on_show_region_hook_set(Evas_Object *obj,
779 void (*func)(void *data,
784 sd->on_show_region_func = func;
785 sd->on_show_region_data = data;
791 * Set the hook to use to show the focused region.
793 * Whenever a new widget gets focused or it's needed to show the focused
794 * area of the current one, this hook will be called on objects that may
795 * want to move their children into their visible area.
796 * The area given in the hook function is relative to the @p obj widget.
798 * @param obj The widget object
799 * @param func The function to call to show the specified area.
804 elm_widget_focus_region_hook_set(Evas_Object *obj,
805 void (*func)(Evas_Object *obj,
812 sd->focus_region_func = func;
818 * Set the hook to retrieve the focused region of a widget.
820 * This hook will be called by elm_widget_focus_region_get() whenever
821 * it's needed to get the focused area of a widget. The area must be relative
822 * to the widget itself and if no hook is set, it will default to the entire
825 * @param obj The widget object
826 * @param func The function used to retrieve the focus region.
831 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
832 void (*func)(const Evas_Object *obj,
839 sd->on_focus_region_func = func;
843 elm_widget_data_set(Evas_Object *obj,
851 elm_widget_data_get(const Evas_Object *obj)
853 API_ENTRY return NULL;
858 elm_widget_sub_object_add(Evas_Object *obj,
862 double scale, pscale = elm_widget_scale_get(sobj);
863 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
864 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
866 if (_elm_widget_is(sobj))
868 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
871 if (sd2->parent_obj == obj)
874 elm_widget_sub_object_del(sd2->parent_obj, sobj);
875 sd2->parent_obj = obj;
876 if (!sd->child_can_focus && (_is_focusable(sobj)))
877 sd->child_can_focus = EINA_TRUE;
882 void *data = evas_object_data_get(sobj, "elm-parent");
885 if (data == obj) return;
886 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
891 sd->subobjs = eina_list_append(sd->subobjs, sobj);
892 evas_object_data_set(sobj, "elm-parent", obj);
893 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
894 if (_elm_widget_is(sobj))
895 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
896 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
897 scale = elm_widget_scale_get(sobj);
898 th = elm_widget_theme_get(sobj);
899 mirrored = elm_widget_mirrored_get(sobj);
900 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
901 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
905 elm_widget_sub_object_del(Evas_Object *obj,
908 Evas_Object *sobj_parent;
912 sobj_parent = evas_object_data_del(sobj, "elm-parent");
913 if (sobj_parent != obj)
915 static int abort_on_warn = -1;
916 ERR("removing sub object %p from parent %p, "
917 "but elm-parent is different %p!",
918 sobj, obj, sobj_parent);
919 if (EINA_UNLIKELY(abort_on_warn == -1))
921 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
922 else abort_on_warn = 0;
924 if (abort_on_warn == 1) abort();
926 if (_elm_widget_is(sobj))
928 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
931 sd2->parent_obj = NULL;
932 if (sd2->resize_obj == sobj)
933 sd2->resize_obj = NULL;
935 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
938 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
939 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
940 if ((sd->child_can_focus) && (_is_focusable(sobj)))
944 sd->child_can_focus = EINA_FALSE;
945 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
947 if (_is_focusable(subobj))
949 sd->child_can_focus = EINA_TRUE;
956 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
957 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
959 if (_elm_widget_is(sobj))
960 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
962 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
966 elm_widget_resize_object_set(Evas_Object *obj,
970 // orphan previous resize obj
973 evas_object_clip_unset(sd->resize_obj);
974 evas_object_data_del(sd->resize_obj, "elm-parent");
975 if (_elm_widget_is(sd->resize_obj))
977 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
978 if (sd2) sd2->parent_obj = NULL;
979 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
982 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
984 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
985 _sub_obj_mouse_up, sd);
986 evas_object_smart_member_del(sd->resize_obj);
987 if (_elm_widget_is(sd->resize_obj))
989 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
992 // orphan new resize obj
995 evas_object_data_del(sobj, "elm-parent");
996 if (_elm_widget_is(sobj))
998 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
999 if (sd2) sd2->parent_obj = NULL;
1000 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1003 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1005 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1006 _sub_obj_mouse_up, sd);
1007 evas_object_smart_member_del(sobj);
1008 if (_elm_widget_is(sobj))
1010 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1013 // set the resize obj up
1014 sd->resize_obj = sobj;
1017 if (_elm_widget_is(sd->resize_obj))
1019 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1020 if (sd2) sd2->parent_obj = obj;
1021 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1024 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1025 evas_object_smart_member_add(sobj, obj);
1026 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1028 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1029 _sub_obj_mouse_up, sd);
1030 _smart_reconfigure(sd);
1031 evas_object_data_set(sobj, "elm-parent", obj);
1032 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1033 if (_elm_widget_is(sobj))
1035 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1041 elm_widget_hover_object_set(Evas_Object *obj,
1047 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1050 sd->hover_obj = sobj;
1053 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1055 _smart_reconfigure(sd);
1060 elm_widget_can_focus_set(Evas_Object *obj,
1061 Eina_Bool can_focus)
1064 sd->can_focus = can_focus;
1067 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1069 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1070 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1072 (void *)(long)EVAS_CALLBACK_KEY_UP);
1073 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1075 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1079 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1081 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1083 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1089 elm_widget_can_focus_get(const Evas_Object *obj)
1091 API_ENTRY return EINA_FALSE;
1092 return sd->can_focus;
1096 elm_widget_child_can_focus_get(const Evas_Object *obj)
1098 API_ENTRY return EINA_FALSE;
1099 return sd->child_can_focus;
1105 * This API makes the widget object and its children to be unfocusable.
1107 * This API can be helpful for an object to be deleted.
1108 * When an object will be deleted soon, it and its children may not
1109 * want to get focus (by focus reverting or by other focus controls).
1110 * Then, just use this API before deleting.
1112 * @param obj The widget root of sub-tree
1113 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1118 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1119 Eina_Bool tree_unfocusable)
1123 if (sd->tree_unfocusable == tree_unfocusable) return;
1124 sd->tree_unfocusable = !!tree_unfocusable;
1125 elm_widget_focus_tree_unfocusable_handle(obj);
1131 * This returns true, if the object sub-tree is unfocusable.
1133 * @param obj The widget root of sub-tree
1134 * @return EINA_TRUE if the object sub-tree is unfocusable
1139 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1141 API_ENTRY return EINA_FALSE;
1142 return sd->tree_unfocusable;
1148 * Get the list of focusable child objects.
1150 * This function retruns list of child objects which can get focus.
1152 * @param obj The parent widget
1153 * @retrun list of focusable child objects.
1158 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1160 API_ENTRY return NULL;
1163 Eina_List *child_list = NULL;
1168 EINA_LIST_FOREACH(sd->subobjs, l, child)
1170 if ((elm_widget_can_focus_get(child)) &&
1171 (evas_object_visible_get(child)) &&
1172 (!elm_widget_disabled_get(child)))
1173 child_list = eina_list_append(child_list, child);
1174 else if (elm_widget_is(child))
1176 Eina_List *can_focus_list;
1177 can_focus_list = elm_widget_can_focus_child_list_get(child);
1179 child_list = eina_list_merge(child_list, can_focus_list);
1187 elm_widget_highlight_ignore_set(Evas_Object *obj,
1191 sd->highlight_ignore = !!ignore;
1195 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1197 API_ENTRY return EINA_FALSE;
1198 return sd->highlight_ignore;
1202 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1203 Eina_Bool highlight)
1206 sd->highlight_in_theme = !!highlight;
1207 /* FIXME: if focused, it should switch from one mode to the other */
1211 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1213 API_ENTRY return EINA_FALSE;
1214 return sd->highlight_in_theme;
1218 elm_widget_focus_get(const Evas_Object *obj)
1220 API_ENTRY return EINA_FALSE;
1225 elm_widget_focused_object_get(const Evas_Object *obj)
1227 const Evas_Object *subobj;
1229 API_ENTRY return NULL;
1231 if (!sd->focused) return NULL;
1232 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1234 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1235 if (fobj) return fobj;
1237 return (Evas_Object *)obj;
1241 elm_widget_top_get(const Evas_Object *obj)
1243 API_ENTRY return NULL;
1244 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1245 return (Evas_Object *)obj;
1249 elm_widget_is(const Evas_Object *obj)
1251 return _elm_widget_is(obj);
1255 elm_widget_parent_widget_get(const Evas_Object *obj)
1257 Evas_Object *parent;
1259 if (_elm_widget_is(obj))
1261 Smart_Data *sd = evas_object_smart_data_get(obj);
1262 if (!sd) return NULL;
1263 parent = sd->parent_obj;
1267 parent = evas_object_data_get(obj, "elm-parent");
1268 if (!parent) parent = evas_object_smart_parent_get(obj);
1273 Evas_Object *elm_parent;
1274 if (_elm_widget_is(parent)) break;
1275 elm_parent = evas_object_data_get(parent, "elm-parent");
1276 if (elm_parent) parent = elm_parent;
1277 else parent = evas_object_smart_parent_get(parent);
1283 elm_widget_parent2_get(const Evas_Object *obj)
1285 if (_elm_widget_is(obj))
1287 Smart_Data *sd = evas_object_smart_data_get(obj);
1288 if (sd) return sd->parent2;
1294 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1297 sd->parent2 = parent;
1301 elm_widget_event_callback_add(Evas_Object *obj,
1306 EINA_SAFETY_ON_NULL_RETURN(func);
1307 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1310 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1314 elm_widget_event_callback_del(Evas_Object *obj,
1318 API_ENTRY return NULL;
1319 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1321 Elm_Event_Cb_Data *ecd;
1322 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1323 if ((ecd->func == func) && (ecd->data == data))
1326 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1327 return (void *)data;
1333 elm_widget_event_propagate(Evas_Object *obj,
1334 Evas_Callback_Type type,
1336 Evas_Event_Flags *event_flags)
1338 API_ENTRY return EINA_FALSE; //TODO reduce.
1339 if (!_elm_widget_is(obj)) return EINA_FALSE;
1340 Evas_Object *parent = obj;
1341 Elm_Event_Cb_Data *ecd;
1342 Eina_List *l, *l_prev;
1345 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1347 sd = evas_object_smart_data_get(parent);
1348 if ((!sd) || (!_elm_widget_is(obj)))
1349 return EINA_FALSE; //Not Elm Widget
1351 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1354 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1356 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1357 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1360 parent = sd->parent_obj;
1369 * Set custom focus chain.
1371 * This function i set one new and overwrite any previous custom focus chain
1372 * with the list of objects. The previous list will be deleted and this list
1373 * will be managed. After setted, don't modity it.
1375 * @note On focus cycle, only will be evaluated children of this container.
1377 * @param obj The container widget
1378 * @param objs Chain of objects to pass focus
1382 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1386 if (!sd->focus_next_func)
1389 elm_widget_focus_custom_chain_unset(obj);
1394 EINA_LIST_FOREACH(objs, l, o)
1396 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1397 _elm_object_focus_chain_del_cb, sd);
1400 sd->focus_chain = objs;
1406 * Get custom focus chain
1408 * @param obj The container widget
1411 EAPI const Eina_List *
1412 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1414 API_ENTRY return NULL;
1415 return (const Eina_List *)sd->focus_chain;
1421 * Unset custom focus chain
1423 * @param obj The container widget
1427 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1430 Eina_List *l, *l_next;
1433 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1435 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1436 _elm_object_focus_chain_del_cb, sd);
1437 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1444 * Append object to custom focus chain.
1446 * @note If relative_child equal to NULL or not in custom chain, the object
1447 * will be added in end.
1449 * @note On focus cycle, only will be evaluated children of this container.
1451 * @param obj The container widget
1452 * @param child The child to be added in custom chain
1453 * @param relative_child The relative object to position the child
1457 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1459 Evas_Object *relative_child)
1462 EINA_SAFETY_ON_NULL_RETURN(child);
1463 if (!sd->focus_next_func)
1466 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1467 _elm_object_focus_chain_del_cb, sd);
1469 if (!relative_child)
1471 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1475 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1482 * Prepend object to custom focus chain.
1484 * @note If relative_child equal to NULL or not in custom chain, the object
1485 * will be added in begin.
1487 * @note On focus cycle, only will be evaluated children of this container.
1489 * @param obj The container widget
1490 * @param child The child to be added in custom chain
1491 * @param relative_child The relative object to position the child
1495 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1497 Evas_Object *relative_child)
1500 EINA_SAFETY_ON_NULL_RETURN(child);
1501 if (!sd->focus_next_func)
1504 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1505 _elm_object_focus_chain_del_cb, sd);
1507 if (!relative_child)
1509 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1513 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1520 * Give focus to next object in object tree.
1522 * Give focus to next object in focus chain of one object sub-tree.
1523 * If the last object of chain already have focus, the focus will go to the
1524 * first object of chain.
1526 * @param obj The widget root of sub-tree
1527 * @param dir Direction to cycle the focus
1532 elm_widget_focus_cycle(Evas_Object *obj,
1533 Elm_Focus_Direction dir)
1535 Evas_Object *target = NULL;
1536 if (!_elm_widget_is(obj))
1538 elm_widget_focus_next_get(obj, dir, &target);
1540 elm_widget_focus_steal(target);
1546 * Give focus to near object in one direction.
1548 * Give focus to near object in direction of one object.
1549 * If none focusable object in given direction, the focus will not change.
1551 * @param obj The reference widget
1552 * @param x Horizontal component of direction to focus
1553 * @param y Vertical component of direction to focus
1558 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1568 * Get next object in focus chain of object tree.
1570 * Get next object in focus chain of one object sub-tree.
1571 * Return the next object by reference. If don't have any candidate to receive
1572 * focus before chain end, the first candidate will be returned.
1574 * @param obj The widget root of sub-tree
1575 * @param dir Direction os focus chain
1576 * @param next The next object in focus chain
1577 * @return EINA_TRUE if don't need focus chain restart/loop back
1578 * to use 'next' obj.
1583 elm_widget_focus_next_get(const Evas_Object *obj,
1584 Elm_Focus_Direction dir,
1591 API_ENTRY return EINA_FALSE;
1593 /* Ignore if disabled */
1594 if ((!evas_object_visible_get(obj))
1595 || (elm_widget_disabled_get(obj))
1596 || (elm_widget_tree_unfocusable_get(obj)))
1600 if (sd->focus_next_func)
1601 return sd->focus_next_func(obj, dir, next);
1603 if (!elm_widget_can_focus_get(obj))
1607 *next = (Evas_Object *)obj;
1608 return !elm_widget_focus_get(obj);
1614 * Get next object in focus chain of object tree in list.
1616 * Get next object in focus chain of one object sub-tree ordered by one list.
1617 * Return the next object by reference. If don't have any candidate to receive
1618 * focus before list end, the first candidate will be returned.
1620 * @param obj The widget root of sub-tree
1621 * @param dir Direction os focus chain
1622 * @param items list with ordered objects
1623 * @param list_data_get function to get the object from one item of list
1624 * @param next The next object in focus chain
1625 * @return EINA_TRUE if don't need focus chain restart/loop back
1626 * to use 'next' obj.
1631 elm_widget_focus_list_next_get(const Evas_Object *obj,
1632 const Eina_List *items,
1633 void *(*list_data_get)(const Eina_List * list),
1634 Elm_Focus_Direction dir,
1637 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1643 if (!_elm_widget_is(obj))
1650 if (dir == ELM_FOCUS_PREVIOUS)
1652 items = eina_list_last(items);
1653 list_next = eina_list_prev;
1655 else if (dir == ELM_FOCUS_NEXT)
1656 list_next = eina_list_next;
1660 const Eina_List *l = items;
1662 /* Recovery last focused sub item */
1663 if (elm_widget_focus_get(obj))
1664 for (; l; l = list_next(l))
1666 Evas_Object *cur = list_data_get(l);
1667 if (elm_widget_focus_get(cur)) break;
1670 const Eina_List *start = l;
1671 Evas_Object *to_focus = NULL;
1673 /* Interate sub items */
1674 /* Go to end of list */
1675 for (; l; l = list_next(l))
1677 Evas_Object *tmp = NULL;
1678 Evas_Object *cur = list_data_get(l);
1680 if (elm_widget_parent_get(cur) != obj)
1683 /* Try Focus cycle in subitem */
1684 if (elm_widget_focus_next_get(cur, dir, &tmp))
1689 else if ((tmp) && (!to_focus))
1695 /* Get First possible */
1696 for (; l != start; l = list_next(l))
1698 Evas_Object *tmp = NULL;
1699 Evas_Object *cur = list_data_get(l);
1701 if (elm_widget_parent_get(cur) != obj)
1704 /* Try Focus cycle in subitem */
1705 elm_widget_focus_next_get(cur, dir, &tmp);
1718 elm_widget_signal_emit(Evas_Object *obj,
1719 const char *emission,
1723 if (!sd->signal_func) return;
1724 sd->signal_func(obj, emission, source);
1728 _edje_signal_callback(void *data,
1729 Evas_Object *obj __UNUSED__,
1730 const char *emission,
1733 Edje_Signal_Data *esd = data;
1734 esd->func(esd->data, esd->obj, emission, source);
1738 elm_widget_signal_callback_add(Evas_Object *obj,
1739 const char *emission,
1741 Edje_Signal_Cb func,
1744 Edje_Signal_Data *esd;
1746 if (!sd->callback_add_func) return;
1747 EINA_SAFETY_ON_NULL_RETURN(func);
1749 esd = ELM_NEW(Edje_Signal_Data);
1754 esd->emission = eina_stringshare_add(emission);
1755 esd->source = eina_stringshare_add(source);
1757 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1758 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1762 elm_widget_signal_callback_del(Evas_Object *obj,
1763 const char *emission,
1765 Edje_Signal_Cb func)
1767 Edje_Signal_Data *esd;
1770 API_ENTRY return NULL;
1771 if (!sd->callback_del_func) return NULL;
1773 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1775 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1776 (!strcmp(esd->source, source)))
1778 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1779 eina_stringshare_del(esd->emission);
1780 eina_stringshare_del(esd->source);
1786 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1791 elm_widget_focus_set(Evas_Object *obj,
1798 sd->focus_order = focus_order;
1799 sd->focused = EINA_TRUE;
1800 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1804 sd->focus_func(obj);
1811 if ((_is_focusable(sd->resize_obj)) &&
1812 (!elm_widget_disabled_get(sd->resize_obj)))
1814 elm_widget_focus_set(sd->resize_obj, first);
1820 EINA_LIST_FOREACH(sd->subobjs, l, child)
1822 if ((_is_focusable(child)) &&
1823 (!elm_widget_disabled_get(child)))
1825 elm_widget_focus_set(child, first);
1835 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1837 if ((_is_focusable(child)) &&
1838 (!elm_widget_disabled_get(child)))
1840 elm_widget_focus_set(child, first);
1846 if ((_is_focusable(sd->resize_obj)) &&
1847 (!elm_widget_disabled_get(sd->resize_obj)))
1849 elm_widget_focus_set(sd->resize_obj, first);
1857 elm_widget_parent_get(const Evas_Object *obj)
1859 API_ENTRY return NULL;
1860 return sd->parent_obj;
1864 elm_widget_focused_object_clear(Evas_Object *obj)
1867 if (!sd->focused) return;
1868 if (elm_widget_focus_get(sd->resize_obj))
1869 elm_widget_focused_object_clear(sd->resize_obj);
1874 EINA_LIST_FOREACH(sd->subobjs, l, child)
1876 if (elm_widget_focus_get(child))
1878 elm_widget_focused_object_clear(child);
1883 sd->focused = EINA_FALSE;
1884 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1885 if (sd->focus_func) sd->focus_func(obj);
1889 elm_widget_focus_steal(Evas_Object *obj)
1891 Evas_Object *parent, *parent2, *o;
1894 if (sd->focused) return;
1895 if (sd->disabled) return;
1896 if (!sd->can_focus) return;
1897 if (sd->tree_unfocusable) return;
1901 o = elm_widget_parent_get(parent);
1903 sd = evas_object_smart_data_get(o);
1904 if (sd->disabled || sd->tree_unfocusable) return;
1905 if (sd->focused) break;
1908 if ((!elm_widget_parent_get(parent)) &&
1909 (!elm_widget_parent2_get(parent)))
1910 elm_widget_focused_object_clear(parent);
1913 parent2 = elm_widget_parent_get(parent);
1914 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1916 sd = evas_object_smart_data_get(parent);
1919 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1920 elm_widget_focused_object_clear(sd->resize_obj);
1925 EINA_LIST_FOREACH(sd->subobjs, l, child)
1927 if (elm_widget_focus_get(child))
1929 elm_widget_focused_object_clear(child);
1941 elm_widget_focus_restore(Evas_Object *obj)
1943 Evas_Object *newest = NULL;
1944 unsigned int newest_focus_order = 0;
1947 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1950 elm_object_focus_set(newest, EINA_FALSE);
1951 elm_object_focus_set(newest, EINA_TRUE);
1956 elm_widget_activate(Evas_Object *obj)
1959 elm_widget_change(obj);
1960 if (sd->activate_func) sd->activate_func(obj);
1964 elm_widget_change(Evas_Object *obj)
1967 elm_widget_change(elm_widget_parent_get(obj));
1968 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
1972 elm_widget_disabled_set(Evas_Object *obj,
1977 if (sd->disabled == disabled) return;
1978 sd->disabled = !!disabled;
1979 elm_widget_focus_disabled_handle(obj);
1980 if (sd->disable_func) sd->disable_func(obj);
1984 elm_widget_disabled_get(const Evas_Object *obj)
1987 return sd->disabled;
1991 elm_widget_show_region_set(Evas_Object *obj,
1996 Eina_Bool forceshow)
1998 Evas_Object *parent_obj, *child_obj;
1999 Evas_Coord px, py, cx, cy;
2002 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2003 && (w == sd->rw) && (h == sd->rh)) return;
2008 if (sd->on_show_region_func)
2009 sd->on_show_region_func(sd->on_show_region_data, obj);
2013 parent_obj = sd->parent_obj;
2014 child_obj = sd->obj;
2015 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2016 sd = evas_object_smart_data_get(parent_obj);
2019 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2020 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2029 if (sd->on_show_region_func)
2031 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2038 elm_widget_show_region_get(const Evas_Object *obj,
2054 * Get the focus region of the given widget.
2056 * The focus region is the area of a widget that should brought into the
2057 * visible area when the widget is focused. Mostly used to show the part of
2058 * an entry where the cursor is, for example. The area returned is relative
2059 * to the object @p obj.
2060 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2061 * function will return the full size of the object.
2063 * @param obj The widget object
2064 * @param x Where to store the x coordinate of the area
2065 * @param y Where to store the y coordinate of the area
2066 * @param w Where to store the width of the area
2067 * @param h Where to store the height of the area
2072 elm_widget_focus_region_get(const Evas_Object *obj,
2082 sd = evas_object_smart_data_get(obj);
2083 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2085 evas_object_geometry_get(obj, NULL, NULL, w, h);
2090 sd->on_focus_region_func(obj, x, y, w, h);
2094 elm_widget_scroll_hold_push(Evas_Object *obj)
2098 if (sd->scroll_hold == 1)
2099 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2100 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2101 // FIXME: on delete/reparent hold pop
2105 elm_widget_scroll_hold_pop(Evas_Object *obj)
2109 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2110 if (!sd->scroll_hold)
2111 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2112 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2116 elm_widget_scroll_hold_get(const Evas_Object *obj)
2119 return sd->scroll_hold;
2123 elm_widget_scroll_freeze_push(Evas_Object *obj)
2126 sd->scroll_freeze++;
2127 if (sd->scroll_freeze == 1)
2128 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2129 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2130 // FIXME: on delete/reparent freeze pop
2134 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2137 sd->scroll_freeze--;
2138 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2139 if (!sd->scroll_freeze)
2140 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2141 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2145 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2148 return sd->scroll_freeze;
2152 elm_widget_scale_set(Evas_Object *obj,
2156 if (scale <= 0.0) scale = 0.0;
2157 if (sd->scale != scale)
2160 elm_widget_theme(obj);
2165 elm_widget_scale_get(const Evas_Object *obj)
2167 API_ENTRY return 1.0;
2168 // FIXME: save walking up the tree by storing/caching parent scale
2169 if (sd->scale == 0.0)
2172 return elm_widget_scale_get(sd->parent_obj);
2180 elm_widget_theme_set(Evas_Object *obj,
2184 if (sd->theme != th)
2186 if (sd->theme) elm_theme_free(sd->theme);
2189 elm_widget_theme(obj);
2194 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2198 if (!sd->on_text_set_func)
2201 sd->on_text_set_func(obj, part, label);
2205 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2207 API_ENTRY return NULL;
2209 if (!sd->on_text_get_func)
2212 return sd->on_text_get_func(obj, part);
2216 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2220 if (!sd->on_content_set_func) return;
2221 sd->on_content_set_func(obj, part, content);
2225 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2227 API_ENTRY return NULL;
2229 if (!sd->on_content_get_func) return NULL;
2230 return sd->on_content_get_func(obj, part);
2234 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2236 API_ENTRY return NULL;
2238 if (!sd->on_content_unset_func) return NULL;
2239 return sd->on_content_unset_func(obj, part);
2243 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2246 if (sd->access_info) eina_stringshare_del(sd->access_info);
2247 if (!txt) sd->access_info = NULL;
2248 else sd->access_info = eina_stringshare_add(txt);
2252 elm_widget_access_info_get(Evas_Object *obj)
2254 API_ENTRY return NULL;
2255 return sd->access_info;
2260 elm_widget_theme_get(const Evas_Object *obj)
2262 API_ENTRY return NULL;
2266 return elm_widget_theme_get(sd->parent_obj);
2274 elm_widget_style_set(Evas_Object *obj,
2279 if (eina_stringshare_replace(&sd->style, style))
2280 elm_widget_theme(obj);
2284 elm_widget_style_get(const Evas_Object *obj)
2286 API_ENTRY return NULL;
2287 if (sd->style) return sd->style;
2292 elm_widget_type_set(Evas_Object *obj,
2296 eina_stringshare_replace(&sd->type, type);
2300 elm_widget_type_get(const Evas_Object *obj)
2302 API_ENTRY return NULL;
2303 if (sd->type) return sd->type;
2308 elm_widget_tooltip_add(Evas_Object *obj,
2312 sd->tooltips = eina_list_append(sd->tooltips, tt);
2316 elm_widget_tooltip_del(Evas_Object *obj,
2320 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2324 elm_widget_cursor_add(Evas_Object *obj,
2328 sd->cursors = eina_list_append(sd->cursors, cur);
2332 elm_widget_cursor_del(Evas_Object *obj,
2336 sd->cursors = eina_list_remove(sd->cursors, cur);
2340 elm_widget_drag_lock_x_set(Evas_Object *obj,
2344 if (sd->drag_x_locked == lock) return;
2345 sd->drag_x_locked = lock;
2346 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2347 else _propagate_x_drag_lock(obj, -1);
2351 elm_widget_drag_lock_y_set(Evas_Object *obj,
2355 if (sd->drag_y_locked == lock) return;
2356 sd->drag_y_locked = lock;
2357 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2358 else _propagate_y_drag_lock(obj, -1);
2362 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2364 API_ENTRY return EINA_FALSE;
2365 return sd->drag_x_locked;
2369 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2371 API_ENTRY return EINA_FALSE;
2372 return sd->drag_y_locked;
2376 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2379 return sd->child_drag_x_locked;
2383 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2386 return sd->child_drag_y_locked;
2390 elm_widget_theme_object_set(Evas_Object *obj,
2393 const char *welement,
2396 API_ENTRY return EINA_FALSE;
2397 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2401 elm_widget_is_check(const Evas_Object *obj)
2403 static int abort_on_warn = -1;
2404 if (elm_widget_is(obj))
2407 ERR("Passing Object: %p.", obj);
2408 if (abort_on_warn == -1)
2410 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2411 else abort_on_warn = 0;
2413 if (abort_on_warn == 1) abort();
2418 elm_widget_type_check(const Evas_Object *obj,
2421 const char *provided, *expected = "(unknown)";
2422 static int abort_on_warn = -1;
2423 provided = elm_widget_type_get(obj);
2424 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2425 if (type) expected = type;
2426 if ((!provided) || (!provided[0]))
2428 provided = evas_object_type_get(obj);
2429 if ((!provided) || (!provided[0]))
2430 provided = "(unknown)";
2432 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2433 if (abort_on_warn == -1)
2435 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2436 else abort_on_warn = 0;
2438 if (abort_on_warn == 1) abort();
2445 * Split string in words
2447 * @param str Source string
2448 * @return List of const words
2450 * @see elm_widget_stringlist_free()
2454 elm_widget_stringlist_get(const char *str)
2456 Eina_List *list = NULL;
2458 if (!str) return NULL;
2459 for (b = s = str; 1; s++)
2461 if ((*s == ' ') || (!*s))
2463 char *t = malloc(s - b + 1);
2466 strncpy(t, b, s - b);
2468 list = eina_list_append(list, eina_stringshare_add(t));
2479 elm_widget_stringlist_free(Eina_List *list)
2482 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2486 elm_widget_focus_hide_handle(Evas_Object *obj)
2488 _if_focused_revert(obj, EINA_TRUE);
2492 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2494 Evas_Object *o = obj;
2497 if (_elm_widget_is(o)) break;
2498 o = evas_object_smart_parent_get(o);
2502 if (!_is_focusable(o)) return;
2503 elm_widget_focus_steal(o);
2507 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2511 if (!elm_widget_parent_get(obj))
2512 elm_widget_focused_object_clear(obj);
2514 _if_focused_revert(obj, EINA_TRUE);
2518 elm_widget_focus_disabled_handle(Evas_Object *obj)
2522 elm_widget_focus_tree_unfocusable_handle(obj);
2528 * Allocate a new Elm_Widget_Item-derived structure.
2530 * The goal of this structure is to provide common ground for actions
2531 * that a widget item have, such as the owner widget, callback to
2532 * notify deletion, data pointer and maybe more.
2534 * @param widget the owner widget that holds this item, must be an elm_widget!
2535 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2536 * be used to allocate memory.
2538 * @return allocated memory that is already zeroed out, or NULL on errors.
2540 * @see elm_widget_item_new() convenience macro.
2541 * @see elm_widget_item_del() to release memory.
2544 EAPI Elm_Widget_Item *
2545 _elm_widget_item_new(Evas_Object *widget,
2548 if (!_elm_widget_is(widget))
2551 Elm_Widget_Item *item;
2553 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2554 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2556 item = calloc(1, alloc_size);
2557 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2559 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2560 item->widget = widget;
2567 * Releases widget item memory, calling back del_cb() if it exists.
2569 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2570 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2571 * this function and then unset it, thus being useful for 2 step
2572 * cleanup whenever the del_cb may use any of the data that must be
2573 * deleted from item.
2575 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2578 * @param item a valid #Elm_Widget_Item to be deleted.
2579 * @see elm_widget_item_del() convenience macro.
2583 _elm_widget_item_del(Elm_Widget_Item *item)
2585 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2588 item->del_cb((void *)item->data, item->widget, item);
2591 evas_object_del(item->view);
2595 _elm_access_clear(item->access);
2597 item->access = NULL;
2599 if (item->access_info)
2601 eina_stringshare_del(item->access_info);
2602 item->access_info = NULL;
2605 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2612 * Notify object will be deleted without actually deleting it.
2614 * This function will callback Elm_Widget_Item::del_cb if it is set
2615 * and then unset it so it is not called twice (ie: from
2616 * elm_widget_item_del()).
2618 * @param item a valid #Elm_Widget_Item to be notified
2619 * @see elm_widget_item_pre_notify_del() convenience macro.
2623 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2625 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2626 if (!item->del_cb) return;
2627 item->del_cb((void *)item->data, item->widget, item);
2628 item->del_cb = NULL;
2634 * Set the function to notify when item is being deleted.
2636 * This function will complain if there was a callback set already,
2637 * however it will set the new one.
2639 * The callback will be called from elm_widget_item_pre_notify_del()
2640 * or elm_widget_item_del() will be called with:
2641 * - data: the Elm_Widget_Item::data value.
2642 * - obj: the Elm_Widget_Item::widget evas object.
2643 * - event_info: the item being deleted.
2645 * @param item a valid #Elm_Widget_Item to be notified
2646 * @see elm_widget_item_del_cb_set() convenience macro.
2650 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2651 Evas_Smart_Cb del_cb)
2653 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2655 if ((item->del_cb) && (item->del_cb != del_cb))
2656 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2657 item->del_cb, item, del_cb);
2659 item->del_cb = del_cb;
2665 * Set user-data in this item.
2667 * User data may be used to identify this item or just store any
2668 * application data. It is automatically given as the first parameter
2669 * of the deletion notify callback.
2671 * @param item a valid #Elm_Widget_Item to store data in.
2672 * @param data user data to store.
2673 * @see elm_widget_item_del_cb_set() convenience macro.
2677 _elm_widget_item_data_set(Elm_Widget_Item *item,
2680 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2681 if ((item->data) && (item->data != data))
2682 DBG("Replacing item %p data %p with %p", item, item->data, data);
2689 * Retrieves user-data of this item.
2691 * @param item a valid #Elm_Widget_Item to get data from.
2692 * @see elm_widget_item_data_set()
2696 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2698 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2699 return (void *)item->data;
2702 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2704 struct _Elm_Widget_Item_Tooltip
2706 Elm_Widget_Item *item;
2707 Elm_Tooltip_Item_Content_Cb func;
2708 Evas_Smart_Cb del_cb;
2712 static Evas_Object *
2713 _elm_widget_item_tooltip_label_create(void *data,
2714 Evas_Object *obj __UNUSED__,
2715 Evas_Object *tooltip,
2716 void *item __UNUSED__)
2718 Evas_Object *label = elm_label_add(tooltip);
2721 elm_object_style_set(label, "tooltip");
2722 elm_object_text_set(label, data);
2727 _elm_widget_item_tooltip_label_del_cb(void *data,
2728 Evas_Object *obj __UNUSED__,
2729 void *event_info __UNUSED__)
2731 eina_stringshare_del(data);
2737 * Set the text to be shown in the widget item.
2739 * @param item Target item
2740 * @param text The text to set in the content
2742 * Setup the text as tooltip to object. The item can have only one tooltip,
2743 * so any previous tooltip data is removed.
2748 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2751 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2752 EINA_SAFETY_ON_NULL_RETURN(text);
2754 text = eina_stringshare_add(text);
2755 _elm_widget_item_tooltip_content_cb_set
2756 (item, _elm_widget_item_tooltip_label_create, text,
2757 _elm_widget_item_tooltip_label_del_cb);
2760 static Evas_Object *
2761 _elm_widget_item_tooltip_create(void *data,
2763 Evas_Object *tooltip)
2765 Elm_Widget_Item_Tooltip *wit = data;
2766 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2770 _elm_widget_item_tooltip_del_cb(void *data,
2772 void *event_info __UNUSED__)
2774 Elm_Widget_Item_Tooltip *wit = data;
2775 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2782 * Set the content to be shown in the tooltip item
2784 * Setup the tooltip to item. The item can have only one tooltip,
2785 * so any previous tooltip data is removed. @p func(with @p data) will
2786 * be called every time that need show the tooltip and it should
2787 * return a valid Evas_Object. This object is then managed fully by
2788 * tooltip system and is deleted when the tooltip is gone.
2790 * @param item the widget item being attached a tooltip.
2791 * @param func the function used to create the tooltip contents.
2792 * @param data what to provide to @a func as callback data/context.
2793 * @param del_cb called when data is not needed anymore, either when
2794 * another callback replaces @func, the tooltip is unset with
2795 * elm_widget_item_tooltip_unset() or the owner @a item
2796 * dies. This callback receives as the first parameter the
2797 * given @a data, and @c event_info is the item.
2802 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2803 Elm_Tooltip_Item_Content_Cb func,
2805 Evas_Smart_Cb del_cb)
2807 Elm_Widget_Item_Tooltip *wit;
2809 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2813 _elm_widget_item_tooltip_unset(item);
2817 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2818 if (!wit) goto error;
2822 wit->del_cb = del_cb;
2824 elm_object_sub_tooltip_content_cb_set
2825 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2826 _elm_widget_item_tooltip_del_cb);
2831 if (del_cb) del_cb((void *)data, NULL, item);
2834 if (del_cb) del_cb((void *)data, item->widget, item);
2840 * Unset tooltip from item
2842 * @param item widget item to remove previously set tooltip.
2844 * Remove tooltip from item. The callback provided as del_cb to
2845 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2846 * it is not used anymore.
2848 * @see elm_widget_item_tooltip_content_cb_set()
2853 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2855 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2856 elm_object_tooltip_unset(item->view);
2862 * Sets a different style for this item tooltip.
2864 * @note before you set a style you should define a tooltip with
2865 * elm_widget_item_tooltip_content_cb_set() or
2866 * elm_widget_item_tooltip_text_set()
2868 * @param item widget item with tooltip already set.
2869 * @param style the theme style to use (default, transparent, ...)
2874 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2877 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2878 elm_object_tooltip_style_set(item->view, style);
2882 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
2884 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2885 return elm_tooltip_size_restrict_disable(item->view, disable);
2889 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
2891 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2892 return elm_tooltip_size_restrict_disabled_get(item->view);
2898 * Get the style for this item tooltip.
2900 * @param item widget item with tooltip already set.
2901 * @return style the theme style in use, defaults to "default". If the
2902 * object does not have a tooltip set, then NULL is returned.
2907 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2909 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2910 return elm_object_tooltip_style_get(item->view);
2914 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2917 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2918 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2922 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2924 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2925 return elm_object_cursor_get(item->view);
2929 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2931 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2932 elm_object_cursor_unset(item->view);
2938 * Sets a different style for this item cursor.
2940 * @note before you set a style you should define a cursor with
2941 * elm_widget_item_cursor_set()
2943 * @param item widget item with cursor already set.
2944 * @param style the theme style to use (default, transparent, ...)
2949 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2952 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2953 elm_object_cursor_style_set(item->view, style);
2959 * Get the style for this item cursor.
2961 * @param item widget item with cursor already set.
2962 * @return style the theme style in use, defaults to "default". If the
2963 * object does not have a cursor set, then NULL is returned.
2968 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2970 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2971 return elm_object_cursor_style_get(item->view);
2977 * Set if the cursor set should be searched on the theme or should use
2978 * the provided by the engine, only.
2980 * @note before you set if should look on theme you should define a cursor
2981 * with elm_object_cursor_set(). By default it will only look for cursors
2982 * provided by the engine.
2984 * @param item widget item with cursor already set.
2985 * @param engine_only boolean to define it cursors should be looked only
2986 * between the provided by the engine or searched on widget's theme as well.
2991 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
2992 Eina_Bool engine_only)
2994 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2995 elm_object_cursor_engine_only_set(item->view, engine_only);
3001 * Get the cursor engine only usage for this item cursor.
3003 * @param item widget item with cursor already set.
3004 * @return engine_only boolean to define it cursors should be looked only
3005 * between the provided by the engine or searched on widget's theme as well. If
3006 * the object does not have a cursor set, then EINA_FALSE is returned.
3011 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3013 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3014 return elm_object_cursor_engine_only_get(item->view);
3017 // smart object funcs
3019 _smart_reconfigure(Smart_Data *sd)
3023 evas_object_move(sd->resize_obj, sd->x, sd->y);
3024 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3028 evas_object_move(sd->hover_obj, sd->x, sd->y);
3029 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3034 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3036 Evas_Object *content)
3038 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3039 if (!item->on_content_set_func) return;
3040 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3044 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3047 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3048 if (!item->on_content_get_func) return NULL;
3049 return item->on_content_get_func((Elm_Object_Item *) item, part);
3053 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3056 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3057 if (!item->on_content_unset_func) return NULL;
3058 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3062 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3066 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3067 if (!item->on_text_set_func) return;
3068 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3072 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3075 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3076 if (!item->on_text_get_func) return NULL;
3077 return item->on_text_get_func((Elm_Object_Item *) item, part);
3081 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3082 Elm_Widget_On_Content_Set_Cb func)
3084 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3085 item->on_content_set_func = func;
3089 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3090 Elm_Widget_On_Content_Get_Cb func)
3092 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3093 item->on_content_get_func = func;
3097 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3098 Elm_Widget_On_Content_Unset_Cb func)
3100 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3101 item->on_content_unset_func = func;
3105 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3106 Elm_Widget_On_Text_Set_Cb func)
3108 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3109 item->on_text_set_func = func;
3113 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3114 Elm_Widget_On_Text_Get_Cb func)
3116 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3117 item->on_text_get_func = func;
3121 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3123 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3124 if (item->access_info) eina_stringshare_del(item->access_info);
3125 if (!txt) item->access_info = NULL;
3126 else item->access_info = eina_stringshare_add(txt);
3131 _smart_add(Evas_Object *obj)
3135 sd = calloc(1, sizeof(Smart_Data));
3138 sd->x = sd->y = sd->w = sd->h = 0;
3140 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3141 evas_object_smart_data_set(obj, sd);
3144 static Evas_Object *
3145 _newest_focus_order_get(Evas_Object *obj,
3146 unsigned int *newest_focus_order,
3147 Eina_Bool can_focus_only)
3150 Evas_Object *child, *ret, *best;
3152 API_ENTRY return NULL;
3154 if (!evas_object_visible_get(obj)
3155 || (elm_widget_disabled_get(obj))
3156 || (elm_widget_tree_unfocusable_get(obj)))
3160 if (*newest_focus_order < sd->focus_order)
3162 *newest_focus_order = sd->focus_order;
3165 EINA_LIST_FOREACH(sd->subobjs, l, child)
3167 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3173 if ((!best) || (!elm_widget_can_focus_get(best)))
3180 _if_focused_revert(Evas_Object *obj,
3181 Eina_Bool can_focus_only)
3184 Evas_Object *newest = NULL;
3185 unsigned int newest_focus_order = 0;
3189 if (!sd->focused) return;
3190 if (!sd->parent_obj) return;
3192 top = elm_widget_top_get(sd->parent_obj);
3195 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3198 elm_object_focus_set(newest, EINA_FALSE);
3199 elm_object_focus_set(newest, EINA_TRUE);
3205 _smart_del(Evas_Object *obj)
3208 Edje_Signal_Data *esd;
3212 if (sd->del_pre_func) sd->del_pre_func(obj);
3215 sobj = sd->resize_obj;
3216 sd->resize_obj = NULL;
3217 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3218 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3219 evas_object_del(sobj);
3223 sobj = sd->hover_obj;
3224 sd->hover_obj = NULL;
3225 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3226 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3227 evas_object_del(sobj);
3229 EINA_LIST_FREE(sd->subobjs, sobj)
3231 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3232 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3233 evas_object_del(sobj);
3235 eina_list_free(sd->tooltips); /* should be empty anyway */
3236 eina_list_free(sd->cursors); /* should be empty anyway */
3237 EINA_LIST_FREE(sd->edje_signals, esd)
3239 eina_stringshare_del(esd->emission);
3240 eina_stringshare_del(esd->source);
3243 eina_list_free(sd->event_cb); /* should be empty anyway */
3244 if (sd->del_func) sd->del_func(obj);
3245 if (sd->style) eina_stringshare_del(sd->style);
3246 if (sd->type) eina_stringshare_del(sd->type);
3247 if (sd->theme) elm_theme_free(sd->theme);
3248 _if_focused_revert(obj, EINA_TRUE);
3249 if (sd->access_info) eina_stringshare_del(sd->access_info);
3254 _smart_move(Evas_Object *obj,
3261 _smart_reconfigure(sd);
3265 _smart_resize(Evas_Object *obj,
3272 _smart_reconfigure(sd);
3276 _smart_show(Evas_Object *obj)
3281 if ((list = evas_object_smart_members_get(obj)))
3283 EINA_LIST_FREE(list, o)
3285 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3286 evas_object_show(o);
3292 _smart_hide(Evas_Object *obj)
3298 list = evas_object_smart_members_get(obj);
3299 EINA_LIST_FREE(list, o)
3301 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3302 evas_object_hide(o);
3307 _smart_color_set(Evas_Object *obj,
3316 if ((list = evas_object_smart_members_get(obj)))
3318 EINA_LIST_FREE(list, o)
3320 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3321 evas_object_color_set(o, r, g, b, a);
3327 _smart_clip_set(Evas_Object *obj,
3333 if ((list = evas_object_smart_members_get(obj)))
3335 EINA_LIST_FREE(list, o)
3337 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3338 evas_object_clip_set(o, clip);
3344 _smart_clip_unset(Evas_Object *obj)
3349 if ((list = evas_object_smart_members_get(obj)))
3351 EINA_LIST_FREE(list, o)
3353 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3354 evas_object_clip_unset(o);
3360 _smart_calculate(Evas_Object *obj)
3363 if (sd->changed_func) sd->changed_func(obj);
3366 /* never need to touch this */
3370 if (_e_smart) return;
3372 static const Evas_Smart_Class sc =
3375 EVAS_SMART_CLASS_VERSION,
3393 _e_smart = evas_smart_class_new(&sc);
3397 /* happy debug functions */
3400 _sub_obj_tree_dump(const Evas_Object *obj,
3405 for (i = 0; i < lvl * 3; i++)
3408 if (_elm_widget_is(obj))
3412 printf("+ %s(%p)\n",
3416 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3417 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3419 if (obj != sd->resize_obj)
3420 _sub_obj_tree_dump(obj, lvl + 1);
3424 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3428 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3431 if (!_elm_widget_is(obj))
3435 Eina_Bool visible = evas_object_visible_get(obj);
3436 Eina_Bool disabled = elm_widget_disabled_get(obj);
3437 Eina_Bool focused = elm_widget_focus_get(obj);
3438 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3442 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3445 fprintf(output, ", style=bold");
3448 fprintf(output, ", color=gray28");
3450 fprintf(output, " ];\n");
3453 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3454 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3455 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3459 fprintf(output, ", style=bold");
3462 fprintf(output, ", fontcolor=gray28");
3464 if ((disabled) || (!visible))
3465 fprintf(output, ", color=gray");
3467 fprintf(output, " ];\n");
3471 EINA_LIST_FOREACH(sd->subobjs, l, o)
3472 _sub_obj_tree_dot_dump(o, output);
3477 elm_widget_tree_dump(const Evas_Object *top)
3480 _sub_obj_tree_dump(top, 0);
3488 elm_widget_tree_dot_dump(const Evas_Object *top,
3492 if (!_elm_widget_is(top))
3494 fprintf(output, "graph " " { node [shape=record];\n");
3495 _sub_obj_tree_dot_dump(top, output);
3496 fprintf(output, "}\n");