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_type_check(const Evas_Object *obj,
2404 const char *provided, *expected = "(unknown)";
2405 static int abort_on_warn = -1;
2406 provided = elm_widget_type_get(obj);
2407 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2408 if (type) expected = type;
2409 if ((!provided) || (!provided[0]))
2411 provided = evas_object_type_get(obj);
2412 if ((!provided) || (!provided[0]))
2413 provided = "(unknown)";
2415 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2416 if (abort_on_warn == -1)
2418 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2419 else abort_on_warn = 0;
2421 if (abort_on_warn == 1) abort();
2428 * Split string in words
2430 * @param str Source string
2431 * @return List of const words
2433 * @see elm_widget_stringlist_free()
2437 elm_widget_stringlist_get(const char *str)
2439 Eina_List *list = NULL;
2441 if (!str) return NULL;
2442 for (b = s = str; 1; s++)
2444 if ((*s == ' ') || (!*s))
2446 char *t = malloc(s - b + 1);
2449 strncpy(t, b, s - b);
2451 list = eina_list_append(list, eina_stringshare_add(t));
2462 elm_widget_stringlist_free(Eina_List *list)
2465 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2469 elm_widget_focus_hide_handle(Evas_Object *obj)
2471 _if_focused_revert(obj, EINA_TRUE);
2475 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2477 Evas_Object *o = obj;
2480 if (_elm_widget_is(o)) break;
2481 o = evas_object_smart_parent_get(o);
2485 if (!_is_focusable(o)) return;
2486 elm_widget_focus_steal(o);
2490 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2494 if (!elm_widget_parent_get(obj))
2495 elm_widget_focused_object_clear(obj);
2497 _if_focused_revert(obj, EINA_TRUE);
2501 elm_widget_focus_disabled_handle(Evas_Object *obj)
2505 elm_widget_focus_tree_unfocusable_handle(obj);
2511 * Allocate a new Elm_Widget_Item-derived structure.
2513 * The goal of this structure is to provide common ground for actions
2514 * that a widget item have, such as the owner widget, callback to
2515 * notify deletion, data pointer and maybe more.
2517 * @param widget the owner widget that holds this item, must be an elm_widget!
2518 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2519 * be used to allocate memory.
2521 * @return allocated memory that is already zeroed out, or NULL on errors.
2523 * @see elm_widget_item_new() convenience macro.
2524 * @see elm_widget_item_del() to release memory.
2527 EAPI Elm_Widget_Item *
2528 _elm_widget_item_new(Evas_Object *widget,
2531 if (!_elm_widget_is(widget))
2534 Elm_Widget_Item *item;
2536 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2537 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2539 item = calloc(1, alloc_size);
2540 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2542 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2543 item->widget = widget;
2550 * Releases widget item memory, calling back del_cb() if it exists.
2552 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2553 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2554 * this function and then unset it, thus being useful for 2 step
2555 * cleanup whenever the del_cb may use any of the data that must be
2556 * deleted from item.
2558 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2561 * @param item a valid #Elm_Widget_Item to be deleted.
2562 * @see elm_widget_item_del() convenience macro.
2566 _elm_widget_item_del(Elm_Widget_Item *item)
2568 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2571 item->del_cb((void *)item->data, item->widget, item);
2574 evas_object_del(item->view);
2578 _elm_access_clear(item->access);
2580 item->access = NULL;
2582 if (item->access_info)
2584 eina_stringshare_del(item->access_info);
2585 item->access_info = NULL;
2588 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2595 * Notify object will be deleted without actually deleting it.
2597 * This function will callback Elm_Widget_Item::del_cb if it is set
2598 * and then unset it so it is not called twice (ie: from
2599 * elm_widget_item_del()).
2601 * @param item a valid #Elm_Widget_Item to be notified
2602 * @see elm_widget_item_pre_notify_del() convenience macro.
2606 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2608 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2609 if (!item->del_cb) return;
2610 item->del_cb((void *)item->data, item->widget, item);
2611 item->del_cb = NULL;
2617 * Set the function to notify when item is being deleted.
2619 * This function will complain if there was a callback set already,
2620 * however it will set the new one.
2622 * The callback will be called from elm_widget_item_pre_notify_del()
2623 * or elm_widget_item_del() will be called with:
2624 * - data: the Elm_Widget_Item::data value.
2625 * - obj: the Elm_Widget_Item::widget evas object.
2626 * - event_info: the item being deleted.
2628 * @param item a valid #Elm_Widget_Item to be notified
2629 * @see elm_widget_item_del_cb_set() convenience macro.
2633 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2634 Evas_Smart_Cb del_cb)
2636 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2638 if ((item->del_cb) && (item->del_cb != del_cb))
2639 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2640 item->del_cb, item, del_cb);
2642 item->del_cb = del_cb;
2648 * Set user-data in this item.
2650 * User data may be used to identify this item or just store any
2651 * application data. It is automatically given as the first parameter
2652 * of the deletion notify callback.
2654 * @param item a valid #Elm_Widget_Item to store data in.
2655 * @param data user data to store.
2656 * @see elm_widget_item_del_cb_set() convenience macro.
2660 _elm_widget_item_data_set(Elm_Widget_Item *item,
2663 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2664 if ((item->data) && (item->data != data))
2665 DBG("Replacing item %p data %p with %p", item, item->data, data);
2672 * Retrieves user-data of this item.
2674 * @param item a valid #Elm_Widget_Item to get data from.
2675 * @see elm_widget_item_data_set()
2679 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2681 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2682 return (void *)item->data;
2685 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2687 struct _Elm_Widget_Item_Tooltip
2689 Elm_Widget_Item *item;
2690 Elm_Tooltip_Item_Content_Cb func;
2691 Evas_Smart_Cb del_cb;
2695 static Evas_Object *
2696 _elm_widget_item_tooltip_label_create(void *data,
2697 Evas_Object *obj __UNUSED__,
2698 Evas_Object *tooltip,
2699 void *item __UNUSED__)
2701 Evas_Object *label = elm_label_add(tooltip);
2704 elm_object_style_set(label, "tooltip");
2705 elm_object_text_set(label, data);
2710 _elm_widget_item_tooltip_label_del_cb(void *data,
2711 Evas_Object *obj __UNUSED__,
2712 void *event_info __UNUSED__)
2714 eina_stringshare_del(data);
2720 * Set the text to be shown in the widget item.
2722 * @param item Target item
2723 * @param text The text to set in the content
2725 * Setup the text as tooltip to object. The item can have only one tooltip,
2726 * so any previous tooltip data is removed.
2731 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2734 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2735 EINA_SAFETY_ON_NULL_RETURN(text);
2737 text = eina_stringshare_add(text);
2738 _elm_widget_item_tooltip_content_cb_set
2739 (item, _elm_widget_item_tooltip_label_create, text,
2740 _elm_widget_item_tooltip_label_del_cb);
2743 static Evas_Object *
2744 _elm_widget_item_tooltip_create(void *data,
2746 Evas_Object *tooltip)
2748 Elm_Widget_Item_Tooltip *wit = data;
2749 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2753 _elm_widget_item_tooltip_del_cb(void *data,
2755 void *event_info __UNUSED__)
2757 Elm_Widget_Item_Tooltip *wit = data;
2758 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2765 * Set the content to be shown in the tooltip item
2767 * Setup the tooltip to item. The item can have only one tooltip,
2768 * so any previous tooltip data is removed. @p func(with @p data) will
2769 * be called every time that need show the tooltip and it should
2770 * return a valid Evas_Object. This object is then managed fully by
2771 * tooltip system and is deleted when the tooltip is gone.
2773 * @param item the widget item being attached a tooltip.
2774 * @param func the function used to create the tooltip contents.
2775 * @param data what to provide to @a func as callback data/context.
2776 * @param del_cb called when data is not needed anymore, either when
2777 * another callback replaces @func, the tooltip is unset with
2778 * elm_widget_item_tooltip_unset() or the owner @a item
2779 * dies. This callback receives as the first parameter the
2780 * given @a data, and @c event_info is the item.
2785 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2786 Elm_Tooltip_Item_Content_Cb func,
2788 Evas_Smart_Cb del_cb)
2790 Elm_Widget_Item_Tooltip *wit;
2792 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2796 _elm_widget_item_tooltip_unset(item);
2800 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2801 if (!wit) goto error;
2805 wit->del_cb = del_cb;
2807 elm_object_sub_tooltip_content_cb_set
2808 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2809 _elm_widget_item_tooltip_del_cb);
2814 if (del_cb) del_cb((void *)data, NULL, item);
2817 if (del_cb) del_cb((void *)data, item->widget, item);
2823 * Unset tooltip from item
2825 * @param item widget item to remove previously set tooltip.
2827 * Remove tooltip from item. The callback provided as del_cb to
2828 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2829 * it is not used anymore.
2831 * @see elm_widget_item_tooltip_content_cb_set()
2836 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2838 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2839 elm_object_tooltip_unset(item->view);
2845 * Sets a different style for this item tooltip.
2847 * @note before you set a style you should define a tooltip with
2848 * elm_widget_item_tooltip_content_cb_set() or
2849 * elm_widget_item_tooltip_text_set()
2851 * @param item widget item with tooltip already set.
2852 * @param style the theme style to use (default, transparent, ...)
2857 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2860 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2861 elm_object_tooltip_style_set(item->view, style);
2865 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
2867 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2868 return elm_tooltip_size_restrict_disable(item->view, disable);
2872 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
2874 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2875 return elm_tooltip_size_restrict_disabled_get(item->view);
2881 * Get the style for this item tooltip.
2883 * @param item widget item with tooltip already set.
2884 * @return style the theme style in use, defaults to "default". If the
2885 * object does not have a tooltip set, then NULL is returned.
2890 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2892 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2893 return elm_object_tooltip_style_get(item->view);
2897 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2900 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2901 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2905 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2907 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2908 return elm_object_cursor_get(item->view);
2912 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2914 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2915 elm_object_cursor_unset(item->view);
2921 * Sets a different style for this item cursor.
2923 * @note before you set a style you should define a cursor with
2924 * elm_widget_item_cursor_set()
2926 * @param item widget item with cursor already set.
2927 * @param style the theme style to use (default, transparent, ...)
2932 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2935 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2936 elm_object_cursor_style_set(item->view, style);
2942 * Get the style for this item cursor.
2944 * @param item widget item with cursor already set.
2945 * @return style the theme style in use, defaults to "default". If the
2946 * object does not have a cursor set, then NULL is returned.
2951 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2953 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2954 return elm_object_cursor_style_get(item->view);
2960 * Set if the cursor set should be searched on the theme or should use
2961 * the provided by the engine, only.
2963 * @note before you set if should look on theme you should define a cursor
2964 * with elm_object_cursor_set(). By default it will only look for cursors
2965 * provided by the engine.
2967 * @param item widget item with cursor already set.
2968 * @param engine_only boolean to define it cursors should be looked only
2969 * between the provided by the engine or searched on widget's theme as well.
2974 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
2975 Eina_Bool engine_only)
2977 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2978 elm_object_cursor_engine_only_set(item->view, engine_only);
2984 * Get the cursor engine only usage for this item cursor.
2986 * @param item widget item with cursor already set.
2987 * @return engine_only boolean to define it cursors should be looked only
2988 * between the provided by the engine or searched on widget's theme as well. If
2989 * the object does not have a cursor set, then EINA_FALSE is returned.
2994 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
2996 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2997 return elm_object_cursor_engine_only_get(item->view);
3000 // smart object funcs
3002 _smart_reconfigure(Smart_Data *sd)
3006 evas_object_move(sd->resize_obj, sd->x, sd->y);
3007 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3011 evas_object_move(sd->hover_obj, sd->x, sd->y);
3012 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3017 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3019 Evas_Object *content)
3021 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3022 if (!item->on_content_set_func) return;
3023 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3027 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3030 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3031 if (!item->on_content_get_func) return NULL;
3032 return item->on_content_get_func((Elm_Object_Item *) item, part);
3036 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3039 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3040 if (!item->on_content_unset_func) return NULL;
3041 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3045 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3049 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3050 if (!item->on_text_set_func) return;
3051 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3055 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3058 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3059 if (!item->on_text_get_func) return NULL;
3060 return item->on_text_get_func((Elm_Object_Item *) item, part);
3064 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3065 Elm_Widget_On_Content_Set_Cb func)
3067 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3068 item->on_content_set_func = func;
3072 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3073 Elm_Widget_On_Content_Get_Cb func)
3075 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3076 item->on_content_get_func = func;
3080 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3081 Elm_Widget_On_Content_Unset_Cb func)
3083 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3084 item->on_content_unset_func = func;
3088 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3089 Elm_Widget_On_Text_Set_Cb func)
3091 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3092 item->on_text_set_func = func;
3096 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3097 Elm_Widget_On_Text_Get_Cb func)
3099 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3100 item->on_text_get_func = func;
3104 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3106 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3107 if (item->access_info) eina_stringshare_del(item->access_info);
3108 if (!txt) item->access_info = NULL;
3109 else item->access_info = eina_stringshare_add(txt);
3114 _smart_add(Evas_Object *obj)
3118 sd = calloc(1, sizeof(Smart_Data));
3121 sd->x = sd->y = sd->w = sd->h = 0;
3123 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3124 evas_object_smart_data_set(obj, sd);
3127 static Evas_Object *
3128 _newest_focus_order_get(Evas_Object *obj,
3129 unsigned int *newest_focus_order,
3130 Eina_Bool can_focus_only)
3133 Evas_Object *child, *ret, *best;
3135 API_ENTRY return NULL;
3137 if (!evas_object_visible_get(obj)
3138 || (elm_widget_disabled_get(obj))
3139 || (elm_widget_tree_unfocusable_get(obj)))
3143 if (*newest_focus_order < sd->focus_order)
3145 *newest_focus_order = sd->focus_order;
3148 EINA_LIST_FOREACH(sd->subobjs, l, child)
3150 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3156 if ((!best) || (!elm_widget_can_focus_get(best)))
3163 _if_focused_revert(Evas_Object *obj,
3164 Eina_Bool can_focus_only)
3167 Evas_Object *newest = NULL;
3168 unsigned int newest_focus_order = 0;
3172 if (!sd->focused) return;
3173 if (!sd->parent_obj) return;
3175 top = elm_widget_top_get(sd->parent_obj);
3178 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3181 elm_object_focus_set(newest, EINA_FALSE);
3182 elm_object_focus_set(newest, EINA_TRUE);
3188 _smart_del(Evas_Object *obj)
3191 Edje_Signal_Data *esd;
3195 if (sd->del_pre_func) sd->del_pre_func(obj);
3198 sobj = sd->resize_obj;
3199 sd->resize_obj = NULL;
3200 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3201 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3202 evas_object_del(sobj);
3206 sobj = sd->hover_obj;
3207 sd->hover_obj = NULL;
3208 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3209 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3210 evas_object_del(sobj);
3212 EINA_LIST_FREE(sd->subobjs, sobj)
3214 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3215 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3216 evas_object_del(sobj);
3218 eina_list_free(sd->tooltips); /* should be empty anyway */
3219 eina_list_free(sd->cursors); /* should be empty anyway */
3220 EINA_LIST_FREE(sd->edje_signals, esd)
3222 eina_stringshare_del(esd->emission);
3223 eina_stringshare_del(esd->source);
3226 eina_list_free(sd->event_cb); /* should be empty anyway */
3227 if (sd->del_func) sd->del_func(obj);
3228 if (sd->style) eina_stringshare_del(sd->style);
3229 if (sd->type) eina_stringshare_del(sd->type);
3230 if (sd->theme) elm_theme_free(sd->theme);
3231 _if_focused_revert(obj, EINA_TRUE);
3232 if (sd->access_info) eina_stringshare_del(sd->access_info);
3237 _smart_move(Evas_Object *obj,
3244 _smart_reconfigure(sd);
3248 _smart_resize(Evas_Object *obj,
3255 _smart_reconfigure(sd);
3259 _smart_show(Evas_Object *obj)
3264 if ((list = evas_object_smart_members_get(obj)))
3266 EINA_LIST_FREE(list, o)
3268 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3269 evas_object_show(o);
3275 _smart_hide(Evas_Object *obj)
3281 list = evas_object_smart_members_get(obj);
3282 EINA_LIST_FREE(list, o)
3284 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3285 evas_object_hide(o);
3290 _smart_color_set(Evas_Object *obj,
3299 if ((list = evas_object_smart_members_get(obj)))
3301 EINA_LIST_FREE(list, o)
3303 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3304 evas_object_color_set(o, r, g, b, a);
3310 _smart_clip_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_clip_set(o, clip);
3327 _smart_clip_unset(Evas_Object *obj)
3332 if ((list = evas_object_smart_members_get(obj)))
3334 EINA_LIST_FREE(list, o)
3336 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3337 evas_object_clip_unset(o);
3343 _smart_calculate(Evas_Object *obj)
3346 if (sd->changed_func) sd->changed_func(obj);
3349 /* never need to touch this */
3353 if (_e_smart) return;
3355 static const Evas_Smart_Class sc =
3358 EVAS_SMART_CLASS_VERSION,
3376 _e_smart = evas_smart_class_new(&sc);
3380 /* happy debug functions */
3383 _sub_obj_tree_dump(const Evas_Object *obj,
3388 for (i = 0; i < lvl * 3; i++)
3391 if (_elm_widget_is(obj))
3395 printf("+ %s(%p)\n",
3399 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3400 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3402 if (obj != sd->resize_obj)
3403 _sub_obj_tree_dump(obj, lvl + 1);
3407 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3411 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3414 if (!_elm_widget_is(obj))
3418 Eina_Bool visible = evas_object_visible_get(obj);
3419 Eina_Bool disabled = elm_widget_disabled_get(obj);
3420 Eina_Bool focused = elm_widget_focus_get(obj);
3421 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3425 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3428 fprintf(output, ", style=bold");
3431 fprintf(output, ", color=gray28");
3433 fprintf(output, " ];\n");
3436 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3437 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3438 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3442 fprintf(output, ", style=bold");
3445 fprintf(output, ", fontcolor=gray28");
3447 if ((disabled) || (!visible))
3448 fprintf(output, ", color=gray");
3450 fprintf(output, " ];\n");
3454 EINA_LIST_FOREACH(sd->subobjs, l, o)
3455 _sub_obj_tree_dot_dump(o, output);
3460 elm_widget_tree_dump(const Evas_Object *top)
3463 _sub_obj_tree_dump(top, 0);
3471 elm_widget_tree_dot_dump(const Evas_Object *top,
3475 if (!_elm_widget_is(top))
3477 fprintf(output, "graph " " { node [shape=record];\n");
3478 _sub_obj_tree_dot_dump(top, output);
3479 fprintf(output, "}\n");