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;
2112 evas_smart_objects_calculate(evas_object_evas_get(obj));
2115 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2116 && (w == sd->rw) && (h == sd->rh)) return;
2121 if (sd->on_show_region_func)
2122 sd->on_show_region_func(sd->on_show_region_data, obj);
2126 parent_obj = sd->parent_obj;
2127 child_obj = sd->obj;
2128 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2129 sd = evas_object_smart_data_get(parent_obj);
2132 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2133 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2142 if (sd->on_show_region_func)
2144 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2151 elm_widget_show_region_get(const Evas_Object *obj,
2167 * Get the focus region of the given widget.
2169 * The focus region is the area of a widget that should brought into the
2170 * visible area when the widget is focused. Mostly used to show the part of
2171 * an entry where the cursor is, for example. The area returned is relative
2172 * to the object @p obj.
2173 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2174 * function will return the full size of the object.
2176 * @param obj The widget object
2177 * @param x Where to store the x coordinate of the area
2178 * @param y Where to store the y coordinate of the area
2179 * @param w Where to store the width of the area
2180 * @param h Where to store the height of the area
2185 elm_widget_focus_region_get(const Evas_Object *obj,
2195 sd = evas_object_smart_data_get(obj);
2196 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2198 evas_object_geometry_get(obj, NULL, NULL, w, h);
2203 sd->on_focus_region_func(obj, x, y, w, h);
2207 elm_widget_scroll_hold_push(Evas_Object *obj)
2211 if (sd->scroll_hold == 1)
2212 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2213 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2214 // FIXME: on delete/reparent hold pop
2218 elm_widget_scroll_hold_pop(Evas_Object *obj)
2222 if (!sd->scroll_hold)
2223 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2224 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2225 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2229 elm_widget_scroll_hold_get(const Evas_Object *obj)
2232 return sd->scroll_hold;
2236 elm_widget_scroll_freeze_push(Evas_Object *obj)
2239 sd->scroll_freeze++;
2240 if (sd->scroll_freeze == 1)
2241 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2242 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2243 // FIXME: on delete/reparent freeze pop
2247 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2250 sd->scroll_freeze--;
2251 if (!sd->scroll_freeze)
2252 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2253 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2254 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2258 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2261 return sd->scroll_freeze;
2265 elm_widget_scale_set(Evas_Object *obj,
2269 if (scale <= 0.0) scale = 0.0;
2270 if (sd->scale != scale)
2273 elm_widget_theme(obj);
2278 elm_widget_scale_get(const Evas_Object *obj)
2280 API_ENTRY return 1.0;
2281 // FIXME: save walking up the tree by storing/caching parent scale
2282 if (sd->scale == 0.0)
2285 return elm_widget_scale_get(sd->parent_obj);
2293 elm_widget_theme_set(Evas_Object *obj,
2297 if (sd->theme != th)
2299 if (sd->theme) elm_theme_free(sd->theme);
2302 elm_widget_theme(obj);
2307 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2311 if (!sd->text_set_func)
2314 sd->text_set_func(obj, part, label);
2318 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2320 API_ENTRY return NULL;
2322 if (!sd->text_get_func)
2325 return sd->text_get_func(obj, part);
2329 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2333 Elm_Translate_String_Data *ts = NULL;
2336 str = eina_stringshare_add(part);
2337 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2344 eina_stringshare_del(str);
2347 ts = malloc(sizeof(Elm_Translate_String_Data));
2351 ts->domain = eina_stringshare_add(domain);
2352 ts->string = eina_stringshare_add(label);
2353 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2359 eina_stringshare_replace(&ts->domain, domain);
2360 eina_stringshare_replace(&ts->string, label);
2364 sd->translate_strings = eina_list_remove_list(
2365 sd->translate_strings, l);
2366 eina_stringshare_del(ts->id);
2367 eina_stringshare_del(ts->domain);
2368 eina_stringshare_del(ts->string);
2371 eina_stringshare_del(str);
2375 if (label && label[0])
2376 label = dgettext(domain, label);
2378 elm_widget_text_part_set(obj, part, label);
2382 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2384 const char *str, *ret = NULL;
2386 Elm_Translate_String_Data *ts;
2387 API_ENTRY return NULL;
2389 str = eina_stringshare_add(part);
2390 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2396 eina_stringshare_del(str);
2401 elm_widget_translate(Evas_Object *obj)
2406 Elm_Translate_String_Data *ts;
2410 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2411 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2412 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2413 if (sd->translate_func) sd->translate_func(obj);
2416 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2418 const char *s = dgettext(ts->domain, ts->string);
2419 elm_widget_text_part_set(obj, ts->id, s);
2425 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2429 if (!sd->content_set_func) return;
2430 sd->content_set_func(obj, part, content);
2434 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2436 API_ENTRY return NULL;
2438 if (!sd->content_get_func) return NULL;
2439 return sd->content_get_func(obj, part);
2443 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2445 API_ENTRY return NULL;
2447 if (!sd->content_unset_func) return NULL;
2448 return sd->content_unset_func(obj, part);
2452 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2455 if (sd->access_info) eina_stringshare_del(sd->access_info);
2456 if (!txt) sd->access_info = NULL;
2457 else sd->access_info = eina_stringshare_add(txt);
2461 elm_widget_access_info_get(const Evas_Object *obj)
2463 API_ENTRY return NULL;
2464 return sd->access_info;
2468 elm_widget_theme_get(const Evas_Object *obj)
2470 API_ENTRY return NULL;
2474 return elm_widget_theme_get(sd->parent_obj);
2482 elm_widget_style_set(Evas_Object *obj,
2487 if (eina_stringshare_replace(&sd->style, style))
2488 elm_widget_theme(obj);
2492 elm_widget_style_get(const Evas_Object *obj)
2494 API_ENTRY return NULL;
2495 if (sd->style) return sd->style;
2500 elm_widget_type_set(Evas_Object *obj,
2504 eina_stringshare_replace(&sd->type, type);
2508 elm_widget_type_get(const Evas_Object *obj)
2510 API_ENTRY return NULL;
2511 if (sd->type) return sd->type;
2516 elm_widget_tooltip_add(Evas_Object *obj,
2520 sd->tooltips = eina_list_append(sd->tooltips, tt);
2524 elm_widget_tooltip_del(Evas_Object *obj,
2528 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2532 elm_widget_cursor_add(Evas_Object *obj,
2536 sd->cursors = eina_list_append(sd->cursors, cur);
2540 elm_widget_cursor_del(Evas_Object *obj,
2544 sd->cursors = eina_list_remove(sd->cursors, cur);
2548 elm_widget_drag_lock_x_set(Evas_Object *obj,
2552 if (sd->drag_x_locked == lock) return;
2553 sd->drag_x_locked = lock;
2554 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2555 else _propagate_x_drag_lock(obj, -1);
2559 elm_widget_drag_lock_y_set(Evas_Object *obj,
2563 if (sd->drag_y_locked == lock) return;
2564 sd->drag_y_locked = lock;
2565 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2566 else _propagate_y_drag_lock(obj, -1);
2570 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2572 API_ENTRY return EINA_FALSE;
2573 return sd->drag_x_locked;
2577 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2579 API_ENTRY return EINA_FALSE;
2580 return sd->drag_y_locked;
2584 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2587 return sd->child_drag_x_locked;
2591 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2594 return sd->child_drag_y_locked;
2598 elm_widget_theme_object_set(Evas_Object *obj,
2601 const char *welement,
2604 API_ENTRY return EINA_FALSE;
2605 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2609 elm_widget_is_check(const Evas_Object *obj)
2611 static int abort_on_warn = -1;
2612 if (elm_widget_is(obj))
2615 ERR("Passing Object: %p.", obj);
2616 if (abort_on_warn == -1)
2618 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2619 else abort_on_warn = 0;
2621 if (abort_on_warn == 1) abort();
2626 elm_widget_type_check(const Evas_Object *obj,
2630 const char *provided, *expected = "(unknown)";
2631 static int abort_on_warn = -1;
2632 provided = elm_widget_type_get(obj);
2633 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2634 if (type) expected = type;
2635 if ((!provided) || (!provided[0]))
2637 provided = evas_object_type_get(obj);
2638 if ((!provided) || (!provided[0]))
2639 provided = "(unknown)";
2641 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2642 if (abort_on_warn == -1)
2644 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2645 else abort_on_warn = 0;
2647 if (abort_on_warn == 1) abort();
2651 static Evas_Object *
2652 _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2657 INTERNAL_ENTRY NULL;
2659 if (!_elm_widget_is(obj)) return NULL;
2662 s = evas_object_name_get(sd->resize_obj);
2663 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
2664 if ((recurse != 0) &&
2665 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
2668 EINA_LIST_FOREACH(sd->subobjs, l, child)
2670 s = evas_object_name_get(child);
2671 if ((s) && (!strcmp(s, name))) return child;
2672 if ((recurse != 0) &&
2673 ((child = _widget_name_find(child, name, recurse - 1))))
2678 s = evas_object_name_get(sd->hover_obj);
2679 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
2680 if ((recurse != 0) &&
2681 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
2688 elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
2690 API_ENTRY return NULL;
2691 if (!name) return NULL;
2692 return _widget_name_find(obj, name, recurse);
2698 * Split string in words
2700 * @param str Source string
2701 * @return List of const words
2703 * @see elm_widget_stringlist_free()
2707 elm_widget_stringlist_get(const char *str)
2709 Eina_List *list = NULL;
2711 if (!str) return NULL;
2712 for (b = s = str; 1; s++)
2714 if ((*s == ' ') || (!*s))
2716 char *t = malloc(s - b + 1);
2719 strncpy(t, b, s - b);
2721 list = eina_list_append(list, eina_stringshare_add(t));
2732 elm_widget_stringlist_free(Eina_List *list)
2735 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2739 elm_widget_focus_hide_handle(Evas_Object *obj)
2741 _if_focused_revert(obj, EINA_TRUE);
2745 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2747 Evas_Object *o = obj;
2750 if (_elm_widget_is(o)) break;
2751 o = evas_object_smart_parent_get(o);
2755 if (!_is_focusable(o)) return;
2756 elm_widget_focus_steal(o);
2760 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2764 if (!elm_widget_parent_get(obj))
2765 elm_widget_focused_object_clear(obj);
2767 _if_focused_revert(obj, EINA_TRUE);
2771 elm_widget_focus_disabled_handle(Evas_Object *obj)
2775 elm_widget_focus_tree_unfocusable_handle(obj);
2781 * Allocate a new Elm_Widget_Item-derived structure.
2783 * The goal of this structure is to provide common ground for actions
2784 * that a widget item have, such as the owner widget, callback to
2785 * notify deletion, data pointer and maybe more.
2787 * @param widget the owner widget that holds this item, must be an elm_widget!
2788 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2789 * be used to allocate memory.
2791 * @return allocated memory that is already zeroed out, or NULL on errors.
2793 * @see elm_widget_item_new() convenience macro.
2794 * @see elm_widget_item_del() to release memory.
2797 EAPI Elm_Widget_Item *
2798 _elm_widget_item_new(Evas_Object *widget,
2801 if (!_elm_widget_is(widget))
2804 Elm_Widget_Item *item;
2806 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2807 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2809 item = calloc(1, alloc_size);
2810 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2812 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2813 item->widget = widget;
2818 _elm_widget_item_free(Elm_Widget_Item *item)
2820 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2823 item->del_func((void *)item->data, item->widget, item);
2826 evas_object_del(item->view);
2830 _elm_access_clear(item->access);
2834 if (item->access_info)
2835 eina_stringshare_del(item->access_info);
2837 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2844 * Releases widget item memory, calling back del_cb() if it exists.
2846 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2847 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2848 * this function and then unset it, thus being useful for 2 step
2849 * cleanup whenever the del_cb may use any of the data that must be
2850 * deleted from item.
2852 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2855 * @param item a valid #Elm_Widget_Item to be deleted.
2856 * @see elm_widget_item_del() convenience macro.
2860 _elm_widget_item_del(Elm_Widget_Item *item)
2862 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2864 //Widget item delete callback
2865 if (item->del_pre_func)
2867 if (item->del_pre_func((Elm_Object_Item *) item))
2868 _elm_widget_item_free(item);
2875 * Set the function to notify to widgets when item is being deleted by user.
2877 * @param item a valid #Elm_Widget_Item to be notified
2878 * @see elm_widget_item_del_pre_hook_set() convenience macro.
2882 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func)
2884 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2885 item->del_pre_func = func;
2891 * Notify object will be deleted without actually deleting it.
2893 * This function will callback Elm_Widget_Item::del_cb if it is set
2894 * and then unset it so it is not called twice (ie: from
2895 * elm_widget_item_del()).
2897 * @param item a valid #Elm_Widget_Item to be notified
2898 * @see elm_widget_item_pre_notify_del() convenience macro.
2902 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2904 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2905 if (!item->del_func) return;
2906 item->del_func((void *)item->data, item->widget, item);
2907 item->del_func = NULL;
2913 * Set the function to notify when item is being deleted.
2915 * This function will complain if there was a callback set already,
2916 * however it will set the new one.
2918 * The callback will be called from elm_widget_item_pre_notify_del()
2919 * or elm_widget_item_del() will be called with:
2920 * - data: the Elm_Widget_Item::data value.
2921 * - obj: the Elm_Widget_Item::widget evas object.
2922 * - event_info: the item being deleted.
2924 * @param item a valid #Elm_Widget_Item to be notified
2925 * @see elm_widget_item_del_cb_set() convenience macro.
2929 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2932 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2934 if ((item->del_func) && (item->del_func != func))
2935 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2936 item->del_func, item, func);
2938 item->del_func = func;
2944 * Set user-data in this item.
2946 * User data may be used to identify this item or just store any
2947 * application data. It is automatically given as the first parameter
2948 * of the deletion notify callback.
2950 * @param item a valid #Elm_Widget_Item to store data in.
2951 * @param data user data to store.
2952 * @see elm_widget_item_del_cb_set() convenience macro.
2956 _elm_widget_item_data_set(Elm_Widget_Item *item,
2959 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2960 if ((item->data) && (item->data != data))
2961 DBG("Replacing item %p data %p with %p", item, item->data, data);
2968 * Retrieves user-data of this item.
2970 * @param item a valid #Elm_Widget_Item to get data from.
2971 * @see elm_widget_item_data_set()
2975 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2977 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2978 return (void *)item->data;
2982 _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled)
2984 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2986 if (item->disabled == disabled) return;
2987 item->disabled = !!disabled;
2988 if (item->disable_func) item->disable_func(item);
2992 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
2994 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2995 return item->disabled;
2999 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3000 Elm_Widget_Disable_Cb func)
3002 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3003 item->disable_func = func;
3006 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3008 struct _Elm_Widget_Item_Tooltip
3010 Elm_Widget_Item *item;
3011 Elm_Tooltip_Item_Content_Cb func;
3012 Evas_Smart_Cb del_cb;
3016 static Evas_Object *
3017 _elm_widget_item_tooltip_label_create(void *data,
3018 Evas_Object *obj __UNUSED__,
3019 Evas_Object *tooltip,
3020 void *item __UNUSED__)
3022 Evas_Object *label = elm_label_add(tooltip);
3025 elm_object_style_set(label, "tooltip");
3026 elm_object_text_set(label, data);
3030 static Evas_Object *
3031 _elm_widget_item_tooltip_trans_label_create(void *data,
3032 Evas_Object *obj __UNUSED__,
3033 Evas_Object *tooltip,
3034 void *item __UNUSED__)
3036 Evas_Object *label = elm_label_add(tooltip);
3039 elm_object_style_set(label, "tooltip");
3040 elm_object_translatable_text_set(label, data);
3045 _elm_widget_item_tooltip_label_del_cb(void *data,
3046 Evas_Object *obj __UNUSED__,
3047 void *event_info __UNUSED__)
3049 eina_stringshare_del(data);
3055 * Set the text to be shown in the widget item.
3057 * @param item Target item
3058 * @param text The text to set in the content
3060 * Setup the text as tooltip to object. The item can have only one tooltip,
3061 * so any previous tooltip data is removed.
3066 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3069 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3070 EINA_SAFETY_ON_NULL_RETURN(text);
3072 text = eina_stringshare_add(text);
3073 _elm_widget_item_tooltip_content_cb_set
3074 (item, _elm_widget_item_tooltip_label_create, text,
3075 _elm_widget_item_tooltip_label_del_cb);
3079 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3082 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3083 EINA_SAFETY_ON_NULL_RETURN(text);
3085 text = eina_stringshare_add(text);
3086 _elm_widget_item_tooltip_content_cb_set
3087 (item, _elm_widget_item_tooltip_trans_label_create, text,
3088 _elm_widget_item_tooltip_label_del_cb);
3091 static Evas_Object *
3092 _elm_widget_item_tooltip_create(void *data,
3094 Evas_Object *tooltip)
3096 Elm_Widget_Item_Tooltip *wit = data;
3097 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3101 _elm_widget_item_tooltip_del_cb(void *data,
3103 void *event_info __UNUSED__)
3105 Elm_Widget_Item_Tooltip *wit = data;
3106 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3113 * Set the content to be shown in the tooltip item
3115 * Setup the tooltip to item. The item can have only one tooltip,
3116 * so any previous tooltip data is removed. @p func(with @p data) will
3117 * be called every time that need show the tooltip and it should
3118 * return a valid Evas_Object. This object is then managed fully by
3119 * tooltip system and is deleted when the tooltip is gone.
3121 * @param item the widget item being attached a tooltip.
3122 * @param func the function used to create the tooltip contents.
3123 * @param data what to provide to @a func as callback data/context.
3124 * @param del_cb called when data is not needed anymore, either when
3125 * another callback replaces @func, the tooltip is unset with
3126 * elm_widget_item_tooltip_unset() or the owner @a item
3127 * dies. This callback receives as the first parameter the
3128 * given @a data, and @c event_info is the item.
3133 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3134 Elm_Tooltip_Item_Content_Cb func,
3136 Evas_Smart_Cb del_cb)
3138 Elm_Widget_Item_Tooltip *wit;
3140 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3144 _elm_widget_item_tooltip_unset(item);
3148 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3149 if (!wit) goto error;
3153 wit->del_cb = del_cb;
3155 elm_object_sub_tooltip_content_cb_set
3156 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3157 _elm_widget_item_tooltip_del_cb);
3162 if (del_cb) del_cb((void *)data, NULL, item);
3165 if (del_cb) del_cb((void *)data, item->widget, item);
3171 * Unset tooltip from item
3173 * @param item widget item to remove previously set tooltip.
3175 * Remove tooltip from item. The callback provided as del_cb to
3176 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3177 * it is not used anymore.
3179 * @see elm_widget_item_tooltip_content_cb_set()
3184 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3186 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3187 elm_object_tooltip_unset(item->view);
3193 * Sets a different style for this item tooltip.
3195 * @note before you set a style you should define a tooltip with
3196 * elm_widget_item_tooltip_content_cb_set() or
3197 * elm_widget_item_tooltip_text_set()
3199 * @param item widget item with tooltip already set.
3200 * @param style the theme style to use (default, transparent, ...)
3205 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3208 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3209 elm_object_tooltip_style_set(item->view, style);
3213 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable)
3215 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3216 return elm_object_tooltip_window_mode_set(item->view, disable);
3220 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
3222 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3223 return elm_object_tooltip_window_mode_get(item->view);
3229 * Get the style for this item tooltip.
3231 * @param item widget item with tooltip already set.
3232 * @return style the theme style in use, defaults to "default". If the
3233 * object does not have a tooltip set, then NULL is returned.
3238 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3240 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3241 return elm_object_tooltip_style_get(item->view);
3245 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3248 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3249 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3253 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3255 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3256 return elm_object_cursor_get(item->view);
3260 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3262 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3263 elm_object_cursor_unset(item->view);
3269 * Sets a different style for this item cursor.
3271 * @note before you set a style you should define a cursor with
3272 * elm_widget_item_cursor_set()
3274 * @param item widget item with cursor already set.
3275 * @param style the theme style to use (default, transparent, ...)
3280 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3283 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3284 elm_object_cursor_style_set(item->view, style);
3290 * Get the style for this item cursor.
3292 * @param item widget item with cursor already set.
3293 * @return style the theme style in use, defaults to "default". If the
3294 * object does not have a cursor set, then NULL is returned.
3299 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3301 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3302 return elm_object_cursor_style_get(item->view);
3308 * Set if the cursor set should be searched on the theme or should use
3309 * the provided by the engine, only.
3311 * @note before you set if should look on theme you should define a cursor
3312 * with elm_object_cursor_set(). By default it will only look for cursors
3313 * provided by the engine.
3315 * @param item widget item with cursor already set.
3316 * @param engine_only boolean to define it cursors should be looked only
3317 * between the provided by the engine or searched on widget's theme as well.
3322 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3323 Eina_Bool engine_only)
3325 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3326 elm_object_cursor_engine_only_set(item->view, engine_only);
3332 * Get the cursor engine only usage for this item cursor.
3334 * @param item widget item with cursor already set.
3335 * @return engine_only boolean to define it cursors should be looked only
3336 * between the provided by the engine or searched on widget's theme as well. If
3337 * the object does not have a cursor set, then EINA_FALSE is returned.
3342 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3344 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3345 return elm_object_cursor_engine_only_get(item->view);
3348 // smart object funcs
3350 _smart_reconfigure(Smart_Data *sd)
3354 evas_object_move(sd->resize_obj, sd->x, sd->y);
3355 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3359 evas_object_move(sd->hover_obj, sd->x, sd->y);
3360 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3365 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3367 Evas_Object *content)
3369 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3370 if (!item->content_set_func) return;
3371 item->content_set_func((Elm_Object_Item *) item, part, content);
3375 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3378 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3379 if (!item->content_get_func) return NULL;
3380 return item->content_get_func((Elm_Object_Item *) item, part);
3384 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3387 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3388 if (!item->content_unset_func) return NULL;
3389 return item->content_unset_func((Elm_Object_Item *) item, part);
3393 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3397 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3398 if (!item->text_set_func) return;
3399 item->text_set_func((Elm_Object_Item *) item, part, label);
3403 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3404 const char *emission,
3407 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3408 if (item->signal_emit_func)
3409 item->signal_emit_func((Elm_Object_Item *) item, emission, source);
3413 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3416 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3417 if (!item->text_get_func) return NULL;
3418 return item->text_get_func((Elm_Object_Item *) item, part);
3422 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3423 Elm_Widget_Content_Set_Cb func)
3425 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3426 item->content_set_func = func;
3430 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3431 Elm_Widget_Content_Get_Cb func)
3433 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3434 item->content_get_func = func;
3438 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3439 Elm_Widget_Content_Unset_Cb func)
3441 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3442 item->content_unset_func = func;
3446 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3447 Elm_Widget_Text_Set_Cb func)
3449 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3450 item->text_set_func = func;
3454 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3455 Elm_Widget_Text_Get_Cb func)
3457 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3458 item->text_get_func = func;
3462 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3463 Elm_Widget_Signal_Emit_Cb func)
3465 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3466 item->signal_emit_func = func;
3470 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3472 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3473 if (item->access_info) eina_stringshare_del(item->access_info);
3474 if (!txt) item->access_info = NULL;
3475 else item->access_info = eina_stringshare_add(txt);
3480 _smart_add(Evas_Object *obj)
3484 sd = calloc(1, sizeof(Smart_Data));
3487 sd->x = sd->y = sd->w = sd->h = 0;
3489 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3490 evas_object_smart_data_set(obj, sd);
3493 static Evas_Object *
3494 _newest_focus_order_get(Evas_Object *obj,
3495 unsigned int *newest_focus_order,
3496 Eina_Bool can_focus_only)
3499 Evas_Object *child, *ret, *best;
3501 API_ENTRY return NULL;
3503 if (!evas_object_visible_get(obj)
3504 || (elm_widget_disabled_get(obj))
3505 || (elm_widget_tree_unfocusable_get(obj)))
3509 if (*newest_focus_order < sd->focus_order)
3511 *newest_focus_order = sd->focus_order;
3514 EINA_LIST_FOREACH(sd->subobjs, l, child)
3516 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3522 if ((!best) || (!elm_widget_can_focus_get(best)))
3529 _if_focused_revert(Evas_Object *obj,
3530 Eina_Bool can_focus_only)
3533 Evas_Object *newest = NULL;
3534 unsigned int newest_focus_order = 0;
3538 if (!sd->focused) return;
3539 if (!sd->parent_obj) return;
3541 top = elm_widget_top_get(sd->parent_obj);
3544 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3547 elm_object_focus_set(newest, EINA_FALSE);
3548 elm_object_focus_set(newest, EINA_TRUE);
3554 _smart_del(Evas_Object *obj)
3557 Edje_Signal_Data *esd;
3558 Elm_Translate_String_Data *ts;
3562 if (sd->del_pre_func) sd->del_pre_func(obj);
3565 sobj = sd->resize_obj;
3566 sd->resize_obj = NULL;
3567 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3568 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3569 evas_object_del(sobj);
3570 sd->resize_obj = NULL;
3574 sobj = sd->hover_obj;
3575 sd->hover_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->hover_obj = NULL;
3581 EINA_LIST_FREE(sd->subobjs, sobj)
3583 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3584 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3585 evas_object_del(sobj);
3587 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3588 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3589 EINA_LIST_FREE(sd->edje_signals, esd)
3591 eina_stringshare_del(esd->emission);
3592 eina_stringshare_del(esd->source);
3595 EINA_LIST_FREE(sd->translate_strings, ts)
3597 eina_stringshare_del(ts->id);
3598 eina_stringshare_del(ts->domain);
3599 eina_stringshare_del(ts->string);
3602 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3603 if (sd->del_func) sd->del_func(obj);
3604 if (sd->style) eina_stringshare_del(sd->style);
3605 if (sd->type) eina_stringshare_del(sd->type);
3606 if (sd->theme) elm_theme_free(sd->theme);
3608 _if_focused_revert(obj, EINA_TRUE);
3609 if (sd->access_info) eina_stringshare_del(sd->access_info);
3611 evas_object_smart_data_set(obj, NULL);
3615 _smart_move(Evas_Object *obj,
3622 _smart_reconfigure(sd);
3626 _smart_resize(Evas_Object *obj,
3633 _smart_reconfigure(sd);
3637 _smart_show(Evas_Object *obj)
3642 if ((list = evas_object_smart_members_get(obj)))
3644 EINA_LIST_FREE(list, o)
3646 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3647 evas_object_show(o);
3653 _smart_hide(Evas_Object *obj)
3659 list = evas_object_smart_members_get(obj);
3660 EINA_LIST_FREE(list, o)
3662 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3663 evas_object_hide(o);
3668 _smart_color_set(Evas_Object *obj,
3677 if ((list = evas_object_smart_members_get(obj)))
3679 EINA_LIST_FREE(list, o)
3681 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3682 evas_object_color_set(o, r, g, b, a);
3688 _smart_clip_set(Evas_Object *obj,
3694 if ((list = evas_object_smart_members_get(obj)))
3696 EINA_LIST_FREE(list, o)
3698 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3699 evas_object_clip_set(o, clip);
3705 _smart_clip_unset(Evas_Object *obj)
3710 if ((list = evas_object_smart_members_get(obj)))
3712 EINA_LIST_FREE(list, o)
3714 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3715 evas_object_clip_unset(o);
3721 _smart_calculate(Evas_Object *obj)
3724 if (sd->changed_func) sd->changed_func(obj);
3727 /* never need to touch this */
3731 if (_e_smart) return;
3733 static const Evas_Smart_Class sc =
3736 EVAS_SMART_CLASS_VERSION,
3754 _e_smart = evas_smart_class_new(&sc);
3758 /* happy debug functions */
3761 _sub_obj_tree_dump(const Evas_Object *obj,
3766 for (i = 0; i < lvl * 3; i++)
3769 if (_elm_widget_is(obj))
3773 printf("+ %s(%p)\n",
3777 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3778 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3780 if (obj != sd->resize_obj)
3781 _sub_obj_tree_dump(obj, lvl + 1);
3785 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3789 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3792 if (!_elm_widget_is(obj))
3796 Eina_Bool visible = evas_object_visible_get(obj);
3797 Eina_Bool disabled = elm_widget_disabled_get(obj);
3798 Eina_Bool focused = elm_widget_focus_get(obj);
3799 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3803 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3806 fprintf(output, ", style=bold");
3809 fprintf(output, ", color=gray28");
3811 fprintf(output, " ];\n");
3814 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3815 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3816 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3820 fprintf(output, ", style=bold");
3823 fprintf(output, ", fontcolor=gray28");
3825 if ((disabled) || (!visible))
3826 fprintf(output, ", color=gray");
3828 fprintf(output, " ];\n");
3832 EINA_LIST_FOREACH(sd->subobjs, l, o)
3833 _sub_obj_tree_dot_dump(o, output);
3838 elm_widget_tree_dump(const Evas_Object *top)
3841 _sub_obj_tree_dump(top, 0);
3849 elm_widget_tree_dot_dump(const Evas_Object *top,
3853 if (!_elm_widget_is(top))
3855 fprintf(output, "graph " " { node [shape=record];\n");
3856 _sub_obj_tree_dot_dump(top, output);
3857 fprintf(output, "}\n");