1 #include <Elementary.h>
4 static const char SMART_NAME[] = "elm_widget";
7 Smart_Data * sd = evas_object_smart_data_get(obj); \
8 if ((!sd) || (!_elm_widget_is(obj)))
9 #define INTERNAL_ENTRY \
10 Smart_Data * sd = evas_object_smart_data_get(obj); \
13 #undef elm_widget_text_set_hook_set
14 #undef elm_widget_text_get_hook_set
15 #undef elm_widget_content_set_hook_set
16 #undef elm_widget_content_get_hook_set
17 #undef elm_widget_content_unset_hook_set
19 typedef struct _Smart_Data Smart_Data;
20 typedef struct _Edje_Signal_Data Edje_Signal_Data;
21 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
22 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
28 Evas_Object *parent_obj;
30 Evas_Coord x, y, w, h;
32 Evas_Object *resize_obj;
33 Evas_Object *hover_obj;
34 Eina_List *tooltips, *cursors;
35 void (*del_func)(Evas_Object *obj);
36 void (*del_pre_func)(Evas_Object *obj);
37 void (*focus_func)(Evas_Object *obj);
38 void (*activate_func)(Evas_Object *obj);
39 void (*disable_func)(Evas_Object *obj);
40 void (*theme_func)(Evas_Object *obj);
41 void (*translate_func)(Evas_Object *obj);
42 Eina_Bool (*event_func)(Evas_Object *obj,
44 Evas_Callback_Type type,
46 void (*signal_func)(Evas_Object *obj,
49 void (*callback_add_func)(Evas_Object *obj,
54 void (*callback_del_func)(Evas_Object *obj,
59 void (*changed_func)(Evas_Object *obj);
60 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
61 Elm_Focus_Direction dir,
63 void (*on_focus_func)(void *data,
66 void (*on_change_func)(void *data,
69 void (*on_show_region_func)(void *data,
71 void *on_show_region_data;
72 void (*focus_region_func)(Evas_Object *obj,
77 void (*on_focus_region_func)(const Evas_Object *obj,
82 Elm_Widget_Text_Set_Cb text_set_func;
83 Elm_Widget_Text_Get_Cb text_get_func;
84 Elm_Widget_Content_Set_Cb content_set_func;
85 Elm_Widget_Content_Get_Cb content_get_func;
86 Elm_Widget_Content_Unset_Cb content_unset_func;
88 Evas_Coord rx, ry, rw, rh;
94 const char *access_info;
95 unsigned int focus_order;
96 Eina_Bool focus_order_on_calc;
98 int child_drag_x_locked;
99 int child_drag_y_locked;
101 Eina_List *edje_signals;
102 Eina_List *translate_strings;
104 Eina_Bool drag_x_locked : 1;
105 Eina_Bool drag_y_locked : 1;
107 Eina_Bool can_focus : 1;
108 Eina_Bool child_can_focus : 1;
109 Eina_Bool focused : 1;
110 Eina_Bool top_win_focused : 1;
111 Eina_Bool tree_unfocusable : 1;
112 Eina_Bool highlight_ignore : 1;
113 Eina_Bool highlight_in_theme : 1;
114 Eina_Bool disabled : 1;
115 Eina_Bool is_mirrored : 1;
116 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
117 Eina_Bool still_in : 1;
119 Eina_List *focus_chain;
123 struct _Edje_Signal_Data
127 const char *emission;
132 struct _Elm_Event_Cb_Data
138 struct _Elm_Translate_String_Data
145 /* local subsystem functions */
146 static void _smart_reconfigure(Smart_Data *sd);
147 static void _smart_add(Evas_Object *obj);
148 static void _smart_del(Evas_Object *obj);
149 static void _smart_move(Evas_Object *obj,
152 static void _smart_resize(Evas_Object *obj,
155 static void _smart_show(Evas_Object *obj);
156 static void _smart_hide(Evas_Object *obj);
157 static void _smart_color_set(Evas_Object *obj,
162 static void _smart_clip_set(Evas_Object *obj,
164 static void _smart_clip_unset(Evas_Object *obj);
165 static void _smart_calculate(Evas_Object *obj);
166 static void _smart_init(void);
168 static void _if_focused_revert(Evas_Object *obj,
169 Eina_Bool can_focus_only);
170 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
171 unsigned int *newest_focus_order,
172 Eina_Bool can_focus_only);
174 /* local subsystem globals */
175 static Evas_Smart *_e_smart = NULL;
176 static Eina_List *widtypes = NULL;
178 static unsigned int focus_order = 0;
181 static inline Eina_Bool
182 _elm_widget_is(const Evas_Object *obj)
184 const char *type = evas_object_type_get(obj);
185 return type == SMART_NAME;
188 static inline Eina_Bool
189 _is_focusable(Evas_Object *obj)
191 API_ENTRY return EINA_FALSE;
192 return sd->can_focus || (sd->child_can_focus);
196 _unfocus_parents(Evas_Object *obj)
198 for (; obj; obj = elm_widget_parent_get(obj))
201 if (!sd->focused) return;
207 _focus_parents(Evas_Object *obj)
209 for (; obj; obj = elm_widget_parent_get(obj))
212 if (sd->focused) return;
218 _sub_obj_del(void *data,
221 void *event_info __UNUSED__)
223 Smart_Data *sd = data;
225 if (_elm_widget_is(obj))
227 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
229 if (obj == sd->resize_obj)
230 sd->resize_obj = NULL;
231 else if (obj == sd->hover_obj)
232 sd->hover_obj = NULL;
234 sd->subobjs = eina_list_remove(sd->subobjs, obj);
235 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
239 _sub_obj_hide(void *data __UNUSED__,
242 void *event_info __UNUSED__)
244 elm_widget_focus_hide_handle(obj);
248 _sub_obj_mouse_down(void *data,
250 Evas_Object *obj __UNUSED__,
253 Smart_Data *sd = data;
254 Evas_Event_Mouse_Down *ev = event_info;
255 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
256 sd->still_in = EINA_TRUE;
260 _sub_obj_mouse_move(void *data,
265 Smart_Data *sd = data;
266 Evas_Event_Mouse_Move *ev = event_info;
269 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
270 sd->still_in = EINA_FALSE;
273 Evas_Coord x, y, w, h;
274 evas_object_geometry_get(obj, &x, &y, &w, &h);
275 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
276 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
277 sd->still_in = EINA_FALSE;
283 _sub_obj_mouse_up(void *data,
286 void *event_info __UNUSED__)
288 Smart_Data *sd = data;
290 elm_widget_focus_mouse_up_handle(obj);
291 sd->still_in = EINA_FALSE;
295 _propagate_x_drag_lock(Evas_Object *obj,
301 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
304 sd2->child_drag_x_locked += dir;
305 _propagate_x_drag_lock(sd->parent_obj, dir);
311 _propagate_y_drag_lock(Evas_Object *obj,
317 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
320 sd2->child_drag_y_locked += dir;
321 _propagate_y_drag_lock(sd->parent_obj, dir);
327 _propagate_event(void *data,
333 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
334 Evas_Event_Flags *event_flags = NULL;
338 case EVAS_CALLBACK_KEY_DOWN:
340 Evas_Event_Key_Down *ev = event_info;
341 event_flags = &(ev->event_flags);
345 case EVAS_CALLBACK_KEY_UP:
347 Evas_Event_Key_Up *ev = event_info;
348 event_flags = &(ev->event_flags);
352 case EVAS_CALLBACK_MOUSE_WHEEL:
354 Evas_Event_Mouse_Wheel *ev = event_info;
355 event_flags = &(ev->event_flags);
363 elm_widget_event_propagate(obj, type, event_info, event_flags);
367 _parent_focus(Evas_Object *obj)
370 if (sd->focused) return;
372 Evas_Object *o = elm_widget_parent_get(obj);
373 sd->focus_order_on_calc = EINA_TRUE;
375 if (o) _parent_focus(o);
377 if (!sd->focus_order_on_calc)
378 return; /* we don't want to override it if by means of any of the
379 callbacks below one gets to calculate our order
383 sd->focus_order = focus_order;
384 if (sd->top_win_focused)
386 sd->focused = EINA_TRUE;
387 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
388 if (sd->focus_func) sd->focus_func(obj);
389 _elm_widget_focus_region_show(obj);
391 sd->focus_order_on_calc = EINA_FALSE;
395 _elm_object_focus_chain_del_cb(void *data,
398 void *event_info __UNUSED__)
400 Smart_Data *sd = data;
402 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
405 // exposed util funcs to elm
407 _elm_widget_type_clear(void)
411 EINA_LIST_FREE(widtypes, ptr)
413 eina_stringshare_del(*ptr);
419 _elm_widget_focus_region_show(const Evas_Object *obj)
421 Evas_Coord x, y, w, h, ox, oy;
427 o = elm_widget_parent_get(obj);
430 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
431 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
435 sd2 = evas_object_smart_data_get(o);
436 if (sd2->focus_region_func)
438 sd2->focus_region_func(o, x, y, w, h);
439 elm_widget_focus_region_get(o, &x, &y, &w, &h);
443 evas_object_geometry_get(o, &px, &py, NULL, NULL);
449 o = elm_widget_parent_get(o);
454 * @defgroup Widget Widget
457 * Exposed api for making widgets
460 elm_widget_type_register(const char **ptr)
462 widtypes = eina_list_append(widtypes, (void *)ptr);
466 * @defgroup Widget Widget
469 * Disposed api for making widgets
472 elm_widget_type_unregister(const char **ptr)
474 widtypes = eina_list_remove(widtypes, (void *)ptr);
478 elm_widget_api_check(int ver)
480 if (ver != ELM_INTERNAL_API_VERSION)
482 CRITICAL("Elementary widget api versions do not match");
489 elm_widget_add(Evas *evas)
493 obj = evas_object_smart_add(evas, _e_smart);
494 elm_widget_mirrored_set(obj, elm_mirrored_get());
499 elm_widget_del_hook_set(Evas_Object *obj,
500 void (*func)(Evas_Object *obj))
507 elm_widget_del_pre_hook_set(Evas_Object *obj,
508 void (*func)(Evas_Object *obj))
511 sd->del_pre_func = func;
515 elm_widget_focus_hook_set(Evas_Object *obj,
516 void (*func)(Evas_Object *obj))
519 sd->focus_func = func;
523 elm_widget_activate_hook_set(Evas_Object *obj,
524 void (*func)(Evas_Object *obj))
527 sd->activate_func = func;
531 elm_widget_disable_hook_set(Evas_Object *obj,
532 void (*func)(Evas_Object *obj))
535 sd->disable_func = func;
539 elm_widget_theme_hook_set(Evas_Object *obj,
540 void (*func)(Evas_Object *obj))
543 sd->theme_func = func;
547 elm_widget_translate_hook_set(Evas_Object *obj,
548 void (*func)(Evas_Object *obj))
551 sd->translate_func = func;
555 elm_widget_event_hook_set(Evas_Object *obj,
556 Eina_Bool (*func)(Evas_Object *obj,
558 Evas_Callback_Type type,
562 sd->event_func = func;
566 elm_widget_text_set_hook_set(Evas_Object *obj,
567 Elm_Widget_Text_Set_Cb func)
570 sd->text_set_func = func;
574 elm_widget_text_get_hook_set(Evas_Object *obj,
575 Elm_Widget_Text_Get_Cb func)
578 sd->text_get_func = func;
582 elm_widget_content_set_hook_set(Evas_Object *obj,
583 Elm_Widget_Content_Set_Cb func)
586 sd->content_set_func = func;
590 elm_widget_content_get_hook_set(Evas_Object *obj,
591 Elm_Widget_Content_Get_Cb func)
594 sd->content_get_func = func;
598 elm_widget_content_unset_hook_set(Evas_Object *obj,
599 Elm_Widget_Content_Unset_Cb func)
602 sd->content_unset_func = func;
606 elm_widget_changed_hook_set(Evas_Object *obj,
607 void (*func)(Evas_Object *obj))
610 sd->changed_func = func;
614 elm_widget_signal_emit_hook_set(Evas_Object *obj,
615 void (*func)(Evas_Object *obj,
616 const char *emission,
620 sd->signal_func = func;
624 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
625 void (*func)(Evas_Object *obj,
626 const char *emission,
628 Edje_Signal_Cb func_cb,
632 sd->callback_add_func = func;
636 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
637 void (*func)(Evas_Object *obj,
638 const char *emission,
640 Edje_Signal_Cb func_cb,
644 sd->callback_del_func = func;
648 elm_widget_theme(Evas_Object *obj)
656 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
657 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
658 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
659 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
660 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
661 if (sd->theme_func) sd->theme_func(obj);
665 elm_widget_theme_specific(Evas_Object *obj,
673 Elm_Theme *th2, *thdef;
676 thdef = elm_theme_default_get();
681 if (!th2) th2 = thdef;
689 if (th2 == thdef) break;
690 th2 = th2->ref_theme;
691 if (!th2) th2 = thdef;
695 EINA_LIST_FOREACH(sd->subobjs, l, child)
696 elm_widget_theme_specific(child, th, force);
697 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
698 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
699 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
700 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
701 if (sd->theme_func) sd->theme_func(obj);
707 * Set hook to get next object in object focus chain.
709 * @param obj The widget object.
710 * @param func The hook to be used with this widget.
715 elm_widget_focus_next_hook_set(Evas_Object *obj,
716 Eina_Bool (*func)(const Evas_Object *obj,
717 Elm_Focus_Direction dir,
721 sd->focus_next_func = func;
725 * Returns the widget's mirrored mode.
727 * @param obj The widget.
728 * @return mirrored mode of the object.
732 elm_widget_mirrored_get(const Evas_Object *obj)
734 API_ENTRY return EINA_FALSE;
735 return sd->is_mirrored;
739 * Sets the widget's mirrored mode.
741 * @param obj The widget.
742 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
745 elm_widget_mirrored_set(Evas_Object *obj,
749 if (sd->is_mirrored != mirrored)
751 sd->is_mirrored = mirrored;
752 elm_widget_theme(obj);
758 * Resets the mirrored mode from the system mirror mode for widgets that are in
759 * automatic mirroring mode. This function does not call elm_widget_theme.
761 * @param obj The widget.
762 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
765 _elm_widget_mirrored_reload(Evas_Object *obj)
768 Eina_Bool mirrored = elm_mirrored_get();
769 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
771 sd->is_mirrored = mirrored;
776 * Returns the widget's mirrored mode setting.
778 * @param obj The widget.
779 * @return mirrored mode setting of the object.
783 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
785 API_ENTRY return EINA_FALSE;
786 return sd->mirrored_auto_mode;
790 * Sets the widget's mirrored mode setting.
791 * When widget in automatic mode, it follows the system mirrored mode set by
792 * elm_mirrored_set().
793 * @param obj The widget.
794 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
797 elm_widget_mirrored_automatic_set(Evas_Object *obj,
801 if (sd->mirrored_auto_mode != automatic)
803 sd->mirrored_auto_mode = automatic;
807 elm_widget_mirrored_set(obj, elm_mirrored_get());
813 elm_widget_on_focus_hook_set(Evas_Object *obj,
814 void (*func)(void *data,
819 sd->on_focus_func = func;
820 sd->on_focus_data = data;
824 elm_widget_on_change_hook_set(Evas_Object *obj,
825 void (*func)(void *data,
830 sd->on_change_func = func;
831 sd->on_change_data = data;
835 elm_widget_on_show_region_hook_set(Evas_Object *obj,
836 void (*func)(void *data,
841 sd->on_show_region_func = func;
842 sd->on_show_region_data = data;
848 * Set the hook to use to show the focused region.
850 * Whenever a new widget gets focused or it's needed to show the focused
851 * area of the current one, this hook will be called on objects that may
852 * want to move their children into their visible area.
853 * The area given in the hook function is relative to the @p obj widget.
855 * @param obj The widget object
856 * @param func The function to call to show the specified area.
861 elm_widget_focus_region_hook_set(Evas_Object *obj,
862 void (*func)(Evas_Object *obj,
869 sd->focus_region_func = func;
875 * Set the hook to retrieve the focused region of a widget.
877 * This hook will be called by elm_widget_focus_region_get() whenever
878 * it's needed to get the focused area of a widget. The area must be relative
879 * to the widget itself and if no hook is set, it will default to the entire
882 * @param obj The widget object
883 * @param func The function used to retrieve the focus region.
888 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
889 void (*func)(const Evas_Object *obj,
896 sd->on_focus_region_func = func;
900 elm_widget_data_set(Evas_Object *obj,
908 elm_widget_data_get(const Evas_Object *obj)
910 API_ENTRY return NULL;
915 elm_widget_sub_object_add(Evas_Object *obj,
919 double scale, pscale = elm_widget_scale_get(sobj);
920 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
921 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
923 if (_elm_widget_is(sobj))
925 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
928 if (sd2->parent_obj == obj)
931 elm_widget_sub_object_del(sd2->parent_obj, sobj);
932 sd2->parent_obj = obj;
933 sd2->top_win_focused = sd->top_win_focused;
934 if (!sd->child_can_focus && (_is_focusable(sobj)))
935 sd->child_can_focus = EINA_TRUE;
940 void *data = evas_object_data_get(sobj, "elm-parent");
943 if (data == obj) return;
944 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
948 sd->subobjs = eina_list_append(sd->subobjs, sobj);
949 evas_object_data_set(sobj, "elm-parent", obj);
950 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
951 if (_elm_widget_is(sobj))
952 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
953 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
954 scale = elm_widget_scale_get(sobj);
955 th = elm_widget_theme_get(sobj);
956 mirrored = elm_widget_mirrored_get(sobj);
957 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
958 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
962 elm_widget_sub_object_del(Evas_Object *obj,
965 Evas_Object *sobj_parent;
969 sobj_parent = evas_object_data_del(sobj, "elm-parent");
970 if (sobj_parent != obj)
972 static int abort_on_warn = -1;
973 ERR("removing sub object %p (%s) from parent %p (%s), "
974 "but elm-parent is different %p (%s)!",
975 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
976 sobj_parent, elm_widget_type_get(sobj_parent));
977 if (EINA_UNLIKELY(abort_on_warn == -1))
979 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
980 else abort_on_warn = 0;
982 if (abort_on_warn == 1) abort();
984 if (_elm_widget_is(sobj))
986 if (elm_widget_focus_get(sobj))
988 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
989 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
991 if ((sd->child_can_focus) && (_is_focusable(sobj)))
995 sd->child_can_focus = EINA_FALSE;
996 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
998 if (_is_focusable(subobj))
1000 sd->child_can_focus = EINA_TRUE;
1005 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1008 sd2->parent_obj = NULL;
1009 if (sd2->resize_obj == sobj)
1010 sd2->resize_obj = NULL;
1012 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1015 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1018 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1019 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1021 if (_elm_widget_is(sobj))
1022 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1024 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1028 elm_widget_resize_object_set(Evas_Object *obj,
1032 // orphan previous resize obj
1035 evas_object_clip_unset(sd->resize_obj);
1036 evas_object_data_del(sd->resize_obj, "elm-parent");
1037 if (_elm_widget_is(sd->resize_obj))
1039 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1040 if (sd2) sd2->parent_obj = NULL;
1041 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1044 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1046 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1047 _sub_obj_mouse_down, sd);
1048 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1049 _sub_obj_mouse_move, sd);
1050 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1051 _sub_obj_mouse_up, sd);
1052 evas_object_smart_member_del(sd->resize_obj);
1053 if (_elm_widget_is(sd->resize_obj))
1055 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1059 sd->resize_obj = sobj;
1062 // orphan new resize obj
1063 evas_object_data_del(sobj, "elm-parent");
1064 if (_elm_widget_is(sobj))
1066 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1067 if (sd2) sd2->parent_obj = NULL;
1068 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1071 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1073 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1074 _sub_obj_mouse_down, sd);
1075 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1076 _sub_obj_mouse_move, sd);
1077 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1078 _sub_obj_mouse_up, sd);
1079 evas_object_smart_member_del(sobj);
1080 if (_elm_widget_is(sobj))
1082 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1085 // set the resize obj up
1086 if (_elm_widget_is(sobj))
1088 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1091 sd2->parent_obj = obj;
1092 sd2->top_win_focused = sd->top_win_focused;
1094 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1097 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1098 evas_object_smart_member_add(sobj, obj);
1099 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1101 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1102 _sub_obj_mouse_down, sd);
1103 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1104 _sub_obj_mouse_move, sd);
1105 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1106 _sub_obj_mouse_up, sd);
1107 _smart_reconfigure(sd);
1108 evas_object_data_set(sobj, "elm-parent", obj);
1109 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1110 if (_elm_widget_is(sobj))
1112 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1117 elm_widget_hover_object_set(Evas_Object *obj,
1123 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1126 sd->hover_obj = sobj;
1129 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1131 _smart_reconfigure(sd);
1136 elm_widget_can_focus_set(Evas_Object *obj,
1137 Eina_Bool can_focus)
1140 sd->can_focus = can_focus;
1143 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1145 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1146 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1148 (void *)(long)EVAS_CALLBACK_KEY_UP);
1149 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1151 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1155 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1157 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1159 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1165 elm_widget_can_focus_get(const Evas_Object *obj)
1167 API_ENTRY return EINA_FALSE;
1168 return sd->can_focus;
1172 elm_widget_child_can_focus_get(const Evas_Object *obj)
1174 API_ENTRY return EINA_FALSE;
1175 return sd->child_can_focus;
1181 * This API makes the widget object and its children to be unfocusable.
1183 * This API can be helpful for an object to be deleted.
1184 * When an object will be deleted soon, it and its children may not
1185 * want to get focus (by focus reverting or by other focus controls).
1186 * Then, just use this API before deleting.
1188 * @param obj The widget root of sub-tree
1189 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1194 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1195 Eina_Bool tree_unfocusable)
1199 if (sd->tree_unfocusable == tree_unfocusable) return;
1200 sd->tree_unfocusable = !!tree_unfocusable;
1201 elm_widget_focus_tree_unfocusable_handle(obj);
1207 * This returns true, if the object sub-tree is unfocusable.
1209 * @param obj The widget root of sub-tree
1210 * @return EINA_TRUE if the object sub-tree is unfocusable
1215 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1217 API_ENTRY return EINA_FALSE;
1218 return sd->tree_unfocusable;
1224 * Get the list of focusable child objects.
1226 * This function retruns list of child objects which can get focus.
1228 * @param obj The parent widget
1229 * @retrun list of focusable child objects.
1234 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1236 API_ENTRY return NULL;
1239 Eina_List *child_list = NULL;
1244 EINA_LIST_FOREACH(sd->subobjs, l, child)
1246 if ((elm_widget_can_focus_get(child)) &&
1247 (evas_object_visible_get(child)) &&
1248 (!elm_widget_disabled_get(child)))
1249 child_list = eina_list_append(child_list, child);
1250 else if (elm_widget_is(child))
1252 Eina_List *can_focus_list;
1253 can_focus_list = elm_widget_can_focus_child_list_get(child);
1255 child_list = eina_list_merge(child_list, can_focus_list);
1263 elm_widget_highlight_ignore_set(Evas_Object *obj,
1267 sd->highlight_ignore = !!ignore;
1271 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1273 API_ENTRY return EINA_FALSE;
1274 return sd->highlight_ignore;
1278 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1279 Eina_Bool highlight)
1282 sd->highlight_in_theme = !!highlight;
1283 /* FIXME: if focused, it should switch from one mode to the other */
1287 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1289 API_ENTRY return EINA_FALSE;
1290 return sd->highlight_in_theme;
1294 elm_widget_focus_get(const Evas_Object *obj)
1296 API_ENTRY return EINA_FALSE;
1301 elm_widget_focused_object_get(const Evas_Object *obj)
1303 const Evas_Object *subobj;
1305 API_ENTRY return NULL;
1307 if (!sd->focused) return NULL;
1308 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1310 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1311 if (fobj) return fobj;
1313 return (Evas_Object *)obj;
1317 elm_widget_top_get(const Evas_Object *obj)
1319 API_ENTRY return NULL;
1320 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1321 return (Evas_Object *)obj;
1325 elm_widget_is(const Evas_Object *obj)
1327 return _elm_widget_is(obj);
1331 elm_widget_parent_widget_get(const Evas_Object *obj)
1333 Evas_Object *parent;
1335 if (_elm_widget_is(obj))
1337 Smart_Data *sd = evas_object_smart_data_get(obj);
1338 if (!sd) return NULL;
1339 parent = sd->parent_obj;
1343 parent = evas_object_data_get(obj, "elm-parent");
1344 if (!parent) parent = evas_object_smart_parent_get(obj);
1349 Evas_Object *elm_parent;
1350 if (_elm_widget_is(parent)) break;
1351 elm_parent = evas_object_data_get(parent, "elm-parent");
1352 if (elm_parent) parent = elm_parent;
1353 else parent = evas_object_smart_parent_get(parent);
1359 elm_widget_parent2_get(const Evas_Object *obj)
1361 if (_elm_widget_is(obj))
1363 Smart_Data *sd = evas_object_smart_data_get(obj);
1364 if (sd) return sd->parent2;
1370 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1373 sd->parent2 = parent;
1377 elm_widget_event_callback_add(Evas_Object *obj,
1382 EINA_SAFETY_ON_NULL_RETURN(func);
1383 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1386 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1390 elm_widget_event_callback_del(Evas_Object *obj,
1394 API_ENTRY return NULL;
1395 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1397 Elm_Event_Cb_Data *ecd;
1398 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1399 if ((ecd->func == func) && (ecd->data == data))
1402 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1403 return (void *)data;
1409 elm_widget_event_propagate(Evas_Object *obj,
1410 Evas_Callback_Type type,
1412 Evas_Event_Flags *event_flags)
1414 API_ENTRY return EINA_FALSE; //TODO reduce.
1415 if (!_elm_widget_is(obj)) return EINA_FALSE;
1416 Evas_Object *parent = obj;
1417 Elm_Event_Cb_Data *ecd;
1418 Eina_List *l, *l_prev;
1421 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1423 sd = evas_object_smart_data_get(parent);
1424 if ((!sd) || (!_elm_widget_is(obj)))
1425 return EINA_FALSE; //Not Elm Widget
1427 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1430 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1432 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1433 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1436 parent = sd->parent_obj;
1445 * Set custom focus chain.
1447 * This function i set one new and overwrite any previous custom focus chain
1448 * with the list of objects. The previous list will be deleted and this list
1449 * will be managed. After setted, don't modity it.
1451 * @note On focus cycle, only will be evaluated children of this container.
1453 * @param obj The container widget
1454 * @param objs Chain of objects to pass focus
1458 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1462 if (!sd->focus_next_func)
1465 elm_widget_focus_custom_chain_unset(obj);
1470 EINA_LIST_FOREACH(objs, l, o)
1472 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1473 _elm_object_focus_chain_del_cb, sd);
1476 sd->focus_chain = objs;
1482 * Get custom focus chain
1484 * @param obj The container widget
1487 EAPI const Eina_List *
1488 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1490 API_ENTRY return NULL;
1491 return (const Eina_List *)sd->focus_chain;
1497 * Unset custom focus chain
1499 * @param obj The container widget
1503 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1506 Eina_List *l, *l_next;
1509 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1511 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1512 _elm_object_focus_chain_del_cb, sd);
1513 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1520 * Append object to custom focus chain.
1522 * @note If relative_child equal to NULL or not in custom chain, the object
1523 * will be added in end.
1525 * @note On focus cycle, only will be evaluated children of this container.
1527 * @param obj The container widget
1528 * @param child The child to be added in custom chain
1529 * @param relative_child The relative object to position the child
1533 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1535 Evas_Object *relative_child)
1538 EINA_SAFETY_ON_NULL_RETURN(child);
1539 if (!sd->focus_next_func)
1542 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1543 _elm_object_focus_chain_del_cb, sd);
1545 if (!relative_child)
1547 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1551 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1558 * Prepend object to custom focus chain.
1560 * @note If relative_child equal to NULL or not in custom chain, the object
1561 * will be added in begin.
1563 * @note On focus cycle, only will be evaluated children of this container.
1565 * @param obj The container widget
1566 * @param child The child to be added in custom chain
1567 * @param relative_child The relative object to position the child
1571 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1573 Evas_Object *relative_child)
1576 EINA_SAFETY_ON_NULL_RETURN(child);
1577 if (!sd->focus_next_func)
1580 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1581 _elm_object_focus_chain_del_cb, sd);
1583 if (!relative_child)
1585 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1589 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1596 * Give focus to next object in object tree.
1598 * Give focus to next object in focus chain of one object sub-tree.
1599 * If the last object of chain already have focus, the focus will go to the
1600 * first object of chain.
1602 * @param obj The widget root of sub-tree
1603 * @param dir Direction to cycle the focus
1608 elm_widget_focus_cycle(Evas_Object *obj,
1609 Elm_Focus_Direction dir)
1611 Evas_Object *target = NULL;
1612 if (!_elm_widget_is(obj))
1614 elm_widget_focus_next_get(obj, dir, &target);
1616 elm_widget_focus_steal(target);
1622 * Give focus to near object in one direction.
1624 * Give focus to near object in direction of one object.
1625 * If none focusable object in given direction, the focus will not change.
1627 * @param obj The reference widget
1628 * @param x Horizontal component of direction to focus
1629 * @param y Vertical component of direction to focus
1634 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1644 * Get next object in focus chain of object tree.
1646 * Get next object in focus chain of one object sub-tree.
1647 * Return the next object by reference. If don't have any candidate to receive
1648 * focus before chain end, the first candidate will be returned.
1650 * @param obj The widget root of sub-tree
1651 * @param dir Direction os focus chain
1652 * @param next The next object in focus chain
1653 * @return EINA_TRUE if don't need focus chain restart/loop back
1654 * to use 'next' obj.
1659 elm_widget_focus_next_get(const Evas_Object *obj,
1660 Elm_Focus_Direction dir,
1667 API_ENTRY return EINA_FALSE;
1669 /* Ignore if disabled */
1670 if ((!evas_object_visible_get(obj))
1671 || (elm_widget_disabled_get(obj))
1672 || (elm_widget_tree_unfocusable_get(obj)))
1676 if (sd->focus_next_func)
1677 return sd->focus_next_func(obj, dir, next);
1679 if (!elm_widget_can_focus_get(obj))
1683 *next = (Evas_Object *)obj;
1684 return !elm_widget_focus_get(obj);
1690 * Get next object in focus chain of object tree in list.
1692 * Get next object in focus chain of one object sub-tree ordered by one list.
1693 * Return the next object by reference. If don't have any candidate to receive
1694 * focus before list end, the first candidate will be returned.
1696 * @param obj The widget root of sub-tree
1697 * @param dir Direction os focus chain
1698 * @param items list with ordered objects
1699 * @param list_data_get function to get the object from one item of list
1700 * @param next The next object in focus chain
1701 * @return EINA_TRUE if don't need focus chain restart/loop back
1702 * to use 'next' obj.
1707 elm_widget_focus_list_next_get(const Evas_Object *obj,
1708 const Eina_List *items,
1709 void *(*list_data_get)(const Eina_List * list),
1710 Elm_Focus_Direction dir,
1713 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1719 if (!_elm_widget_is(obj))
1726 if (dir == ELM_FOCUS_PREVIOUS)
1728 items = eina_list_last(items);
1729 list_next = eina_list_prev;
1731 else if (dir == ELM_FOCUS_NEXT)
1732 list_next = eina_list_next;
1736 const Eina_List *l = items;
1738 /* Recovery last focused sub item */
1739 if (elm_widget_focus_get(obj))
1740 for (; l; l = list_next(l))
1742 Evas_Object *cur = list_data_get(l);
1743 if (elm_widget_focus_get(cur)) break;
1746 const Eina_List *start = l;
1747 Evas_Object *to_focus = NULL;
1749 /* Interate sub items */
1750 /* Go to end of list */
1751 for (; l; l = list_next(l))
1753 Evas_Object *tmp = NULL;
1754 Evas_Object *cur = list_data_get(l);
1756 if (elm_widget_parent_get(cur) != obj)
1759 /* Try Focus cycle in subitem */
1760 if (elm_widget_focus_next_get(cur, dir, &tmp))
1765 else if ((tmp) && (!to_focus))
1771 /* Get First possible */
1772 for (; l != start; l = list_next(l))
1774 Evas_Object *tmp = NULL;
1775 Evas_Object *cur = list_data_get(l);
1777 if (elm_widget_parent_get(cur) != obj)
1780 /* Try Focus cycle in subitem */
1781 elm_widget_focus_next_get(cur, dir, &tmp);
1794 elm_widget_signal_emit(Evas_Object *obj,
1795 const char *emission,
1799 if (!sd->signal_func) return;
1800 sd->signal_func(obj, emission, source);
1804 _edje_signal_callback(void *data,
1805 Evas_Object *obj __UNUSED__,
1806 const char *emission,
1809 Edje_Signal_Data *esd = data;
1810 esd->func(esd->data, esd->obj, emission, source);
1814 elm_widget_signal_callback_add(Evas_Object *obj,
1815 const char *emission,
1817 Edje_Signal_Cb func,
1820 Edje_Signal_Data *esd;
1822 if (!sd->callback_add_func) return;
1823 EINA_SAFETY_ON_NULL_RETURN(func);
1825 esd = ELM_NEW(Edje_Signal_Data);
1830 esd->emission = eina_stringshare_add(emission);
1831 esd->source = eina_stringshare_add(source);
1833 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1834 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1838 elm_widget_signal_callback_del(Evas_Object *obj,
1839 const char *emission,
1841 Edje_Signal_Cb func)
1843 Edje_Signal_Data *esd;
1846 API_ENTRY return NULL;
1847 if (!sd->callback_del_func) return NULL;
1849 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1851 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1852 (!strcmp(esd->source, source)))
1854 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1855 eina_stringshare_del(esd->emission);
1856 eina_stringshare_del(esd->source);
1862 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1867 elm_widget_focus_set(Evas_Object *obj,
1874 sd->focus_order = focus_order;
1875 sd->focused = EINA_TRUE;
1876 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1880 sd->focus_func(obj);
1887 if ((_is_focusable(sd->resize_obj)) &&
1888 (!elm_widget_disabled_get(sd->resize_obj)))
1890 elm_widget_focus_set(sd->resize_obj, first);
1896 EINA_LIST_FOREACH(sd->subobjs, l, child)
1898 if ((_is_focusable(child)) &&
1899 (!elm_widget_disabled_get(child)))
1901 elm_widget_focus_set(child, first);
1911 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1913 if ((_is_focusable(child)) &&
1914 (!elm_widget_disabled_get(child)))
1916 elm_widget_focus_set(child, first);
1922 if ((_is_focusable(sd->resize_obj)) &&
1923 (!elm_widget_disabled_get(sd->resize_obj)))
1925 elm_widget_focus_set(sd->resize_obj, first);
1933 elm_widget_parent_get(const Evas_Object *obj)
1935 API_ENTRY return NULL;
1936 return sd->parent_obj;
1940 elm_widget_focused_object_clear(Evas_Object *obj)
1943 if (!sd->focused) return;
1944 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
1945 elm_widget_focused_object_clear(sd->resize_obj);
1950 EINA_LIST_FOREACH(sd->subobjs, l, child)
1952 if (elm_widget_focus_get(child))
1954 elm_widget_focused_object_clear(child);
1959 sd->focused = EINA_FALSE;
1960 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1961 if (sd->focus_func) sd->focus_func(obj);
1965 elm_widget_focus_steal(Evas_Object *obj)
1967 Evas_Object *parent, *parent2, *o;
1970 if (sd->focused) return;
1971 if (sd->disabled) return;
1972 if (!sd->can_focus) return;
1973 if (sd->tree_unfocusable) return;
1977 o = elm_widget_parent_get(parent);
1979 sd = evas_object_smart_data_get(o);
1980 if (sd->disabled || sd->tree_unfocusable) return;
1981 if (sd->focused) break;
1984 if ((!elm_widget_parent_get(parent)) &&
1985 (!elm_widget_parent2_get(parent)))
1986 elm_widget_focused_object_clear(parent);
1989 parent2 = elm_widget_parent_get(parent);
1990 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1992 sd = evas_object_smart_data_get(parent);
1995 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1996 elm_widget_focused_object_clear(sd->resize_obj);
2001 EINA_LIST_FOREACH(sd->subobjs, l, child)
2003 if (elm_widget_focus_get(child))
2005 elm_widget_focused_object_clear(child);
2017 elm_widget_focus_restore(Evas_Object *obj)
2019 Evas_Object *newest = NULL;
2020 unsigned int newest_focus_order = 0;
2023 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2026 elm_object_focus_set(newest, EINA_FALSE);
2027 elm_object_focus_set(newest, EINA_TRUE);
2032 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
2038 if (sd->top_win_focused == top_win_focused) return;
2040 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2041 EINA_LIST_FOREACH(sd->subobjs, l, child)
2043 _elm_widget_top_win_focused_set(child, top_win_focused);
2045 sd->top_win_focused = top_win_focused;
2049 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2051 API_ENTRY return EINA_FALSE;
2052 return sd->top_win_focused;
2056 elm_widget_activate(Evas_Object *obj)
2059 elm_widget_change(obj);
2060 if (sd->activate_func) sd->activate_func(obj);
2064 elm_widget_change(Evas_Object *obj)
2067 elm_widget_change(elm_widget_parent_get(obj));
2068 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2072 elm_widget_disabled_set(Evas_Object *obj,
2077 if (sd->disabled == disabled) return;
2078 sd->disabled = !!disabled;
2079 elm_widget_focus_disabled_handle(obj);
2080 if (sd->disable_func) sd->disable_func(obj);
2084 elm_widget_disabled_get(const Evas_Object *obj)
2087 return sd->disabled;
2091 elm_widget_show_region_set(Evas_Object *obj,
2096 Eina_Bool forceshow)
2098 Evas_Object *parent_obj, *child_obj;
2099 Evas_Coord px, py, cx, cy;
2101 evas_smart_objects_calculate(evas_object_evas_get(obj));
2104 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2105 && (w == sd->rw) && (h == sd->rh)) return;
2110 if (sd->on_show_region_func)
2111 sd->on_show_region_func(sd->on_show_region_data, obj);
2115 parent_obj = sd->parent_obj;
2116 child_obj = sd->obj;
2117 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2118 sd = evas_object_smart_data_get(parent_obj);
2121 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2122 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2131 if (sd->on_show_region_func)
2133 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2140 elm_widget_show_region_get(const Evas_Object *obj,
2156 * Get the focus region of the given widget.
2158 * The focus region is the area of a widget that should brought into the
2159 * visible area when the widget is focused. Mostly used to show the part of
2160 * an entry where the cursor is, for example. The area returned is relative
2161 * to the object @p obj.
2162 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2163 * function will return the full size of the object.
2165 * @param obj The widget object
2166 * @param x Where to store the x coordinate of the area
2167 * @param y Where to store the y coordinate of the area
2168 * @param w Where to store the width of the area
2169 * @param h Where to store the height of the area
2174 elm_widget_focus_region_get(const Evas_Object *obj,
2184 sd = evas_object_smart_data_get(obj);
2185 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2187 evas_object_geometry_get(obj, NULL, NULL, w, h);
2192 sd->on_focus_region_func(obj, x, y, w, h);
2196 elm_widget_scroll_hold_push(Evas_Object *obj)
2200 if (sd->scroll_hold == 1)
2201 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2202 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2203 // FIXME: on delete/reparent hold pop
2207 elm_widget_scroll_hold_pop(Evas_Object *obj)
2211 if (!sd->scroll_hold)
2212 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2213 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2214 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2218 elm_widget_scroll_hold_get(const Evas_Object *obj)
2221 return sd->scroll_hold;
2225 elm_widget_scroll_freeze_push(Evas_Object *obj)
2228 sd->scroll_freeze++;
2229 if (sd->scroll_freeze == 1)
2230 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2231 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2232 // FIXME: on delete/reparent freeze pop
2236 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2239 sd->scroll_freeze--;
2240 if (!sd->scroll_freeze)
2241 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2242 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2243 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2247 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2250 return sd->scroll_freeze;
2254 elm_widget_scale_set(Evas_Object *obj,
2258 if (scale <= 0.0) scale = 0.0;
2259 if (sd->scale != scale)
2262 elm_widget_theme(obj);
2267 elm_widget_scale_get(const Evas_Object *obj)
2269 API_ENTRY return 1.0;
2270 // FIXME: save walking up the tree by storing/caching parent scale
2271 if (sd->scale == 0.0)
2274 return elm_widget_scale_get(sd->parent_obj);
2282 elm_widget_theme_set(Evas_Object *obj,
2286 if (sd->theme != th)
2288 if (sd->theme) elm_theme_free(sd->theme);
2291 elm_widget_theme(obj);
2296 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2300 if (!sd->text_set_func)
2303 sd->text_set_func(obj, part, label);
2307 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2309 API_ENTRY return NULL;
2311 if (!sd->text_get_func)
2314 return sd->text_get_func(obj, part);
2318 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2322 Elm_Translate_String_Data *ts = NULL;
2325 str = eina_stringshare_add(part);
2326 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2333 eina_stringshare_del(str);
2336 ts = malloc(sizeof(Elm_Translate_String_Data));
2340 ts->domain = eina_stringshare_add(domain);
2341 ts->string = eina_stringshare_add(label);
2342 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2348 eina_stringshare_replace(&ts->domain, domain);
2349 eina_stringshare_replace(&ts->string, label);
2353 sd->translate_strings = eina_list_remove_list(
2354 sd->translate_strings, l);
2355 eina_stringshare_del(ts->id);
2356 eina_stringshare_del(ts->domain);
2357 eina_stringshare_del(ts->string);
2360 eina_stringshare_del(str);
2364 if (label && label[0])
2365 label = dgettext(domain, label);
2367 elm_widget_text_part_set(obj, part, label);
2371 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2373 const char *str, *ret = NULL;
2375 Elm_Translate_String_Data *ts;
2376 API_ENTRY return NULL;
2378 str = eina_stringshare_add(part);
2379 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2385 eina_stringshare_del(str);
2390 elm_widget_translate(Evas_Object *obj)
2395 Elm_Translate_String_Data *ts;
2399 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2400 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2401 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2402 if (sd->translate_func) sd->translate_func(obj);
2405 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2407 const char *s = dgettext(ts->domain, ts->string);
2408 elm_widget_text_part_set(obj, ts->id, s);
2414 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2418 if (!sd->content_set_func) return;
2419 sd->content_set_func(obj, part, content);
2423 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2425 API_ENTRY return NULL;
2427 if (!sd->content_get_func) return NULL;
2428 return sd->content_get_func(obj, part);
2432 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2434 API_ENTRY return NULL;
2436 if (!sd->content_unset_func) return NULL;
2437 return sd->content_unset_func(obj, part);
2441 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2444 if (sd->access_info) eina_stringshare_del(sd->access_info);
2445 if (!txt) sd->access_info = NULL;
2446 else sd->access_info = eina_stringshare_add(txt);
2450 elm_widget_access_info_get(Evas_Object *obj)
2452 API_ENTRY return NULL;
2453 return sd->access_info;
2457 elm_widget_theme_get(const Evas_Object *obj)
2459 API_ENTRY return NULL;
2463 return elm_widget_theme_get(sd->parent_obj);
2471 elm_widget_style_set(Evas_Object *obj,
2476 if (eina_stringshare_replace(&sd->style, style))
2477 elm_widget_theme(obj);
2481 elm_widget_style_get(const Evas_Object *obj)
2483 API_ENTRY return NULL;
2484 if (sd->style) return sd->style;
2489 elm_widget_type_set(Evas_Object *obj,
2493 eina_stringshare_replace(&sd->type, type);
2497 elm_widget_type_get(const Evas_Object *obj)
2499 API_ENTRY return NULL;
2500 if (sd->type) return sd->type;
2505 elm_widget_tooltip_add(Evas_Object *obj,
2509 sd->tooltips = eina_list_append(sd->tooltips, tt);
2513 elm_widget_tooltip_del(Evas_Object *obj,
2517 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2521 elm_widget_cursor_add(Evas_Object *obj,
2525 sd->cursors = eina_list_append(sd->cursors, cur);
2529 elm_widget_cursor_del(Evas_Object *obj,
2533 sd->cursors = eina_list_remove(sd->cursors, cur);
2537 elm_widget_drag_lock_x_set(Evas_Object *obj,
2541 if (sd->drag_x_locked == lock) return;
2542 sd->drag_x_locked = lock;
2543 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2544 else _propagate_x_drag_lock(obj, -1);
2548 elm_widget_drag_lock_y_set(Evas_Object *obj,
2552 if (sd->drag_y_locked == lock) return;
2553 sd->drag_y_locked = lock;
2554 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2555 else _propagate_y_drag_lock(obj, -1);
2559 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2561 API_ENTRY return EINA_FALSE;
2562 return sd->drag_x_locked;
2566 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2568 API_ENTRY return EINA_FALSE;
2569 return sd->drag_y_locked;
2573 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2576 return sd->child_drag_x_locked;
2580 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2583 return sd->child_drag_y_locked;
2587 elm_widget_theme_object_set(Evas_Object *obj,
2590 const char *welement,
2593 API_ENTRY return EINA_FALSE;
2594 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2598 elm_widget_is_check(const Evas_Object *obj)
2600 static int abort_on_warn = -1;
2601 if (elm_widget_is(obj))
2604 ERR("Passing Object: %p.", obj);
2605 if (abort_on_warn == -1)
2607 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2608 else abort_on_warn = 0;
2610 if (abort_on_warn == 1) abort();
2615 elm_widget_type_check(const Evas_Object *obj,
2619 const char *provided, *expected = "(unknown)";
2620 static int abort_on_warn = -1;
2621 provided = elm_widget_type_get(obj);
2622 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2623 if (type) expected = type;
2624 if ((!provided) || (!provided[0]))
2626 provided = evas_object_type_get(obj);
2627 if ((!provided) || (!provided[0]))
2628 provided = "(unknown)";
2630 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2631 if (abort_on_warn == -1)
2633 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2634 else abort_on_warn = 0;
2636 if (abort_on_warn == 1) abort();
2641 elm_widget_item_type_check(const Evas_Object *obj,
2645 const char *provided, *expected = "(unknown)";
2646 static int abort_on_warn = -1;
2647 provided = elm_widget_type_get(obj);
2648 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2649 if (type) expected = type;
2650 if ((!provided) || (!provided[0]))
2652 provided = evas_object_type_get(obj);
2653 if ((!provided) || (!provided[0]))
2654 provided = "(unknown)";
2656 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2657 if (abort_on_warn == -1)
2659 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2660 else abort_on_warn = 0;
2662 if (abort_on_warn == 1) abort();
2666 static Evas_Object *
2667 _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2672 INTERNAL_ENTRY NULL;
2674 if (!_elm_widget_is(obj)) return NULL;
2677 s = evas_object_name_get(sd->resize_obj);
2678 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
2679 if ((recurse != 0) &&
2680 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
2683 EINA_LIST_FOREACH(sd->subobjs, l, child)
2685 s = evas_object_name_get(child);
2686 if ((s) && (!strcmp(s, name))) return child;
2687 if ((recurse != 0) &&
2688 ((child = _widget_name_find(child, name, recurse - 1))))
2693 s = evas_object_name_get(sd->hover_obj);
2694 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
2695 if ((recurse != 0) &&
2696 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
2703 elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2705 API_ENTRY return NULL;
2706 if (!name) return NULL;
2707 return _widget_name_find(obj, name, recurse);
2713 * Split string in words
2715 * @param str Source string
2716 * @return List of const words
2718 * @see elm_widget_stringlist_free()
2722 elm_widget_stringlist_get(const char *str)
2724 Eina_List *list = NULL;
2726 if (!str) return NULL;
2727 for (b = s = str; 1; s++)
2729 if ((*s == ' ') || (!*s))
2731 char *t = malloc(s - b + 1);
2734 strncpy(t, b, s - b);
2736 list = eina_list_append(list, eina_stringshare_add(t));
2747 elm_widget_stringlist_free(Eina_List *list)
2750 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2754 elm_widget_focus_hide_handle(Evas_Object *obj)
2756 _if_focused_revert(obj, EINA_TRUE);
2760 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2762 Evas_Object *o = obj;
2765 if (_elm_widget_is(o)) break;
2766 o = evas_object_smart_parent_get(o);
2770 if (!_is_focusable(o)) return;
2771 elm_widget_focus_steal(o);
2775 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2779 if (!elm_widget_parent_get(obj))
2780 elm_widget_focused_object_clear(obj);
2782 _if_focused_revert(obj, EINA_TRUE);
2786 elm_widget_focus_disabled_handle(Evas_Object *obj)
2790 elm_widget_focus_tree_unfocusable_handle(obj);
2796 * Allocate a new Elm_Widget_Item-derived structure.
2798 * The goal of this structure is to provide common ground for actions
2799 * that a widget item have, such as the owner widget, callback to
2800 * notify deletion, data pointer and maybe more.
2802 * @param widget the owner widget that holds this item, must be an elm_widget!
2803 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2804 * be used to allocate memory.
2806 * @return allocated memory that is already zeroed out, or NULL on errors.
2808 * @see elm_widget_item_new() convenience macro.
2809 * @see elm_widget_item_del() to release memory.
2812 EAPI Elm_Widget_Item *
2813 _elm_widget_item_new(Evas_Object *widget,
2816 if (!_elm_widget_is(widget))
2819 Elm_Widget_Item *item;
2821 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2822 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2824 item = calloc(1, alloc_size);
2825 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2827 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2828 item->widget = widget;
2833 _elm_widget_item_free(Elm_Widget_Item *item)
2835 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2838 item->del_func((void *)item->data, item->widget, item);
2841 evas_object_del(item->view);
2845 _elm_access_clear(item->access);
2849 if (item->access_info)
2850 eina_stringshare_del(item->access_info);
2852 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2859 * Releases widget item memory, calling back del_cb() if it exists.
2861 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2862 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2863 * this function and then unset it, thus being useful for 2 step
2864 * cleanup whenever the del_cb may use any of the data that must be
2865 * deleted from item.
2867 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2870 * @param item a valid #Elm_Widget_Item to be deleted.
2871 * @see elm_widget_item_del() convenience macro.
2875 _elm_widget_item_del(Elm_Widget_Item *item)
2877 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2879 //Widget item delete callback
2880 if (item->del_pre_func)
2882 if (item->del_pre_func((Elm_Object_Item *) item))
2883 _elm_widget_item_free(item);
2890 * Set the function to notify to widgets when item is being deleted by user.
2892 * @param item a valid #Elm_Widget_Item to be notified
2893 * @see elm_widget_item_del_pre_hook_set() convenience macro.
2897 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func)
2899 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2900 item->del_pre_func = func;
2906 * Notify object will be deleted without actually deleting it.
2908 * This function will callback Elm_Widget_Item::del_cb if it is set
2909 * and then unset it so it is not called twice (ie: from
2910 * elm_widget_item_del()).
2912 * @param item a valid #Elm_Widget_Item to be notified
2913 * @see elm_widget_item_pre_notify_del() convenience macro.
2917 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2919 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2920 if (!item->del_func) return;
2921 item->del_func((void *)item->data, item->widget, item);
2922 item->del_func = NULL;
2928 * Set the function to notify when item is being deleted.
2930 * This function will complain if there was a callback set already,
2931 * however it will set the new one.
2933 * The callback will be called from elm_widget_item_pre_notify_del()
2934 * or elm_widget_item_del() will be called with:
2935 * - data: the Elm_Widget_Item::data value.
2936 * - obj: the Elm_Widget_Item::widget evas object.
2937 * - event_info: the item being deleted.
2939 * @param item a valid #Elm_Widget_Item to be notified
2940 * @see elm_widget_item_del_cb_set() convenience macro.
2944 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2947 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2949 if ((item->del_func) && (item->del_func != func))
2950 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2951 item->del_func, item, func);
2953 item->del_func = func;
2959 * Set user-data in this item.
2961 * User data may be used to identify this item or just store any
2962 * application data. It is automatically given as the first parameter
2963 * of the deletion notify callback.
2965 * @param item a valid #Elm_Widget_Item to store data in.
2966 * @param data user data to store.
2967 * @see elm_widget_item_del_cb_set() convenience macro.
2971 _elm_widget_item_data_set(Elm_Widget_Item *item,
2974 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2975 if ((item->data) && (item->data != data))
2976 DBG("Replacing item %p data %p with %p", item, item->data, data);
2983 * Retrieves user-data of this item.
2985 * @param item a valid #Elm_Widget_Item to get data from.
2986 * @see elm_widget_item_data_set()
2990 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2992 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2993 return (void *)item->data;
2997 _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
2999 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3001 if (item->disabled == disabled) return;
3002 item->disabled = !!disabled;
3003 if (item->disable_func) item->disable_func(item);
3007 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3009 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3010 return item->disabled;
3014 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3015 Elm_Widget_Disable_Cb func)
3017 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3018 item->disable_func = func;
3021 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3023 struct _Elm_Widget_Item_Tooltip
3025 Elm_Widget_Item *item;
3026 Elm_Tooltip_Item_Content_Cb func;
3027 Evas_Smart_Cb del_cb;
3031 static Evas_Object *
3032 _elm_widget_item_tooltip_label_create(void *data,
3033 Evas_Object *obj __UNUSED__,
3034 Evas_Object *tooltip,
3035 void *item __UNUSED__)
3037 Evas_Object *label = elm_label_add(tooltip);
3040 elm_object_style_set(label, "tooltip");
3041 elm_object_text_set(label, data);
3045 static Evas_Object *
3046 _elm_widget_item_tooltip_trans_label_create(void *data,
3047 Evas_Object *obj __UNUSED__,
3048 Evas_Object *tooltip,
3049 void *item __UNUSED__)
3051 Evas_Object *label = elm_label_add(tooltip);
3054 elm_object_style_set(label, "tooltip");
3055 elm_object_translatable_text_set(label, data);
3060 _elm_widget_item_tooltip_label_del_cb(void *data,
3061 Evas_Object *obj __UNUSED__,
3062 void *event_info __UNUSED__)
3064 eina_stringshare_del(data);
3070 * Set the text to be shown in the widget item.
3072 * @param item Target item
3073 * @param text The text to set in the content
3075 * Setup the text as tooltip to object. The item can have only one tooltip,
3076 * so any previous tooltip data is removed.
3081 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3084 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3085 EINA_SAFETY_ON_NULL_RETURN(text);
3087 text = eina_stringshare_add(text);
3088 _elm_widget_item_tooltip_content_cb_set
3089 (item, _elm_widget_item_tooltip_label_create, text,
3090 _elm_widget_item_tooltip_label_del_cb);
3094 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3097 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3098 EINA_SAFETY_ON_NULL_RETURN(text);
3100 text = eina_stringshare_add(text);
3101 _elm_widget_item_tooltip_content_cb_set
3102 (item, _elm_widget_item_tooltip_trans_label_create, text,
3103 _elm_widget_item_tooltip_label_del_cb);
3106 static Evas_Object *
3107 _elm_widget_item_tooltip_create(void *data,
3109 Evas_Object *tooltip)
3111 Elm_Widget_Item_Tooltip *wit = data;
3112 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3116 _elm_widget_item_tooltip_del_cb(void *data,
3118 void *event_info __UNUSED__)
3120 Elm_Widget_Item_Tooltip *wit = data;
3121 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3128 * Set the content to be shown in the tooltip item
3130 * Setup the tooltip to item. The item can have only one tooltip,
3131 * so any previous tooltip data is removed. @p func(with @p data) will
3132 * be called every time that need show the tooltip and it should
3133 * return a valid Evas_Object. This object is then managed fully by
3134 * tooltip system and is deleted when the tooltip is gone.
3136 * @param item the widget item being attached a tooltip.
3137 * @param func the function used to create the tooltip contents.
3138 * @param data what to provide to @a func as callback data/context.
3139 * @param del_cb called when data is not needed anymore, either when
3140 * another callback replaces @func, the tooltip is unset with
3141 * elm_widget_item_tooltip_unset() or the owner @a item
3142 * dies. This callback receives as the first parameter the
3143 * given @a data, and @c event_info is the item.
3148 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3149 Elm_Tooltip_Item_Content_Cb func,
3151 Evas_Smart_Cb del_cb)
3153 Elm_Widget_Item_Tooltip *wit;
3155 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3159 _elm_widget_item_tooltip_unset(item);
3163 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3164 if (!wit) goto error;
3168 wit->del_cb = del_cb;
3170 elm_object_sub_tooltip_content_cb_set
3171 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3172 _elm_widget_item_tooltip_del_cb);
3177 if (del_cb) del_cb((void *)data, NULL, item);
3180 if (del_cb) del_cb((void *)data, item->widget, item);
3186 * Unset tooltip from item
3188 * @param item widget item to remove previously set tooltip.
3190 * Remove tooltip from item. The callback provided as del_cb to
3191 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3192 * it is not used anymore.
3194 * @see elm_widget_item_tooltip_content_cb_set()
3199 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3201 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3202 elm_object_tooltip_unset(item->view);
3208 * Sets a different style for this item tooltip.
3210 * @note before you set a style you should define a tooltip with
3211 * elm_widget_item_tooltip_content_cb_set() or
3212 * elm_widget_item_tooltip_text_set()
3214 * @param item widget item with tooltip already set.
3215 * @param style the theme style to use (default, transparent, ...)
3220 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3223 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3224 elm_object_tooltip_style_set(item->view, style);
3228 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
3230 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3231 return elm_object_tooltip_window_mode_set(item->view, disable);
3235 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
3237 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3238 return elm_object_tooltip_window_mode_get(item->view);
3244 * Get the style for this item tooltip.
3246 * @param item widget item with tooltip already set.
3247 * @return style the theme style in use, defaults to "default". If the
3248 * object does not have a tooltip set, then NULL is returned.
3253 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3255 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3256 return elm_object_tooltip_style_get(item->view);
3260 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3263 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3264 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3268 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3270 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3271 return elm_object_cursor_get(item->view);
3275 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3277 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3278 elm_object_cursor_unset(item->view);
3284 * Sets a different style for this item cursor.
3286 * @note before you set a style you should define a cursor with
3287 * elm_widget_item_cursor_set()
3289 * @param item widget item with cursor already set.
3290 * @param style the theme style to use (default, transparent, ...)
3295 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3298 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3299 elm_object_cursor_style_set(item->view, style);
3305 * Get the style for this item cursor.
3307 * @param item widget item with cursor already set.
3308 * @return style the theme style in use, defaults to "default". If the
3309 * object does not have a cursor set, then NULL is returned.
3314 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3316 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3317 return elm_object_cursor_style_get(item->view);
3323 * Set if the cursor set should be searched on the theme or should use
3324 * the provided by the engine, only.
3326 * @note before you set if should look on theme you should define a cursor
3327 * with elm_object_cursor_set(). By default it will only look for cursors
3328 * provided by the engine.
3330 * @param item widget item with cursor already set.
3331 * @param engine_only boolean to define it cursors should be looked only
3332 * between the provided by the engine or searched on widget's theme as well.
3337 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3338 Eina_Bool engine_only)
3340 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3341 elm_object_cursor_engine_only_set(item->view, engine_only);
3347 * Get the cursor engine only usage for this item cursor.
3349 * @param item widget item with cursor already set.
3350 * @return engine_only boolean to define it cursors should be looked only
3351 * between the provided by the engine or searched on widget's theme as well. If
3352 * the object does not have a cursor set, then EINA_FALSE is returned.
3357 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3359 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3360 return elm_object_cursor_engine_only_get(item->view);
3363 // smart object funcs
3365 _smart_reconfigure(Smart_Data *sd)
3369 evas_object_move(sd->resize_obj, sd->x, sd->y);
3370 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3374 evas_object_move(sd->hover_obj, sd->x, sd->y);
3375 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3380 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3382 Evas_Object *content)
3384 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3385 if (!item->content_set_func) return;
3386 item->content_set_func((Elm_Object_Item *) item, part, content);
3390 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3393 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3394 if (!item->content_get_func) return NULL;
3395 return item->content_get_func((Elm_Object_Item *) item, part);
3399 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3402 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3403 if (!item->content_unset_func) return NULL;
3404 return item->content_unset_func((Elm_Object_Item *) item, part);
3408 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3412 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3413 if (!item->text_set_func) return;
3414 item->text_set_func((Elm_Object_Item *) item, part, label);
3418 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3419 const char *emission,
3422 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3423 if (item->signal_emit_func)
3424 item->signal_emit_func((Elm_Object_Item *) item, emission, source);
3428 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3431 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3432 if (!item->text_get_func) return NULL;
3433 return item->text_get_func((Elm_Object_Item *) item, part);
3437 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3438 Elm_Widget_Content_Set_Cb func)
3440 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3441 item->content_set_func = func;
3445 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3446 Elm_Widget_Content_Get_Cb func)
3448 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3449 item->content_get_func = func;
3453 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3454 Elm_Widget_Content_Unset_Cb func)
3456 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3457 item->content_unset_func = func;
3461 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3462 Elm_Widget_Text_Set_Cb func)
3464 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3465 item->text_set_func = func;
3469 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3470 Elm_Widget_Text_Get_Cb func)
3472 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3473 item->text_get_func = func;
3477 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3478 Elm_Widget_Signal_Emit_Cb func)
3480 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3481 item->signal_emit_func = func;
3485 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3487 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3488 if (item->access_info) eina_stringshare_del(item->access_info);
3489 if (!txt) item->access_info = NULL;
3490 else item->access_info = eina_stringshare_add(txt);
3495 _smart_add(Evas_Object *obj)
3499 sd = calloc(1, sizeof(Smart_Data));
3502 sd->x = sd->y = sd->w = sd->h = 0;
3504 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3505 evas_object_smart_data_set(obj, sd);
3508 static Evas_Object *
3509 _newest_focus_order_get(Evas_Object *obj,
3510 unsigned int *newest_focus_order,
3511 Eina_Bool can_focus_only)
3514 Evas_Object *child, *ret, *best;
3516 API_ENTRY return NULL;
3518 if (!evas_object_visible_get(obj)
3519 || (elm_widget_disabled_get(obj))
3520 || (elm_widget_tree_unfocusable_get(obj)))
3524 if (*newest_focus_order < sd->focus_order)
3526 *newest_focus_order = sd->focus_order;
3529 EINA_LIST_FOREACH(sd->subobjs, l, child)
3531 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3537 if ((!best) || (!elm_widget_can_focus_get(best)))
3544 _if_focused_revert(Evas_Object *obj,
3545 Eina_Bool can_focus_only)
3548 Evas_Object *newest = NULL;
3549 unsigned int newest_focus_order = 0;
3553 if (!sd->focused) return;
3554 if (!sd->parent_obj) return;
3556 top = elm_widget_top_get(sd->parent_obj);
3559 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3562 elm_object_focus_set(newest, EINA_FALSE);
3563 elm_object_focus_set(newest, EINA_TRUE);
3569 _smart_del(Evas_Object *obj)
3572 Edje_Signal_Data *esd;
3573 Elm_Translate_String_Data *ts;
3577 if (sd->del_pre_func) sd->del_pre_func(obj);
3580 sobj = sd->resize_obj;
3581 sd->resize_obj = NULL;
3582 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3583 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3584 evas_object_del(sobj);
3585 sd->resize_obj = NULL;
3589 sobj = sd->hover_obj;
3590 sd->hover_obj = NULL;
3591 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3592 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3593 evas_object_del(sobj);
3594 sd->hover_obj = NULL;
3596 EINA_LIST_FREE(sd->subobjs, sobj)
3598 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3599 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3600 evas_object_del(sobj);
3602 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3603 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3604 EINA_LIST_FREE(sd->edje_signals, esd)
3606 eina_stringshare_del(esd->emission);
3607 eina_stringshare_del(esd->source);
3610 EINA_LIST_FREE(sd->translate_strings, ts)
3612 eina_stringshare_del(ts->id);
3613 eina_stringshare_del(ts->domain);
3614 eina_stringshare_del(ts->string);
3617 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3618 if (sd->del_func) sd->del_func(obj);
3619 if (sd->style) eina_stringshare_del(sd->style);
3620 if (sd->type) eina_stringshare_del(sd->type);
3621 if (sd->theme) elm_theme_free(sd->theme);
3623 _if_focused_revert(obj, EINA_TRUE);
3624 if (sd->access_info) eina_stringshare_del(sd->access_info);
3626 evas_object_smart_data_set(obj, NULL);
3630 _smart_move(Evas_Object *obj,
3637 _smart_reconfigure(sd);
3641 _smart_resize(Evas_Object *obj,
3648 _smart_reconfigure(sd);
3652 _smart_show(Evas_Object *obj)
3657 if ((list = evas_object_smart_members_get(obj)))
3659 EINA_LIST_FREE(list, o)
3661 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3662 evas_object_show(o);
3668 _smart_hide(Evas_Object *obj)
3674 list = evas_object_smart_members_get(obj);
3675 EINA_LIST_FREE(list, o)
3677 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3678 evas_object_hide(o);
3683 _smart_color_set(Evas_Object *obj,
3692 if ((list = evas_object_smart_members_get(obj)))
3694 EINA_LIST_FREE(list, o)
3696 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3697 evas_object_color_set(o, r, g, b, a);
3703 _smart_clip_set(Evas_Object *obj,
3709 if ((list = evas_object_smart_members_get(obj)))
3711 EINA_LIST_FREE(list, o)
3713 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3714 evas_object_clip_set(o, clip);
3720 _smart_clip_unset(Evas_Object *obj)
3725 if ((list = evas_object_smart_members_get(obj)))
3727 EINA_LIST_FREE(list, o)
3729 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3730 evas_object_clip_unset(o);
3736 _smart_calculate(Evas_Object *obj)
3739 if (sd->changed_func) sd->changed_func(obj);
3742 /* never need to touch this */
3746 if (_e_smart) return;
3748 static const Evas_Smart_Class sc =
3751 EVAS_SMART_CLASS_VERSION,
3769 _e_smart = evas_smart_class_new(&sc);
3773 /* happy debug functions */
3776 _sub_obj_tree_dump(const Evas_Object *obj,
3781 for (i = 0; i < lvl * 3; i++)
3784 if (_elm_widget_is(obj))
3788 printf("+ %s(%p)\n",
3792 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3793 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3795 if (obj != sd->resize_obj)
3796 _sub_obj_tree_dump(obj, lvl + 1);
3800 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3804 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3807 if (!_elm_widget_is(obj))
3811 Eina_Bool visible = evas_object_visible_get(obj);
3812 Eina_Bool disabled = elm_widget_disabled_get(obj);
3813 Eina_Bool focused = elm_widget_focus_get(obj);
3814 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3818 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3821 fprintf(output, ", style=bold");
3824 fprintf(output, ", color=gray28");
3826 fprintf(output, " ];\n");
3829 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3830 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3831 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3835 fprintf(output, ", style=bold");
3838 fprintf(output, ", fontcolor=gray28");
3840 if ((disabled) || (!visible))
3841 fprintf(output, ", color=gray");
3843 fprintf(output, " ];\n");
3847 EINA_LIST_FOREACH(sd->subobjs, l, o)
3848 _sub_obj_tree_dot_dump(o, output);
3853 elm_widget_tree_dump(const Evas_Object *top)
3856 _sub_obj_tree_dump(top, 0);
3864 elm_widget_tree_dot_dump(const Evas_Object *top,
3868 if (!_elm_widget_is(top))
3870 fprintf(output, "graph " " { node [shape=record];\n");
3871 _sub_obj_tree_dot_dump(top, output);
3872 fprintf(output, "}\n");