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);
1013 // orphan new resize obj
1016 evas_object_data_del(sobj, "elm-parent");
1017 if (_elm_widget_is(sobj))
1019 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1020 if (sd2) sd2->parent_obj = NULL;
1021 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1024 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1026 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1027 _sub_obj_mouse_up, sd);
1028 evas_object_smart_member_del(sobj);
1029 if (_elm_widget_is(sobj))
1031 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1034 // set the resize obj up
1035 sd->resize_obj = sobj;
1038 if (_elm_widget_is(sd->resize_obj))
1040 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1043 sd2->parent_obj = obj;
1044 sd2->top_win_focused = sd->top_win_focused;
1046 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1049 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1050 evas_object_smart_member_add(sobj, obj);
1051 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1053 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1054 _sub_obj_mouse_up, sd);
1055 _smart_reconfigure(sd);
1056 evas_object_data_set(sobj, "elm-parent", obj);
1057 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1058 if (_elm_widget_is(sobj))
1060 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1066 elm_widget_hover_object_set(Evas_Object *obj,
1072 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1075 sd->hover_obj = sobj;
1078 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1080 _smart_reconfigure(sd);
1085 elm_widget_can_focus_set(Evas_Object *obj,
1086 Eina_Bool can_focus)
1089 sd->can_focus = can_focus;
1092 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1094 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1095 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1097 (void *)(long)EVAS_CALLBACK_KEY_UP);
1098 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1100 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1104 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1106 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1108 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1114 elm_widget_can_focus_get(const Evas_Object *obj)
1116 API_ENTRY return EINA_FALSE;
1117 return sd->can_focus;
1121 elm_widget_child_can_focus_get(const Evas_Object *obj)
1123 API_ENTRY return EINA_FALSE;
1124 return sd->child_can_focus;
1130 * This API makes the widget object and its children to be unfocusable.
1132 * This API can be helpful for an object to be deleted.
1133 * When an object will be deleted soon, it and its children may not
1134 * want to get focus (by focus reverting or by other focus controls).
1135 * Then, just use this API before deleting.
1137 * @param obj The widget root of sub-tree
1138 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1143 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1144 Eina_Bool tree_unfocusable)
1148 if (sd->tree_unfocusable == tree_unfocusable) return;
1149 sd->tree_unfocusable = !!tree_unfocusable;
1150 elm_widget_focus_tree_unfocusable_handle(obj);
1156 * This returns true, if the object sub-tree is unfocusable.
1158 * @param obj The widget root of sub-tree
1159 * @return EINA_TRUE if the object sub-tree is unfocusable
1164 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1166 API_ENTRY return EINA_FALSE;
1167 return sd->tree_unfocusable;
1173 * Get the list of focusable child objects.
1175 * This function retruns list of child objects which can get focus.
1177 * @param obj The parent widget
1178 * @retrun list of focusable child objects.
1183 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1185 API_ENTRY return NULL;
1188 Eina_List *child_list = NULL;
1193 EINA_LIST_FOREACH(sd->subobjs, l, child)
1195 if ((elm_widget_can_focus_get(child)) &&
1196 (evas_object_visible_get(child)) &&
1197 (!elm_widget_disabled_get(child)))
1198 child_list = eina_list_append(child_list, child);
1199 else if (elm_widget_is(child))
1201 Eina_List *can_focus_list;
1202 can_focus_list = elm_widget_can_focus_child_list_get(child);
1204 child_list = eina_list_merge(child_list, can_focus_list);
1212 elm_widget_highlight_ignore_set(Evas_Object *obj,
1216 sd->highlight_ignore = !!ignore;
1220 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1222 API_ENTRY return EINA_FALSE;
1223 return sd->highlight_ignore;
1227 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1228 Eina_Bool highlight)
1231 sd->highlight_in_theme = !!highlight;
1232 /* FIXME: if focused, it should switch from one mode to the other */
1236 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1238 API_ENTRY return EINA_FALSE;
1239 return sd->highlight_in_theme;
1243 elm_widget_focus_get(const Evas_Object *obj)
1245 API_ENTRY return EINA_FALSE;
1250 elm_widget_focused_object_get(const Evas_Object *obj)
1252 const Evas_Object *subobj;
1254 API_ENTRY return NULL;
1256 if (!sd->focused) return NULL;
1257 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1259 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1260 if (fobj) return fobj;
1262 return (Evas_Object *)obj;
1266 elm_widget_top_get(const Evas_Object *obj)
1268 API_ENTRY return NULL;
1269 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1270 return (Evas_Object *)obj;
1274 elm_widget_is(const Evas_Object *obj)
1276 return _elm_widget_is(obj);
1280 elm_widget_parent_widget_get(const Evas_Object *obj)
1282 Evas_Object *parent;
1284 if (_elm_widget_is(obj))
1286 Smart_Data *sd = evas_object_smart_data_get(obj);
1287 if (!sd) return NULL;
1288 parent = sd->parent_obj;
1292 parent = evas_object_data_get(obj, "elm-parent");
1293 if (!parent) parent = evas_object_smart_parent_get(obj);
1298 Evas_Object *elm_parent;
1299 if (_elm_widget_is(parent)) break;
1300 elm_parent = evas_object_data_get(parent, "elm-parent");
1301 if (elm_parent) parent = elm_parent;
1302 else parent = evas_object_smart_parent_get(parent);
1308 elm_widget_parent2_get(const Evas_Object *obj)
1310 if (_elm_widget_is(obj))
1312 Smart_Data *sd = evas_object_smart_data_get(obj);
1313 if (sd) return sd->parent2;
1319 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1322 sd->parent2 = parent;
1326 elm_widget_event_callback_add(Evas_Object *obj,
1331 EINA_SAFETY_ON_NULL_RETURN(func);
1332 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1335 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1339 elm_widget_event_callback_del(Evas_Object *obj,
1343 API_ENTRY return NULL;
1344 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1346 Elm_Event_Cb_Data *ecd;
1347 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1348 if ((ecd->func == func) && (ecd->data == data))
1351 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1352 return (void *)data;
1358 elm_widget_event_propagate(Evas_Object *obj,
1359 Evas_Callback_Type type,
1361 Evas_Event_Flags *event_flags)
1363 API_ENTRY return EINA_FALSE; //TODO reduce.
1364 if (!_elm_widget_is(obj)) return EINA_FALSE;
1365 Evas_Object *parent = obj;
1366 Elm_Event_Cb_Data *ecd;
1367 Eina_List *l, *l_prev;
1370 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1372 sd = evas_object_smart_data_get(parent);
1373 if ((!sd) || (!_elm_widget_is(obj)))
1374 return EINA_FALSE; //Not Elm Widget
1376 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1379 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1381 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1382 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1385 parent = sd->parent_obj;
1394 * Set custom focus chain.
1396 * This function i set one new and overwrite any previous custom focus chain
1397 * with the list of objects. The previous list will be deleted and this list
1398 * will be managed. After setted, don't modity it.
1400 * @note On focus cycle, only will be evaluated children of this container.
1402 * @param obj The container widget
1403 * @param objs Chain of objects to pass focus
1407 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1411 if (!sd->focus_next_func)
1414 elm_widget_focus_custom_chain_unset(obj);
1419 EINA_LIST_FOREACH(objs, l, o)
1421 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1422 _elm_object_focus_chain_del_cb, sd);
1425 sd->focus_chain = objs;
1431 * Get custom focus chain
1433 * @param obj The container widget
1436 EAPI const Eina_List *
1437 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1439 API_ENTRY return NULL;
1440 return (const Eina_List *)sd->focus_chain;
1446 * Unset custom focus chain
1448 * @param obj The container widget
1452 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1455 Eina_List *l, *l_next;
1458 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1460 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1461 _elm_object_focus_chain_del_cb, sd);
1462 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1469 * Append object to custom focus chain.
1471 * @note If relative_child equal to NULL or not in custom chain, the object
1472 * will be added in end.
1474 * @note On focus cycle, only will be evaluated children of this container.
1476 * @param obj The container widget
1477 * @param child The child to be added in custom chain
1478 * @param relative_child The relative object to position the child
1482 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1484 Evas_Object *relative_child)
1487 EINA_SAFETY_ON_NULL_RETURN(child);
1488 if (!sd->focus_next_func)
1491 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1492 _elm_object_focus_chain_del_cb, sd);
1494 if (!relative_child)
1496 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1500 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1507 * Prepend object to custom focus chain.
1509 * @note If relative_child equal to NULL or not in custom chain, the object
1510 * will be added in begin.
1512 * @note On focus cycle, only will be evaluated children of this container.
1514 * @param obj The container widget
1515 * @param child The child to be added in custom chain
1516 * @param relative_child The relative object to position the child
1520 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1522 Evas_Object *relative_child)
1525 EINA_SAFETY_ON_NULL_RETURN(child);
1526 if (!sd->focus_next_func)
1529 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1530 _elm_object_focus_chain_del_cb, sd);
1532 if (!relative_child)
1534 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1538 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1545 * Give focus to next object in object tree.
1547 * Give focus to next object in focus chain of one object sub-tree.
1548 * If the last object of chain already have focus, the focus will go to the
1549 * first object of chain.
1551 * @param obj The widget root of sub-tree
1552 * @param dir Direction to cycle the focus
1557 elm_widget_focus_cycle(Evas_Object *obj,
1558 Elm_Focus_Direction dir)
1560 Evas_Object *target = NULL;
1561 if (!_elm_widget_is(obj))
1563 elm_widget_focus_next_get(obj, dir, &target);
1565 elm_widget_focus_steal(target);
1571 * Give focus to near object in one direction.
1573 * Give focus to near object in direction of one object.
1574 * If none focusable object in given direction, the focus will not change.
1576 * @param obj The reference widget
1577 * @param x Horizontal component of direction to focus
1578 * @param y Vertical component of direction to focus
1583 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1593 * Get next object in focus chain of object tree.
1595 * Get next object in focus chain of one object sub-tree.
1596 * Return the next object by reference. If don't have any candidate to receive
1597 * focus before chain end, the first candidate will be returned.
1599 * @param obj The widget root of sub-tree
1600 * @param dir Direction os focus chain
1601 * @param next The next object in focus chain
1602 * @return EINA_TRUE if don't need focus chain restart/loop back
1603 * to use 'next' obj.
1608 elm_widget_focus_next_get(const Evas_Object *obj,
1609 Elm_Focus_Direction dir,
1616 API_ENTRY return EINA_FALSE;
1618 /* Ignore if disabled */
1619 if ((!evas_object_visible_get(obj))
1620 || (elm_widget_disabled_get(obj))
1621 || (elm_widget_tree_unfocusable_get(obj)))
1625 if (sd->focus_next_func)
1626 return sd->focus_next_func(obj, dir, next);
1628 if (!elm_widget_can_focus_get(obj))
1632 *next = (Evas_Object *)obj;
1633 return !elm_widget_focus_get(obj);
1639 * Get next object in focus chain of object tree in list.
1641 * Get next object in focus chain of one object sub-tree ordered by one list.
1642 * Return the next object by reference. If don't have any candidate to receive
1643 * focus before list end, the first candidate will be returned.
1645 * @param obj The widget root of sub-tree
1646 * @param dir Direction os focus chain
1647 * @param items list with ordered objects
1648 * @param list_data_get function to get the object from one item of list
1649 * @param next The next object in focus chain
1650 * @return EINA_TRUE if don't need focus chain restart/loop back
1651 * to use 'next' obj.
1656 elm_widget_focus_list_next_get(const Evas_Object *obj,
1657 const Eina_List *items,
1658 void *(*list_data_get)(const Eina_List * list),
1659 Elm_Focus_Direction dir,
1662 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1668 if (!_elm_widget_is(obj))
1675 if (dir == ELM_FOCUS_PREVIOUS)
1677 items = eina_list_last(items);
1678 list_next = eina_list_prev;
1680 else if (dir == ELM_FOCUS_NEXT)
1681 list_next = eina_list_next;
1685 const Eina_List *l = items;
1687 /* Recovery last focused sub item */
1688 if (elm_widget_focus_get(obj))
1689 for (; l; l = list_next(l))
1691 Evas_Object *cur = list_data_get(l);
1692 if (elm_widget_focus_get(cur)) break;
1695 const Eina_List *start = l;
1696 Evas_Object *to_focus = NULL;
1698 /* Interate sub items */
1699 /* Go to end of list */
1700 for (; l; l = list_next(l))
1702 Evas_Object *tmp = NULL;
1703 Evas_Object *cur = list_data_get(l);
1705 if (elm_widget_parent_get(cur) != obj)
1708 /* Try Focus cycle in subitem */
1709 if (elm_widget_focus_next_get(cur, dir, &tmp))
1714 else if ((tmp) && (!to_focus))
1720 /* Get First possible */
1721 for (; l != start; l = list_next(l))
1723 Evas_Object *tmp = NULL;
1724 Evas_Object *cur = list_data_get(l);
1726 if (elm_widget_parent_get(cur) != obj)
1729 /* Try Focus cycle in subitem */
1730 elm_widget_focus_next_get(cur, dir, &tmp);
1743 elm_widget_signal_emit(Evas_Object *obj,
1744 const char *emission,
1748 if (!sd->signal_func) return;
1749 sd->signal_func(obj, emission, source);
1753 _edje_signal_callback(void *data,
1754 Evas_Object *obj __UNUSED__,
1755 const char *emission,
1758 Edje_Signal_Data *esd = data;
1759 esd->func(esd->data, esd->obj, emission, source);
1763 elm_widget_signal_callback_add(Evas_Object *obj,
1764 const char *emission,
1766 Edje_Signal_Cb func,
1769 Edje_Signal_Data *esd;
1771 if (!sd->callback_add_func) return;
1772 EINA_SAFETY_ON_NULL_RETURN(func);
1774 esd = ELM_NEW(Edje_Signal_Data);
1779 esd->emission = eina_stringshare_add(emission);
1780 esd->source = eina_stringshare_add(source);
1782 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1783 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1787 elm_widget_signal_callback_del(Evas_Object *obj,
1788 const char *emission,
1790 Edje_Signal_Cb func)
1792 Edje_Signal_Data *esd;
1795 API_ENTRY return NULL;
1796 if (!sd->callback_del_func) return NULL;
1798 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1800 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1801 (!strcmp(esd->source, source)))
1803 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1804 eina_stringshare_del(esd->emission);
1805 eina_stringshare_del(esd->source);
1811 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1816 elm_widget_focus_set(Evas_Object *obj,
1823 sd->focus_order = focus_order;
1824 sd->focused = EINA_TRUE;
1825 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1829 sd->focus_func(obj);
1836 if ((_is_focusable(sd->resize_obj)) &&
1837 (!elm_widget_disabled_get(sd->resize_obj)))
1839 elm_widget_focus_set(sd->resize_obj, first);
1845 EINA_LIST_FOREACH(sd->subobjs, l, child)
1847 if ((_is_focusable(child)) &&
1848 (!elm_widget_disabled_get(child)))
1850 elm_widget_focus_set(child, first);
1860 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1862 if ((_is_focusable(child)) &&
1863 (!elm_widget_disabled_get(child)))
1865 elm_widget_focus_set(child, first);
1871 if ((_is_focusable(sd->resize_obj)) &&
1872 (!elm_widget_disabled_get(sd->resize_obj)))
1874 elm_widget_focus_set(sd->resize_obj, first);
1882 elm_widget_parent_get(const Evas_Object *obj)
1884 API_ENTRY return NULL;
1885 return sd->parent_obj;
1889 elm_widget_focused_object_clear(Evas_Object *obj)
1892 if (!sd->focused) return;
1893 if (elm_widget_focus_get(sd->resize_obj))
1894 elm_widget_focused_object_clear(sd->resize_obj);
1899 EINA_LIST_FOREACH(sd->subobjs, l, child)
1901 if (elm_widget_focus_get(child))
1903 elm_widget_focused_object_clear(child);
1908 sd->focused = EINA_FALSE;
1909 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1910 if (sd->focus_func) sd->focus_func(obj);
1914 elm_widget_focus_steal(Evas_Object *obj)
1916 Evas_Object *parent, *parent2, *o;
1919 if (sd->focused) return;
1920 if (sd->disabled) return;
1921 if (!sd->can_focus) return;
1922 if (sd->tree_unfocusable) return;
1926 o = elm_widget_parent_get(parent);
1928 sd = evas_object_smart_data_get(o);
1929 if (sd->disabled || sd->tree_unfocusable) return;
1930 if (sd->focused) break;
1933 if ((!elm_widget_parent_get(parent)) &&
1934 (!elm_widget_parent2_get(parent)))
1935 elm_widget_focused_object_clear(parent);
1938 parent2 = elm_widget_parent_get(parent);
1939 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1941 sd = evas_object_smart_data_get(parent);
1944 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1945 elm_widget_focused_object_clear(sd->resize_obj);
1950 EINA_LIST_FOREACH(sd->subobjs, l, child)
1952 if (elm_widget_focus_get(child))
1954 elm_widget_focused_object_clear(child);
1966 elm_widget_focus_restore(Evas_Object *obj)
1968 Evas_Object *newest = NULL;
1969 unsigned int newest_focus_order = 0;
1972 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1975 elm_object_focus_set(newest, EINA_FALSE);
1976 elm_object_focus_set(newest, EINA_TRUE);
1981 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1987 if (sd->top_win_focused == top_win_focused) return;
1989 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1990 EINA_LIST_FOREACH(sd->subobjs, l, child)
1992 _elm_widget_top_win_focused_set(child, top_win_focused);
1994 sd->top_win_focused = top_win_focused;
1998 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2000 API_ENTRY return EINA_FALSE;
2001 return sd->top_win_focused;
2005 elm_widget_activate(Evas_Object *obj)
2008 elm_widget_change(obj);
2009 if (sd->activate_func) sd->activate_func(obj);
2013 elm_widget_change(Evas_Object *obj)
2016 elm_widget_change(elm_widget_parent_get(obj));
2017 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2021 elm_widget_disabled_set(Evas_Object *obj,
2026 if (sd->disabled == disabled) return;
2027 sd->disabled = !!disabled;
2028 elm_widget_focus_disabled_handle(obj);
2029 if (sd->disable_func) sd->disable_func(obj);
2033 elm_widget_disabled_get(const Evas_Object *obj)
2036 return sd->disabled;
2040 elm_widget_show_region_set(Evas_Object *obj,
2045 Eina_Bool forceshow)
2047 Evas_Object *parent_obj, *child_obj;
2048 Evas_Coord px, py, cx, cy;
2051 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2052 && (w == sd->rw) && (h == sd->rh)) return;
2057 if (sd->on_show_region_func)
2058 sd->on_show_region_func(sd->on_show_region_data, obj);
2062 parent_obj = sd->parent_obj;
2063 child_obj = sd->obj;
2064 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2065 sd = evas_object_smart_data_get(parent_obj);
2068 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2069 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2078 if (sd->on_show_region_func)
2080 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2087 elm_widget_show_region_get(const Evas_Object *obj,
2103 * Get the focus region of the given widget.
2105 * The focus region is the area of a widget that should brought into the
2106 * visible area when the widget is focused. Mostly used to show the part of
2107 * an entry where the cursor is, for example. The area returned is relative
2108 * to the object @p obj.
2109 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2110 * function will return the full size of the object.
2112 * @param obj The widget object
2113 * @param x Where to store the x coordinate of the area
2114 * @param y Where to store the y coordinate of the area
2115 * @param w Where to store the width of the area
2116 * @param h Where to store the height of the area
2121 elm_widget_focus_region_get(const Evas_Object *obj,
2131 sd = evas_object_smart_data_get(obj);
2132 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2134 evas_object_geometry_get(obj, NULL, NULL, w, h);
2139 sd->on_focus_region_func(obj, x, y, w, h);
2143 elm_widget_scroll_hold_push(Evas_Object *obj)
2147 if (sd->scroll_hold == 1)
2148 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2149 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2150 // FIXME: on delete/reparent hold pop
2154 elm_widget_scroll_hold_pop(Evas_Object *obj)
2158 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2159 if (!sd->scroll_hold)
2160 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2161 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2165 elm_widget_scroll_hold_get(const Evas_Object *obj)
2168 return sd->scroll_hold;
2172 elm_widget_scroll_freeze_push(Evas_Object *obj)
2175 sd->scroll_freeze++;
2176 if (sd->scroll_freeze == 1)
2177 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2178 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2179 // FIXME: on delete/reparent freeze pop
2183 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2186 sd->scroll_freeze--;
2187 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2188 if (!sd->scroll_freeze)
2189 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2190 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2194 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2197 return sd->scroll_freeze;
2201 elm_widget_scale_set(Evas_Object *obj,
2205 if (scale <= 0.0) scale = 0.0;
2206 if (sd->scale != scale)
2209 elm_widget_theme(obj);
2214 elm_widget_scale_get(const Evas_Object *obj)
2216 API_ENTRY return 1.0;
2217 // FIXME: save walking up the tree by storing/caching parent scale
2218 if (sd->scale == 0.0)
2221 return elm_widget_scale_get(sd->parent_obj);
2229 elm_widget_theme_set(Evas_Object *obj,
2233 if (sd->theme != th)
2235 if (sd->theme) elm_theme_free(sd->theme);
2238 elm_widget_theme(obj);
2243 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2247 if (!sd->on_text_set_func)
2250 sd->on_text_set_func(obj, part, label);
2254 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2256 API_ENTRY return NULL;
2258 if (!sd->on_text_get_func)
2261 return sd->on_text_get_func(obj, part);
2265 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2269 Elm_Translate_String_Data *ts = NULL;
2272 str = eina_stringshare_add(part);
2273 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2280 eina_stringshare_del(str);
2283 ts = malloc(sizeof(Elm_Translate_String_Data));
2287 ts->domain = eina_stringshare_add(domain);
2288 ts->string = eina_stringshare_add(label);
2289 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2295 eina_stringshare_replace(&ts->domain, domain);
2296 eina_stringshare_replace(&ts->string, label);
2300 sd->translate_strings = eina_list_remove_list(
2301 sd->translate_strings, l);
2302 eina_stringshare_del(ts->id);
2303 eina_stringshare_del(ts->domain);
2304 eina_stringshare_del(ts->string);
2307 eina_stringshare_del(str);
2311 if (label && label[0])
2312 label = dgettext(domain, label);
2314 elm_widget_text_part_set(obj, part, label);
2318 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2320 const char *str, *ret = NULL;
2322 Elm_Translate_String_Data *ts;
2323 API_ENTRY return NULL;
2325 str = eina_stringshare_add(part);
2326 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2332 eina_stringshare_del(str);
2337 elm_widget_translate(Evas_Object *obj)
2341 Elm_Translate_String_Data *ts;
2344 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2345 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2346 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2347 if (sd->translate_func) sd->translate_func(obj);
2350 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2352 const char *s = dgettext(ts->domain, ts->string);
2353 elm_widget_text_part_set(obj, ts->id, s);
2359 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2363 if (!sd->on_content_set_func) return;
2364 sd->on_content_set_func(obj, part, content);
2368 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2370 API_ENTRY return NULL;
2372 if (!sd->on_content_get_func) return NULL;
2373 return sd->on_content_get_func(obj, part);
2377 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2379 API_ENTRY return NULL;
2381 if (!sd->on_content_unset_func) return NULL;
2382 return sd->on_content_unset_func(obj, part);
2386 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2389 if (sd->access_info) eina_stringshare_del(sd->access_info);
2390 if (!txt) sd->access_info = NULL;
2391 else sd->access_info = eina_stringshare_add(txt);
2395 elm_widget_access_info_get(Evas_Object *obj)
2397 API_ENTRY return NULL;
2398 return sd->access_info;
2402 elm_widget_theme_get(const Evas_Object *obj)
2404 API_ENTRY return NULL;
2408 return elm_widget_theme_get(sd->parent_obj);
2416 elm_widget_style_set(Evas_Object *obj,
2421 if (eina_stringshare_replace(&sd->style, style))
2422 elm_widget_theme(obj);
2426 elm_widget_style_get(const Evas_Object *obj)
2428 API_ENTRY return NULL;
2429 if (sd->style) return sd->style;
2434 elm_widget_type_set(Evas_Object *obj,
2438 eina_stringshare_replace(&sd->type, type);
2442 elm_widget_type_get(const Evas_Object *obj)
2444 API_ENTRY return NULL;
2445 if (sd->type) return sd->type;
2450 elm_widget_tooltip_add(Evas_Object *obj,
2454 sd->tooltips = eina_list_append(sd->tooltips, tt);
2458 elm_widget_tooltip_del(Evas_Object *obj,
2462 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2466 elm_widget_cursor_add(Evas_Object *obj,
2470 sd->cursors = eina_list_append(sd->cursors, cur);
2474 elm_widget_cursor_del(Evas_Object *obj,
2478 sd->cursors = eina_list_remove(sd->cursors, cur);
2482 elm_widget_drag_lock_x_set(Evas_Object *obj,
2486 if (sd->drag_x_locked == lock) return;
2487 sd->drag_x_locked = lock;
2488 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2489 else _propagate_x_drag_lock(obj, -1);
2493 elm_widget_drag_lock_y_set(Evas_Object *obj,
2497 if (sd->drag_y_locked == lock) return;
2498 sd->drag_y_locked = lock;
2499 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2500 else _propagate_y_drag_lock(obj, -1);
2504 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2506 API_ENTRY return EINA_FALSE;
2507 return sd->drag_x_locked;
2511 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2513 API_ENTRY return EINA_FALSE;
2514 return sd->drag_y_locked;
2518 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2521 return sd->child_drag_x_locked;
2525 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2528 return sd->child_drag_y_locked;
2532 elm_widget_theme_object_set(Evas_Object *obj,
2535 const char *welement,
2538 API_ENTRY return EINA_FALSE;
2539 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2543 elm_widget_is_check(const Evas_Object *obj)
2545 static int abort_on_warn = -1;
2546 if (elm_widget_is(obj))
2549 ERR("Passing Object: %p.", obj);
2550 if (abort_on_warn == -1)
2552 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2553 else abort_on_warn = 0;
2555 if (abort_on_warn == 1) abort();
2560 elm_widget_type_check(const Evas_Object *obj,
2564 const char *provided, *expected = "(unknown)";
2565 static int abort_on_warn = -1;
2566 provided = elm_widget_type_get(obj);
2567 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2568 if (type) expected = type;
2569 if ((!provided) || (!provided[0]))
2571 provided = evas_object_type_get(obj);
2572 if ((!provided) || (!provided[0]))
2573 provided = "(unknown)";
2575 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2576 if (abort_on_warn == -1)
2578 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2579 else abort_on_warn = 0;
2581 if (abort_on_warn == 1) abort();
2588 * Split string in words
2590 * @param str Source string
2591 * @return List of const words
2593 * @see elm_widget_stringlist_free()
2597 elm_widget_stringlist_get(const char *str)
2599 Eina_List *list = NULL;
2601 if (!str) return NULL;
2602 for (b = s = str; 1; s++)
2604 if ((*s == ' ') || (!*s))
2606 char *t = malloc(s - b + 1);
2609 strncpy(t, b, s - b);
2611 list = eina_list_append(list, eina_stringshare_add(t));
2622 elm_widget_stringlist_free(Eina_List *list)
2625 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2629 elm_widget_focus_hide_handle(Evas_Object *obj)
2631 _if_focused_revert(obj, EINA_TRUE);
2635 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2637 Evas_Object *o = obj;
2640 if (_elm_widget_is(o)) break;
2641 o = evas_object_smart_parent_get(o);
2645 if (!_is_focusable(o)) return;
2646 elm_widget_focus_steal(o);
2650 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2654 if (!elm_widget_parent_get(obj))
2655 elm_widget_focused_object_clear(obj);
2657 _if_focused_revert(obj, EINA_TRUE);
2661 elm_widget_focus_disabled_handle(Evas_Object *obj)
2665 elm_widget_focus_tree_unfocusable_handle(obj);
2671 * Allocate a new Elm_Widget_Item-derived structure.
2673 * The goal of this structure is to provide common ground for actions
2674 * that a widget item have, such as the owner widget, callback to
2675 * notify deletion, data pointer and maybe more.
2677 * @param widget the owner widget that holds this item, must be an elm_widget!
2678 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2679 * be used to allocate memory.
2681 * @return allocated memory that is already zeroed out, or NULL on errors.
2683 * @see elm_widget_item_new() convenience macro.
2684 * @see elm_widget_item_del() to release memory.
2687 EAPI Elm_Widget_Item *
2688 _elm_widget_item_new(Evas_Object *widget,
2691 if (!_elm_widget_is(widget))
2694 Elm_Widget_Item *item;
2696 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2697 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2699 item = calloc(1, alloc_size);
2700 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2702 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2703 item->widget = widget;
2710 * Releases widget item memory, calling back del_cb() if it exists.
2712 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2713 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2714 * this function and then unset it, thus being useful for 2 step
2715 * cleanup whenever the del_cb may use any of the data that must be
2716 * deleted from item.
2718 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2721 * @param item a valid #Elm_Widget_Item to be deleted.
2722 * @see elm_widget_item_del() convenience macro.
2726 _elm_widget_item_del(Elm_Widget_Item *item)
2728 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2731 item->del_cb((void *)item->data, item->widget, item);
2734 evas_object_del(item->view);
2738 _elm_access_clear(item->access);
2740 item->access = NULL;
2742 if (item->access_info)
2744 eina_stringshare_del(item->access_info);
2745 item->access_info = NULL;
2748 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2755 * Notify object will be deleted without actually deleting it.
2757 * This function will callback Elm_Widget_Item::del_cb if it is set
2758 * and then unset it so it is not called twice (ie: from
2759 * elm_widget_item_del()).
2761 * @param item a valid #Elm_Widget_Item to be notified
2762 * @see elm_widget_item_pre_notify_del() convenience macro.
2766 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2768 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2769 if (!item->del_cb) return;
2770 item->del_cb((void *)item->data, item->widget, item);
2771 item->del_cb = NULL;
2777 * Set the function to notify when item is being deleted.
2779 * This function will complain if there was a callback set already,
2780 * however it will set the new one.
2782 * The callback will be called from elm_widget_item_pre_notify_del()
2783 * or elm_widget_item_del() will be called with:
2784 * - data: the Elm_Widget_Item::data value.
2785 * - obj: the Elm_Widget_Item::widget evas object.
2786 * - event_info: the item being deleted.
2788 * @param item a valid #Elm_Widget_Item to be notified
2789 * @see elm_widget_item_del_cb_set() convenience macro.
2793 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2794 Evas_Smart_Cb del_cb)
2796 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2798 if ((item->del_cb) && (item->del_cb != del_cb))
2799 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2800 item->del_cb, item, del_cb);
2802 item->del_cb = del_cb;
2808 * Set user-data in this item.
2810 * User data may be used to identify this item or just store any
2811 * application data. It is automatically given as the first parameter
2812 * of the deletion notify callback.
2814 * @param item a valid #Elm_Widget_Item to store data in.
2815 * @param data user data to store.
2816 * @see elm_widget_item_del_cb_set() convenience macro.
2820 _elm_widget_item_data_set(Elm_Widget_Item *item,
2823 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2824 if ((item->data) && (item->data != data))
2825 DBG("Replacing item %p data %p with %p", item, item->data, data);
2832 * Retrieves user-data of this item.
2834 * @param item a valid #Elm_Widget_Item to get data from.
2835 * @see elm_widget_item_data_set()
2839 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2841 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2842 return (void *)item->data;
2845 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2847 struct _Elm_Widget_Item_Tooltip
2849 Elm_Widget_Item *item;
2850 Elm_Tooltip_Item_Content_Cb func;
2851 Evas_Smart_Cb del_cb;
2855 static Evas_Object *
2856 _elm_widget_item_tooltip_label_create(void *data,
2857 Evas_Object *obj __UNUSED__,
2858 Evas_Object *tooltip,
2859 void *item __UNUSED__)
2861 Evas_Object *label = elm_label_add(tooltip);
2864 elm_object_style_set(label, "tooltip");
2865 elm_object_text_set(label, data);
2869 static Evas_Object *
2870 _elm_widget_item_tooltip_trans_label_create(void *data,
2871 Evas_Object *obj __UNUSED__,
2872 Evas_Object *tooltip,
2873 void *item __UNUSED__)
2875 Evas_Object *label = elm_label_add(tooltip);
2878 elm_object_style_set(label, "tooltip");
2879 elm_object_translatable_text_set(label, data);
2884 _elm_widget_item_tooltip_label_del_cb(void *data,
2885 Evas_Object *obj __UNUSED__,
2886 void *event_info __UNUSED__)
2888 eina_stringshare_del(data);
2894 * Set the text to be shown in the widget item.
2896 * @param item Target item
2897 * @param text The text to set in the content
2899 * Setup the text as tooltip to object. The item can have only one tooltip,
2900 * so any previous tooltip data is removed.
2905 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2908 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2909 EINA_SAFETY_ON_NULL_RETURN(text);
2911 text = eina_stringshare_add(text);
2912 _elm_widget_item_tooltip_content_cb_set
2913 (item, _elm_widget_item_tooltip_label_create, text,
2914 _elm_widget_item_tooltip_label_del_cb);
2918 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2921 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2922 EINA_SAFETY_ON_NULL_RETURN(text);
2924 text = eina_stringshare_add(text);
2925 _elm_widget_item_tooltip_content_cb_set
2926 (item, _elm_widget_item_tooltip_trans_label_create, text,
2927 _elm_widget_item_tooltip_label_del_cb);
2930 static Evas_Object *
2931 _elm_widget_item_tooltip_create(void *data,
2933 Evas_Object *tooltip)
2935 Elm_Widget_Item_Tooltip *wit = data;
2936 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2940 _elm_widget_item_tooltip_del_cb(void *data,
2942 void *event_info __UNUSED__)
2944 Elm_Widget_Item_Tooltip *wit = data;
2945 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2952 * Set the content to be shown in the tooltip item
2954 * Setup the tooltip to item. The item can have only one tooltip,
2955 * so any previous tooltip data is removed. @p func(with @p data) will
2956 * be called every time that need show the tooltip and it should
2957 * return a valid Evas_Object. This object is then managed fully by
2958 * tooltip system and is deleted when the tooltip is gone.
2960 * @param item the widget item being attached a tooltip.
2961 * @param func the function used to create the tooltip contents.
2962 * @param data what to provide to @a func as callback data/context.
2963 * @param del_cb called when data is not needed anymore, either when
2964 * another callback replaces @func, the tooltip is unset with
2965 * elm_widget_item_tooltip_unset() or the owner @a item
2966 * dies. This callback receives as the first parameter the
2967 * given @a data, and @c event_info is the item.
2972 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2973 Elm_Tooltip_Item_Content_Cb func,
2975 Evas_Smart_Cb del_cb)
2977 Elm_Widget_Item_Tooltip *wit;
2979 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2983 _elm_widget_item_tooltip_unset(item);
2987 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2988 if (!wit) goto error;
2992 wit->del_cb = del_cb;
2994 elm_object_sub_tooltip_content_cb_set
2995 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2996 _elm_widget_item_tooltip_del_cb);
3001 if (del_cb) del_cb((void *)data, NULL, item);
3004 if (del_cb) del_cb((void *)data, item->widget, item);
3010 * Unset tooltip from item
3012 * @param item widget item to remove previously set tooltip.
3014 * Remove tooltip from item. The callback provided as del_cb to
3015 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3016 * it is not used anymore.
3018 * @see elm_widget_item_tooltip_content_cb_set()
3023 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3025 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3026 elm_object_tooltip_unset(item->view);
3032 * Sets a different style for this item tooltip.
3034 * @note before you set a style you should define a tooltip with
3035 * elm_widget_item_tooltip_content_cb_set() or
3036 * elm_widget_item_tooltip_text_set()
3038 * @param item widget item with tooltip already set.
3039 * @param style the theme style to use (default, transparent, ...)
3044 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3047 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3048 elm_object_tooltip_style_set(item->view, style);
3052 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
3054 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3055 return elm_tooltip_size_restrict_disable(item->view, disable);
3059 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
3061 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3062 return elm_tooltip_size_restrict_disabled_get(item->view);
3068 * Get the style for this item tooltip.
3070 * @param item widget item with tooltip already set.
3071 * @return style the theme style in use, defaults to "default". If the
3072 * object does not have a tooltip set, then NULL is returned.
3077 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3079 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3080 return elm_object_tooltip_style_get(item->view);
3084 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3087 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3088 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3092 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3094 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3095 return elm_object_cursor_get(item->view);
3099 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3101 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3102 elm_object_cursor_unset(item->view);
3108 * Sets a different style for this item cursor.
3110 * @note before you set a style you should define a cursor with
3111 * elm_widget_item_cursor_set()
3113 * @param item widget item with cursor already set.
3114 * @param style the theme style to use (default, transparent, ...)
3119 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3122 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3123 elm_object_cursor_style_set(item->view, style);
3129 * Get the style for this item cursor.
3131 * @param item widget item with cursor already set.
3132 * @return style the theme style in use, defaults to "default". If the
3133 * object does not have a cursor set, then NULL is returned.
3138 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3140 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3141 return elm_object_cursor_style_get(item->view);
3147 * Set if the cursor set should be searched on the theme or should use
3148 * the provided by the engine, only.
3150 * @note before you set if should look on theme you should define a cursor
3151 * with elm_object_cursor_set(). By default it will only look for cursors
3152 * provided by the engine.
3154 * @param item widget item with cursor already set.
3155 * @param engine_only boolean to define it cursors should be looked only
3156 * between the provided by the engine or searched on widget's theme as well.
3161 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3162 Eina_Bool engine_only)
3164 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3165 elm_object_cursor_engine_only_set(item->view, engine_only);
3171 * Get the cursor engine only usage for this item cursor.
3173 * @param item widget item with cursor already set.
3174 * @return engine_only boolean to define it cursors should be looked only
3175 * between the provided by the engine or searched on widget's theme as well. If
3176 * the object does not have a cursor set, then EINA_FALSE is returned.
3181 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3183 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3184 return elm_object_cursor_engine_only_get(item->view);
3187 // smart object funcs
3189 _smart_reconfigure(Smart_Data *sd)
3193 evas_object_move(sd->resize_obj, sd->x, sd->y);
3194 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3198 evas_object_move(sd->hover_obj, sd->x, sd->y);
3199 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3204 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3206 Evas_Object *content)
3208 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3209 if (!item->on_content_set_func) return;
3210 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3214 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3217 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3218 if (!item->on_content_get_func) return NULL;
3219 return item->on_content_get_func((Elm_Object_Item *) item, part);
3223 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3226 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3227 if (!item->on_content_unset_func) return NULL;
3228 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3232 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3236 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3237 if (!item->on_text_set_func) return;
3238 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3242 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3243 const char *emission,
3246 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3247 if (item->on_signal_emit_func)
3248 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3252 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3255 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3256 if (!item->on_text_get_func) return NULL;
3257 return item->on_text_get_func((Elm_Object_Item *) item, part);
3261 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3262 Elm_Widget_On_Content_Set_Cb func)
3264 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3265 item->on_content_set_func = func;
3269 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3270 Elm_Widget_On_Content_Get_Cb func)
3272 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3273 item->on_content_get_func = func;
3277 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3278 Elm_Widget_On_Content_Unset_Cb func)
3280 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3281 item->on_content_unset_func = func;
3285 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3286 Elm_Widget_On_Text_Set_Cb func)
3288 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3289 item->on_text_set_func = func;
3293 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3294 Elm_Widget_On_Text_Get_Cb func)
3296 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3297 item->on_text_get_func = func;
3301 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3302 Elm_Widget_On_Signal_Emit_Cb func)
3304 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3305 item->on_signal_emit_func = func;
3309 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3311 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3312 if (item->access_info) eina_stringshare_del(item->access_info);
3313 if (!txt) item->access_info = NULL;
3314 else item->access_info = eina_stringshare_add(txt);
3319 _smart_add(Evas_Object *obj)
3323 sd = calloc(1, sizeof(Smart_Data));
3326 sd->x = sd->y = sd->w = sd->h = 0;
3328 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3329 evas_object_smart_data_set(obj, sd);
3332 static Evas_Object *
3333 _newest_focus_order_get(Evas_Object *obj,
3334 unsigned int *newest_focus_order,
3335 Eina_Bool can_focus_only)
3338 Evas_Object *child, *ret, *best;
3340 API_ENTRY return NULL;
3342 if (!evas_object_visible_get(obj)
3343 || (elm_widget_disabled_get(obj))
3344 || (elm_widget_tree_unfocusable_get(obj)))
3348 if (*newest_focus_order < sd->focus_order)
3350 *newest_focus_order = sd->focus_order;
3353 EINA_LIST_FOREACH(sd->subobjs, l, child)
3355 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3361 if ((!best) || (!elm_widget_can_focus_get(best)))
3368 _if_focused_revert(Evas_Object *obj,
3369 Eina_Bool can_focus_only)
3372 Evas_Object *newest = NULL;
3373 unsigned int newest_focus_order = 0;
3377 if (!sd->focused) return;
3378 if (!sd->parent_obj) return;
3380 top = elm_widget_top_get(sd->parent_obj);
3383 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3386 elm_object_focus_set(newest, EINA_FALSE);
3387 elm_object_focus_set(newest, EINA_TRUE);
3393 _smart_del(Evas_Object *obj)
3396 Edje_Signal_Data *esd;
3397 Elm_Translate_String_Data *ts;
3401 if (sd->del_pre_func) sd->del_pre_func(obj);
3404 sobj = sd->resize_obj;
3405 sd->resize_obj = NULL;
3406 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3407 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3408 evas_object_del(sobj);
3412 sobj = sd->hover_obj;
3413 sd->hover_obj = NULL;
3414 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3415 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3416 evas_object_del(sobj);
3418 EINA_LIST_FREE(sd->subobjs, sobj)
3420 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3421 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3422 evas_object_del(sobj);
3424 eina_list_free(sd->tooltips); /* should be empty anyway */
3425 eina_list_free(sd->cursors); /* should be empty anyway */
3426 EINA_LIST_FREE(sd->edje_signals, esd)
3428 eina_stringshare_del(esd->emission);
3429 eina_stringshare_del(esd->source);
3432 EINA_LIST_FREE(sd->translate_strings, ts)
3434 eina_stringshare_del(ts->id);
3435 eina_stringshare_del(ts->domain);
3436 eina_stringshare_del(ts->string);
3439 eina_list_free(sd->event_cb); /* should be empty anyway */
3440 if (sd->del_func) sd->del_func(obj);
3441 if (sd->style) eina_stringshare_del(sd->style);
3442 if (sd->type) eina_stringshare_del(sd->type);
3443 if (sd->theme) elm_theme_free(sd->theme);
3444 _if_focused_revert(obj, EINA_TRUE);
3445 if (sd->access_info) eina_stringshare_del(sd->access_info);
3450 _smart_move(Evas_Object *obj,
3457 _smart_reconfigure(sd);
3461 _smart_resize(Evas_Object *obj,
3468 _smart_reconfigure(sd);
3472 _smart_show(Evas_Object *obj)
3477 if ((list = evas_object_smart_members_get(obj)))
3479 EINA_LIST_FREE(list, o)
3481 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3482 evas_object_show(o);
3488 _smart_hide(Evas_Object *obj)
3494 list = evas_object_smart_members_get(obj);
3495 EINA_LIST_FREE(list, o)
3497 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3498 evas_object_hide(o);
3503 _smart_color_set(Evas_Object *obj,
3512 if ((list = evas_object_smart_members_get(obj)))
3514 EINA_LIST_FREE(list, o)
3516 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3517 evas_object_color_set(o, r, g, b, a);
3523 _smart_clip_set(Evas_Object *obj,
3529 if ((list = evas_object_smart_members_get(obj)))
3531 EINA_LIST_FREE(list, o)
3533 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3534 evas_object_clip_set(o, clip);
3540 _smart_clip_unset(Evas_Object *obj)
3545 if ((list = evas_object_smart_members_get(obj)))
3547 EINA_LIST_FREE(list, o)
3549 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3550 evas_object_clip_unset(o);
3556 _smart_calculate(Evas_Object *obj)
3559 if (sd->changed_func) sd->changed_func(obj);
3562 /* never need to touch this */
3566 if (_e_smart) return;
3568 static const Evas_Smart_Class sc =
3571 EVAS_SMART_CLASS_VERSION,
3589 _e_smart = evas_smart_class_new(&sc);
3593 /* happy debug functions */
3596 _sub_obj_tree_dump(const Evas_Object *obj,
3601 for (i = 0; i < lvl * 3; i++)
3604 if (_elm_widget_is(obj))
3608 printf("+ %s(%p)\n",
3612 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3613 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3615 if (obj != sd->resize_obj)
3616 _sub_obj_tree_dump(obj, lvl + 1);
3620 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3624 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3627 if (!_elm_widget_is(obj))
3631 Eina_Bool visible = evas_object_visible_get(obj);
3632 Eina_Bool disabled = elm_widget_disabled_get(obj);
3633 Eina_Bool focused = elm_widget_focus_get(obj);
3634 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3638 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3641 fprintf(output, ", style=bold");
3644 fprintf(output, ", color=gray28");
3646 fprintf(output, " ];\n");
3649 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3650 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3651 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3655 fprintf(output, ", style=bold");
3658 fprintf(output, ", fontcolor=gray28");
3660 if ((disabled) || (!visible))
3661 fprintf(output, ", color=gray");
3663 fprintf(output, " ];\n");
3667 EINA_LIST_FOREACH(sd->subobjs, l, o)
3668 _sub_obj_tree_dot_dump(o, output);
3673 elm_widget_tree_dump(const Evas_Object *top)
3676 _sub_obj_tree_dump(top, 0);
3684 elm_widget_tree_dot_dump(const Evas_Object *top,
3688 if (!_elm_widget_is(top))
3690 fprintf(output, "graph " " { node [shape=record];\n");
3691 _sub_obj_tree_dot_dump(top, output);
3692 fprintf(output, "}\n");