1 #include <Elementary.h>
4 static const char SMART_NAME[] = "elm_widget";
7 Smart_Data * sd = evas_object_smart_data_get(obj); \
8 if ((!obj) || (!sd) || (!_elm_widget_is(obj)))
9 #define INTERNAL_ENTRY \
10 Smart_Data * sd = evas_object_smart_data_get(obj); \
13 #undef elm_widget_text_set_hook_set
14 #undef elm_widget_text_get_hook_set
15 #undef elm_widget_content_set_hook_set
16 #undef elm_widget_content_get_hook_set
17 #undef elm_widget_content_unset_hook_set
19 typedef struct _Smart_Data Smart_Data;
20 typedef struct _Edje_Signal_Data Edje_Signal_Data;
21 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
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_On_Text_Set_Cb on_text_set_func;
83 Elm_Widget_On_Text_Get_Cb on_text_get_func;
84 Elm_Widget_On_Content_Set_Cb on_content_set_func;
85 Elm_Widget_On_Content_Get_Cb on_content_get_func;
86 Elm_Widget_On_Content_Unset_Cb on_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 */
118 Eina_List *focus_chain;
122 struct _Edje_Signal_Data
126 const char *emission;
131 struct _Elm_Event_Cb_Data
137 struct _Elm_Translate_String_Data
144 /* local subsystem functions */
145 static void _smart_reconfigure(Smart_Data *sd);
146 static void _smart_add(Evas_Object *obj);
147 static void _smart_del(Evas_Object *obj);
148 static void _smart_move(Evas_Object *obj,
151 static void _smart_resize(Evas_Object *obj,
154 static void _smart_show(Evas_Object *obj);
155 static void _smart_hide(Evas_Object *obj);
156 static void _smart_color_set(Evas_Object *obj,
161 static void _smart_clip_set(Evas_Object *obj,
163 static void _smart_clip_unset(Evas_Object *obj);
164 static void _smart_calculate(Evas_Object *obj);
165 static void _smart_init(void);
167 static void _if_focused_revert(Evas_Object *obj,
168 Eina_Bool can_focus_only);
169 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
170 unsigned int *newest_focus_order,
171 Eina_Bool can_focus_only);
173 /* local subsystem globals */
174 static Evas_Smart *_e_smart = NULL;
175 static Eina_List *widtypes = NULL;
177 static unsigned int focus_order = 0;
180 static inline Eina_Bool
181 _elm_widget_is(const Evas_Object *obj)
183 const char *type = evas_object_type_get(obj);
184 return type == SMART_NAME;
187 static inline Eina_Bool
188 _is_focusable(Evas_Object *obj)
190 API_ENTRY return EINA_FALSE;
191 return sd->can_focus || (sd->child_can_focus);
195 _unfocus_parents(Evas_Object *obj)
197 for (; obj; obj = elm_widget_parent_get(obj))
200 if (!sd->focused) return;
206 _focus_parents(Evas_Object *obj)
208 for (; obj; obj = elm_widget_parent_get(obj))
211 if (sd->focused) return;
217 _sub_obj_del(void *data,
220 void *event_info __UNUSED__)
222 Smart_Data *sd = data;
224 if (_elm_widget_is(obj))
226 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
228 if (obj == sd->resize_obj)
229 sd->resize_obj = NULL;
230 else if (obj == sd->hover_obj)
231 sd->hover_obj = NULL;
233 sd->subobjs = eina_list_remove(sd->subobjs, obj);
234 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
238 _sub_obj_hide(void *data __UNUSED__,
241 void *event_info __UNUSED__)
243 elm_widget_focus_hide_handle(obj);
247 _sub_obj_mouse_up(void *data __UNUSED__,
252 Evas_Event_Mouse_Up *ev = event_info;
253 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
254 elm_widget_focus_mouse_up_handle(obj);
258 _propagate_x_drag_lock(Evas_Object *obj,
264 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
267 sd2->child_drag_x_locked += dir;
268 _propagate_x_drag_lock(sd->parent_obj, dir);
274 _propagate_y_drag_lock(Evas_Object *obj,
280 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
283 sd2->child_drag_y_locked += dir;
284 _propagate_y_drag_lock(sd->parent_obj, dir);
290 _propagate_event(void *data,
296 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
297 Evas_Event_Flags *event_flags = NULL;
301 case EVAS_CALLBACK_KEY_DOWN:
303 Evas_Event_Key_Down *ev = event_info;
304 event_flags = &(ev->event_flags);
308 case EVAS_CALLBACK_KEY_UP:
310 Evas_Event_Key_Up *ev = event_info;
311 event_flags = &(ev->event_flags);
315 case EVAS_CALLBACK_MOUSE_WHEEL:
317 Evas_Event_Mouse_Wheel *ev = event_info;
318 event_flags = &(ev->event_flags);
326 elm_widget_event_propagate(obj, type, event_info, event_flags);
330 _parent_focus(Evas_Object *obj)
333 if (sd->focused) return;
335 Evas_Object *o = elm_widget_parent_get(obj);
336 sd->focus_order_on_calc = EINA_TRUE;
338 if (o) _parent_focus(o);
340 if (!sd->focus_order_on_calc)
341 return; /* we don't want to override it if by means of any of the
342 callbacks below one gets to calculate our order
346 sd->focus_order = focus_order;
347 if (sd->top_win_focused)
349 sd->focused = EINA_TRUE;
350 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
351 if (sd->focus_func) sd->focus_func(obj);
352 _elm_widget_focus_region_show(obj);
354 sd->focus_order_on_calc = EINA_FALSE;
358 _elm_object_focus_chain_del_cb(void *data,
361 void *event_info __UNUSED__)
363 Smart_Data *sd = data;
365 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
368 // exposed util funcs to elm
370 _elm_widget_type_clear(void)
374 EINA_LIST_FREE(widtypes, ptr)
376 eina_stringshare_del(*ptr);
382 _elm_widget_focus_region_show(const Evas_Object *obj)
384 Evas_Coord x, y, w, h, ox, oy;
390 o = elm_widget_parent_get(obj);
393 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
394 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
398 sd2 = evas_object_smart_data_get(o);
399 if (sd2->focus_region_func)
401 sd2->focus_region_func(o, x, y, w, h);
402 elm_widget_focus_region_get(o, &x, &y, &w, &h);
406 evas_object_geometry_get(o, &px, &py, NULL, NULL);
412 o = elm_widget_parent_get(o);
417 * @defgroup Widget Widget
420 * Exposed api for making widgets
423 elm_widget_type_register(const char **ptr)
425 widtypes = eina_list_append(widtypes, (void *)ptr);
429 * @defgroup Widget Widget
432 * Disposed api for making widgets
435 elm_widget_type_unregister(const char **ptr)
437 widtypes = eina_list_remove(widtypes, (void *)ptr);
441 elm_widget_api_check(int ver)
443 if (ver != ELM_INTERNAL_API_VERSION)
445 CRITICAL("Elementary widget api versions do not match");
452 elm_widget_add(Evas *evas)
456 obj = evas_object_smart_add(evas, _e_smart);
457 elm_widget_mirrored_set(obj, elm_mirrored_get());
462 elm_widget_del_hook_set(Evas_Object *obj,
463 void (*func)(Evas_Object *obj))
470 elm_widget_del_pre_hook_set(Evas_Object *obj,
471 void (*func)(Evas_Object *obj))
474 sd->del_pre_func = func;
478 elm_widget_focus_hook_set(Evas_Object *obj,
479 void (*func)(Evas_Object *obj))
482 sd->focus_func = func;
486 elm_widget_activate_hook_set(Evas_Object *obj,
487 void (*func)(Evas_Object *obj))
490 sd->activate_func = func;
494 elm_widget_disable_hook_set(Evas_Object *obj,
495 void (*func)(Evas_Object *obj))
498 sd->disable_func = func;
502 elm_widget_theme_hook_set(Evas_Object *obj,
503 void (*func)(Evas_Object *obj))
506 sd->theme_func = func;
510 elm_widget_translate_hook_set(Evas_Object *obj,
511 void (*func)(Evas_Object *obj))
514 sd->translate_func = func;
518 elm_widget_event_hook_set(Evas_Object *obj,
519 Eina_Bool (*func)(Evas_Object *obj,
521 Evas_Callback_Type type,
525 sd->event_func = func;
529 elm_widget_text_set_hook_set(Evas_Object *obj,
530 Elm_Widget_On_Text_Set_Cb func)
533 sd->on_text_set_func = func;
537 elm_widget_text_get_hook_set(Evas_Object *obj,
538 Elm_Widget_On_Text_Get_Cb func)
541 sd->on_text_get_func = func;
545 elm_widget_content_set_hook_set(Evas_Object *obj,
546 Elm_Widget_On_Content_Set_Cb func)
549 sd->on_content_set_func = func;
553 elm_widget_content_get_hook_set(Evas_Object *obj,
554 Elm_Widget_On_Content_Get_Cb func)
557 sd->on_content_get_func = func;
561 elm_widget_content_unset_hook_set(Evas_Object *obj,
562 Elm_Widget_On_Content_Unset_Cb func)
565 sd->on_content_unset_func = func;
569 elm_widget_changed_hook_set(Evas_Object *obj,
570 void (*func)(Evas_Object *obj))
573 sd->changed_func = func;
577 elm_widget_signal_emit_hook_set(Evas_Object *obj,
578 void (*func)(Evas_Object *obj,
579 const char *emission,
583 sd->signal_func = func;
587 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
588 void (*func)(Evas_Object *obj,
589 const char *emission,
591 Edje_Signal_Cb func_cb,
595 sd->callback_add_func = func;
599 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
600 void (*func)(Evas_Object *obj,
601 const char *emission,
603 Edje_Signal_Cb func_cb,
607 sd->callback_del_func = func;
611 elm_widget_theme(Evas_Object *obj)
619 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
620 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
621 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
622 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
623 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
624 if (sd->theme_func) sd->theme_func(obj);
628 elm_widget_theme_specific(Evas_Object *obj,
636 Elm_Theme *th2, *thdef;
639 thdef = elm_theme_default_get();
644 if (!th2) th2 = thdef;
652 if (th2 == thdef) break;
653 th2 = th2->ref_theme;
654 if (!th2) th2 = thdef;
658 EINA_LIST_FOREACH(sd->subobjs, l, child)
659 elm_widget_theme_specific(child, th, force);
660 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
661 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
662 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
663 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
664 if (sd->theme_func) sd->theme_func(obj);
670 * Set hook to get next object in object focus chain.
672 * @param obj The widget object.
673 * @param func The hook to be used with this widget.
678 elm_widget_focus_next_hook_set(Evas_Object *obj,
679 Eina_Bool (*func)(const Evas_Object *obj,
680 Elm_Focus_Direction dir,
684 sd->focus_next_func = func;
688 * Returns the widget's mirrored mode.
690 * @param obj The widget.
691 * @return mirrored mode of the object.
695 elm_widget_mirrored_get(const Evas_Object *obj)
697 API_ENTRY return EINA_FALSE;
698 return sd->is_mirrored;
702 * Sets the widget's mirrored mode.
704 * @param obj The widget.
705 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
708 elm_widget_mirrored_set(Evas_Object *obj,
712 if (sd->is_mirrored != mirrored)
714 sd->is_mirrored = mirrored;
715 elm_widget_theme(obj);
721 * Resets the mirrored mode from the system mirror mode for widgets that are in
722 * automatic mirroring mode. This function does not call elm_widget_theme.
724 * @param obj The widget.
725 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
728 _elm_widget_mirrored_reload(Evas_Object *obj)
731 Eina_Bool mirrored = elm_mirrored_get();
732 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
734 sd->is_mirrored = mirrored;
739 * Returns the widget's mirrored mode setting.
741 * @param obj The widget.
742 * @return mirrored mode setting of the object.
746 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
748 API_ENTRY return EINA_FALSE;
749 return sd->mirrored_auto_mode;
753 * Sets the widget's mirrored mode setting.
754 * When widget in automatic mode, it follows the system mirrored mode set by
755 * elm_mirrored_set().
756 * @param obj The widget.
757 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
760 elm_widget_mirrored_automatic_set(Evas_Object *obj,
764 if (sd->mirrored_auto_mode != automatic)
766 sd->mirrored_auto_mode = automatic;
770 elm_widget_mirrored_set(obj, elm_mirrored_get());
776 elm_widget_on_focus_hook_set(Evas_Object *obj,
777 void (*func)(void *data,
782 sd->on_focus_func = func;
783 sd->on_focus_data = data;
787 elm_widget_on_change_hook_set(Evas_Object *obj,
788 void (*func)(void *data,
793 sd->on_change_func = func;
794 sd->on_change_data = data;
798 elm_widget_on_show_region_hook_set(Evas_Object *obj,
799 void (*func)(void *data,
804 sd->on_show_region_func = func;
805 sd->on_show_region_data = data;
811 * Set the hook to use to show the focused region.
813 * Whenever a new widget gets focused or it's needed to show the focused
814 * area of the current one, this hook will be called on objects that may
815 * want to move their children into their visible area.
816 * The area given in the hook function is relative to the @p obj widget.
818 * @param obj The widget object
819 * @param func The function to call to show the specified area.
824 elm_widget_focus_region_hook_set(Evas_Object *obj,
825 void (*func)(Evas_Object *obj,
832 sd->focus_region_func = func;
838 * Set the hook to retrieve the focused region of a widget.
840 * This hook will be called by elm_widget_focus_region_get() whenever
841 * it's needed to get the focused area of a widget. The area must be relative
842 * to the widget itself and if no hook is set, it will default to the entire
845 * @param obj The widget object
846 * @param func The function used to retrieve the focus region.
851 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
852 void (*func)(const Evas_Object *obj,
859 sd->on_focus_region_func = func;
863 elm_widget_data_set(Evas_Object *obj,
871 elm_widget_data_get(const Evas_Object *obj)
873 API_ENTRY return NULL;
878 elm_widget_sub_object_add(Evas_Object *obj,
882 double scale, pscale = elm_widget_scale_get(sobj);
883 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
884 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
886 if (_elm_widget_is(sobj))
888 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
891 if (sd2->parent_obj == obj)
894 elm_widget_sub_object_del(sd2->parent_obj, sobj);
895 sd2->parent_obj = obj;
896 sd2->top_win_focused = sd->top_win_focused;
897 if (!sd->child_can_focus && (_is_focusable(sobj)))
898 sd->child_can_focus = EINA_TRUE;
903 void *data = evas_object_data_get(sobj, "elm-parent");
906 if (data == obj) return;
907 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
912 sd->subobjs = eina_list_append(sd->subobjs, sobj);
913 evas_object_data_set(sobj, "elm-parent", obj);
914 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
915 if (_elm_widget_is(sobj))
916 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
917 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
918 scale = elm_widget_scale_get(sobj);
919 th = elm_widget_theme_get(sobj);
920 mirrored = elm_widget_mirrored_get(sobj);
921 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
922 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
926 elm_widget_sub_object_del(Evas_Object *obj,
929 Evas_Object *sobj_parent;
933 sobj_parent = evas_object_data_del(sobj, "elm-parent");
934 if (sobj_parent != obj)
936 static int abort_on_warn = -1;
937 ERR("removing sub object %p from parent %p, "
938 "but elm-parent is different %p!",
939 sobj, obj, sobj_parent);
940 if (EINA_UNLIKELY(abort_on_warn == -1))
942 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
943 else abort_on_warn = 0;
945 if (abort_on_warn == 1) abort();
947 if (_elm_widget_is(sobj))
949 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
952 sd2->parent_obj = NULL;
953 if (sd2->resize_obj == sobj)
954 sd2->resize_obj = NULL;
956 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
959 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
960 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
961 if ((sd->child_can_focus) && (_is_focusable(sobj)))
965 sd->child_can_focus = EINA_FALSE;
966 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
968 if (_is_focusable(subobj))
970 sd->child_can_focus = EINA_TRUE;
977 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
978 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
980 if (_elm_widget_is(sobj))
981 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
983 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
987 elm_widget_resize_object_set(Evas_Object *obj,
991 // orphan previous resize obj
994 evas_object_clip_unset(sd->resize_obj);
995 evas_object_data_del(sd->resize_obj, "elm-parent");
996 if (_elm_widget_is(sd->resize_obj))
998 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
999 if (sd2) sd2->parent_obj = NULL;
1000 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1003 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1005 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1006 _sub_obj_mouse_up, sd);
1007 evas_object_smart_member_del(sd->resize_obj);
1008 if (_elm_widget_is(sd->resize_obj))
1010 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1014 sd->resize_obj = sobj;
1017 // orphan new resize obj
1018 evas_object_data_del(sobj, "elm-parent");
1019 if (_elm_widget_is(sobj))
1021 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1022 if (sd2) sd2->parent_obj = NULL;
1023 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1026 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1028 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1029 _sub_obj_mouse_up, sd);
1030 evas_object_smart_member_del(sobj);
1031 if (_elm_widget_is(sobj))
1033 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1036 // set the resize obj up
1037 if (_elm_widget_is(sobj))
1039 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1042 sd2->parent_obj = obj;
1043 sd2->top_win_focused = sd->top_win_focused;
1045 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1048 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1049 evas_object_smart_member_add(sobj, obj);
1050 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1052 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1053 _sub_obj_mouse_up, sd);
1054 _smart_reconfigure(sd);
1055 evas_object_data_set(sobj, "elm-parent", obj);
1056 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1057 if (_elm_widget_is(sobj))
1059 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1064 elm_widget_hover_object_set(Evas_Object *obj,
1070 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1073 sd->hover_obj = sobj;
1076 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1078 _smart_reconfigure(sd);
1083 elm_widget_can_focus_set(Evas_Object *obj,
1084 Eina_Bool can_focus)
1087 sd->can_focus = can_focus;
1090 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1092 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1093 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1095 (void *)(long)EVAS_CALLBACK_KEY_UP);
1096 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1098 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1102 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1104 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1106 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1112 elm_widget_can_focus_get(const Evas_Object *obj)
1114 API_ENTRY return EINA_FALSE;
1115 return sd->can_focus;
1119 elm_widget_child_can_focus_get(const Evas_Object *obj)
1121 API_ENTRY return EINA_FALSE;
1122 return sd->child_can_focus;
1128 * This API makes the widget object and its children to be unfocusable.
1130 * This API can be helpful for an object to be deleted.
1131 * When an object will be deleted soon, it and its children may not
1132 * want to get focus (by focus reverting or by other focus controls).
1133 * Then, just use this API before deleting.
1135 * @param obj The widget root of sub-tree
1136 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1141 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1142 Eina_Bool tree_unfocusable)
1146 if (sd->tree_unfocusable == tree_unfocusable) return;
1147 sd->tree_unfocusable = !!tree_unfocusable;
1148 elm_widget_focus_tree_unfocusable_handle(obj);
1154 * This returns true, if the object sub-tree is unfocusable.
1156 * @param obj The widget root of sub-tree
1157 * @return EINA_TRUE if the object sub-tree is unfocusable
1162 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1164 API_ENTRY return EINA_FALSE;
1165 return sd->tree_unfocusable;
1171 * Get the list of focusable child objects.
1173 * This function retruns list of child objects which can get focus.
1175 * @param obj The parent widget
1176 * @retrun list of focusable child objects.
1181 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1183 API_ENTRY return NULL;
1186 Eina_List *child_list = NULL;
1191 EINA_LIST_FOREACH(sd->subobjs, l, child)
1193 if ((elm_widget_can_focus_get(child)) &&
1194 (evas_object_visible_get(child)) &&
1195 (!elm_widget_disabled_get(child)))
1196 child_list = eina_list_append(child_list, child);
1197 else if (elm_widget_is(child))
1199 Eina_List *can_focus_list;
1200 can_focus_list = elm_widget_can_focus_child_list_get(child);
1202 child_list = eina_list_merge(child_list, can_focus_list);
1210 elm_widget_highlight_ignore_set(Evas_Object *obj,
1214 sd->highlight_ignore = !!ignore;
1218 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1220 API_ENTRY return EINA_FALSE;
1221 return sd->highlight_ignore;
1225 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1226 Eina_Bool highlight)
1229 sd->highlight_in_theme = !!highlight;
1230 /* FIXME: if focused, it should switch from one mode to the other */
1234 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1236 API_ENTRY return EINA_FALSE;
1237 return sd->highlight_in_theme;
1241 elm_widget_focus_get(const Evas_Object *obj)
1243 API_ENTRY return EINA_FALSE;
1248 elm_widget_focused_object_get(const Evas_Object *obj)
1250 const Evas_Object *subobj;
1252 API_ENTRY return NULL;
1254 if (!sd->focused) return NULL;
1255 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1257 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1258 if (fobj) return fobj;
1260 return (Evas_Object *)obj;
1264 elm_widget_top_get(const Evas_Object *obj)
1266 API_ENTRY return NULL;
1267 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1268 return (Evas_Object *)obj;
1272 elm_widget_is(const Evas_Object *obj)
1274 return _elm_widget_is(obj);
1278 elm_widget_parent_widget_get(const Evas_Object *obj)
1280 Evas_Object *parent;
1282 if (_elm_widget_is(obj))
1284 Smart_Data *sd = evas_object_smart_data_get(obj);
1285 if (!sd) return NULL;
1286 parent = sd->parent_obj;
1290 parent = evas_object_data_get(obj, "elm-parent");
1291 if (!parent) parent = evas_object_smart_parent_get(obj);
1296 Evas_Object *elm_parent;
1297 if (_elm_widget_is(parent)) break;
1298 elm_parent = evas_object_data_get(parent, "elm-parent");
1299 if (elm_parent) parent = elm_parent;
1300 else parent = evas_object_smart_parent_get(parent);
1306 elm_widget_parent2_get(const Evas_Object *obj)
1308 if (_elm_widget_is(obj))
1310 Smart_Data *sd = evas_object_smart_data_get(obj);
1311 if (sd) return sd->parent2;
1317 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1320 sd->parent2 = parent;
1324 elm_widget_event_callback_add(Evas_Object *obj,
1329 EINA_SAFETY_ON_NULL_RETURN(func);
1330 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1333 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1337 elm_widget_event_callback_del(Evas_Object *obj,
1341 API_ENTRY return NULL;
1342 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1344 Elm_Event_Cb_Data *ecd;
1345 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1346 if ((ecd->func == func) && (ecd->data == data))
1349 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1350 return (void *)data;
1356 elm_widget_event_propagate(Evas_Object *obj,
1357 Evas_Callback_Type type,
1359 Evas_Event_Flags *event_flags)
1361 API_ENTRY return EINA_FALSE; //TODO reduce.
1362 if (!_elm_widget_is(obj)) return EINA_FALSE;
1363 Evas_Object *parent = obj;
1364 Elm_Event_Cb_Data *ecd;
1365 Eina_List *l, *l_prev;
1368 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1370 sd = evas_object_smart_data_get(parent);
1371 if ((!sd) || (!_elm_widget_is(obj)))
1372 return EINA_FALSE; //Not Elm Widget
1374 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1377 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1379 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1380 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1383 parent = sd->parent_obj;
1392 * Set custom focus chain.
1394 * This function i set one new and overwrite any previous custom focus chain
1395 * with the list of objects. The previous list will be deleted and this list
1396 * will be managed. After setted, don't modity it.
1398 * @note On focus cycle, only will be evaluated children of this container.
1400 * @param obj The container widget
1401 * @param objs Chain of objects to pass focus
1405 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1409 if (!sd->focus_next_func)
1412 elm_widget_focus_custom_chain_unset(obj);
1417 EINA_LIST_FOREACH(objs, l, o)
1419 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1420 _elm_object_focus_chain_del_cb, sd);
1423 sd->focus_chain = objs;
1429 * Get custom focus chain
1431 * @param obj The container widget
1434 EAPI const Eina_List *
1435 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1437 API_ENTRY return NULL;
1438 return (const Eina_List *)sd->focus_chain;
1444 * Unset custom focus chain
1446 * @param obj The container widget
1450 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1453 Eina_List *l, *l_next;
1456 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1458 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1459 _elm_object_focus_chain_del_cb, sd);
1460 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1467 * Append object to custom focus chain.
1469 * @note If relative_child equal to NULL or not in custom chain, the object
1470 * will be added in end.
1472 * @note On focus cycle, only will be evaluated children of this container.
1474 * @param obj The container widget
1475 * @param child The child to be added in custom chain
1476 * @param relative_child The relative object to position the child
1480 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1482 Evas_Object *relative_child)
1485 EINA_SAFETY_ON_NULL_RETURN(child);
1486 if (!sd->focus_next_func)
1489 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1490 _elm_object_focus_chain_del_cb, sd);
1492 if (!relative_child)
1494 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1498 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1505 * Prepend object to custom focus chain.
1507 * @note If relative_child equal to NULL or not in custom chain, the object
1508 * will be added in begin.
1510 * @note On focus cycle, only will be evaluated children of this container.
1512 * @param obj The container widget
1513 * @param child The child to be added in custom chain
1514 * @param relative_child The relative object to position the child
1518 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1520 Evas_Object *relative_child)
1523 EINA_SAFETY_ON_NULL_RETURN(child);
1524 if (!sd->focus_next_func)
1527 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1528 _elm_object_focus_chain_del_cb, sd);
1530 if (!relative_child)
1532 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1536 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1543 * Give focus to next object in object tree.
1545 * Give focus to next object in focus chain of one object sub-tree.
1546 * If the last object of chain already have focus, the focus will go to the
1547 * first object of chain.
1549 * @param obj The widget root of sub-tree
1550 * @param dir Direction to cycle the focus
1555 elm_widget_focus_cycle(Evas_Object *obj,
1556 Elm_Focus_Direction dir)
1558 Evas_Object *target = NULL;
1559 if (!_elm_widget_is(obj))
1561 elm_widget_focus_next_get(obj, dir, &target);
1563 elm_widget_focus_steal(target);
1569 * Give focus to near object in one direction.
1571 * Give focus to near object in direction of one object.
1572 * If none focusable object in given direction, the focus will not change.
1574 * @param obj The reference widget
1575 * @param x Horizontal component of direction to focus
1576 * @param y Vertical component of direction to focus
1581 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1591 * Get next object in focus chain of object tree.
1593 * Get next object in focus chain of one object sub-tree.
1594 * Return the next object by reference. If don't have any candidate to receive
1595 * focus before chain end, the first candidate will be returned.
1597 * @param obj The widget root of sub-tree
1598 * @param dir Direction os focus chain
1599 * @param next The next object in focus chain
1600 * @return EINA_TRUE if don't need focus chain restart/loop back
1601 * to use 'next' obj.
1606 elm_widget_focus_next_get(const Evas_Object *obj,
1607 Elm_Focus_Direction dir,
1614 API_ENTRY return EINA_FALSE;
1616 /* Ignore if disabled */
1617 if ((!evas_object_visible_get(obj))
1618 || (elm_widget_disabled_get(obj))
1619 || (elm_widget_tree_unfocusable_get(obj)))
1623 if (sd->focus_next_func)
1624 return sd->focus_next_func(obj, dir, next);
1626 if (!elm_widget_can_focus_get(obj))
1630 *next = (Evas_Object *)obj;
1631 return !elm_widget_focus_get(obj);
1637 * Get next object in focus chain of object tree in list.
1639 * Get next object in focus chain of one object sub-tree ordered by one list.
1640 * Return the next object by reference. If don't have any candidate to receive
1641 * focus before list end, the first candidate will be returned.
1643 * @param obj The widget root of sub-tree
1644 * @param dir Direction os focus chain
1645 * @param items list with ordered objects
1646 * @param list_data_get function to get the object from one item of list
1647 * @param next The next object in focus chain
1648 * @return EINA_TRUE if don't need focus chain restart/loop back
1649 * to use 'next' obj.
1654 elm_widget_focus_list_next_get(const Evas_Object *obj,
1655 const Eina_List *items,
1656 void *(*list_data_get)(const Eina_List * list),
1657 Elm_Focus_Direction dir,
1660 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1666 if (!_elm_widget_is(obj))
1673 if (dir == ELM_FOCUS_PREVIOUS)
1675 items = eina_list_last(items);
1676 list_next = eina_list_prev;
1678 else if (dir == ELM_FOCUS_NEXT)
1679 list_next = eina_list_next;
1683 const Eina_List *l = items;
1685 /* Recovery last focused sub item */
1686 if (elm_widget_focus_get(obj))
1687 for (; l; l = list_next(l))
1689 Evas_Object *cur = list_data_get(l);
1690 if (elm_widget_focus_get(cur)) break;
1693 const Eina_List *start = l;
1694 Evas_Object *to_focus = NULL;
1696 /* Interate sub items */
1697 /* Go to end of list */
1698 for (; l; l = list_next(l))
1700 Evas_Object *tmp = NULL;
1701 Evas_Object *cur = list_data_get(l);
1703 if (elm_widget_parent_get(cur) != obj)
1706 /* Try Focus cycle in subitem */
1707 if (elm_widget_focus_next_get(cur, dir, &tmp))
1712 else if ((tmp) && (!to_focus))
1718 /* Get First possible */
1719 for (; l != start; l = list_next(l))
1721 Evas_Object *tmp = NULL;
1722 Evas_Object *cur = list_data_get(l);
1724 if (elm_widget_parent_get(cur) != obj)
1727 /* Try Focus cycle in subitem */
1728 elm_widget_focus_next_get(cur, dir, &tmp);
1741 elm_widget_signal_emit(Evas_Object *obj,
1742 const char *emission,
1746 if (!sd->signal_func) return;
1747 sd->signal_func(obj, emission, source);
1751 _edje_signal_callback(void *data,
1752 Evas_Object *obj __UNUSED__,
1753 const char *emission,
1756 Edje_Signal_Data *esd = data;
1757 esd->func(esd->data, esd->obj, emission, source);
1761 elm_widget_signal_callback_add(Evas_Object *obj,
1762 const char *emission,
1764 Edje_Signal_Cb func,
1767 Edje_Signal_Data *esd;
1769 if (!sd->callback_add_func) return;
1770 EINA_SAFETY_ON_NULL_RETURN(func);
1772 esd = ELM_NEW(Edje_Signal_Data);
1777 esd->emission = eina_stringshare_add(emission);
1778 esd->source = eina_stringshare_add(source);
1780 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1781 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1785 elm_widget_signal_callback_del(Evas_Object *obj,
1786 const char *emission,
1788 Edje_Signal_Cb func)
1790 Edje_Signal_Data *esd;
1793 API_ENTRY return NULL;
1794 if (!sd->callback_del_func) return NULL;
1796 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1798 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1799 (!strcmp(esd->source, source)))
1801 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1802 eina_stringshare_del(esd->emission);
1803 eina_stringshare_del(esd->source);
1809 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1814 elm_widget_focus_set(Evas_Object *obj,
1821 sd->focus_order = focus_order;
1822 sd->focused = EINA_TRUE;
1823 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1827 sd->focus_func(obj);
1834 if ((_is_focusable(sd->resize_obj)) &&
1835 (!elm_widget_disabled_get(sd->resize_obj)))
1837 elm_widget_focus_set(sd->resize_obj, first);
1843 EINA_LIST_FOREACH(sd->subobjs, l, child)
1845 if ((_is_focusable(child)) &&
1846 (!elm_widget_disabled_get(child)))
1848 elm_widget_focus_set(child, first);
1858 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1860 if ((_is_focusable(child)) &&
1861 (!elm_widget_disabled_get(child)))
1863 elm_widget_focus_set(child, first);
1869 if ((_is_focusable(sd->resize_obj)) &&
1870 (!elm_widget_disabled_get(sd->resize_obj)))
1872 elm_widget_focus_set(sd->resize_obj, first);
1880 elm_widget_parent_get(const Evas_Object *obj)
1882 API_ENTRY return NULL;
1883 return sd->parent_obj;
1887 elm_widget_focused_object_clear(Evas_Object *obj)
1890 if (!sd->focused) return;
1891 if (elm_widget_focus_get(sd->resize_obj))
1892 elm_widget_focused_object_clear(sd->resize_obj);
1897 EINA_LIST_FOREACH(sd->subobjs, l, child)
1899 if (elm_widget_focus_get(child))
1901 elm_widget_focused_object_clear(child);
1906 sd->focused = EINA_FALSE;
1907 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1908 if (sd->focus_func) sd->focus_func(obj);
1912 elm_widget_focus_steal(Evas_Object *obj)
1914 Evas_Object *parent, *parent2, *o;
1917 if (sd->focused) return;
1918 if (sd->disabled) return;
1919 if (!sd->can_focus) return;
1920 if (sd->tree_unfocusable) return;
1924 o = elm_widget_parent_get(parent);
1926 sd = evas_object_smart_data_get(o);
1927 if (sd->disabled || sd->tree_unfocusable) return;
1928 if (sd->focused) break;
1931 if ((!elm_widget_parent_get(parent)) &&
1932 (!elm_widget_parent2_get(parent)))
1933 elm_widget_focused_object_clear(parent);
1936 parent2 = elm_widget_parent_get(parent);
1937 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1939 sd = evas_object_smart_data_get(parent);
1942 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1943 elm_widget_focused_object_clear(sd->resize_obj);
1948 EINA_LIST_FOREACH(sd->subobjs, l, child)
1950 if (elm_widget_focus_get(child))
1952 elm_widget_focused_object_clear(child);
1964 elm_widget_focus_restore(Evas_Object *obj)
1966 Evas_Object *newest = NULL;
1967 unsigned int newest_focus_order = 0;
1970 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1973 elm_object_focus_set(newest, EINA_FALSE);
1974 elm_object_focus_set(newest, EINA_TRUE);
1979 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1985 if (sd->top_win_focused == top_win_focused) return;
1987 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1988 EINA_LIST_FOREACH(sd->subobjs, l, child)
1990 _elm_widget_top_win_focused_set(child, top_win_focused);
1992 sd->top_win_focused = top_win_focused;
1996 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1998 API_ENTRY return EINA_FALSE;
1999 return sd->top_win_focused;
2003 elm_widget_activate(Evas_Object *obj)
2006 elm_widget_change(obj);
2007 if (sd->activate_func) sd->activate_func(obj);
2011 elm_widget_change(Evas_Object *obj)
2014 elm_widget_change(elm_widget_parent_get(obj));
2015 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2019 elm_widget_disabled_set(Evas_Object *obj,
2024 if (sd->disabled == disabled) return;
2025 sd->disabled = !!disabled;
2026 elm_widget_focus_disabled_handle(obj);
2027 if (sd->disable_func) sd->disable_func(obj);
2031 elm_widget_disabled_get(const Evas_Object *obj)
2034 return sd->disabled;
2038 elm_widget_show_region_set(Evas_Object *obj,
2043 Eina_Bool forceshow)
2045 Evas_Object *parent_obj, *child_obj;
2046 Evas_Coord px, py, cx, cy;
2049 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2050 && (w == sd->rw) && (h == sd->rh)) return;
2055 if (sd->on_show_region_func)
2056 sd->on_show_region_func(sd->on_show_region_data, obj);
2060 parent_obj = sd->parent_obj;
2061 child_obj = sd->obj;
2062 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2063 sd = evas_object_smart_data_get(parent_obj);
2066 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2067 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2076 if (sd->on_show_region_func)
2078 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2085 elm_widget_show_region_get(const Evas_Object *obj,
2101 * Get the focus region of the given widget.
2103 * The focus region is the area of a widget that should brought into the
2104 * visible area when the widget is focused. Mostly used to show the part of
2105 * an entry where the cursor is, for example. The area returned is relative
2106 * to the object @p obj.
2107 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2108 * function will return the full size of the object.
2110 * @param obj The widget object
2111 * @param x Where to store the x coordinate of the area
2112 * @param y Where to store the y coordinate of the area
2113 * @param w Where to store the width of the area
2114 * @param h Where to store the height of the area
2119 elm_widget_focus_region_get(const Evas_Object *obj,
2129 sd = evas_object_smart_data_get(obj);
2130 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2132 evas_object_geometry_get(obj, NULL, NULL, w, h);
2137 sd->on_focus_region_func(obj, x, y, w, h);
2141 elm_widget_scroll_hold_push(Evas_Object *obj)
2145 if (sd->scroll_hold == 1)
2146 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2147 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2148 // FIXME: on delete/reparent hold pop
2152 elm_widget_scroll_hold_pop(Evas_Object *obj)
2156 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2157 if (!sd->scroll_hold)
2158 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2159 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2163 elm_widget_scroll_hold_get(const Evas_Object *obj)
2166 return sd->scroll_hold;
2170 elm_widget_scroll_freeze_push(Evas_Object *obj)
2173 sd->scroll_freeze++;
2174 if (sd->scroll_freeze == 1)
2175 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2176 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2177 // FIXME: on delete/reparent freeze pop
2181 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2184 sd->scroll_freeze--;
2185 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2186 if (!sd->scroll_freeze)
2187 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2188 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2192 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2195 return sd->scroll_freeze;
2199 elm_widget_scale_set(Evas_Object *obj,
2203 if (scale <= 0.0) scale = 0.0;
2204 if (sd->scale != scale)
2207 elm_widget_theme(obj);
2212 elm_widget_scale_get(const Evas_Object *obj)
2214 API_ENTRY return 1.0;
2215 // FIXME: save walking up the tree by storing/caching parent scale
2216 if (sd->scale == 0.0)
2219 return elm_widget_scale_get(sd->parent_obj);
2227 elm_widget_theme_set(Evas_Object *obj,
2231 if (sd->theme != th)
2233 if (sd->theme) elm_theme_free(sd->theme);
2236 elm_widget_theme(obj);
2241 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2245 if (!sd->on_text_set_func)
2248 sd->on_text_set_func(obj, part, label);
2252 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2254 API_ENTRY return NULL;
2256 if (!sd->on_text_get_func)
2259 return sd->on_text_get_func(obj, part);
2263 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2267 Elm_Translate_String_Data *ts = NULL;
2270 str = eina_stringshare_add(part);
2271 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2278 eina_stringshare_del(str);
2281 ts = malloc(sizeof(Elm_Translate_String_Data));
2285 ts->domain = eina_stringshare_add(domain);
2286 ts->string = eina_stringshare_add(label);
2287 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2293 eina_stringshare_replace(&ts->domain, domain);
2294 eina_stringshare_replace(&ts->string, label);
2298 sd->translate_strings = eina_list_remove_list(
2299 sd->translate_strings, l);
2300 eina_stringshare_del(ts->id);
2301 eina_stringshare_del(ts->domain);
2302 eina_stringshare_del(ts->string);
2305 eina_stringshare_del(str);
2309 if (label && label[0])
2310 label = dgettext(domain, label);
2312 elm_widget_text_part_set(obj, part, label);
2316 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2318 const char *str, *ret = NULL;
2320 Elm_Translate_String_Data *ts;
2321 API_ENTRY return NULL;
2323 str = eina_stringshare_add(part);
2324 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2330 eina_stringshare_del(str);
2335 elm_widget_translate(Evas_Object *obj)
2339 Elm_Translate_String_Data *ts;
2342 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2343 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2344 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2345 if (sd->translate_func) sd->translate_func(obj);
2348 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2350 const char *s = dgettext(ts->domain, ts->string);
2351 elm_widget_text_part_set(obj, ts->id, s);
2357 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2361 if (!sd->on_content_set_func) return;
2362 sd->on_content_set_func(obj, part, content);
2366 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2368 API_ENTRY return NULL;
2370 if (!sd->on_content_get_func) return NULL;
2371 return sd->on_content_get_func(obj, part);
2375 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2377 API_ENTRY return NULL;
2379 if (!sd->on_content_unset_func) return NULL;
2380 return sd->on_content_unset_func(obj, part);
2384 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2387 if (sd->access_info) eina_stringshare_del(sd->access_info);
2388 if (!txt) sd->access_info = NULL;
2389 else sd->access_info = eina_stringshare_add(txt);
2393 elm_widget_access_info_get(Evas_Object *obj)
2395 API_ENTRY return NULL;
2396 return sd->access_info;
2400 elm_widget_theme_get(const Evas_Object *obj)
2402 API_ENTRY return NULL;
2406 return elm_widget_theme_get(sd->parent_obj);
2414 elm_widget_style_set(Evas_Object *obj,
2419 if (eina_stringshare_replace(&sd->style, style))
2420 elm_widget_theme(obj);
2424 elm_widget_style_get(const Evas_Object *obj)
2426 API_ENTRY return NULL;
2427 if (sd->style) return sd->style;
2432 elm_widget_type_set(Evas_Object *obj,
2436 eina_stringshare_replace(&sd->type, type);
2440 elm_widget_type_get(const Evas_Object *obj)
2442 API_ENTRY return NULL;
2443 if (sd->type) return sd->type;
2448 elm_widget_tooltip_add(Evas_Object *obj,
2452 sd->tooltips = eina_list_append(sd->tooltips, tt);
2456 elm_widget_tooltip_del(Evas_Object *obj,
2460 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2464 elm_widget_cursor_add(Evas_Object *obj,
2468 sd->cursors = eina_list_append(sd->cursors, cur);
2472 elm_widget_cursor_del(Evas_Object *obj,
2476 sd->cursors = eina_list_remove(sd->cursors, cur);
2480 elm_widget_drag_lock_x_set(Evas_Object *obj,
2484 if (sd->drag_x_locked == lock) return;
2485 sd->drag_x_locked = lock;
2486 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2487 else _propagate_x_drag_lock(obj, -1);
2491 elm_widget_drag_lock_y_set(Evas_Object *obj,
2495 if (sd->drag_y_locked == lock) return;
2496 sd->drag_y_locked = lock;
2497 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2498 else _propagate_y_drag_lock(obj, -1);
2502 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2504 API_ENTRY return EINA_FALSE;
2505 return sd->drag_x_locked;
2509 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2511 API_ENTRY return EINA_FALSE;
2512 return sd->drag_y_locked;
2516 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2519 return sd->child_drag_x_locked;
2523 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2526 return sd->child_drag_y_locked;
2530 elm_widget_theme_object_set(Evas_Object *obj,
2533 const char *welement,
2536 API_ENTRY return EINA_FALSE;
2537 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2541 elm_widget_is_check(const Evas_Object *obj)
2543 static int abort_on_warn = -1;
2544 if (elm_widget_is(obj))
2547 ERR("Passing Object: %p.", obj);
2548 if (abort_on_warn == -1)
2550 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2551 else abort_on_warn = 0;
2553 if (abort_on_warn == 1) abort();
2558 elm_widget_type_check(const Evas_Object *obj,
2562 const char *provided, *expected = "(unknown)";
2563 static int abort_on_warn = -1;
2564 provided = elm_widget_type_get(obj);
2565 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2566 if (type) expected = type;
2567 if ((!provided) || (!provided[0]))
2569 provided = evas_object_type_get(obj);
2570 if ((!provided) || (!provided[0]))
2571 provided = "(unknown)";
2573 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2574 if (abort_on_warn == -1)
2576 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2577 else abort_on_warn = 0;
2579 if (abort_on_warn == 1) abort();
2586 * Split string in words
2588 * @param str Source string
2589 * @return List of const words
2591 * @see elm_widget_stringlist_free()
2595 elm_widget_stringlist_get(const char *str)
2597 Eina_List *list = NULL;
2599 if (!str) return NULL;
2600 for (b = s = str; 1; s++)
2602 if ((*s == ' ') || (!*s))
2604 char *t = malloc(s - b + 1);
2607 strncpy(t, b, s - b);
2609 list = eina_list_append(list, eina_stringshare_add(t));
2620 elm_widget_stringlist_free(Eina_List *list)
2623 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2627 elm_widget_focus_hide_handle(Evas_Object *obj)
2629 _if_focused_revert(obj, EINA_TRUE);
2633 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2635 Evas_Object *o = obj;
2638 if (_elm_widget_is(o)) break;
2639 o = evas_object_smart_parent_get(o);
2643 if (!_is_focusable(o)) return;
2644 elm_widget_focus_steal(o);
2648 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2652 if (!elm_widget_parent_get(obj))
2653 elm_widget_focused_object_clear(obj);
2655 _if_focused_revert(obj, EINA_TRUE);
2659 elm_widget_focus_disabled_handle(Evas_Object *obj)
2663 elm_widget_focus_tree_unfocusable_handle(obj);
2669 * Allocate a new Elm_Widget_Item-derived structure.
2671 * The goal of this structure is to provide common ground for actions
2672 * that a widget item have, such as the owner widget, callback to
2673 * notify deletion, data pointer and maybe more.
2675 * @param widget the owner widget that holds this item, must be an elm_widget!
2676 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2677 * be used to allocate memory.
2679 * @return allocated memory that is already zeroed out, or NULL on errors.
2681 * @see elm_widget_item_new() convenience macro.
2682 * @see elm_widget_item_del() to release memory.
2685 EAPI Elm_Widget_Item *
2686 _elm_widget_item_new(Evas_Object *widget,
2689 if (!_elm_widget_is(widget))
2692 Elm_Widget_Item *item;
2694 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2695 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2697 item = calloc(1, alloc_size);
2698 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2700 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2701 item->widget = widget;
2708 * Releases widget item memory, calling back del_cb() if it exists.
2710 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2711 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2712 * this function and then unset it, thus being useful for 2 step
2713 * cleanup whenever the del_cb may use any of the data that must be
2714 * deleted from item.
2716 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2719 * @param item a valid #Elm_Widget_Item to be deleted.
2720 * @see elm_widget_item_del() convenience macro.
2724 _elm_widget_item_del(Elm_Widget_Item *item)
2726 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2729 item->del_cb((void *)item->data, item->widget, item);
2732 evas_object_del(item->view);
2736 _elm_access_clear(item->access);
2738 item->access = NULL;
2740 if (item->access_info)
2742 eina_stringshare_del(item->access_info);
2743 item->access_info = NULL;
2746 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2753 * Notify object will be deleted without actually deleting it.
2755 * This function will callback Elm_Widget_Item::del_cb if it is set
2756 * and then unset it so it is not called twice (ie: from
2757 * elm_widget_item_del()).
2759 * @param item a valid #Elm_Widget_Item to be notified
2760 * @see elm_widget_item_pre_notify_del() convenience macro.
2764 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2766 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2767 if (!item->del_cb) return;
2768 item->del_cb((void *)item->data, item->widget, item);
2769 item->del_cb = NULL;
2775 * Set the function to notify when item is being deleted.
2777 * This function will complain if there was a callback set already,
2778 * however it will set the new one.
2780 * The callback will be called from elm_widget_item_pre_notify_del()
2781 * or elm_widget_item_del() will be called with:
2782 * - data: the Elm_Widget_Item::data value.
2783 * - obj: the Elm_Widget_Item::widget evas object.
2784 * - event_info: the item being deleted.
2786 * @param item a valid #Elm_Widget_Item to be notified
2787 * @see elm_widget_item_del_cb_set() convenience macro.
2791 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2792 Evas_Smart_Cb del_cb)
2794 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2796 if ((item->del_cb) && (item->del_cb != del_cb))
2797 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2798 item->del_cb, item, del_cb);
2800 item->del_cb = del_cb;
2806 * Set user-data in this item.
2808 * User data may be used to identify this item or just store any
2809 * application data. It is automatically given as the first parameter
2810 * of the deletion notify callback.
2812 * @param item a valid #Elm_Widget_Item to store data in.
2813 * @param data user data to store.
2814 * @see elm_widget_item_del_cb_set() convenience macro.
2818 _elm_widget_item_data_set(Elm_Widget_Item *item,
2821 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2822 if ((item->data) && (item->data != data))
2823 DBG("Replacing item %p data %p with %p", item, item->data, data);
2830 * Retrieves user-data of this item.
2832 * @param item a valid #Elm_Widget_Item to get data from.
2833 * @see elm_widget_item_data_set()
2837 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2839 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2840 return (void *)item->data;
2843 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2845 struct _Elm_Widget_Item_Tooltip
2847 Elm_Widget_Item *item;
2848 Elm_Tooltip_Item_Content_Cb func;
2849 Evas_Smart_Cb del_cb;
2853 static Evas_Object *
2854 _elm_widget_item_tooltip_label_create(void *data,
2855 Evas_Object *obj __UNUSED__,
2856 Evas_Object *tooltip,
2857 void *item __UNUSED__)
2859 Evas_Object *label = elm_label_add(tooltip);
2862 elm_object_style_set(label, "tooltip");
2863 elm_object_text_set(label, data);
2867 static Evas_Object *
2868 _elm_widget_item_tooltip_trans_label_create(void *data,
2869 Evas_Object *obj __UNUSED__,
2870 Evas_Object *tooltip,
2871 void *item __UNUSED__)
2873 Evas_Object *label = elm_label_add(tooltip);
2876 elm_object_style_set(label, "tooltip");
2877 elm_object_translatable_text_set(label, data);
2882 _elm_widget_item_tooltip_label_del_cb(void *data,
2883 Evas_Object *obj __UNUSED__,
2884 void *event_info __UNUSED__)
2886 eina_stringshare_del(data);
2892 * Set the text to be shown in the widget item.
2894 * @param item Target item
2895 * @param text The text to set in the content
2897 * Setup the text as tooltip to object. The item can have only one tooltip,
2898 * so any previous tooltip data is removed.
2903 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2906 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2907 EINA_SAFETY_ON_NULL_RETURN(text);
2909 text = eina_stringshare_add(text);
2910 _elm_widget_item_tooltip_content_cb_set
2911 (item, _elm_widget_item_tooltip_label_create, text,
2912 _elm_widget_item_tooltip_label_del_cb);
2916 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2919 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2920 EINA_SAFETY_ON_NULL_RETURN(text);
2922 text = eina_stringshare_add(text);
2923 _elm_widget_item_tooltip_content_cb_set
2924 (item, _elm_widget_item_tooltip_trans_label_create, text,
2925 _elm_widget_item_tooltip_label_del_cb);
2928 static Evas_Object *
2929 _elm_widget_item_tooltip_create(void *data,
2931 Evas_Object *tooltip)
2933 Elm_Widget_Item_Tooltip *wit = data;
2934 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2938 _elm_widget_item_tooltip_del_cb(void *data,
2940 void *event_info __UNUSED__)
2942 Elm_Widget_Item_Tooltip *wit = data;
2943 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2950 * Set the content to be shown in the tooltip item
2952 * Setup the tooltip to item. The item can have only one tooltip,
2953 * so any previous tooltip data is removed. @p func(with @p data) will
2954 * be called every time that need show the tooltip and it should
2955 * return a valid Evas_Object. This object is then managed fully by
2956 * tooltip system and is deleted when the tooltip is gone.
2958 * @param item the widget item being attached a tooltip.
2959 * @param func the function used to create the tooltip contents.
2960 * @param data what to provide to @a func as callback data/context.
2961 * @param del_cb called when data is not needed anymore, either when
2962 * another callback replaces @func, the tooltip is unset with
2963 * elm_widget_item_tooltip_unset() or the owner @a item
2964 * dies. This callback receives as the first parameter the
2965 * given @a data, and @c event_info is the item.
2970 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2971 Elm_Tooltip_Item_Content_Cb func,
2973 Evas_Smart_Cb del_cb)
2975 Elm_Widget_Item_Tooltip *wit;
2977 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2981 _elm_widget_item_tooltip_unset(item);
2985 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2986 if (!wit) goto error;
2990 wit->del_cb = del_cb;
2992 elm_object_sub_tooltip_content_cb_set
2993 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2994 _elm_widget_item_tooltip_del_cb);
2999 if (del_cb) del_cb((void *)data, NULL, item);
3002 if (del_cb) del_cb((void *)data, item->widget, item);
3008 * Unset tooltip from item
3010 * @param item widget item to remove previously set tooltip.
3012 * Remove tooltip from item. The callback provided as del_cb to
3013 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3014 * it is not used anymore.
3016 * @see elm_widget_item_tooltip_content_cb_set()
3021 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3023 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3024 elm_object_tooltip_unset(item->view);
3030 * Sets a different style for this item tooltip.
3032 * @note before you set a style you should define a tooltip with
3033 * elm_widget_item_tooltip_content_cb_set() or
3034 * elm_widget_item_tooltip_text_set()
3036 * @param item widget item with tooltip already set.
3037 * @param style the theme style to use (default, transparent, ...)
3042 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3045 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3046 elm_object_tooltip_style_set(item->view, style);
3050 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
3052 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3053 return elm_tooltip_size_restrict_disable(item->view, disable);
3057 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
3059 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3060 return elm_tooltip_size_restrict_disabled_get(item->view);
3066 * Get the style for this item tooltip.
3068 * @param item widget item with tooltip already set.
3069 * @return style the theme style in use, defaults to "default". If the
3070 * object does not have a tooltip set, then NULL is returned.
3075 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3077 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3078 return elm_object_tooltip_style_get(item->view);
3082 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3085 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3086 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3090 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3092 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3093 return elm_object_cursor_get(item->view);
3097 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3099 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3100 elm_object_cursor_unset(item->view);
3106 * Sets a different style for this item cursor.
3108 * @note before you set a style you should define a cursor with
3109 * elm_widget_item_cursor_set()
3111 * @param item widget item with cursor already set.
3112 * @param style the theme style to use (default, transparent, ...)
3117 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3120 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3121 elm_object_cursor_style_set(item->view, style);
3127 * Get the style for this item cursor.
3129 * @param item widget item with cursor already set.
3130 * @return style the theme style in use, defaults to "default". If the
3131 * object does not have a cursor set, then NULL is returned.
3136 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3138 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3139 return elm_object_cursor_style_get(item->view);
3145 * Set if the cursor set should be searched on the theme or should use
3146 * the provided by the engine, only.
3148 * @note before you set if should look on theme you should define a cursor
3149 * with elm_object_cursor_set(). By default it will only look for cursors
3150 * provided by the engine.
3152 * @param item widget item with cursor already set.
3153 * @param engine_only boolean to define it cursors should be looked only
3154 * between the provided by the engine or searched on widget's theme as well.
3159 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3160 Eina_Bool engine_only)
3162 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3163 elm_object_cursor_engine_only_set(item->view, engine_only);
3169 * Get the cursor engine only usage for this item cursor.
3171 * @param item widget item with cursor already set.
3172 * @return engine_only boolean to define it cursors should be looked only
3173 * between the provided by the engine or searched on widget's theme as well. If
3174 * the object does not have a cursor set, then EINA_FALSE is returned.
3179 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3181 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3182 return elm_object_cursor_engine_only_get(item->view);
3185 // smart object funcs
3187 _smart_reconfigure(Smart_Data *sd)
3191 evas_object_move(sd->resize_obj, sd->x, sd->y);
3192 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3196 evas_object_move(sd->hover_obj, sd->x, sd->y);
3197 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3202 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3204 Evas_Object *content)
3206 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3207 if (!item->on_content_set_func) return;
3208 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3212 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3215 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3216 if (!item->on_content_get_func) return NULL;
3217 return item->on_content_get_func((Elm_Object_Item *) item, part);
3221 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3224 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3225 if (!item->on_content_unset_func) return NULL;
3226 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3230 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3234 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3235 if (!item->on_text_set_func) return;
3236 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3240 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3241 const char *emission,
3244 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3245 if (item->on_signal_emit_func)
3246 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3250 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3253 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3254 if (!item->on_text_get_func) return NULL;
3255 return item->on_text_get_func((Elm_Object_Item *) item, part);
3259 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3260 Elm_Widget_On_Content_Set_Cb func)
3262 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3263 item->on_content_set_func = func;
3267 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3268 Elm_Widget_On_Content_Get_Cb func)
3270 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3271 item->on_content_get_func = func;
3275 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3276 Elm_Widget_On_Content_Unset_Cb func)
3278 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3279 item->on_content_unset_func = func;
3283 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3284 Elm_Widget_On_Text_Set_Cb func)
3286 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3287 item->on_text_set_func = func;
3291 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3292 Elm_Widget_On_Text_Get_Cb func)
3294 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3295 item->on_text_get_func = func;
3299 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3300 Elm_Widget_On_Signal_Emit_Cb func)
3302 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3303 item->on_signal_emit_func = func;
3307 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3309 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3310 if (item->access_info) eina_stringshare_del(item->access_info);
3311 if (!txt) item->access_info = NULL;
3312 else item->access_info = eina_stringshare_add(txt);
3317 _smart_add(Evas_Object *obj)
3321 sd = calloc(1, sizeof(Smart_Data));
3324 sd->x = sd->y = sd->w = sd->h = 0;
3326 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3327 evas_object_smart_data_set(obj, sd);
3330 static Evas_Object *
3331 _newest_focus_order_get(Evas_Object *obj,
3332 unsigned int *newest_focus_order,
3333 Eina_Bool can_focus_only)
3336 Evas_Object *child, *ret, *best;
3338 API_ENTRY return NULL;
3340 if (!evas_object_visible_get(obj)
3341 || (elm_widget_disabled_get(obj))
3342 || (elm_widget_tree_unfocusable_get(obj)))
3346 if (*newest_focus_order < sd->focus_order)
3348 *newest_focus_order = sd->focus_order;
3351 EINA_LIST_FOREACH(sd->subobjs, l, child)
3353 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3359 if ((!best) || (!elm_widget_can_focus_get(best)))
3366 _if_focused_revert(Evas_Object *obj,
3367 Eina_Bool can_focus_only)
3370 Evas_Object *newest = NULL;
3371 unsigned int newest_focus_order = 0;
3375 if (!sd->focused) return;
3376 if (!sd->parent_obj) return;
3378 top = elm_widget_top_get(sd->parent_obj);
3381 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3384 elm_object_focus_set(newest, EINA_FALSE);
3385 elm_object_focus_set(newest, EINA_TRUE);
3391 _smart_del(Evas_Object *obj)
3394 Edje_Signal_Data *esd;
3395 Elm_Translate_String_Data *ts;
3399 if (sd->del_pre_func) sd->del_pre_func(obj);
3402 sobj = sd->resize_obj;
3403 sd->resize_obj = NULL;
3404 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3405 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3406 evas_object_del(sobj);
3410 sobj = sd->hover_obj;
3411 sd->hover_obj = NULL;
3412 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3413 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3414 evas_object_del(sobj);
3416 EINA_LIST_FREE(sd->subobjs, sobj)
3418 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3419 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3420 evas_object_del(sobj);
3422 eina_list_free(sd->tooltips); /* should be empty anyway */
3423 eina_list_free(sd->cursors); /* should be empty anyway */
3424 EINA_LIST_FREE(sd->edje_signals, esd)
3426 eina_stringshare_del(esd->emission);
3427 eina_stringshare_del(esd->source);
3430 EINA_LIST_FREE(sd->translate_strings, ts)
3432 eina_stringshare_del(ts->id);
3433 eina_stringshare_del(ts->domain);
3434 eina_stringshare_del(ts->string);
3437 eina_list_free(sd->event_cb); /* should be empty anyway */
3438 if (sd->del_func) sd->del_func(obj);
3439 if (sd->style) eina_stringshare_del(sd->style);
3440 if (sd->type) eina_stringshare_del(sd->type);
3441 if (sd->theme) elm_theme_free(sd->theme);
3442 _if_focused_revert(obj, EINA_TRUE);
3443 if (sd->access_info) eina_stringshare_del(sd->access_info);
3448 _smart_move(Evas_Object *obj,
3455 _smart_reconfigure(sd);
3459 _smart_resize(Evas_Object *obj,
3466 _smart_reconfigure(sd);
3470 _smart_show(Evas_Object *obj)
3475 if ((list = evas_object_smart_members_get(obj)))
3477 EINA_LIST_FREE(list, o)
3479 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3480 evas_object_show(o);
3486 _smart_hide(Evas_Object *obj)
3492 list = evas_object_smart_members_get(obj);
3493 EINA_LIST_FREE(list, o)
3495 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3496 evas_object_hide(o);
3501 _smart_color_set(Evas_Object *obj,
3510 if ((list = evas_object_smart_members_get(obj)))
3512 EINA_LIST_FREE(list, o)
3514 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3515 evas_object_color_set(o, r, g, b, a);
3521 _smart_clip_set(Evas_Object *obj,
3527 if ((list = evas_object_smart_members_get(obj)))
3529 EINA_LIST_FREE(list, o)
3531 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3532 evas_object_clip_set(o, clip);
3538 _smart_clip_unset(Evas_Object *obj)
3543 if ((list = evas_object_smart_members_get(obj)))
3545 EINA_LIST_FREE(list, o)
3547 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3548 evas_object_clip_unset(o);
3554 _smart_calculate(Evas_Object *obj)
3557 if (sd->changed_func) sd->changed_func(obj);
3560 /* never need to touch this */
3564 if (_e_smart) return;
3566 static const Evas_Smart_Class sc =
3569 EVAS_SMART_CLASS_VERSION,
3587 _e_smart = evas_smart_class_new(&sc);
3591 /* happy debug functions */
3594 _sub_obj_tree_dump(const Evas_Object *obj,
3599 for (i = 0; i < lvl * 3; i++)
3602 if (_elm_widget_is(obj))
3606 printf("+ %s(%p)\n",
3610 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3611 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3613 if (obj != sd->resize_obj)
3614 _sub_obj_tree_dump(obj, lvl + 1);
3618 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3622 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3625 if (!_elm_widget_is(obj))
3629 Eina_Bool visible = evas_object_visible_get(obj);
3630 Eina_Bool disabled = elm_widget_disabled_get(obj);
3631 Eina_Bool focused = elm_widget_focus_get(obj);
3632 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3636 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3639 fprintf(output, ", style=bold");
3642 fprintf(output, ", color=gray28");
3644 fprintf(output, " ];\n");
3647 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3648 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3649 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3653 fprintf(output, ", style=bold");
3656 fprintf(output, ", fontcolor=gray28");
3658 if ((disabled) || (!visible))
3659 fprintf(output, ", color=gray");
3661 fprintf(output, " ];\n");
3665 EINA_LIST_FOREACH(sd->subobjs, l, o)
3666 _sub_obj_tree_dot_dump(o, output);
3671 elm_widget_tree_dump(const Evas_Object *top)
3674 _sub_obj_tree_dump(top, 0);
3682 elm_widget_tree_dot_dump(const Evas_Object *top,
3686 if (!_elm_widget_is(top))
3688 fprintf(output, "graph " " { node [shape=record];\n");
3689 _sub_obj_tree_dot_dump(top, output);
3690 fprintf(output, "}\n");