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 (sobj == sd->parent_obj)
925 elm_widget_sub_object_del(sobj, obj);
926 WRN("You passed a parent object of obj = %p as the sub object = %p!", obj, sobj);
929 if (_elm_widget_is(sobj))
931 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
934 if (sd2->parent_obj == obj)
937 elm_widget_sub_object_del(sd2->parent_obj, sobj);
938 sd2->parent_obj = obj;
939 sd2->top_win_focused = sd->top_win_focused;
940 if (!sd->child_can_focus && (_is_focusable(sobj)))
941 sd->child_can_focus = EINA_TRUE;
946 void *data = evas_object_data_get(sobj, "elm-parent");
949 if (data == obj) return;
950 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
954 sd->subobjs = eina_list_append(sd->subobjs, sobj);
955 evas_object_data_set(sobj, "elm-parent", obj);
956 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
957 if (_elm_widget_is(sobj))
958 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
959 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
960 scale = elm_widget_scale_get(sobj);
961 th = elm_widget_theme_get(sobj);
962 mirrored = elm_widget_mirrored_get(sobj);
963 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
964 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
968 elm_widget_sub_object_del(Evas_Object *obj,
971 Evas_Object *sobj_parent;
975 sobj_parent = evas_object_data_del(sobj, "elm-parent");
976 if (sobj_parent != obj)
978 static int abort_on_warn = -1;
979 ERR("removing sub object %p (%s) from parent %p (%s), "
980 "but elm-parent is different %p (%s)!",
981 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
982 sobj_parent, elm_widget_type_get(sobj_parent));
983 if (EINA_UNLIKELY(abort_on_warn == -1))
985 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
986 else abort_on_warn = 0;
988 if (abort_on_warn == 1) abort();
990 if (_elm_widget_is(sobj))
992 if (elm_widget_focus_get(sobj))
994 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
995 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
997 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1001 sd->child_can_focus = EINA_FALSE;
1002 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1004 if (_is_focusable(subobj))
1006 sd->child_can_focus = EINA_TRUE;
1011 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1014 sd2->parent_obj = NULL;
1015 if (sd2->resize_obj == sobj)
1016 sd2->resize_obj = NULL;
1018 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1021 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1024 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1025 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1027 if (_elm_widget_is(sobj))
1028 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1030 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1034 elm_widget_resize_object_set(Evas_Object *obj,
1038 // orphan previous resize obj
1041 evas_object_clip_unset(sd->resize_obj);
1042 evas_object_data_del(sd->resize_obj, "elm-parent");
1043 if (_elm_widget_is(sd->resize_obj))
1045 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1046 if (sd2) sd2->parent_obj = NULL;
1047 evas_object_event_callback_del_full(sd->resize_obj,
1051 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1053 evas_object_event_callback_del_full(sd->resize_obj,
1054 EVAS_CALLBACK_MOUSE_DOWN,
1055 _sub_obj_mouse_down, sd);
1056 evas_object_event_callback_del_full(sd->resize_obj,
1057 EVAS_CALLBACK_MOUSE_MOVE,
1058 _sub_obj_mouse_move, sd);
1059 evas_object_event_callback_del_full(sd->resize_obj,
1060 EVAS_CALLBACK_MOUSE_UP,
1061 _sub_obj_mouse_up, sd);
1062 evas_object_smart_member_del(sd->resize_obj);
1064 if (_elm_widget_is(sd->resize_obj))
1066 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1070 sd->resize_obj = sobj;
1073 // orphan new resize obj
1074 evas_object_data_del(sobj, "elm-parent");
1075 if (_elm_widget_is(sobj))
1077 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1078 if (sd2) sd2->parent_obj = NULL;
1079 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1082 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1084 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1085 _sub_obj_mouse_down, sd);
1086 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1087 _sub_obj_mouse_move, sd);
1088 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1089 _sub_obj_mouse_up, sd);
1090 evas_object_smart_member_del(sobj);
1091 if (_elm_widget_is(sobj))
1093 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1096 // set the resize obj up
1097 if (_elm_widget_is(sobj))
1099 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1102 sd2->parent_obj = obj;
1103 sd2->top_win_focused = sd->top_win_focused;
1105 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1108 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1109 evas_object_smart_member_add(sobj, obj);
1110 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1112 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1113 _sub_obj_mouse_down, sd);
1114 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1115 _sub_obj_mouse_move, sd);
1116 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1117 _sub_obj_mouse_up, sd);
1118 _smart_reconfigure(sd);
1119 evas_object_data_set(sobj, "elm-parent", obj);
1120 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1121 if (_elm_widget_is(sobj))
1123 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1128 elm_widget_hover_object_set(Evas_Object *obj,
1134 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1137 sd->hover_obj = sobj;
1140 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1142 _smart_reconfigure(sd);
1147 elm_widget_can_focus_set(Evas_Object *obj,
1148 Eina_Bool can_focus)
1151 sd->can_focus = can_focus;
1154 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1156 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1157 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1159 (void *)(long)EVAS_CALLBACK_KEY_UP);
1160 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1162 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1166 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1168 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1170 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1176 elm_widget_can_focus_get(const Evas_Object *obj)
1178 API_ENTRY return EINA_FALSE;
1179 return sd->can_focus;
1183 elm_widget_child_can_focus_get(const Evas_Object *obj)
1185 API_ENTRY return EINA_FALSE;
1186 return sd->child_can_focus;
1192 * This API makes the widget object and its children to be unfocusable.
1194 * This API can be helpful for an object to be deleted.
1195 * When an object will be deleted soon, it and its children may not
1196 * want to get focus (by focus reverting or by other focus controls).
1197 * Then, just use this API before deleting.
1199 * @param obj The widget root of sub-tree
1200 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1205 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1206 Eina_Bool tree_unfocusable)
1210 if (sd->tree_unfocusable == tree_unfocusable) return;
1211 sd->tree_unfocusable = !!tree_unfocusable;
1212 elm_widget_focus_tree_unfocusable_handle(obj);
1218 * This returns true, if the object sub-tree is unfocusable.
1220 * @param obj The widget root of sub-tree
1221 * @return EINA_TRUE if the object sub-tree is unfocusable
1226 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1228 API_ENTRY return EINA_FALSE;
1229 return sd->tree_unfocusable;
1235 * Get the list of focusable child objects.
1237 * This function retruns list of child objects which can get focus.
1239 * @param obj The parent widget
1240 * @retrun list of focusable child objects.
1245 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1247 API_ENTRY return NULL;
1250 Eina_List *child_list = NULL;
1255 EINA_LIST_FOREACH(sd->subobjs, l, child)
1257 if ((elm_widget_can_focus_get(child)) &&
1258 (evas_object_visible_get(child)) &&
1259 (!elm_widget_disabled_get(child)))
1260 child_list = eina_list_append(child_list, child);
1261 else if (elm_widget_is(child))
1263 Eina_List *can_focus_list;
1264 can_focus_list = elm_widget_can_focus_child_list_get(child);
1266 child_list = eina_list_merge(child_list, can_focus_list);
1274 elm_widget_highlight_ignore_set(Evas_Object *obj,
1278 sd->highlight_ignore = !!ignore;
1282 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1284 API_ENTRY return EINA_FALSE;
1285 return sd->highlight_ignore;
1289 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1290 Eina_Bool highlight)
1293 sd->highlight_in_theme = !!highlight;
1294 /* FIXME: if focused, it should switch from one mode to the other */
1298 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1300 API_ENTRY return EINA_FALSE;
1301 return sd->highlight_in_theme;
1305 elm_widget_focus_get(const Evas_Object *obj)
1307 API_ENTRY return EINA_FALSE;
1312 elm_widget_focused_object_get(const Evas_Object *obj)
1314 const Evas_Object *subobj;
1316 API_ENTRY return NULL;
1318 if (!sd->focused) return NULL;
1319 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1321 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1322 if (fobj) return fobj;
1324 return (Evas_Object *)obj;
1328 elm_widget_top_get(const Evas_Object *obj)
1330 API_ENTRY return NULL;
1331 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1332 return (Evas_Object *)obj;
1336 elm_widget_is(const Evas_Object *obj)
1338 return _elm_widget_is(obj);
1342 elm_widget_parent_widget_get(const Evas_Object *obj)
1344 Evas_Object *parent;
1346 if (_elm_widget_is(obj))
1348 Smart_Data *sd = evas_object_smart_data_get(obj);
1349 if (!sd) return NULL;
1350 parent = sd->parent_obj;
1354 parent = evas_object_data_get(obj, "elm-parent");
1355 if (!parent) parent = evas_object_smart_parent_get(obj);
1360 Evas_Object *elm_parent;
1361 if (_elm_widget_is(parent)) break;
1362 elm_parent = evas_object_data_get(parent, "elm-parent");
1363 if (elm_parent) parent = elm_parent;
1364 else parent = evas_object_smart_parent_get(parent);
1370 elm_widget_parent2_get(const Evas_Object *obj)
1372 if (_elm_widget_is(obj))
1374 Smart_Data *sd = evas_object_smart_data_get(obj);
1375 if (sd) return sd->parent2;
1381 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1384 sd->parent2 = parent;
1388 elm_widget_event_callback_add(Evas_Object *obj,
1393 EINA_SAFETY_ON_NULL_RETURN(func);
1394 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1397 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1401 elm_widget_event_callback_del(Evas_Object *obj,
1405 API_ENTRY return NULL;
1406 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1408 Elm_Event_Cb_Data *ecd;
1409 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1410 if ((ecd->func == func) && (ecd->data == data))
1413 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1414 return (void *)data;
1420 elm_widget_event_propagate(Evas_Object *obj,
1421 Evas_Callback_Type type,
1423 Evas_Event_Flags *event_flags)
1425 API_ENTRY return EINA_FALSE; //TODO reduce.
1426 if (!_elm_widget_is(obj)) return EINA_FALSE;
1427 Evas_Object *parent = obj;
1428 Elm_Event_Cb_Data *ecd;
1429 Eina_List *l, *l_prev;
1432 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1434 sd = evas_object_smart_data_get(parent);
1435 if ((!sd) || (!_elm_widget_is(obj)))
1436 return EINA_FALSE; //Not Elm Widget
1438 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1441 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1443 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1444 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1447 parent = sd->parent_obj;
1456 * Set custom focus chain.
1458 * This function i set one new and overwrite any previous custom focus chain
1459 * with the list of objects. The previous list will be deleted and this list
1460 * will be managed. After setted, don't modity it.
1462 * @note On focus cycle, only will be evaluated children of this container.
1464 * @param obj The container widget
1465 * @param objs Chain of objects to pass focus
1469 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1473 if (!sd->focus_next_func)
1476 elm_widget_focus_custom_chain_unset(obj);
1481 EINA_LIST_FOREACH(objs, l, o)
1483 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1484 _elm_object_focus_chain_del_cb, sd);
1487 sd->focus_chain = objs;
1493 * Get custom focus chain
1495 * @param obj The container widget
1498 EAPI const Eina_List *
1499 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1501 API_ENTRY return NULL;
1502 return (const Eina_List *)sd->focus_chain;
1508 * Unset custom focus chain
1510 * @param obj The container widget
1514 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1517 Eina_List *l, *l_next;
1520 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1522 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1523 _elm_object_focus_chain_del_cb, sd);
1524 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1531 * Append object to custom focus chain.
1533 * @note If relative_child equal to NULL or not in custom chain, the object
1534 * will be added in end.
1536 * @note On focus cycle, only will be evaluated children of this container.
1538 * @param obj The container widget
1539 * @param child The child to be added in custom chain
1540 * @param relative_child The relative object to position the child
1544 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1546 Evas_Object *relative_child)
1549 EINA_SAFETY_ON_NULL_RETURN(child);
1550 if (!sd->focus_next_func)
1553 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1554 _elm_object_focus_chain_del_cb, sd);
1556 if (!relative_child)
1558 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1562 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1569 * Prepend object to custom focus chain.
1571 * @note If relative_child equal to NULL or not in custom chain, the object
1572 * will be added in begin.
1574 * @note On focus cycle, only will be evaluated children of this container.
1576 * @param obj The container widget
1577 * @param child The child to be added in custom chain
1578 * @param relative_child The relative object to position the child
1582 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1584 Evas_Object *relative_child)
1587 EINA_SAFETY_ON_NULL_RETURN(child);
1588 if (!sd->focus_next_func)
1591 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1592 _elm_object_focus_chain_del_cb, sd);
1594 if (!relative_child)
1596 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1600 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1607 * Give focus to next object in object tree.
1609 * Give focus to next object in focus chain of one object sub-tree.
1610 * If the last object of chain already have focus, the focus will go to the
1611 * first object of chain.
1613 * @param obj The widget root of sub-tree
1614 * @param dir Direction to cycle the focus
1619 elm_widget_focus_cycle(Evas_Object *obj,
1620 Elm_Focus_Direction dir)
1622 Evas_Object *target = NULL;
1623 if (!_elm_widget_is(obj))
1625 elm_widget_focus_next_get(obj, dir, &target);
1627 elm_widget_focus_steal(target);
1633 * Give focus to near object in one direction.
1635 * Give focus to near object in direction of one object.
1636 * If none focusable object in given direction, the focus will not change.
1638 * @param obj The reference widget
1639 * @param x Horizontal component of direction to focus
1640 * @param y Vertical component of direction to focus
1645 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1655 * Get next object in focus chain of object tree.
1657 * Get next object in focus chain of one object sub-tree.
1658 * Return the next object by reference. If don't have any candidate to receive
1659 * focus before chain end, the first candidate will be returned.
1661 * @param obj The widget root of sub-tree
1662 * @param dir Direction os focus chain
1663 * @param next The next object in focus chain
1664 * @return EINA_TRUE if don't need focus chain restart/loop back
1665 * to use 'next' obj.
1670 elm_widget_focus_next_get(const Evas_Object *obj,
1671 Elm_Focus_Direction dir,
1678 API_ENTRY return EINA_FALSE;
1680 /* Ignore if disabled */
1681 if ((!evas_object_visible_get(obj))
1682 || (elm_widget_disabled_get(obj))
1683 || (elm_widget_tree_unfocusable_get(obj)))
1687 if (sd->focus_next_func)
1688 return sd->focus_next_func(obj, dir, next);
1690 if (!elm_widget_can_focus_get(obj))
1694 *next = (Evas_Object *)obj;
1695 return !elm_widget_focus_get(obj);
1701 * Get next object in focus chain of object tree in list.
1703 * Get next object in focus chain of one object sub-tree ordered by one list.
1704 * Return the next object by reference. If don't have any candidate to receive
1705 * focus before list end, the first candidate will be returned.
1707 * @param obj The widget root of sub-tree
1708 * @param dir Direction os focus chain
1709 * @param items list with ordered objects
1710 * @param list_data_get function to get the object from one item of list
1711 * @param next The next object in focus chain
1712 * @return EINA_TRUE if don't need focus chain restart/loop back
1713 * to use 'next' obj.
1718 elm_widget_focus_list_next_get(const Evas_Object *obj,
1719 const Eina_List *items,
1720 void *(*list_data_get)(const Eina_List * list),
1721 Elm_Focus_Direction dir,
1724 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1730 if (!_elm_widget_is(obj))
1737 if (dir == ELM_FOCUS_PREVIOUS)
1739 items = eina_list_last(items);
1740 list_next = eina_list_prev;
1742 else if (dir == ELM_FOCUS_NEXT)
1743 list_next = eina_list_next;
1747 const Eina_List *l = items;
1749 /* Recovery last focused sub item */
1750 if (elm_widget_focus_get(obj))
1751 for (; l; l = list_next(l))
1753 Evas_Object *cur = list_data_get(l);
1754 if (elm_widget_focus_get(cur)) break;
1757 const Eina_List *start = l;
1758 Evas_Object *to_focus = NULL;
1760 /* Interate sub items */
1761 /* Go to end of list */
1762 for (; l; l = list_next(l))
1764 Evas_Object *tmp = NULL;
1765 Evas_Object *cur = list_data_get(l);
1767 if (elm_widget_parent_get(cur) != obj)
1770 /* Try Focus cycle in subitem */
1771 if (elm_widget_focus_next_get(cur, dir, &tmp))
1776 else if ((tmp) && (!to_focus))
1782 /* Get First possible */
1783 for (; l != start; l = list_next(l))
1785 Evas_Object *tmp = NULL;
1786 Evas_Object *cur = list_data_get(l);
1788 if (elm_widget_parent_get(cur) != obj)
1791 /* Try Focus cycle in subitem */
1792 elm_widget_focus_next_get(cur, dir, &tmp);
1805 elm_widget_signal_emit(Evas_Object *obj,
1806 const char *emission,
1810 if (!sd->signal_func) return;
1811 sd->signal_func(obj, emission, source);
1815 _edje_signal_callback(void *data,
1816 Evas_Object *obj __UNUSED__,
1817 const char *emission,
1820 Edje_Signal_Data *esd = data;
1821 esd->func(esd->data, esd->obj, emission, source);
1825 elm_widget_signal_callback_add(Evas_Object *obj,
1826 const char *emission,
1828 Edje_Signal_Cb func,
1831 Edje_Signal_Data *esd;
1833 if (!sd->callback_add_func) return;
1834 EINA_SAFETY_ON_NULL_RETURN(func);
1836 esd = ELM_NEW(Edje_Signal_Data);
1841 esd->emission = eina_stringshare_add(emission);
1842 esd->source = eina_stringshare_add(source);
1844 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1845 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1849 elm_widget_signal_callback_del(Evas_Object *obj,
1850 const char *emission,
1852 Edje_Signal_Cb func)
1854 Edje_Signal_Data *esd;
1857 API_ENTRY return NULL;
1858 if (!sd->callback_del_func) return NULL;
1860 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1862 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1863 (!strcmp(esd->source, source)))
1865 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1866 eina_stringshare_del(esd->emission);
1867 eina_stringshare_del(esd->source);
1873 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1878 elm_widget_focus_set(Evas_Object *obj,
1885 sd->focus_order = focus_order;
1886 sd->focused = EINA_TRUE;
1887 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1891 sd->focus_func(obj);
1898 if ((_is_focusable(sd->resize_obj)) &&
1899 (!elm_widget_disabled_get(sd->resize_obj)))
1901 elm_widget_focus_set(sd->resize_obj, first);
1907 EINA_LIST_FOREACH(sd->subobjs, l, child)
1909 if ((_is_focusable(child)) &&
1910 (!elm_widget_disabled_get(child)))
1912 elm_widget_focus_set(child, first);
1922 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1924 if ((_is_focusable(child)) &&
1925 (!elm_widget_disabled_get(child)))
1927 elm_widget_focus_set(child, first);
1933 if ((_is_focusable(sd->resize_obj)) &&
1934 (!elm_widget_disabled_get(sd->resize_obj)))
1936 elm_widget_focus_set(sd->resize_obj, first);
1944 elm_widget_parent_get(const Evas_Object *obj)
1946 API_ENTRY return NULL;
1947 return sd->parent_obj;
1951 elm_widget_focused_object_clear(Evas_Object *obj)
1954 if (!sd->focused) return;
1955 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
1956 elm_widget_focused_object_clear(sd->resize_obj);
1961 EINA_LIST_FOREACH(sd->subobjs, l, child)
1963 if (elm_widget_focus_get(child))
1965 elm_widget_focused_object_clear(child);
1970 sd->focused = EINA_FALSE;
1971 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1972 if (sd->focus_func) sd->focus_func(obj);
1976 elm_widget_focus_steal(Evas_Object *obj)
1978 Evas_Object *parent, *parent2, *o;
1981 if (sd->focused) return;
1982 if (sd->disabled) return;
1983 if (!sd->can_focus) return;
1984 if (sd->tree_unfocusable) return;
1988 o = elm_widget_parent_get(parent);
1990 sd = evas_object_smart_data_get(o);
1991 if (sd->disabled || sd->tree_unfocusable) return;
1992 if (sd->focused) break;
1995 if ((!elm_widget_parent_get(parent)) &&
1996 (!elm_widget_parent2_get(parent)))
1997 elm_widget_focused_object_clear(parent);
2000 parent2 = elm_widget_parent_get(parent);
2001 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2003 sd = evas_object_smart_data_get(parent);
2006 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2007 elm_widget_focused_object_clear(sd->resize_obj);
2012 EINA_LIST_FOREACH(sd->subobjs, l, child)
2014 if (elm_widget_focus_get(child))
2016 elm_widget_focused_object_clear(child);
2028 elm_widget_focus_restore(Evas_Object *obj)
2030 Evas_Object *newest = NULL;
2031 unsigned int newest_focus_order = 0;
2034 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2037 elm_object_focus_set(newest, EINA_FALSE);
2038 elm_object_focus_set(newest, EINA_TRUE);
2043 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
2049 if (sd->top_win_focused == top_win_focused) return;
2051 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2052 EINA_LIST_FOREACH(sd->subobjs, l, child)
2054 _elm_widget_top_win_focused_set(child, top_win_focused);
2056 sd->top_win_focused = top_win_focused;
2060 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2062 API_ENTRY return EINA_FALSE;
2063 return sd->top_win_focused;
2067 elm_widget_activate(Evas_Object *obj)
2070 elm_widget_change(obj);
2071 if (sd->activate_func) sd->activate_func(obj);
2075 elm_widget_change(Evas_Object *obj)
2078 elm_widget_change(elm_widget_parent_get(obj));
2079 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2083 elm_widget_disabled_set(Evas_Object *obj,
2088 if (sd->disabled == disabled) return;
2089 sd->disabled = !!disabled;
2090 elm_widget_focus_disabled_handle(obj);
2091 if (sd->disable_func) sd->disable_func(obj);
2095 elm_widget_disabled_get(const Evas_Object *obj)
2098 return sd->disabled;
2102 elm_widget_show_region_set(Evas_Object *obj,
2107 Eina_Bool forceshow)
2109 Evas_Object *parent_obj, *child_obj;
2110 Evas_Coord px, py, cx, cy;
2114 evas_smart_objects_calculate(evas_object_evas_get(obj));
2116 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2117 (w == sd->rw) && (h == sd->rh)) return;
2122 if (sd->on_show_region_func)
2123 sd->on_show_region_func(sd->on_show_region_data, obj);
2127 parent_obj = sd->parent_obj;
2128 child_obj = sd->obj;
2129 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2130 sd = evas_object_smart_data_get(parent_obj);
2133 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2134 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2143 if (sd->on_show_region_func)
2145 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2152 elm_widget_show_region_get(const Evas_Object *obj,
2168 * Get the focus region of the given widget.
2170 * The focus region is the area of a widget that should brought into the
2171 * visible area when the widget is focused. Mostly used to show the part of
2172 * an entry where the cursor is, for example. The area returned is relative
2173 * to the object @p obj.
2174 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2175 * function will return the full size of the object.
2177 * @param obj The widget object
2178 * @param x Where to store the x coordinate of the area
2179 * @param y Where to store the y coordinate of the area
2180 * @param w Where to store the width of the area
2181 * @param h Where to store the height of the area
2186 elm_widget_focus_region_get(const Evas_Object *obj,
2196 sd = evas_object_smart_data_get(obj);
2197 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2199 evas_object_geometry_get(obj, NULL, NULL, w, h);
2204 sd->on_focus_region_func(obj, x, y, w, h);
2208 elm_widget_scroll_hold_push(Evas_Object *obj)
2212 if (sd->scroll_hold == 1)
2213 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2214 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2215 // FIXME: on delete/reparent hold pop
2219 elm_widget_scroll_hold_pop(Evas_Object *obj)
2223 if (!sd->scroll_hold)
2224 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2225 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2226 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2230 elm_widget_scroll_hold_get(const Evas_Object *obj)
2233 return sd->scroll_hold;
2237 elm_widget_scroll_freeze_push(Evas_Object *obj)
2240 sd->scroll_freeze++;
2241 if (sd->scroll_freeze == 1)
2242 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2243 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2244 // FIXME: on delete/reparent freeze pop
2248 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2251 sd->scroll_freeze--;
2252 if (!sd->scroll_freeze)
2253 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2254 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2255 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2259 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2262 return sd->scroll_freeze;
2266 elm_widget_scale_set(Evas_Object *obj,
2270 if (scale <= 0.0) scale = 0.0;
2271 if (sd->scale != scale)
2274 elm_widget_theme(obj);
2279 elm_widget_scale_get(const Evas_Object *obj)
2281 API_ENTRY return 1.0;
2282 // FIXME: save walking up the tree by storing/caching parent scale
2283 if (sd->scale == 0.0)
2286 return elm_widget_scale_get(sd->parent_obj);
2294 elm_widget_theme_set(Evas_Object *obj,
2298 if (sd->theme != th)
2300 if (sd->theme) elm_theme_free(sd->theme);
2303 elm_widget_theme(obj);
2308 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2312 if (!sd->text_set_func)
2315 sd->text_set_func(obj, part, label);
2319 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2321 API_ENTRY return NULL;
2323 if (!sd->text_get_func)
2326 return sd->text_get_func(obj, part);
2330 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2334 Elm_Translate_String_Data *ts = NULL;
2337 str = eina_stringshare_add(part);
2338 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2345 eina_stringshare_del(str);
2348 ts = malloc(sizeof(Elm_Translate_String_Data));
2352 ts->domain = eina_stringshare_add(domain);
2353 ts->string = eina_stringshare_add(label);
2354 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2360 eina_stringshare_replace(&ts->domain, domain);
2361 eina_stringshare_replace(&ts->string, label);
2365 sd->translate_strings = eina_list_remove_list(
2366 sd->translate_strings, l);
2367 eina_stringshare_del(ts->id);
2368 eina_stringshare_del(ts->domain);
2369 eina_stringshare_del(ts->string);
2372 eina_stringshare_del(str);
2376 if (label && label[0])
2377 label = dgettext(domain, label);
2379 elm_widget_text_part_set(obj, part, label);
2383 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2385 const char *str, *ret = NULL;
2387 Elm_Translate_String_Data *ts;
2388 API_ENTRY return NULL;
2390 str = eina_stringshare_add(part);
2391 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2397 eina_stringshare_del(str);
2402 elm_widget_translate(Evas_Object *obj)
2407 Elm_Translate_String_Data *ts;
2411 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2412 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2413 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2414 if (sd->translate_func) sd->translate_func(obj);
2417 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2419 const char *s = dgettext(ts->domain, ts->string);
2420 elm_widget_text_part_set(obj, ts->id, s);
2426 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2430 if (!sd->content_set_func) return;
2431 sd->content_set_func(obj, part, content);
2435 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2437 API_ENTRY return NULL;
2439 if (!sd->content_get_func) return NULL;
2440 return sd->content_get_func(obj, part);
2444 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2446 API_ENTRY return NULL;
2448 if (!sd->content_unset_func) return NULL;
2449 return sd->content_unset_func(obj, part);
2453 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2456 if (sd->access_info) eina_stringshare_del(sd->access_info);
2457 if (!txt) sd->access_info = NULL;
2458 else sd->access_info = eina_stringshare_add(txt);
2462 elm_widget_access_info_get(const Evas_Object *obj)
2464 API_ENTRY return NULL;
2465 return sd->access_info;
2469 elm_widget_theme_get(const Evas_Object *obj)
2471 API_ENTRY return NULL;
2475 return elm_widget_theme_get(sd->parent_obj);
2483 elm_widget_style_set(Evas_Object *obj,
2488 if (eina_stringshare_replace(&sd->style, style))
2489 elm_widget_theme(obj);
2493 elm_widget_style_get(const Evas_Object *obj)
2495 API_ENTRY return NULL;
2496 if (sd->style) return sd->style;
2501 elm_widget_type_set(Evas_Object *obj,
2505 eina_stringshare_replace(&sd->type, type);
2509 elm_widget_type_get(const Evas_Object *obj)
2511 API_ENTRY return NULL;
2512 if (sd->type) return sd->type;
2517 elm_widget_tooltip_add(Evas_Object *obj,
2521 sd->tooltips = eina_list_append(sd->tooltips, tt);
2525 elm_widget_tooltip_del(Evas_Object *obj,
2529 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2533 elm_widget_cursor_add(Evas_Object *obj,
2537 sd->cursors = eina_list_append(sd->cursors, cur);
2541 elm_widget_cursor_del(Evas_Object *obj,
2545 sd->cursors = eina_list_remove(sd->cursors, cur);
2549 elm_widget_drag_lock_x_set(Evas_Object *obj,
2553 if (sd->drag_x_locked == lock) return;
2554 sd->drag_x_locked = lock;
2555 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2556 else _propagate_x_drag_lock(obj, -1);
2560 elm_widget_drag_lock_y_set(Evas_Object *obj,
2564 if (sd->drag_y_locked == lock) return;
2565 sd->drag_y_locked = lock;
2566 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2567 else _propagate_y_drag_lock(obj, -1);
2571 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2573 API_ENTRY return EINA_FALSE;
2574 return sd->drag_x_locked;
2578 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2580 API_ENTRY return EINA_FALSE;
2581 return sd->drag_y_locked;
2585 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2588 return sd->child_drag_x_locked;
2592 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2595 return sd->child_drag_y_locked;
2599 elm_widget_theme_object_set(Evas_Object *obj,
2602 const char *welement,
2605 API_ENTRY return EINA_FALSE;
2606 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2610 elm_widget_is_check(const Evas_Object *obj)
2612 static int abort_on_warn = -1;
2613 if (elm_widget_is(obj))
2616 ERR("Passing Object: %p.", obj);
2617 if (abort_on_warn == -1)
2619 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2620 else abort_on_warn = 0;
2622 if (abort_on_warn == 1) abort();
2627 elm_widget_type_check(const Evas_Object *obj,
2631 const char *provided, *expected = "(unknown)";
2632 static int abort_on_warn = -1;
2633 provided = elm_widget_type_get(obj);
2634 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2635 if (type) expected = type;
2636 if ((!provided) || (!provided[0]))
2638 provided = evas_object_type_get(obj);
2639 if ((!provided) || (!provided[0]))
2640 provided = "(unknown)";
2642 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2643 if (abort_on_warn == -1)
2645 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2646 else abort_on_warn = 0;
2648 if (abort_on_warn == 1) abort();
2652 static Evas_Object *
2653 _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2658 INTERNAL_ENTRY NULL;
2660 if (!_elm_widget_is(obj)) return NULL;
2663 s = evas_object_name_get(sd->resize_obj);
2664 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
2665 if ((recurse != 0) &&
2666 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
2669 EINA_LIST_FOREACH(sd->subobjs, l, child)
2671 s = evas_object_name_get(child);
2672 if ((s) && (!strcmp(s, name))) return child;
2673 if ((recurse != 0) &&
2674 ((child = _widget_name_find(child, name, recurse - 1))))
2679 s = evas_object_name_get(sd->hover_obj);
2680 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
2681 if ((recurse != 0) &&
2682 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
2689 elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2691 API_ENTRY return NULL;
2692 if (!name) return NULL;
2693 return _widget_name_find(obj, name, recurse);
2699 * Split string in words
2701 * @param str Source string
2702 * @return List of const words
2704 * @see elm_widget_stringlist_free()
2708 elm_widget_stringlist_get(const char *str)
2710 Eina_List *list = NULL;
2712 if (!str) return NULL;
2713 for (b = s = str; 1; s++)
2715 if ((*s == ' ') || (!*s))
2717 char *t = malloc(s - b + 1);
2720 strncpy(t, b, s - b);
2722 list = eina_list_append(list, eina_stringshare_add(t));
2733 elm_widget_stringlist_free(Eina_List *list)
2736 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2740 elm_widget_focus_hide_handle(Evas_Object *obj)
2742 if (!_elm_widget_is(obj))
2744 _if_focused_revert(obj, EINA_TRUE);
2748 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2750 Evas_Object *o = obj;
2753 if (_elm_widget_is(o)) break;
2754 o = evas_object_smart_parent_get(o);
2758 if (!_is_focusable(o)) return;
2759 elm_widget_focus_steal(o);
2763 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2767 if (!elm_widget_parent_get(obj))
2768 elm_widget_focused_object_clear(obj);
2770 _if_focused_revert(obj, EINA_TRUE);
2774 elm_widget_focus_disabled_handle(Evas_Object *obj)
2778 elm_widget_focus_tree_unfocusable_handle(obj);
2782 elm_widget_focus_order_get(const Evas_Object *obj)
2785 return sd->focus_order;
2791 * Allocate a new Elm_Widget_Item-derived structure.
2793 * The goal of this structure is to provide common ground for actions
2794 * that a widget item have, such as the owner widget, callback to
2795 * notify deletion, data pointer and maybe more.
2797 * @param widget the owner widget that holds this item, must be an elm_widget!
2798 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2799 * be used to allocate memory.
2801 * @return allocated memory that is already zeroed out, or NULL on errors.
2803 * @see elm_widget_item_new() convenience macro.
2804 * @see elm_widget_item_del() to release memory.
2807 EAPI Elm_Widget_Item *
2808 _elm_widget_item_new(Evas_Object *widget,
2811 if (!_elm_widget_is(widget))
2814 Elm_Widget_Item *item;
2816 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2817 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2819 item = calloc(1, alloc_size);
2820 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2822 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2823 item->widget = widget;
2828 _elm_widget_item_free(Elm_Widget_Item *item)
2830 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2833 item->del_func((void *)item->data, item->widget, item);
2836 evas_object_del(item->view);
2840 _elm_access_clear(item->access);
2844 if (item->access_info)
2845 eina_stringshare_del(item->access_info);
2847 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2854 * Releases widget item memory, calling back del_cb() if it exists.
2856 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2857 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2858 * this function and then unset it, thus being useful for 2 step
2859 * cleanup whenever the del_cb may use any of the data that must be
2860 * deleted from item.
2862 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2865 * @param item a valid #Elm_Widget_Item to be deleted.
2866 * @see elm_widget_item_del() convenience macro.
2870 _elm_widget_item_del(Elm_Widget_Item *item)
2872 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2874 //Widget item delete callback
2875 if (item->del_pre_func)
2877 if (item->del_pre_func((Elm_Object_Item *) item))
2878 _elm_widget_item_free(item);
2885 * Set the function to notify to widgets when item is being deleted by user.
2887 * @param item a valid #Elm_Widget_Item to be notified
2888 * @see elm_widget_item_del_pre_hook_set() convenience macro.
2892 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func)
2894 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2895 item->del_pre_func = func;
2901 * Notify object will be deleted without actually deleting it.
2903 * This function will callback Elm_Widget_Item::del_cb if it is set
2904 * and then unset it so it is not called twice (ie: from
2905 * elm_widget_item_del()).
2907 * @param item a valid #Elm_Widget_Item to be notified
2908 * @see elm_widget_item_pre_notify_del() convenience macro.
2912 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2914 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2915 if (!item->del_func) return;
2916 item->del_func((void *)item->data, item->widget, item);
2917 item->del_func = NULL;
2923 * Set the function to notify when item is being deleted.
2925 * This function will complain if there was a callback set already,
2926 * however it will set the new one.
2928 * The callback will be called from elm_widget_item_pre_notify_del()
2929 * or elm_widget_item_del() will be called with:
2930 * - data: the Elm_Widget_Item::data value.
2931 * - obj: the Elm_Widget_Item::widget evas object.
2932 * - event_info: the item being deleted.
2934 * @param item a valid #Elm_Widget_Item to be notified
2935 * @see elm_widget_item_del_cb_set() convenience macro.
2939 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2942 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2944 if ((item->del_func) && (item->del_func != func))
2945 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2946 item->del_func, item, func);
2948 item->del_func = func;
2954 * Set user-data in this item.
2956 * User data may be used to identify this item or just store any
2957 * application data. It is automatically given as the first parameter
2958 * of the deletion notify callback.
2960 * @param item a valid #Elm_Widget_Item to store data in.
2961 * @param data user data to store.
2962 * @see elm_widget_item_del_cb_set() convenience macro.
2966 _elm_widget_item_data_set(Elm_Widget_Item *item,
2969 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2970 if ((item->data) && (item->data != data))
2971 DBG("Replacing item %p data %p with %p", item, item->data, data);
2978 * Retrieves user-data of this item.
2980 * @param item a valid #Elm_Widget_Item to get data from.
2981 * @see elm_widget_item_data_set()
2985 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2987 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2988 return (void *)item->data;
2992 _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
2994 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2996 if (item->disabled == disabled) return;
2997 item->disabled = !!disabled;
2998 if (item->disable_func) item->disable_func(item);
3002 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3004 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3005 return item->disabled;
3009 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3010 Elm_Widget_Disable_Cb func)
3012 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3013 item->disable_func = func;
3016 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3018 struct _Elm_Widget_Item_Tooltip
3020 Elm_Widget_Item *item;
3021 Elm_Tooltip_Item_Content_Cb func;
3022 Evas_Smart_Cb del_cb;
3026 static Evas_Object *
3027 _elm_widget_item_tooltip_label_create(void *data,
3028 Evas_Object *obj __UNUSED__,
3029 Evas_Object *tooltip,
3030 void *item __UNUSED__)
3032 Evas_Object *label = elm_label_add(tooltip);
3035 elm_object_style_set(label, "tooltip");
3036 elm_object_text_set(label, data);
3040 static Evas_Object *
3041 _elm_widget_item_tooltip_trans_label_create(void *data,
3042 Evas_Object *obj __UNUSED__,
3043 Evas_Object *tooltip,
3044 void *item __UNUSED__)
3046 Evas_Object *label = elm_label_add(tooltip);
3049 elm_object_style_set(label, "tooltip");
3050 elm_object_translatable_text_set(label, data);
3055 _elm_widget_item_tooltip_label_del_cb(void *data,
3056 Evas_Object *obj __UNUSED__,
3057 void *event_info __UNUSED__)
3059 eina_stringshare_del(data);
3065 * Set the text to be shown in the widget item.
3067 * @param item Target item
3068 * @param text The text to set in the content
3070 * Setup the text as tooltip to object. The item can have only one tooltip,
3071 * so any previous tooltip data is removed.
3076 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3079 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3080 EINA_SAFETY_ON_NULL_RETURN(text);
3082 text = eina_stringshare_add(text);
3083 _elm_widget_item_tooltip_content_cb_set
3084 (item, _elm_widget_item_tooltip_label_create, text,
3085 _elm_widget_item_tooltip_label_del_cb);
3089 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3092 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3093 EINA_SAFETY_ON_NULL_RETURN(text);
3095 text = eina_stringshare_add(text);
3096 _elm_widget_item_tooltip_content_cb_set
3097 (item, _elm_widget_item_tooltip_trans_label_create, text,
3098 _elm_widget_item_tooltip_label_del_cb);
3101 static Evas_Object *
3102 _elm_widget_item_tooltip_create(void *data,
3104 Evas_Object *tooltip)
3106 Elm_Widget_Item_Tooltip *wit = data;
3107 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3111 _elm_widget_item_tooltip_del_cb(void *data,
3113 void *event_info __UNUSED__)
3115 Elm_Widget_Item_Tooltip *wit = data;
3116 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3123 * Set the content to be shown in the tooltip item
3125 * Setup the tooltip to item. The item can have only one tooltip,
3126 * so any previous tooltip data is removed. @p func(with @p data) will
3127 * be called every time that need show the tooltip and it should
3128 * return a valid Evas_Object. This object is then managed fully by
3129 * tooltip system and is deleted when the tooltip is gone.
3131 * @param item the widget item being attached a tooltip.
3132 * @param func the function used to create the tooltip contents.
3133 * @param data what to provide to @a func as callback data/context.
3134 * @param del_cb called when data is not needed anymore, either when
3135 * another callback replaces @func, the tooltip is unset with
3136 * elm_widget_item_tooltip_unset() or the owner @a item
3137 * dies. This callback receives as the first parameter the
3138 * given @a data, and @c event_info is the item.
3143 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3144 Elm_Tooltip_Item_Content_Cb func,
3146 Evas_Smart_Cb del_cb)
3148 Elm_Widget_Item_Tooltip *wit;
3150 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3154 _elm_widget_item_tooltip_unset(item);
3158 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3159 if (!wit) goto error;
3163 wit->del_cb = del_cb;
3165 elm_object_sub_tooltip_content_cb_set
3166 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3167 _elm_widget_item_tooltip_del_cb);
3172 if (del_cb) del_cb((void *)data, NULL, item);
3175 if (del_cb) del_cb((void *)data, item->widget, item);
3181 * Unset tooltip from item
3183 * @param item widget item to remove previously set tooltip.
3185 * Remove tooltip from item. The callback provided as del_cb to
3186 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3187 * it is not used anymore.
3189 * @see elm_widget_item_tooltip_content_cb_set()
3194 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3196 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3197 elm_object_tooltip_unset(item->view);
3203 * Sets a different style for this item tooltip.
3205 * @note before you set a style you should define a tooltip with
3206 * elm_widget_item_tooltip_content_cb_set() or
3207 * elm_widget_item_tooltip_text_set()
3209 * @param item widget item with tooltip already set.
3210 * @param style the theme style to use (default, transparent, ...)
3215 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3218 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3219 elm_object_tooltip_style_set(item->view, style);
3223 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
3225 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3226 return elm_object_tooltip_window_mode_set(item->view, disable);
3230 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
3232 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3233 return elm_object_tooltip_window_mode_get(item->view);
3239 * Get the style for this item tooltip.
3241 * @param item widget item with tooltip already set.
3242 * @return style the theme style in use, defaults to "default". If the
3243 * object does not have a tooltip set, then NULL is returned.
3248 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3250 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3251 return elm_object_tooltip_style_get(item->view);
3255 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3258 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3259 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3263 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3265 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3266 return elm_object_cursor_get(item->view);
3270 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3272 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3273 elm_object_cursor_unset(item->view);
3279 * Sets a different style for this item cursor.
3281 * @note before you set a style you should define a cursor with
3282 * elm_widget_item_cursor_set()
3284 * @param item widget item with cursor already set.
3285 * @param style the theme style to use (default, transparent, ...)
3290 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3293 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3294 elm_object_cursor_style_set(item->view, style);
3300 * Get the style for this item cursor.
3302 * @param item widget item with cursor already set.
3303 * @return style the theme style in use, defaults to "default". If the
3304 * object does not have a cursor set, then NULL is returned.
3309 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3311 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3312 return elm_object_cursor_style_get(item->view);
3318 * Set if the cursor set should be searched on the theme or should use
3319 * the provided by the engine, only.
3321 * @note before you set if should look on theme you should define a cursor
3322 * with elm_object_cursor_set(). By default it will only look for cursors
3323 * provided by the engine.
3325 * @param item widget item with cursor already set.
3326 * @param engine_only boolean to define it cursors should be looked only
3327 * between the provided by the engine or searched on widget's theme as well.
3332 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3333 Eina_Bool engine_only)
3335 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3336 elm_object_cursor_engine_only_set(item->view, engine_only);
3342 * Get the cursor engine only usage for this item cursor.
3344 * @param item widget item with cursor already set.
3345 * @return engine_only boolean to define it cursors should be looked only
3346 * between the provided by the engine or searched on widget's theme as well. If
3347 * the object does not have a cursor set, then EINA_FALSE is returned.
3352 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3354 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3355 return elm_object_cursor_engine_only_get(item->view);
3358 // smart object funcs
3360 _smart_reconfigure(Smart_Data *sd)
3364 evas_object_move(sd->resize_obj, sd->x, sd->y);
3365 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3369 evas_object_move(sd->hover_obj, sd->x, sd->y);
3370 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3375 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3377 Evas_Object *content)
3379 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3380 if (!item->content_set_func) return;
3381 item->content_set_func((Elm_Object_Item *) item, part, content);
3385 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3388 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3389 if (!item->content_get_func) return NULL;
3390 return item->content_get_func((Elm_Object_Item *) item, part);
3394 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3397 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3398 if (!item->content_unset_func) return NULL;
3399 return item->content_unset_func((Elm_Object_Item *) item, part);
3403 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3407 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3408 if (!item->text_set_func) return;
3409 item->text_set_func((Elm_Object_Item *) item, part, label);
3413 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3414 const char *emission,
3417 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3418 if (item->signal_emit_func)
3419 item->signal_emit_func((Elm_Object_Item *) item, emission, source);
3423 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3426 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3427 if (!item->text_get_func) return NULL;
3428 return item->text_get_func((Elm_Object_Item *) item, part);
3432 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3433 Elm_Widget_Content_Set_Cb func)
3435 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3436 item->content_set_func = func;
3440 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3441 Elm_Widget_Content_Get_Cb func)
3443 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3444 item->content_get_func = func;
3448 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3449 Elm_Widget_Content_Unset_Cb func)
3451 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3452 item->content_unset_func = func;
3456 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3457 Elm_Widget_Text_Set_Cb func)
3459 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3460 item->text_set_func = func;
3464 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3465 Elm_Widget_Text_Get_Cb func)
3467 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3468 item->text_get_func = func;
3472 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3473 Elm_Widget_Signal_Emit_Cb func)
3475 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3476 item->signal_emit_func = func;
3480 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3482 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3483 if (item->access_info) eina_stringshare_del(item->access_info);
3484 if (!txt) item->access_info = NULL;
3485 else item->access_info = eina_stringshare_add(txt);
3489 _smart_add(Evas_Object *obj)
3493 sd = calloc(1, sizeof(Smart_Data));
3496 sd->x = sd->y = sd->w = sd->h = 0;
3498 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3499 evas_object_smart_data_set(obj, sd);
3502 static Evas_Object *
3503 _newest_focus_order_get(Evas_Object *obj,
3504 unsigned int *newest_focus_order,
3505 Eina_Bool can_focus_only)
3508 Evas_Object *child, *ret, *best;
3510 API_ENTRY return NULL;
3512 if (!evas_object_visible_get(obj)
3513 || (elm_widget_disabled_get(obj))
3514 || (elm_widget_tree_unfocusable_get(obj)))
3518 if (*newest_focus_order < sd->focus_order)
3520 *newest_focus_order = sd->focus_order;
3523 EINA_LIST_FOREACH(sd->subobjs, l, child)
3525 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3531 if ((!best) || (!elm_widget_can_focus_get(best)))
3538 _if_focused_revert(Evas_Object *obj,
3539 Eina_Bool can_focus_only)
3542 Evas_Object *newest = NULL;
3543 unsigned int newest_focus_order = 0;
3547 if (!sd->focused) return;
3548 if (!sd->parent_obj) return;
3550 top = elm_widget_top_get(sd->parent_obj);
3553 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3556 elm_object_focus_set(newest, EINA_FALSE);
3557 elm_object_focus_set(newest, EINA_TRUE);
3563 _smart_del(Evas_Object *obj)
3566 Edje_Signal_Data *esd;
3567 Elm_Translate_String_Data *ts;
3571 if (sd->del_pre_func) sd->del_pre_func(obj);
3574 sobj = sd->resize_obj;
3575 sd->resize_obj = NULL;
3576 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3577 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3578 evas_object_del(sobj);
3579 sd->resize_obj = NULL;
3583 sobj = sd->hover_obj;
3584 sd->hover_obj = NULL;
3585 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3586 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3587 evas_object_del(sobj);
3588 sd->hover_obj = NULL;
3590 EINA_LIST_FREE(sd->subobjs, sobj)
3592 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3593 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3594 evas_object_del(sobj);
3596 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3597 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3598 EINA_LIST_FREE(sd->edje_signals, esd)
3600 eina_stringshare_del(esd->emission);
3601 eina_stringshare_del(esd->source);
3604 EINA_LIST_FREE(sd->translate_strings, ts)
3606 eina_stringshare_del(ts->id);
3607 eina_stringshare_del(ts->domain);
3608 eina_stringshare_del(ts->string);
3611 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3612 if (sd->del_func) sd->del_func(obj);
3613 if (sd->style) eina_stringshare_del(sd->style);
3614 if (sd->type) eina_stringshare_del(sd->type);
3615 if (sd->theme) elm_theme_free(sd->theme);
3617 _if_focused_revert(obj, EINA_TRUE);
3618 if (sd->access_info) eina_stringshare_del(sd->access_info);
3620 evas_object_smart_data_set(obj, NULL);
3624 _smart_move(Evas_Object *obj,
3631 _smart_reconfigure(sd);
3635 _smart_resize(Evas_Object *obj,
3642 _smart_reconfigure(sd);
3646 _smart_show(Evas_Object *obj)
3651 if ((list = evas_object_smart_members_get(obj)))
3653 EINA_LIST_FREE(list, o)
3655 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3656 evas_object_show(o);
3662 _smart_hide(Evas_Object *obj)
3668 list = evas_object_smart_members_get(obj);
3669 EINA_LIST_FREE(list, o)
3671 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3672 evas_object_hide(o);
3677 _smart_color_set(Evas_Object *obj,
3686 if ((list = evas_object_smart_members_get(obj)))
3688 EINA_LIST_FREE(list, o)
3690 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3691 evas_object_color_set(o, r, g, b, a);
3697 _smart_clip_set(Evas_Object *obj,
3703 if ((list = evas_object_smart_members_get(obj)))
3705 EINA_LIST_FREE(list, o)
3707 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3708 evas_object_clip_set(o, clip);
3714 _smart_clip_unset(Evas_Object *obj)
3719 if ((list = evas_object_smart_members_get(obj)))
3721 EINA_LIST_FREE(list, o)
3723 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3724 evas_object_clip_unset(o);
3730 _smart_calculate(Evas_Object *obj)
3733 if (sd->changed_func) sd->changed_func(obj);
3736 /* never need to touch this */
3740 if (_e_smart) return;
3742 static const Evas_Smart_Class sc =
3745 EVAS_SMART_CLASS_VERSION,
3763 _e_smart = evas_smart_class_new(&sc);
3767 /* happy debug functions */
3770 _sub_obj_tree_dump(const Evas_Object *obj,
3775 for (i = 0; i < lvl * 3; i++)
3778 if (_elm_widget_is(obj))
3782 printf("+ %s(%p)\n",
3786 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3787 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3789 if (obj != sd->resize_obj)
3790 _sub_obj_tree_dump(obj, lvl + 1);
3794 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3798 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3801 if (!_elm_widget_is(obj))
3805 Eina_Bool visible = evas_object_visible_get(obj);
3806 Eina_Bool disabled = elm_widget_disabled_get(obj);
3807 Eina_Bool focused = elm_widget_focus_get(obj);
3808 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3812 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3815 fprintf(output, ", style=bold");
3818 fprintf(output, ", color=gray28");
3820 fprintf(output, " ];\n");
3823 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3824 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3825 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3829 fprintf(output, ", style=bold");
3832 fprintf(output, ", fontcolor=gray28");
3834 if ((disabled) || (!visible))
3835 fprintf(output, ", color=gray");
3837 fprintf(output, " ];\n");
3841 EINA_LIST_FOREACH(sd->subobjs, l, o)
3842 _sub_obj_tree_dot_dump(o, output);
3847 elm_widget_tree_dump(const Evas_Object *top)
3850 if (!_elm_widget_is(top))
3852 _sub_obj_tree_dump(top, 0);
3860 elm_widget_tree_dot_dump(const Evas_Object *top,
3864 if (!_elm_widget_is(top))
3866 fprintf(output, "graph " " { node [shape=record];\n");
3867 _sub_obj_tree_dot_dump(top, output);
3868 fprintf(output, "}\n");