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 top_win_focused : 1;
108 Eina_Bool tree_unfocusable : 1;
109 Eina_Bool highlight_ignore : 1;
110 Eina_Bool highlight_in_theme : 1;
111 Eina_Bool disabled : 1;
112 Eina_Bool is_mirrored : 1;
113 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
115 Eina_List *focus_chain;
119 struct _Edje_Signal_Data
123 const char *emission;
128 struct _Elm_Event_Cb_Data
134 /* local subsystem functions */
135 static void _smart_reconfigure(Smart_Data *sd);
136 static void _smart_add(Evas_Object *obj);
137 static void _smart_del(Evas_Object *obj);
138 static void _smart_move(Evas_Object *obj,
141 static void _smart_resize(Evas_Object *obj,
144 static void _smart_show(Evas_Object *obj);
145 static void _smart_hide(Evas_Object *obj);
146 static void _smart_color_set(Evas_Object *obj,
151 static void _smart_clip_set(Evas_Object *obj,
153 static void _smart_clip_unset(Evas_Object *obj);
154 static void _smart_calculate(Evas_Object *obj);
155 static void _smart_init(void);
157 static void _if_focused_revert(Evas_Object *obj,
158 Eina_Bool can_focus_only);
159 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
160 unsigned int *newest_focus_order,
161 Eina_Bool can_focus_only);
163 /* local subsystem globals */
164 static Evas_Smart *_e_smart = NULL;
165 static Eina_List *widtypes = NULL;
167 static unsigned int focus_order = 0;
170 static inline Eina_Bool
171 _elm_widget_is(const Evas_Object *obj)
173 const char *type = evas_object_type_get(obj);
174 return type == SMART_NAME;
177 static inline Eina_Bool
178 _is_focusable(Evas_Object *obj)
180 API_ENTRY return EINA_FALSE;
181 return sd->can_focus || (sd->child_can_focus);
185 _unfocus_parents(Evas_Object *obj)
187 for (; obj; obj = elm_widget_parent_get(obj))
190 if (!sd->focused) return;
196 _focus_parents(Evas_Object *obj)
198 for (; obj; obj = elm_widget_parent_get(obj))
201 if (sd->focused) return;
207 _sub_obj_del(void *data,
210 void *event_info __UNUSED__)
212 Smart_Data *sd = data;
214 if (_elm_widget_is(obj))
216 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
218 if (obj == sd->resize_obj)
219 sd->resize_obj = NULL;
220 else if (obj == sd->hover_obj)
221 sd->hover_obj = NULL;
223 sd->subobjs = eina_list_remove(sd->subobjs, obj);
224 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
228 _sub_obj_hide(void *data __UNUSED__,
231 void *event_info __UNUSED__)
233 elm_widget_focus_hide_handle(obj);
237 _sub_obj_mouse_up(void *data __UNUSED__,
242 Evas_Event_Mouse_Up *ev = event_info;
243 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
244 elm_widget_focus_mouse_up_handle(obj);
248 _propagate_x_drag_lock(Evas_Object *obj,
254 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
257 sd2->child_drag_x_locked += dir;
258 _propagate_x_drag_lock(sd->parent_obj, dir);
264 _propagate_y_drag_lock(Evas_Object *obj,
270 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
273 sd2->child_drag_y_locked += dir;
274 _propagate_y_drag_lock(sd->parent_obj, dir);
280 _propagate_event(void *data,
286 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
287 Evas_Event_Flags *event_flags = NULL;
291 case EVAS_CALLBACK_KEY_DOWN:
293 Evas_Event_Key_Down *ev = event_info;
294 event_flags = &(ev->event_flags);
298 case EVAS_CALLBACK_KEY_UP:
300 Evas_Event_Key_Up *ev = event_info;
301 event_flags = &(ev->event_flags);
305 case EVAS_CALLBACK_MOUSE_WHEEL:
307 Evas_Event_Mouse_Wheel *ev = event_info;
308 event_flags = &(ev->event_flags);
316 elm_widget_event_propagate(obj, type, event_info, event_flags);
320 _parent_focus(Evas_Object *obj)
323 if (sd->focused) return;
325 Evas_Object *o = elm_widget_parent_get(obj);
326 sd->focus_order_on_calc = EINA_TRUE;
328 if (o) _parent_focus(o);
330 if (!sd->focus_order_on_calc)
331 return; /* we don't want to override it if by means of any of the
332 callbacks below one gets to calculate our order
336 sd->focus_order = focus_order;
337 if (sd->top_win_focused)
339 sd->focused = EINA_TRUE;
340 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
341 if (sd->focus_func) sd->focus_func(obj);
342 _elm_widget_focus_region_show(obj);
344 sd->focus_order_on_calc = EINA_FALSE;
348 _elm_object_focus_chain_del_cb(void *data,
351 void *event_info __UNUSED__)
353 Smart_Data *sd = data;
355 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
358 // exposed util funcs to elm
360 _elm_widget_type_clear(void)
364 EINA_LIST_FREE(widtypes, ptr)
366 eina_stringshare_del(*ptr);
372 _elm_widget_focus_region_show(const Evas_Object *obj)
374 Evas_Coord x, y, w, h, ox, oy;
380 o = elm_widget_parent_get(obj);
383 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
384 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
388 sd2 = evas_object_smart_data_get(o);
389 if (sd2->focus_region_func)
391 sd2->focus_region_func(o, x, y, w, h);
392 elm_widget_focus_region_get(o, &x, &y, &w, &h);
396 evas_object_geometry_get(o, &px, &py, NULL, NULL);
402 o = elm_widget_parent_get(o);
407 * @defgroup Widget Widget
410 * Exposed api for making widgets
413 elm_widget_type_register(const char **ptr)
415 widtypes = eina_list_append(widtypes, (void *)ptr);
419 * @defgroup Widget Widget
422 * Disposed api for making widgets
425 elm_widget_type_unregister(const char **ptr)
427 widtypes = eina_list_remove(widtypes, (void *)ptr);
431 elm_widget_api_check(int ver)
433 if (ver != ELM_INTERNAL_API_VERSION)
435 CRITICAL("Elementary widget api versions do not match");
442 elm_widget_add(Evas *evas)
446 obj = evas_object_smart_add(evas, _e_smart);
447 elm_widget_mirrored_set(obj, elm_mirrored_get());
452 elm_widget_del_hook_set(Evas_Object *obj,
453 void (*func)(Evas_Object *obj))
460 elm_widget_del_pre_hook_set(Evas_Object *obj,
461 void (*func)(Evas_Object *obj))
464 sd->del_pre_func = func;
468 elm_widget_focus_hook_set(Evas_Object *obj,
469 void (*func)(Evas_Object *obj))
472 sd->focus_func = func;
476 elm_widget_activate_hook_set(Evas_Object *obj,
477 void (*func)(Evas_Object *obj))
480 sd->activate_func = func;
484 elm_widget_disable_hook_set(Evas_Object *obj,
485 void (*func)(Evas_Object *obj))
488 sd->disable_func = func;
492 elm_widget_theme_hook_set(Evas_Object *obj,
493 void (*func)(Evas_Object *obj))
496 sd->theme_func = func;
500 elm_widget_event_hook_set(Evas_Object *obj,
501 Eina_Bool (*func)(Evas_Object *obj,
503 Evas_Callback_Type type,
507 sd->event_func = func;
511 elm_widget_text_set_hook_set(Evas_Object *obj,
512 Elm_Widget_On_Text_Set_Cb func)
515 sd->on_text_set_func = func;
519 elm_widget_text_get_hook_set(Evas_Object *obj,
520 Elm_Widget_On_Text_Get_Cb func)
523 sd->on_text_get_func = func;
527 elm_widget_content_set_hook_set(Evas_Object *obj,
528 Elm_Widget_On_Content_Set_Cb func)
531 sd->on_content_set_func = func;
535 elm_widget_content_get_hook_set(Evas_Object *obj,
536 Elm_Widget_On_Content_Get_Cb func)
539 sd->on_content_get_func = func;
543 elm_widget_content_unset_hook_set(Evas_Object *obj,
544 Elm_Widget_On_Content_Unset_Cb func)
547 sd->on_content_unset_func = func;
551 elm_widget_changed_hook_set(Evas_Object *obj,
552 void (*func)(Evas_Object *obj))
555 sd->changed_func = func;
559 elm_widget_signal_emit_hook_set(Evas_Object *obj,
560 void (*func)(Evas_Object *obj,
561 const char *emission,
565 sd->signal_func = func;
569 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
570 void (*func)(Evas_Object *obj,
571 const char *emission,
573 Edje_Signal_Cb func_cb,
577 sd->callback_add_func = func;
581 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
582 void (*func)(Evas_Object *obj,
583 const char *emission,
585 Edje_Signal_Cb func_cb,
589 sd->callback_del_func = func;
593 elm_widget_theme(Evas_Object *obj)
601 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
602 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
603 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
604 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
605 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
606 if (sd->theme_func) sd->theme_func(obj);
610 elm_widget_theme_specific(Evas_Object *obj,
618 Elm_Theme *th2, *thdef;
621 thdef = elm_theme_default_get();
626 if (!th2) th2 = thdef;
634 if (th2 == thdef) break;
635 th2 = th2->ref_theme;
636 if (!th2) th2 = thdef;
640 EINA_LIST_FOREACH(sd->subobjs, l, child)
641 elm_widget_theme_specific(child, th, force);
642 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
643 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
644 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
645 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
646 if (sd->theme_func) sd->theme_func(obj);
652 * Set hook to get next object in object focus chain.
654 * @param obj The widget object.
655 * @param func The hook to be used with this widget.
660 elm_widget_focus_next_hook_set(Evas_Object *obj,
661 Eina_Bool (*func)(const Evas_Object *obj,
662 Elm_Focus_Direction dir,
666 sd->focus_next_func = func;
670 * Returns the widget's mirrored mode.
672 * @param obj The widget.
673 * @return mirrored mode of the object.
677 elm_widget_mirrored_get(const Evas_Object *obj)
679 API_ENTRY return EINA_FALSE;
680 return sd->is_mirrored;
684 * Sets the widget's mirrored mode.
686 * @param obj The widget.
687 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
690 elm_widget_mirrored_set(Evas_Object *obj,
694 if (sd->is_mirrored != mirrored)
696 sd->is_mirrored = mirrored;
697 elm_widget_theme(obj);
703 * Resets the mirrored mode from the system mirror mode for widgets that are in
704 * automatic mirroring mode. This function does not call elm_widget_theme.
706 * @param obj The widget.
707 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
710 _elm_widget_mirrored_reload(Evas_Object *obj)
713 Eina_Bool mirrored = elm_mirrored_get();
714 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
716 sd->is_mirrored = mirrored;
721 * Returns the widget's mirrored mode setting.
723 * @param obj The widget.
724 * @return mirrored mode setting of the object.
728 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
730 API_ENTRY return EINA_FALSE;
731 return sd->mirrored_auto_mode;
735 * Sets the widget's mirrored mode setting.
736 * When widget in automatic mode, it follows the system mirrored mode set by
737 * elm_mirrored_set().
738 * @param obj The widget.
739 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
742 elm_widget_mirrored_automatic_set(Evas_Object *obj,
746 if (sd->mirrored_auto_mode != automatic)
748 sd->mirrored_auto_mode = automatic;
752 elm_widget_mirrored_set(obj, elm_mirrored_get());
758 elm_widget_on_focus_hook_set(Evas_Object *obj,
759 void (*func)(void *data,
764 sd->on_focus_func = func;
765 sd->on_focus_data = data;
769 elm_widget_on_change_hook_set(Evas_Object *obj,
770 void (*func)(void *data,
775 sd->on_change_func = func;
776 sd->on_change_data = data;
780 elm_widget_on_show_region_hook_set(Evas_Object *obj,
781 void (*func)(void *data,
786 sd->on_show_region_func = func;
787 sd->on_show_region_data = data;
793 * Set the hook to use to show the focused region.
795 * Whenever a new widget gets focused or it's needed to show the focused
796 * area of the current one, this hook will be called on objects that may
797 * want to move their children into their visible area.
798 * The area given in the hook function is relative to the @p obj widget.
800 * @param obj The widget object
801 * @param func The function to call to show the specified area.
806 elm_widget_focus_region_hook_set(Evas_Object *obj,
807 void (*func)(Evas_Object *obj,
814 sd->focus_region_func = func;
820 * Set the hook to retrieve the focused region of a widget.
822 * This hook will be called by elm_widget_focus_region_get() whenever
823 * it's needed to get the focused area of a widget. The area must be relative
824 * to the widget itself and if no hook is set, it will default to the entire
827 * @param obj The widget object
828 * @param func The function used to retrieve the focus region.
833 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
834 void (*func)(const Evas_Object *obj,
841 sd->on_focus_region_func = func;
845 elm_widget_data_set(Evas_Object *obj,
853 elm_widget_data_get(const Evas_Object *obj)
855 API_ENTRY return NULL;
860 elm_widget_sub_object_add(Evas_Object *obj,
864 double scale, pscale = elm_widget_scale_get(sobj);
865 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
866 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
868 if (_elm_widget_is(sobj))
870 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
873 if (sd2->parent_obj == obj)
876 elm_widget_sub_object_del(sd2->parent_obj, sobj);
877 sd2->parent_obj = obj;
878 sd2->top_win_focused = sd->top_win_focused;
879 if (!sd->child_can_focus && (_is_focusable(sobj)))
880 sd->child_can_focus = EINA_TRUE;
885 void *data = evas_object_data_get(sobj, "elm-parent");
888 if (data == obj) return;
889 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
894 sd->subobjs = eina_list_append(sd->subobjs, sobj);
895 evas_object_data_set(sobj, "elm-parent", obj);
896 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
897 if (_elm_widget_is(sobj))
898 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
899 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
900 scale = elm_widget_scale_get(sobj);
901 th = elm_widget_theme_get(sobj);
902 mirrored = elm_widget_mirrored_get(sobj);
903 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
904 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
908 elm_widget_sub_object_del(Evas_Object *obj,
911 Evas_Object *sobj_parent;
915 sobj_parent = evas_object_data_del(sobj, "elm-parent");
916 if (sobj_parent != obj)
918 static int abort_on_warn = -1;
919 ERR("removing sub object %p from parent %p, "
920 "but elm-parent is different %p!",
921 sobj, obj, sobj_parent);
922 if (EINA_UNLIKELY(abort_on_warn == -1))
924 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
925 else abort_on_warn = 0;
927 if (abort_on_warn == 1) abort();
929 if (_elm_widget_is(sobj))
931 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
934 sd2->parent_obj = NULL;
935 if (sd2->resize_obj == sobj)
936 sd2->resize_obj = NULL;
938 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
941 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
942 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
943 if ((sd->child_can_focus) && (_is_focusable(sobj)))
947 sd->child_can_focus = EINA_FALSE;
948 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
950 if (_is_focusable(subobj))
952 sd->child_can_focus = EINA_TRUE;
959 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
960 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
962 if (_elm_widget_is(sobj))
963 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
965 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
969 elm_widget_resize_object_set(Evas_Object *obj,
973 // orphan previous resize obj
976 evas_object_clip_unset(sd->resize_obj);
977 evas_object_data_del(sd->resize_obj, "elm-parent");
978 if (_elm_widget_is(sd->resize_obj))
980 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
981 if (sd2) sd2->parent_obj = NULL;
982 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
985 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
987 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
988 _sub_obj_mouse_up, sd);
989 evas_object_smart_member_del(sd->resize_obj);
990 if (_elm_widget_is(sd->resize_obj))
992 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
995 // orphan new resize obj
998 evas_object_data_del(sobj, "elm-parent");
999 if (_elm_widget_is(sobj))
1001 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1002 if (sd2) sd2->parent_obj = NULL;
1003 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1006 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1008 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1009 _sub_obj_mouse_up, sd);
1010 evas_object_smart_member_del(sobj);
1011 if (_elm_widget_is(sobj))
1013 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1016 // set the resize obj up
1017 sd->resize_obj = sobj;
1020 if (_elm_widget_is(sd->resize_obj))
1022 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1025 sd2->parent_obj = obj;
1026 sd2->top_win_focused = sd->top_win_focused;
1028 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1031 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1032 evas_object_smart_member_add(sobj, obj);
1033 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1035 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1036 _sub_obj_mouse_up, sd);
1037 _smart_reconfigure(sd);
1038 evas_object_data_set(sobj, "elm-parent", obj);
1039 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1040 if (_elm_widget_is(sobj))
1042 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1048 elm_widget_hover_object_set(Evas_Object *obj,
1054 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1057 sd->hover_obj = sobj;
1060 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1062 _smart_reconfigure(sd);
1067 elm_widget_can_focus_set(Evas_Object *obj,
1068 Eina_Bool can_focus)
1071 sd->can_focus = can_focus;
1074 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1076 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1077 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1079 (void *)(long)EVAS_CALLBACK_KEY_UP);
1080 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1082 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1086 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1088 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1090 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1096 elm_widget_can_focus_get(const Evas_Object *obj)
1098 API_ENTRY return EINA_FALSE;
1099 return sd->can_focus;
1103 elm_widget_child_can_focus_get(const Evas_Object *obj)
1105 API_ENTRY return EINA_FALSE;
1106 return sd->child_can_focus;
1112 * This API makes the widget object and its children to be unfocusable.
1114 * This API can be helpful for an object to be deleted.
1115 * When an object will be deleted soon, it and its children may not
1116 * want to get focus (by focus reverting or by other focus controls).
1117 * Then, just use this API before deleting.
1119 * @param obj The widget root of sub-tree
1120 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1125 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1126 Eina_Bool tree_unfocusable)
1130 if (sd->tree_unfocusable == tree_unfocusable) return;
1131 sd->tree_unfocusable = !!tree_unfocusable;
1132 elm_widget_focus_tree_unfocusable_handle(obj);
1138 * This returns true, if the object sub-tree is unfocusable.
1140 * @param obj The widget root of sub-tree
1141 * @return EINA_TRUE if the object sub-tree is unfocusable
1146 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1148 API_ENTRY return EINA_FALSE;
1149 return sd->tree_unfocusable;
1155 * Get the list of focusable child objects.
1157 * This function retruns list of child objects which can get focus.
1159 * @param obj The parent widget
1160 * @retrun list of focusable child objects.
1165 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1167 API_ENTRY return NULL;
1170 Eina_List *child_list = NULL;
1175 EINA_LIST_FOREACH(sd->subobjs, l, child)
1177 if ((elm_widget_can_focus_get(child)) &&
1178 (evas_object_visible_get(child)) &&
1179 (!elm_widget_disabled_get(child)))
1180 child_list = eina_list_append(child_list, child);
1181 else if (elm_widget_is(child))
1183 Eina_List *can_focus_list;
1184 can_focus_list = elm_widget_can_focus_child_list_get(child);
1186 child_list = eina_list_merge(child_list, can_focus_list);
1194 elm_widget_highlight_ignore_set(Evas_Object *obj,
1198 sd->highlight_ignore = !!ignore;
1202 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1204 API_ENTRY return EINA_FALSE;
1205 return sd->highlight_ignore;
1209 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1210 Eina_Bool highlight)
1213 sd->highlight_in_theme = !!highlight;
1214 /* FIXME: if focused, it should switch from one mode to the other */
1218 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1220 API_ENTRY return EINA_FALSE;
1221 return sd->highlight_in_theme;
1225 elm_widget_focus_get(const Evas_Object *obj)
1227 API_ENTRY return EINA_FALSE;
1232 elm_widget_focused_object_get(const Evas_Object *obj)
1234 const Evas_Object *subobj;
1236 API_ENTRY return NULL;
1238 if (!sd->focused) return NULL;
1239 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1241 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1242 if (fobj) return fobj;
1244 return (Evas_Object *)obj;
1248 elm_widget_top_get(const Evas_Object *obj)
1250 API_ENTRY return NULL;
1251 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1252 return (Evas_Object *)obj;
1256 elm_widget_is(const Evas_Object *obj)
1258 return _elm_widget_is(obj);
1262 elm_widget_parent_widget_get(const Evas_Object *obj)
1264 Evas_Object *parent;
1266 if (_elm_widget_is(obj))
1268 Smart_Data *sd = evas_object_smart_data_get(obj);
1269 if (!sd) return NULL;
1270 parent = sd->parent_obj;
1274 parent = evas_object_data_get(obj, "elm-parent");
1275 if (!parent) parent = evas_object_smart_parent_get(obj);
1280 Evas_Object *elm_parent;
1281 if (_elm_widget_is(parent)) break;
1282 elm_parent = evas_object_data_get(parent, "elm-parent");
1283 if (elm_parent) parent = elm_parent;
1284 else parent = evas_object_smart_parent_get(parent);
1290 elm_widget_parent2_get(const Evas_Object *obj)
1292 if (_elm_widget_is(obj))
1294 Smart_Data *sd = evas_object_smart_data_get(obj);
1295 if (sd) return sd->parent2;
1301 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1304 sd->parent2 = parent;
1308 elm_widget_event_callback_add(Evas_Object *obj,
1313 EINA_SAFETY_ON_NULL_RETURN(func);
1314 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1317 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1321 elm_widget_event_callback_del(Evas_Object *obj,
1325 API_ENTRY return NULL;
1326 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1328 Elm_Event_Cb_Data *ecd;
1329 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1330 if ((ecd->func == func) && (ecd->data == data))
1333 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1334 return (void *)data;
1340 elm_widget_event_propagate(Evas_Object *obj,
1341 Evas_Callback_Type type,
1343 Evas_Event_Flags *event_flags)
1345 API_ENTRY return EINA_FALSE; //TODO reduce.
1346 if (!_elm_widget_is(obj)) return EINA_FALSE;
1347 Evas_Object *parent = obj;
1348 Elm_Event_Cb_Data *ecd;
1349 Eina_List *l, *l_prev;
1352 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1354 sd = evas_object_smart_data_get(parent);
1355 if ((!sd) || (!_elm_widget_is(obj)))
1356 return EINA_FALSE; //Not Elm Widget
1358 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1361 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1363 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1364 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1367 parent = sd->parent_obj;
1376 * Set custom focus chain.
1378 * This function i set one new and overwrite any previous custom focus chain
1379 * with the list of objects. The previous list will be deleted and this list
1380 * will be managed. After setted, don't modity it.
1382 * @note On focus cycle, only will be evaluated children of this container.
1384 * @param obj The container widget
1385 * @param objs Chain of objects to pass focus
1389 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1393 if (!sd->focus_next_func)
1396 elm_widget_focus_custom_chain_unset(obj);
1401 EINA_LIST_FOREACH(objs, l, o)
1403 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1404 _elm_object_focus_chain_del_cb, sd);
1407 sd->focus_chain = objs;
1413 * Get custom focus chain
1415 * @param obj The container widget
1418 EAPI const Eina_List *
1419 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1421 API_ENTRY return NULL;
1422 return (const Eina_List *)sd->focus_chain;
1428 * Unset custom focus chain
1430 * @param obj The container widget
1434 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1437 Eina_List *l, *l_next;
1440 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1442 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1443 _elm_object_focus_chain_del_cb, sd);
1444 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1451 * Append object to custom focus chain.
1453 * @note If relative_child equal to NULL or not in custom chain, the object
1454 * will be added in end.
1456 * @note On focus cycle, only will be evaluated children of this container.
1458 * @param obj The container widget
1459 * @param child The child to be added in custom chain
1460 * @param relative_child The relative object to position the child
1464 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1466 Evas_Object *relative_child)
1469 EINA_SAFETY_ON_NULL_RETURN(child);
1470 if (!sd->focus_next_func)
1473 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1474 _elm_object_focus_chain_del_cb, sd);
1476 if (!relative_child)
1478 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1482 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1489 * Prepend object to custom focus chain.
1491 * @note If relative_child equal to NULL or not in custom chain, the object
1492 * will be added in begin.
1494 * @note On focus cycle, only will be evaluated children of this container.
1496 * @param obj The container widget
1497 * @param child The child to be added in custom chain
1498 * @param relative_child The relative object to position the child
1502 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1504 Evas_Object *relative_child)
1507 EINA_SAFETY_ON_NULL_RETURN(child);
1508 if (!sd->focus_next_func)
1511 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1512 _elm_object_focus_chain_del_cb, sd);
1514 if (!relative_child)
1516 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1520 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1527 * Give focus to next object in object tree.
1529 * Give focus to next object in focus chain of one object sub-tree.
1530 * If the last object of chain already have focus, the focus will go to the
1531 * first object of chain.
1533 * @param obj The widget root of sub-tree
1534 * @param dir Direction to cycle the focus
1539 elm_widget_focus_cycle(Evas_Object *obj,
1540 Elm_Focus_Direction dir)
1542 Evas_Object *target = NULL;
1543 if (!_elm_widget_is(obj))
1545 elm_widget_focus_next_get(obj, dir, &target);
1547 elm_widget_focus_steal(target);
1553 * Give focus to near object in one direction.
1555 * Give focus to near object in direction of one object.
1556 * If none focusable object in given direction, the focus will not change.
1558 * @param obj The reference widget
1559 * @param x Horizontal component of direction to focus
1560 * @param y Vertical component of direction to focus
1565 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1575 * Get next object in focus chain of object tree.
1577 * Get next object in focus chain of one object sub-tree.
1578 * Return the next object by reference. If don't have any candidate to receive
1579 * focus before chain end, the first candidate will be returned.
1581 * @param obj The widget root of sub-tree
1582 * @param dir Direction os focus chain
1583 * @param next The next object in focus chain
1584 * @return EINA_TRUE if don't need focus chain restart/loop back
1585 * to use 'next' obj.
1590 elm_widget_focus_next_get(const Evas_Object *obj,
1591 Elm_Focus_Direction dir,
1598 API_ENTRY return EINA_FALSE;
1600 /* Ignore if disabled */
1601 if ((!evas_object_visible_get(obj))
1602 || (elm_widget_disabled_get(obj))
1603 || (elm_widget_tree_unfocusable_get(obj)))
1607 if (sd->focus_next_func)
1608 return sd->focus_next_func(obj, dir, next);
1610 if (!elm_widget_can_focus_get(obj))
1614 *next = (Evas_Object *)obj;
1615 return !elm_widget_focus_get(obj);
1621 * Get next object in focus chain of object tree in list.
1623 * Get next object in focus chain of one object sub-tree ordered by one list.
1624 * Return the next object by reference. If don't have any candidate to receive
1625 * focus before list end, the first candidate will be returned.
1627 * @param obj The widget root of sub-tree
1628 * @param dir Direction os focus chain
1629 * @param items list with ordered objects
1630 * @param list_data_get function to get the object from one item of list
1631 * @param next The next object in focus chain
1632 * @return EINA_TRUE if don't need focus chain restart/loop back
1633 * to use 'next' obj.
1638 elm_widget_focus_list_next_get(const Evas_Object *obj,
1639 const Eina_List *items,
1640 void *(*list_data_get)(const Eina_List * list),
1641 Elm_Focus_Direction dir,
1644 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1650 if (!_elm_widget_is(obj))
1657 if (dir == ELM_FOCUS_PREVIOUS)
1659 items = eina_list_last(items);
1660 list_next = eina_list_prev;
1662 else if (dir == ELM_FOCUS_NEXT)
1663 list_next = eina_list_next;
1667 const Eina_List *l = items;
1669 /* Recovery last focused sub item */
1670 if (elm_widget_focus_get(obj))
1671 for (; l; l = list_next(l))
1673 Evas_Object *cur = list_data_get(l);
1674 if (elm_widget_focus_get(cur)) break;
1677 const Eina_List *start = l;
1678 Evas_Object *to_focus = NULL;
1680 /* Interate sub items */
1681 /* Go to end of list */
1682 for (; l; l = list_next(l))
1684 Evas_Object *tmp = NULL;
1685 Evas_Object *cur = list_data_get(l);
1687 if (elm_widget_parent_get(cur) != obj)
1690 /* Try Focus cycle in subitem */
1691 if (elm_widget_focus_next_get(cur, dir, &tmp))
1696 else if ((tmp) && (!to_focus))
1702 /* Get First possible */
1703 for (; l != start; l = list_next(l))
1705 Evas_Object *tmp = NULL;
1706 Evas_Object *cur = list_data_get(l);
1708 if (elm_widget_parent_get(cur) != obj)
1711 /* Try Focus cycle in subitem */
1712 elm_widget_focus_next_get(cur, dir, &tmp);
1725 elm_widget_signal_emit(Evas_Object *obj,
1726 const char *emission,
1730 if (!sd->signal_func) return;
1731 sd->signal_func(obj, emission, source);
1735 _edje_signal_callback(void *data,
1736 Evas_Object *obj __UNUSED__,
1737 const char *emission,
1740 Edje_Signal_Data *esd = data;
1741 esd->func(esd->data, esd->obj, emission, source);
1745 elm_widget_signal_callback_add(Evas_Object *obj,
1746 const char *emission,
1748 Edje_Signal_Cb func,
1751 Edje_Signal_Data *esd;
1753 if (!sd->callback_add_func) return;
1754 EINA_SAFETY_ON_NULL_RETURN(func);
1756 esd = ELM_NEW(Edje_Signal_Data);
1761 esd->emission = eina_stringshare_add(emission);
1762 esd->source = eina_stringshare_add(source);
1764 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1765 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1769 elm_widget_signal_callback_del(Evas_Object *obj,
1770 const char *emission,
1772 Edje_Signal_Cb func)
1774 Edje_Signal_Data *esd;
1777 API_ENTRY return NULL;
1778 if (!sd->callback_del_func) return NULL;
1780 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1782 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1783 (!strcmp(esd->source, source)))
1785 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1786 eina_stringshare_del(esd->emission);
1787 eina_stringshare_del(esd->source);
1793 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1798 elm_widget_focus_set(Evas_Object *obj,
1805 sd->focus_order = focus_order;
1806 sd->focused = EINA_TRUE;
1807 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1811 sd->focus_func(obj);
1818 if ((_is_focusable(sd->resize_obj)) &&
1819 (!elm_widget_disabled_get(sd->resize_obj)))
1821 elm_widget_focus_set(sd->resize_obj, first);
1827 EINA_LIST_FOREACH(sd->subobjs, l, child)
1829 if ((_is_focusable(child)) &&
1830 (!elm_widget_disabled_get(child)))
1832 elm_widget_focus_set(child, first);
1842 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1844 if ((_is_focusable(child)) &&
1845 (!elm_widget_disabled_get(child)))
1847 elm_widget_focus_set(child, first);
1853 if ((_is_focusable(sd->resize_obj)) &&
1854 (!elm_widget_disabled_get(sd->resize_obj)))
1856 elm_widget_focus_set(sd->resize_obj, first);
1864 elm_widget_parent_get(const Evas_Object *obj)
1866 API_ENTRY return NULL;
1867 return sd->parent_obj;
1871 elm_widget_focused_object_clear(Evas_Object *obj)
1874 if (!sd->focused) return;
1875 if (elm_widget_focus_get(sd->resize_obj))
1876 elm_widget_focused_object_clear(sd->resize_obj);
1881 EINA_LIST_FOREACH(sd->subobjs, l, child)
1883 if (elm_widget_focus_get(child))
1885 elm_widget_focused_object_clear(child);
1890 sd->focused = EINA_FALSE;
1891 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1892 if (sd->focus_func) sd->focus_func(obj);
1896 elm_widget_focus_steal(Evas_Object *obj)
1898 Evas_Object *parent, *parent2, *o;
1901 if (sd->focused) return;
1902 if (sd->disabled) return;
1903 if (!sd->can_focus) return;
1904 if (sd->tree_unfocusable) return;
1908 o = elm_widget_parent_get(parent);
1910 sd = evas_object_smart_data_get(o);
1911 if (sd->disabled || sd->tree_unfocusable) return;
1912 if (sd->focused) break;
1915 if ((!elm_widget_parent_get(parent)) &&
1916 (!elm_widget_parent2_get(parent)))
1917 elm_widget_focused_object_clear(parent);
1920 parent2 = elm_widget_parent_get(parent);
1921 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1923 sd = evas_object_smart_data_get(parent);
1926 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1927 elm_widget_focused_object_clear(sd->resize_obj);
1932 EINA_LIST_FOREACH(sd->subobjs, l, child)
1934 if (elm_widget_focus_get(child))
1936 elm_widget_focused_object_clear(child);
1948 elm_widget_focus_restore(Evas_Object *obj)
1950 Evas_Object *newest = NULL;
1951 unsigned int newest_focus_order = 0;
1954 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1957 elm_object_focus_set(newest, EINA_FALSE);
1958 elm_object_focus_set(newest, EINA_TRUE);
1963 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1969 if (sd->top_win_focused == top_win_focused) return;
1971 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1972 EINA_LIST_FOREACH(sd->subobjs, l, child)
1974 _elm_widget_top_win_focused_set(child, top_win_focused);
1976 sd->top_win_focused = top_win_focused;
1980 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1982 API_ENTRY return EINA_FALSE;
1983 return sd->top_win_focused;
1987 elm_widget_activate(Evas_Object *obj)
1990 elm_widget_change(obj);
1991 if (sd->activate_func) sd->activate_func(obj);
1995 elm_widget_change(Evas_Object *obj)
1998 elm_widget_change(elm_widget_parent_get(obj));
1999 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2003 elm_widget_disabled_set(Evas_Object *obj,
2008 if (sd->disabled == disabled) return;
2009 sd->disabled = !!disabled;
2010 elm_widget_focus_disabled_handle(obj);
2011 if (sd->disable_func) sd->disable_func(obj);
2015 elm_widget_disabled_get(const Evas_Object *obj)
2018 return sd->disabled;
2022 elm_widget_show_region_set(Evas_Object *obj,
2027 Eina_Bool forceshow)
2029 Evas_Object *parent_obj, *child_obj;
2030 Evas_Coord px, py, cx, cy;
2033 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2034 && (w == sd->rw) && (h == sd->rh)) return;
2039 if (sd->on_show_region_func)
2040 sd->on_show_region_func(sd->on_show_region_data, obj);
2044 parent_obj = sd->parent_obj;
2045 child_obj = sd->obj;
2046 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2047 sd = evas_object_smart_data_get(parent_obj);
2050 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2051 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2060 if (sd->on_show_region_func)
2062 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2069 elm_widget_show_region_get(const Evas_Object *obj,
2085 * Get the focus region of the given widget.
2087 * The focus region is the area of a widget that should brought into the
2088 * visible area when the widget is focused. Mostly used to show the part of
2089 * an entry where the cursor is, for example. The area returned is relative
2090 * to the object @p obj.
2091 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2092 * function will return the full size of the object.
2094 * @param obj The widget object
2095 * @param x Where to store the x coordinate of the area
2096 * @param y Where to store the y coordinate of the area
2097 * @param w Where to store the width of the area
2098 * @param h Where to store the height of the area
2103 elm_widget_focus_region_get(const Evas_Object *obj,
2113 sd = evas_object_smart_data_get(obj);
2114 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2116 evas_object_geometry_get(obj, NULL, NULL, w, h);
2121 sd->on_focus_region_func(obj, x, y, w, h);
2125 elm_widget_scroll_hold_push(Evas_Object *obj)
2129 if (sd->scroll_hold == 1)
2130 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2131 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2132 // FIXME: on delete/reparent hold pop
2136 elm_widget_scroll_hold_pop(Evas_Object *obj)
2140 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2141 if (!sd->scroll_hold)
2142 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2143 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2147 elm_widget_scroll_hold_get(const Evas_Object *obj)
2150 return sd->scroll_hold;
2154 elm_widget_scroll_freeze_push(Evas_Object *obj)
2157 sd->scroll_freeze++;
2158 if (sd->scroll_freeze == 1)
2159 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2160 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2161 // FIXME: on delete/reparent freeze pop
2165 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2168 sd->scroll_freeze--;
2169 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2170 if (!sd->scroll_freeze)
2171 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2172 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2176 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2179 return sd->scroll_freeze;
2183 elm_widget_scale_set(Evas_Object *obj,
2187 if (scale <= 0.0) scale = 0.0;
2188 if (sd->scale != scale)
2191 elm_widget_theme(obj);
2196 elm_widget_scale_get(const Evas_Object *obj)
2198 API_ENTRY return 1.0;
2199 // FIXME: save walking up the tree by storing/caching parent scale
2200 if (sd->scale == 0.0)
2203 return elm_widget_scale_get(sd->parent_obj);
2211 elm_widget_theme_set(Evas_Object *obj,
2215 if (sd->theme != th)
2217 if (sd->theme) elm_theme_free(sd->theme);
2220 elm_widget_theme(obj);
2225 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2229 if (!sd->on_text_set_func)
2232 sd->on_text_set_func(obj, part, label);
2236 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2238 API_ENTRY return NULL;
2240 if (!sd->on_text_get_func)
2243 return sd->on_text_get_func(obj, part);
2247 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2251 if (!sd->on_content_set_func) return;
2252 sd->on_content_set_func(obj, part, content);
2256 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2258 API_ENTRY return NULL;
2260 if (!sd->on_content_get_func) return NULL;
2261 return sd->on_content_get_func(obj, part);
2265 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2267 API_ENTRY return NULL;
2269 if (!sd->on_content_unset_func) return NULL;
2270 return sd->on_content_unset_func(obj, part);
2274 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2277 if (sd->access_info) eina_stringshare_del(sd->access_info);
2278 if (!txt) sd->access_info = NULL;
2279 else sd->access_info = eina_stringshare_add(txt);
2283 elm_widget_access_info_get(Evas_Object *obj)
2285 API_ENTRY return NULL;
2286 return sd->access_info;
2291 elm_widget_theme_get(const Evas_Object *obj)
2293 API_ENTRY return NULL;
2297 return elm_widget_theme_get(sd->parent_obj);
2305 elm_widget_style_set(Evas_Object *obj,
2310 if (eina_stringshare_replace(&sd->style, style))
2311 elm_widget_theme(obj);
2315 elm_widget_style_get(const Evas_Object *obj)
2317 API_ENTRY return NULL;
2318 if (sd->style) return sd->style;
2323 elm_widget_type_set(Evas_Object *obj,
2327 eina_stringshare_replace(&sd->type, type);
2331 elm_widget_type_get(const Evas_Object *obj)
2333 API_ENTRY return NULL;
2334 if (sd->type) return sd->type;
2339 elm_widget_tooltip_add(Evas_Object *obj,
2343 sd->tooltips = eina_list_append(sd->tooltips, tt);
2347 elm_widget_tooltip_del(Evas_Object *obj,
2351 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2355 elm_widget_cursor_add(Evas_Object *obj,
2359 sd->cursors = eina_list_append(sd->cursors, cur);
2363 elm_widget_cursor_del(Evas_Object *obj,
2367 sd->cursors = eina_list_remove(sd->cursors, cur);
2371 elm_widget_drag_lock_x_set(Evas_Object *obj,
2375 if (sd->drag_x_locked == lock) return;
2376 sd->drag_x_locked = lock;
2377 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2378 else _propagate_x_drag_lock(obj, -1);
2382 elm_widget_drag_lock_y_set(Evas_Object *obj,
2386 if (sd->drag_y_locked == lock) return;
2387 sd->drag_y_locked = lock;
2388 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2389 else _propagate_y_drag_lock(obj, -1);
2393 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2395 API_ENTRY return EINA_FALSE;
2396 return sd->drag_x_locked;
2400 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2402 API_ENTRY return EINA_FALSE;
2403 return sd->drag_y_locked;
2407 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2410 return sd->child_drag_x_locked;
2414 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2417 return sd->child_drag_y_locked;
2421 elm_widget_theme_object_set(Evas_Object *obj,
2424 const char *welement,
2427 API_ENTRY return EINA_FALSE;
2428 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2432 elm_widget_is_check(const Evas_Object *obj)
2434 static int abort_on_warn = -1;
2435 if (elm_widget_is(obj))
2438 ERR("Passing Object: %p.", obj);
2439 if (abort_on_warn == -1)
2441 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2442 else abort_on_warn = 0;
2444 if (abort_on_warn == 1) abort();
2449 elm_widget_type_check(const Evas_Object *obj,
2453 const char *provided, *expected = "(unknown)";
2454 static int abort_on_warn = -1;
2455 provided = elm_widget_type_get(obj);
2456 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2457 if (type) expected = type;
2458 if ((!provided) || (!provided[0]))
2460 provided = evas_object_type_get(obj);
2461 if ((!provided) || (!provided[0]))
2462 provided = "(unknown)";
2464 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2465 if (abort_on_warn == -1)
2467 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2468 else abort_on_warn = 0;
2470 if (abort_on_warn == 1) abort();
2477 * Split string in words
2479 * @param str Source string
2480 * @return List of const words
2482 * @see elm_widget_stringlist_free()
2486 elm_widget_stringlist_get(const char *str)
2488 Eina_List *list = NULL;
2490 if (!str) return NULL;
2491 for (b = s = str; 1; s++)
2493 if ((*s == ' ') || (!*s))
2495 char *t = malloc(s - b + 1);
2498 strncpy(t, b, s - b);
2500 list = eina_list_append(list, eina_stringshare_add(t));
2511 elm_widget_stringlist_free(Eina_List *list)
2514 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2518 elm_widget_focus_hide_handle(Evas_Object *obj)
2520 _if_focused_revert(obj, EINA_TRUE);
2524 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2526 Evas_Object *o = obj;
2529 if (_elm_widget_is(o)) break;
2530 o = evas_object_smart_parent_get(o);
2534 if (!_is_focusable(o)) return;
2535 elm_widget_focus_steal(o);
2539 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2543 if (!elm_widget_parent_get(obj))
2544 elm_widget_focused_object_clear(obj);
2546 _if_focused_revert(obj, EINA_TRUE);
2550 elm_widget_focus_disabled_handle(Evas_Object *obj)
2554 elm_widget_focus_tree_unfocusable_handle(obj);
2560 * Allocate a new Elm_Widget_Item-derived structure.
2562 * The goal of this structure is to provide common ground for actions
2563 * that a widget item have, such as the owner widget, callback to
2564 * notify deletion, data pointer and maybe more.
2566 * @param widget the owner widget that holds this item, must be an elm_widget!
2567 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2568 * be used to allocate memory.
2570 * @return allocated memory that is already zeroed out, or NULL on errors.
2572 * @see elm_widget_item_new() convenience macro.
2573 * @see elm_widget_item_del() to release memory.
2576 EAPI Elm_Widget_Item *
2577 _elm_widget_item_new(Evas_Object *widget,
2580 if (!_elm_widget_is(widget))
2583 Elm_Widget_Item *item;
2585 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2586 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2588 item = calloc(1, alloc_size);
2589 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2591 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2592 item->widget = widget;
2599 * Releases widget item memory, calling back del_cb() if it exists.
2601 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2602 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2603 * this function and then unset it, thus being useful for 2 step
2604 * cleanup whenever the del_cb may use any of the data that must be
2605 * deleted from item.
2607 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2610 * @param item a valid #Elm_Widget_Item to be deleted.
2611 * @see elm_widget_item_del() convenience macro.
2615 _elm_widget_item_del(Elm_Widget_Item *item)
2617 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2620 item->del_cb((void *)item->data, item->widget, item);
2623 evas_object_del(item->view);
2627 _elm_access_clear(item->access);
2629 item->access = NULL;
2631 if (item->access_info)
2633 eina_stringshare_del(item->access_info);
2634 item->access_info = NULL;
2637 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2644 * Notify object will be deleted without actually deleting it.
2646 * This function will callback Elm_Widget_Item::del_cb if it is set
2647 * and then unset it so it is not called twice (ie: from
2648 * elm_widget_item_del()).
2650 * @param item a valid #Elm_Widget_Item to be notified
2651 * @see elm_widget_item_pre_notify_del() convenience macro.
2655 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2657 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2658 if (!item->del_cb) return;
2659 item->del_cb((void *)item->data, item->widget, item);
2660 item->del_cb = NULL;
2666 * Set the function to notify when item is being deleted.
2668 * This function will complain if there was a callback set already,
2669 * however it will set the new one.
2671 * The callback will be called from elm_widget_item_pre_notify_del()
2672 * or elm_widget_item_del() will be called with:
2673 * - data: the Elm_Widget_Item::data value.
2674 * - obj: the Elm_Widget_Item::widget evas object.
2675 * - event_info: the item being deleted.
2677 * @param item a valid #Elm_Widget_Item to be notified
2678 * @see elm_widget_item_del_cb_set() convenience macro.
2682 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2683 Evas_Smart_Cb del_cb)
2685 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2687 if ((item->del_cb) && (item->del_cb != del_cb))
2688 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2689 item->del_cb, item, del_cb);
2691 item->del_cb = del_cb;
2697 * Set user-data in this item.
2699 * User data may be used to identify this item or just store any
2700 * application data. It is automatically given as the first parameter
2701 * of the deletion notify callback.
2703 * @param item a valid #Elm_Widget_Item to store data in.
2704 * @param data user data to store.
2705 * @see elm_widget_item_del_cb_set() convenience macro.
2709 _elm_widget_item_data_set(Elm_Widget_Item *item,
2712 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2713 if ((item->data) && (item->data != data))
2714 DBG("Replacing item %p data %p with %p", item, item->data, data);
2721 * Retrieves user-data of this item.
2723 * @param item a valid #Elm_Widget_Item to get data from.
2724 * @see elm_widget_item_data_set()
2728 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2730 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2731 return (void *)item->data;
2734 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2736 struct _Elm_Widget_Item_Tooltip
2738 Elm_Widget_Item *item;
2739 Elm_Tooltip_Item_Content_Cb func;
2740 Evas_Smart_Cb del_cb;
2744 static Evas_Object *
2745 _elm_widget_item_tooltip_label_create(void *data,
2746 Evas_Object *obj __UNUSED__,
2747 Evas_Object *tooltip,
2748 void *item __UNUSED__)
2750 Evas_Object *label = elm_label_add(tooltip);
2753 elm_object_style_set(label, "tooltip");
2754 elm_object_text_set(label, data);
2759 _elm_widget_item_tooltip_label_del_cb(void *data,
2760 Evas_Object *obj __UNUSED__,
2761 void *event_info __UNUSED__)
2763 eina_stringshare_del(data);
2769 * Set the text to be shown in the widget item.
2771 * @param item Target item
2772 * @param text The text to set in the content
2774 * Setup the text as tooltip to object. The item can have only one tooltip,
2775 * so any previous tooltip data is removed.
2780 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2783 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2784 EINA_SAFETY_ON_NULL_RETURN(text);
2786 text = eina_stringshare_add(text);
2787 _elm_widget_item_tooltip_content_cb_set
2788 (item, _elm_widget_item_tooltip_label_create, text,
2789 _elm_widget_item_tooltip_label_del_cb);
2792 static Evas_Object *
2793 _elm_widget_item_tooltip_create(void *data,
2795 Evas_Object *tooltip)
2797 Elm_Widget_Item_Tooltip *wit = data;
2798 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2802 _elm_widget_item_tooltip_del_cb(void *data,
2804 void *event_info __UNUSED__)
2806 Elm_Widget_Item_Tooltip *wit = data;
2807 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2814 * Set the content to be shown in the tooltip item
2816 * Setup the tooltip to item. The item can have only one tooltip,
2817 * so any previous tooltip data is removed. @p func(with @p data) will
2818 * be called every time that need show the tooltip and it should
2819 * return a valid Evas_Object. This object is then managed fully by
2820 * tooltip system and is deleted when the tooltip is gone.
2822 * @param item the widget item being attached a tooltip.
2823 * @param func the function used to create the tooltip contents.
2824 * @param data what to provide to @a func as callback data/context.
2825 * @param del_cb called when data is not needed anymore, either when
2826 * another callback replaces @func, the tooltip is unset with
2827 * elm_widget_item_tooltip_unset() or the owner @a item
2828 * dies. This callback receives as the first parameter the
2829 * given @a data, and @c event_info is the item.
2834 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2835 Elm_Tooltip_Item_Content_Cb func,
2837 Evas_Smart_Cb del_cb)
2839 Elm_Widget_Item_Tooltip *wit;
2841 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2845 _elm_widget_item_tooltip_unset(item);
2849 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2850 if (!wit) goto error;
2854 wit->del_cb = del_cb;
2856 elm_object_sub_tooltip_content_cb_set
2857 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2858 _elm_widget_item_tooltip_del_cb);
2863 if (del_cb) del_cb((void *)data, NULL, item);
2866 if (del_cb) del_cb((void *)data, item->widget, item);
2872 * Unset tooltip from item
2874 * @param item widget item to remove previously set tooltip.
2876 * Remove tooltip from item. The callback provided as del_cb to
2877 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2878 * it is not used anymore.
2880 * @see elm_widget_item_tooltip_content_cb_set()
2885 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2887 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2888 elm_object_tooltip_unset(item->view);
2894 * Sets a different style for this item tooltip.
2896 * @note before you set a style you should define a tooltip with
2897 * elm_widget_item_tooltip_content_cb_set() or
2898 * elm_widget_item_tooltip_text_set()
2900 * @param item widget item with tooltip already set.
2901 * @param style the theme style to use (default, transparent, ...)
2906 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2909 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2910 elm_object_tooltip_style_set(item->view, style);
2914 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
2916 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2917 return elm_tooltip_size_restrict_disable(item->view, disable);
2921 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
2923 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2924 return elm_tooltip_size_restrict_disabled_get(item->view);
2930 * Get the style for this item tooltip.
2932 * @param item widget item with tooltip already set.
2933 * @return style the theme style in use, defaults to "default". If the
2934 * object does not have a tooltip set, then NULL is returned.
2939 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2941 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2942 return elm_object_tooltip_style_get(item->view);
2946 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2949 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2950 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2954 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2956 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2957 return elm_object_cursor_get(item->view);
2961 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2963 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2964 elm_object_cursor_unset(item->view);
2970 * Sets a different style for this item cursor.
2972 * @note before you set a style you should define a cursor with
2973 * elm_widget_item_cursor_set()
2975 * @param item widget item with cursor already set.
2976 * @param style the theme style to use (default, transparent, ...)
2981 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2984 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2985 elm_object_cursor_style_set(item->view, style);
2991 * Get the style for this item cursor.
2993 * @param item widget item with cursor already set.
2994 * @return style the theme style in use, defaults to "default". If the
2995 * object does not have a cursor set, then NULL is returned.
3000 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3002 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3003 return elm_object_cursor_style_get(item->view);
3009 * Set if the cursor set should be searched on the theme or should use
3010 * the provided by the engine, only.
3012 * @note before you set if should look on theme you should define a cursor
3013 * with elm_object_cursor_set(). By default it will only look for cursors
3014 * provided by the engine.
3016 * @param item widget item with cursor already set.
3017 * @param engine_only boolean to define it cursors should be looked only
3018 * between the provided by the engine or searched on widget's theme as well.
3023 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3024 Eina_Bool engine_only)
3026 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3027 elm_object_cursor_engine_only_set(item->view, engine_only);
3033 * Get the cursor engine only usage for this item cursor.
3035 * @param item widget item with cursor already set.
3036 * @return engine_only boolean to define it cursors should be looked only
3037 * between the provided by the engine or searched on widget's theme as well. If
3038 * the object does not have a cursor set, then EINA_FALSE is returned.
3043 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3045 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3046 return elm_object_cursor_engine_only_get(item->view);
3049 // smart object funcs
3051 _smart_reconfigure(Smart_Data *sd)
3055 evas_object_move(sd->resize_obj, sd->x, sd->y);
3056 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3060 evas_object_move(sd->hover_obj, sd->x, sd->y);
3061 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3066 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3068 Evas_Object *content)
3070 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3071 if (!item->on_content_set_func) return;
3072 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3076 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3079 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3080 if (!item->on_content_get_func) return NULL;
3081 return item->on_content_get_func((Elm_Object_Item *) item, part);
3085 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3088 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3089 if (!item->on_content_unset_func) return NULL;
3090 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3094 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3098 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3099 if (!item->on_text_set_func) return;
3100 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3104 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3107 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3108 if (!item->on_text_get_func) return NULL;
3109 return item->on_text_get_func((Elm_Object_Item *) item, part);
3113 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3114 Elm_Widget_On_Content_Set_Cb func)
3116 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3117 item->on_content_set_func = func;
3121 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3122 Elm_Widget_On_Content_Get_Cb func)
3124 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3125 item->on_content_get_func = func;
3129 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3130 Elm_Widget_On_Content_Unset_Cb func)
3132 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3133 item->on_content_unset_func = func;
3137 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3138 Elm_Widget_On_Text_Set_Cb func)
3140 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3141 item->on_text_set_func = func;
3145 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3146 Elm_Widget_On_Text_Get_Cb func)
3148 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3149 item->on_text_get_func = func;
3153 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3155 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3156 if (item->access_info) eina_stringshare_del(item->access_info);
3157 if (!txt) item->access_info = NULL;
3158 else item->access_info = eina_stringshare_add(txt);
3163 _smart_add(Evas_Object *obj)
3167 sd = calloc(1, sizeof(Smart_Data));
3170 sd->x = sd->y = sd->w = sd->h = 0;
3172 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3173 evas_object_smart_data_set(obj, sd);
3176 static Evas_Object *
3177 _newest_focus_order_get(Evas_Object *obj,
3178 unsigned int *newest_focus_order,
3179 Eina_Bool can_focus_only)
3182 Evas_Object *child, *ret, *best;
3184 API_ENTRY return NULL;
3186 if (!evas_object_visible_get(obj)
3187 || (elm_widget_disabled_get(obj))
3188 || (elm_widget_tree_unfocusable_get(obj)))
3192 if (*newest_focus_order < sd->focus_order)
3194 *newest_focus_order = sd->focus_order;
3197 EINA_LIST_FOREACH(sd->subobjs, l, child)
3199 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3205 if ((!best) || (!elm_widget_can_focus_get(best)))
3212 _if_focused_revert(Evas_Object *obj,
3213 Eina_Bool can_focus_only)
3216 Evas_Object *newest = NULL;
3217 unsigned int newest_focus_order = 0;
3221 if (!sd->focused) return;
3222 if (!sd->parent_obj) return;
3224 top = elm_widget_top_get(sd->parent_obj);
3227 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3230 elm_object_focus_set(newest, EINA_FALSE);
3231 elm_object_focus_set(newest, EINA_TRUE);
3237 _smart_del(Evas_Object *obj)
3240 Edje_Signal_Data *esd;
3244 if (sd->del_pre_func) sd->del_pre_func(obj);
3247 sobj = sd->resize_obj;
3248 sd->resize_obj = NULL;
3249 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3250 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3251 evas_object_del(sobj);
3255 sobj = sd->hover_obj;
3256 sd->hover_obj = NULL;
3257 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3258 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3259 evas_object_del(sobj);
3261 EINA_LIST_FREE(sd->subobjs, sobj)
3263 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3264 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3265 evas_object_del(sobj);
3267 eina_list_free(sd->tooltips); /* should be empty anyway */
3268 eina_list_free(sd->cursors); /* should be empty anyway */
3269 EINA_LIST_FREE(sd->edje_signals, esd)
3271 eina_stringshare_del(esd->emission);
3272 eina_stringshare_del(esd->source);
3275 eina_list_free(sd->event_cb); /* should be empty anyway */
3276 if (sd->del_func) sd->del_func(obj);
3277 if (sd->style) eina_stringshare_del(sd->style);
3278 if (sd->type) eina_stringshare_del(sd->type);
3279 if (sd->theme) elm_theme_free(sd->theme);
3280 _if_focused_revert(obj, EINA_TRUE);
3281 if (sd->access_info) eina_stringshare_del(sd->access_info);
3286 _smart_move(Evas_Object *obj,
3293 _smart_reconfigure(sd);
3297 _smart_resize(Evas_Object *obj,
3304 _smart_reconfigure(sd);
3308 _smart_show(Evas_Object *obj)
3313 if ((list = evas_object_smart_members_get(obj)))
3315 EINA_LIST_FREE(list, o)
3317 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3318 evas_object_show(o);
3324 _smart_hide(Evas_Object *obj)
3330 list = evas_object_smart_members_get(obj);
3331 EINA_LIST_FREE(list, o)
3333 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3334 evas_object_hide(o);
3339 _smart_color_set(Evas_Object *obj,
3348 if ((list = evas_object_smart_members_get(obj)))
3350 EINA_LIST_FREE(list, o)
3352 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3353 evas_object_color_set(o, r, g, b, a);
3359 _smart_clip_set(Evas_Object *obj,
3365 if ((list = evas_object_smart_members_get(obj)))
3367 EINA_LIST_FREE(list, o)
3369 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3370 evas_object_clip_set(o, clip);
3376 _smart_clip_unset(Evas_Object *obj)
3381 if ((list = evas_object_smart_members_get(obj)))
3383 EINA_LIST_FREE(list, o)
3385 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3386 evas_object_clip_unset(o);
3392 _smart_calculate(Evas_Object *obj)
3395 if (sd->changed_func) sd->changed_func(obj);
3398 /* never need to touch this */
3402 if (_e_smart) return;
3404 static const Evas_Smart_Class sc =
3407 EVAS_SMART_CLASS_VERSION,
3425 _e_smart = evas_smart_class_new(&sc);
3429 /* happy debug functions */
3432 _sub_obj_tree_dump(const Evas_Object *obj,
3437 for (i = 0; i < lvl * 3; i++)
3440 if (_elm_widget_is(obj))
3444 printf("+ %s(%p)\n",
3448 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3449 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3451 if (obj != sd->resize_obj)
3452 _sub_obj_tree_dump(obj, lvl + 1);
3456 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3460 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3463 if (!_elm_widget_is(obj))
3467 Eina_Bool visible = evas_object_visible_get(obj);
3468 Eina_Bool disabled = elm_widget_disabled_get(obj);
3469 Eina_Bool focused = elm_widget_focus_get(obj);
3470 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3474 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3477 fprintf(output, ", style=bold");
3480 fprintf(output, ", color=gray28");
3482 fprintf(output, " ];\n");
3485 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3486 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3487 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3491 fprintf(output, ", style=bold");
3494 fprintf(output, ", fontcolor=gray28");
3496 if ((disabled) || (!visible))
3497 fprintf(output, ", color=gray");
3499 fprintf(output, " ];\n");
3503 EINA_LIST_FOREACH(sd->subobjs, l, o)
3504 _sub_obj_tree_dot_dump(o, output);
3509 elm_widget_tree_dump(const Evas_Object *top)
3512 _sub_obj_tree_dump(top, 0);
3520 elm_widget_tree_dot_dump(const Evas_Object *top,
3524 if (!_elm_widget_is(top))
3526 fprintf(output, "graph " " { node [shape=record];\n");
3527 _sub_obj_tree_dot_dump(top, output);
3528 fprintf(output, "}\n");