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;
29 Evas_Coord x, y, w, h;
31 Evas_Object *resize_obj;
32 Evas_Object *hover_obj;
33 Eina_List *tooltips, *cursors;
34 void (*del_func)(Evas_Object *obj);
35 void (*del_pre_func)(Evas_Object *obj);
36 void (*focus_func)(Evas_Object *obj);
37 void (*activate_func)(Evas_Object *obj);
38 void (*disable_func)(Evas_Object *obj);
39 void (*theme_func)(Evas_Object *obj);
40 void (*translate_func)(Evas_Object *obj);
41 Eina_Bool (*event_func)(Evas_Object *obj,
43 Evas_Callback_Type type,
45 void (*signal_func)(Evas_Object *obj,
48 void (*callback_add_func)(Evas_Object *obj,
53 void (*callback_del_func)(Evas_Object *obj,
58 void (*changed_func)(Evas_Object *obj);
59 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
60 Elm_Focus_Direction dir,
62 void (*on_focus_func)(void *data,
65 void (*on_change_func)(void *data,
68 void (*on_show_region_func)(void *data,
70 void *on_show_region_data;
71 void (*focus_region_func)(Evas_Object *obj,
76 void (*on_focus_region_func)(const Evas_Object *obj,
81 Elm_Widget_On_Text_Set_Cb on_text_set_func;
82 Elm_Widget_On_Text_Get_Cb on_text_get_func;
83 Elm_Widget_On_Content_Set_Cb on_content_set_func;
84 Elm_Widget_On_Content_Get_Cb on_content_get_func;
85 Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
87 Evas_Coord rx, ry, rw, rh;
93 const char *access_info;
94 unsigned int focus_order;
95 Eina_Bool focus_order_on_calc;
97 int child_drag_x_locked;
98 int child_drag_y_locked;
100 Eina_List *edje_signals;
101 Eina_List *translate_strings;
103 Eina_Bool drag_x_locked : 1;
104 Eina_Bool drag_y_locked : 1;
106 Eina_Bool can_focus : 1;
107 Eina_Bool child_can_focus : 1;
108 Eina_Bool focused : 1;
109 Eina_Bool top_win_focused : 1;
110 Eina_Bool tree_unfocusable : 1;
111 Eina_Bool highlight_ignore : 1;
112 Eina_Bool highlight_in_theme : 1;
113 Eina_Bool disabled : 1;
114 Eina_Bool is_mirrored : 1;
115 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
116 Eina_Bool still_in : 1;
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_down(void *data,
249 Evas_Object *obj __UNUSED__,
252 Smart_Data *sd = data;
253 Evas_Event_Mouse_Down *ev = event_info;
254 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
255 sd->still_in = EINA_TRUE;
259 _sub_obj_mouse_move(void *data,
264 Smart_Data *sd = data;
265 Evas_Event_Mouse_Move *ev = event_info;
268 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
269 sd->still_in = EINA_FALSE;
272 Evas_Coord x, y, w, h;
273 evas_object_geometry_get(obj, &x, &y, &w, &h);
274 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
275 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
276 sd->still_in = EINA_FALSE;
282 _sub_obj_mouse_up(void *data,
285 void *event_info __UNUSED__)
287 Smart_Data *sd = data;
289 elm_widget_focus_mouse_up_handle(obj);
290 sd->still_in = EINA_FALSE;
294 _propagate_x_drag_lock(Evas_Object *obj,
300 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
303 sd2->child_drag_x_locked += dir;
304 _propagate_x_drag_lock(sd->parent_obj, dir);
310 _propagate_y_drag_lock(Evas_Object *obj,
316 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
319 sd2->child_drag_y_locked += dir;
320 _propagate_y_drag_lock(sd->parent_obj, dir);
326 _propagate_event(void *data,
332 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
333 Evas_Event_Flags *event_flags = NULL;
337 case EVAS_CALLBACK_KEY_DOWN:
339 Evas_Event_Key_Down *ev = event_info;
340 event_flags = &(ev->event_flags);
344 case EVAS_CALLBACK_KEY_UP:
346 Evas_Event_Key_Up *ev = event_info;
347 event_flags = &(ev->event_flags);
351 case EVAS_CALLBACK_MOUSE_WHEEL:
353 Evas_Event_Mouse_Wheel *ev = event_info;
354 event_flags = &(ev->event_flags);
362 elm_widget_event_propagate(obj, type, event_info, event_flags);
366 _parent_focus(Evas_Object *obj)
369 if (sd->focused) return;
371 Evas_Object *o = elm_widget_parent_get(obj);
372 sd->focus_order_on_calc = EINA_TRUE;
374 if (o) _parent_focus(o);
376 if (!sd->focus_order_on_calc)
377 return; /* we don't want to override it if by means of any of the
378 callbacks below one gets to calculate our order
382 sd->focus_order = focus_order;
383 if (sd->top_win_focused)
385 sd->focused = EINA_TRUE;
386 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
387 if (sd->focus_func) sd->focus_func(obj);
388 _elm_widget_focus_region_show(obj);
390 sd->focus_order_on_calc = EINA_FALSE;
394 _elm_object_focus_chain_del_cb(void *data,
397 void *event_info __UNUSED__)
399 Smart_Data *sd = data;
401 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
404 // exposed util funcs to elm
406 _elm_widget_type_clear(void)
410 EINA_LIST_FREE(widtypes, ptr)
412 eina_stringshare_del(*ptr);
418 _elm_widget_focus_region_show(const Evas_Object *obj)
420 Evas_Coord x, y, w, h, ox, oy;
426 o = elm_widget_parent_get(obj);
429 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
430 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
434 sd2 = evas_object_smart_data_get(o);
435 if (sd2->focus_region_func)
437 sd2->focus_region_func(o, x, y, w, h);
438 elm_widget_focus_region_get(o, &x, &y, &w, &h);
442 evas_object_geometry_get(o, &px, &py, NULL, NULL);
448 o = elm_widget_parent_get(o);
453 * @defgroup Widget Widget
456 * Exposed api for making widgets
459 elm_widget_type_register(const char **ptr)
461 widtypes = eina_list_append(widtypes, (void *)ptr);
465 * @defgroup Widget Widget
468 * Disposed api for making widgets
471 elm_widget_type_unregister(const char **ptr)
473 widtypes = eina_list_remove(widtypes, (void *)ptr);
477 elm_widget_api_check(int ver)
479 if (ver != ELM_INTERNAL_API_VERSION)
481 CRITICAL("Elementary widget api versions do not match");
488 elm_widget_add(Evas *evas)
492 obj = evas_object_smart_add(evas, _e_smart);
493 elm_widget_mirrored_set(obj, elm_mirrored_get());
498 elm_widget_del_hook_set(Evas_Object *obj,
499 void (*func)(Evas_Object *obj))
506 elm_widget_del_pre_hook_set(Evas_Object *obj,
507 void (*func)(Evas_Object *obj))
510 sd->del_pre_func = func;
514 elm_widget_focus_hook_set(Evas_Object *obj,
515 void (*func)(Evas_Object *obj))
518 sd->focus_func = func;
522 elm_widget_activate_hook_set(Evas_Object *obj,
523 void (*func)(Evas_Object *obj))
526 sd->activate_func = func;
530 elm_widget_disable_hook_set(Evas_Object *obj,
531 void (*func)(Evas_Object *obj))
534 sd->disable_func = func;
538 elm_widget_theme_hook_set(Evas_Object *obj,
539 void (*func)(Evas_Object *obj))
542 sd->theme_func = func;
546 elm_widget_translate_hook_set(Evas_Object *obj,
547 void (*func)(Evas_Object *obj))
550 sd->translate_func = func;
554 elm_widget_event_hook_set(Evas_Object *obj,
555 Eina_Bool (*func)(Evas_Object *obj,
557 Evas_Callback_Type type,
561 sd->event_func = func;
565 elm_widget_text_set_hook_set(Evas_Object *obj,
566 Elm_Widget_On_Text_Set_Cb func)
569 sd->on_text_set_func = func;
573 elm_widget_text_get_hook_set(Evas_Object *obj,
574 Elm_Widget_On_Text_Get_Cb func)
577 sd->on_text_get_func = func;
581 elm_widget_content_set_hook_set(Evas_Object *obj,
582 Elm_Widget_On_Content_Set_Cb func)
585 sd->on_content_set_func = func;
589 elm_widget_content_get_hook_set(Evas_Object *obj,
590 Elm_Widget_On_Content_Get_Cb func)
593 sd->on_content_get_func = func;
597 elm_widget_content_unset_hook_set(Evas_Object *obj,
598 Elm_Widget_On_Content_Unset_Cb func)
601 sd->on_content_unset_func = func;
605 elm_widget_changed_hook_set(Evas_Object *obj,
606 void (*func)(Evas_Object *obj))
609 sd->changed_func = func;
613 elm_widget_signal_emit_hook_set(Evas_Object *obj,
614 void (*func)(Evas_Object *obj,
615 const char *emission,
619 sd->signal_func = func;
623 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
624 void (*func)(Evas_Object *obj,
625 const char *emission,
627 Edje_Signal_Cb func_cb,
631 sd->callback_add_func = func;
635 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
636 void (*func)(Evas_Object *obj,
637 const char *emission,
639 Edje_Signal_Cb func_cb,
643 sd->callback_del_func = func;
647 elm_widget_theme(Evas_Object *obj)
655 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
656 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
657 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
658 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
659 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
660 if (sd->theme_func) sd->theme_func(obj);
664 elm_widget_theme_specific(Evas_Object *obj,
672 Elm_Theme *th2, *thdef;
675 thdef = elm_theme_default_get();
680 if (!th2) th2 = thdef;
688 if (th2 == thdef) break;
689 th2 = th2->ref_theme;
690 if (!th2) th2 = thdef;
694 EINA_LIST_FOREACH(sd->subobjs, l, child)
695 elm_widget_theme_specific(child, th, force);
696 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
697 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
698 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
699 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
700 if (sd->theme_func) sd->theme_func(obj);
706 * Set hook to get next object in object focus chain.
708 * @param obj The widget object.
709 * @param func The hook to be used with this widget.
714 elm_widget_focus_next_hook_set(Evas_Object *obj,
715 Eina_Bool (*func)(const Evas_Object *obj,
716 Elm_Focus_Direction dir,
720 sd->focus_next_func = func;
724 * Returns the widget's mirrored mode.
726 * @param obj The widget.
727 * @return mirrored mode of the object.
731 elm_widget_mirrored_get(const Evas_Object *obj)
733 API_ENTRY return EINA_FALSE;
734 return sd->is_mirrored;
738 * Sets the widget's mirrored mode.
740 * @param obj The widget.
741 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
744 elm_widget_mirrored_set(Evas_Object *obj,
748 if (sd->is_mirrored != mirrored)
750 sd->is_mirrored = mirrored;
751 elm_widget_theme(obj);
757 * Resets the mirrored mode from the system mirror mode for widgets that are in
758 * automatic mirroring mode. This function does not call elm_widget_theme.
760 * @param obj The widget.
761 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
764 _elm_widget_mirrored_reload(Evas_Object *obj)
767 Eina_Bool mirrored = elm_mirrored_get();
768 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
770 sd->is_mirrored = mirrored;
775 * Returns the widget's mirrored mode setting.
777 * @param obj The widget.
778 * @return mirrored mode setting of the object.
782 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
784 API_ENTRY return EINA_FALSE;
785 return sd->mirrored_auto_mode;
789 * Sets the widget's mirrored mode setting.
790 * When widget in automatic mode, it follows the system mirrored mode set by
791 * elm_mirrored_set().
792 * @param obj The widget.
793 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
796 elm_widget_mirrored_automatic_set(Evas_Object *obj,
800 if (sd->mirrored_auto_mode != automatic)
802 sd->mirrored_auto_mode = automatic;
806 elm_widget_mirrored_set(obj, elm_mirrored_get());
812 elm_widget_on_focus_hook_set(Evas_Object *obj,
813 void (*func)(void *data,
818 sd->on_focus_func = func;
819 sd->on_focus_data = data;
823 elm_widget_on_change_hook_set(Evas_Object *obj,
824 void (*func)(void *data,
829 sd->on_change_func = func;
830 sd->on_change_data = data;
834 elm_widget_on_show_region_hook_set(Evas_Object *obj,
835 void (*func)(void *data,
840 sd->on_show_region_func = func;
841 sd->on_show_region_data = data;
847 * Set the hook to use to show the focused region.
849 * Whenever a new widget gets focused or it's needed to show the focused
850 * area of the current one, this hook will be called on objects that may
851 * want to move their children into their visible area.
852 * The area given in the hook function is relative to the @p obj widget.
854 * @param obj The widget object
855 * @param func The function to call to show the specified area.
860 elm_widget_focus_region_hook_set(Evas_Object *obj,
861 void (*func)(Evas_Object *obj,
868 sd->focus_region_func = func;
874 * Set the hook to retrieve the focused region of a widget.
876 * This hook will be called by elm_widget_focus_region_get() whenever
877 * it's needed to get the focused area of a widget. The area must be relative
878 * to the widget itself and if no hook is set, it will default to the entire
881 * @param obj The widget object
882 * @param func The function used to retrieve the focus region.
887 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
888 void (*func)(const Evas_Object *obj,
895 sd->on_focus_region_func = func;
899 elm_widget_data_set(Evas_Object *obj,
907 elm_widget_data_get(const Evas_Object *obj)
909 API_ENTRY return NULL;
914 elm_widget_sub_object_add(Evas_Object *obj,
918 double scale, pscale = elm_widget_scale_get(sobj);
919 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
920 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
922 if (_elm_widget_is(sobj))
924 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
927 if (sd2->parent_obj == obj)
930 elm_widget_sub_object_del(sd2->parent_obj, sobj);
931 sd2->parent_obj = obj;
932 sd2->top_win_focused = sd->top_win_focused;
933 if (!sd->child_can_focus && (_is_focusable(sobj)))
934 sd->child_can_focus = EINA_TRUE;
939 void *data = evas_object_data_get(sobj, "elm-parent");
942 if (data == obj) return;
943 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
948 sd->subobjs = eina_list_append(sd->subobjs, sobj);
949 evas_object_data_set(sobj, "elm-parent", obj);
950 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
951 if (_elm_widget_is(sobj))
952 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
953 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
954 scale = elm_widget_scale_get(sobj);
955 th = elm_widget_theme_get(sobj);
956 mirrored = elm_widget_mirrored_get(sobj);
957 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
958 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
962 elm_widget_sub_object_del(Evas_Object *obj,
965 Evas_Object *sobj_parent;
969 sobj_parent = evas_object_data_del(sobj, "elm-parent");
970 if (sobj_parent != obj)
972 static int abort_on_warn = -1;
973 ERR("removing sub object %p from parent %p, "
974 "but elm-parent is different %p!",
975 sobj, obj, sobj_parent);
976 if (EINA_UNLIKELY(abort_on_warn == -1))
978 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
979 else abort_on_warn = 0;
981 if (abort_on_warn == 1) abort();
983 if (_elm_widget_is(sobj))
985 if (elm_widget_focus_get(sobj))
987 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
988 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
990 if ((sd->child_can_focus) && (_is_focusable(sobj)))
994 sd->child_can_focus = EINA_FALSE;
995 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
997 if (_is_focusable(subobj))
999 sd->child_can_focus = EINA_TRUE;
1004 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1007 sd2->parent_obj = NULL;
1008 if (sd2->resize_obj == sobj)
1009 sd2->resize_obj = NULL;
1011 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1014 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1017 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1018 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1020 if (_elm_widget_is(sobj))
1021 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1023 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1027 elm_widget_resize_object_set(Evas_Object *obj,
1031 // orphan previous resize obj
1034 evas_object_clip_unset(sd->resize_obj);
1035 evas_object_data_del(sd->resize_obj, "elm-parent");
1036 if (_elm_widget_is(sd->resize_obj))
1038 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1039 if (sd2) sd2->parent_obj = NULL;
1040 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1043 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1045 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1046 _sub_obj_mouse_down, sd);
1047 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1048 _sub_obj_mouse_move, sd);
1049 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1050 _sub_obj_mouse_up, sd);
1051 evas_object_smart_member_del(sd->resize_obj);
1052 if (_elm_widget_is(sd->resize_obj))
1054 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1057 // orphan new resize obj
1060 evas_object_data_del(sobj, "elm-parent");
1061 if (_elm_widget_is(sobj))
1063 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1064 if (sd2) sd2->parent_obj = NULL;
1065 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1068 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1070 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1071 _sub_obj_mouse_down, sd);
1072 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1073 _sub_obj_mouse_move, sd);
1074 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1075 _sub_obj_mouse_up, sd);
1076 evas_object_smart_member_del(sobj);
1077 if (_elm_widget_is(sobj))
1079 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1082 // set the resize obj up
1083 sd->resize_obj = sobj;
1086 if (_elm_widget_is(sd->resize_obj))
1088 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1091 sd2->parent_obj = obj;
1092 sd2->top_win_focused = sd->top_win_focused;
1094 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1097 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1098 evas_object_smart_member_add(sobj, obj);
1099 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1101 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1102 _sub_obj_mouse_down, sd);
1103 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1104 _sub_obj_mouse_move, sd);
1105 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1106 _sub_obj_mouse_up, sd);
1107 _smart_reconfigure(sd);
1108 evas_object_data_set(sobj, "elm-parent", obj);
1109 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1110 if (_elm_widget_is(sobj))
1112 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1118 elm_widget_hover_object_set(Evas_Object *obj,
1124 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1127 sd->hover_obj = sobj;
1130 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1132 _smart_reconfigure(sd);
1137 elm_widget_can_focus_set(Evas_Object *obj,
1138 Eina_Bool can_focus)
1141 sd->can_focus = can_focus;
1144 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1146 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1147 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1149 (void *)(long)EVAS_CALLBACK_KEY_UP);
1150 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1152 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1156 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1158 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1160 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1166 elm_widget_can_focus_get(const Evas_Object *obj)
1168 API_ENTRY return EINA_FALSE;
1169 return sd->can_focus;
1173 elm_widget_child_can_focus_get(const Evas_Object *obj)
1175 API_ENTRY return EINA_FALSE;
1176 return sd->child_can_focus;
1182 * This API makes the widget object and its children to be unfocusable.
1184 * This API can be helpful for an object to be deleted.
1185 * When an object will be deleted soon, it and its children may not
1186 * want to get focus (by focus reverting or by other focus controls).
1187 * Then, just use this API before deleting.
1189 * @param obj The widget root of sub-tree
1190 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1195 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1196 Eina_Bool tree_unfocusable)
1200 if (sd->tree_unfocusable == tree_unfocusable) return;
1201 sd->tree_unfocusable = !!tree_unfocusable;
1202 elm_widget_focus_tree_unfocusable_handle(obj);
1208 * This returns true, if the object sub-tree is unfocusable.
1210 * @param obj The widget root of sub-tree
1211 * @return EINA_TRUE if the object sub-tree is unfocusable
1216 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1218 API_ENTRY return EINA_FALSE;
1219 return sd->tree_unfocusable;
1223 elm_widget_highlight_ignore_set(Evas_Object *obj,
1227 sd->highlight_ignore = !!ignore;
1231 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1233 API_ENTRY return EINA_FALSE;
1234 return sd->highlight_ignore;
1238 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1239 Eina_Bool highlight)
1242 sd->highlight_in_theme = !!highlight;
1243 /* FIXME: if focused, it should switch from one mode to the other */
1247 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1249 API_ENTRY return EINA_FALSE;
1250 return sd->highlight_in_theme;
1254 elm_widget_focus_get(const Evas_Object *obj)
1256 API_ENTRY return EINA_FALSE;
1261 elm_widget_focused_object_get(const Evas_Object *obj)
1263 const Evas_Object *subobj;
1265 API_ENTRY return NULL;
1267 if (!sd->focused) return NULL;
1268 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1270 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1271 if (fobj) return fobj;
1273 return (Evas_Object *)obj;
1277 elm_widget_top_get(const Evas_Object *obj)
1279 API_ENTRY return NULL;
1280 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1281 return (Evas_Object *)obj;
1285 elm_widget_is(const Evas_Object *obj)
1287 return _elm_widget_is(obj);
1291 elm_widget_parent_widget_get(const Evas_Object *obj)
1293 Evas_Object *parent;
1295 if (_elm_widget_is(obj))
1297 Smart_Data *sd = evas_object_smart_data_get(obj);
1298 if (!sd) return NULL;
1299 parent = sd->parent_obj;
1303 parent = evas_object_data_get(obj, "elm-parent");
1304 if (!parent) parent = evas_object_smart_parent_get(obj);
1309 Evas_Object *elm_parent;
1310 if (_elm_widget_is(parent)) break;
1311 elm_parent = evas_object_data_get(parent, "elm-parent");
1312 if (elm_parent) parent = elm_parent;
1313 else parent = evas_object_smart_parent_get(parent);
1319 elm_widget_event_callback_add(Evas_Object *obj,
1324 EINA_SAFETY_ON_NULL_RETURN(func);
1325 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1328 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1332 elm_widget_event_callback_del(Evas_Object *obj,
1336 API_ENTRY return NULL;
1337 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1339 Elm_Event_Cb_Data *ecd;
1340 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1341 if ((ecd->func == func) && (ecd->data == data))
1344 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1345 return (void *)data;
1351 elm_widget_event_propagate(Evas_Object *obj,
1352 Evas_Callback_Type type,
1354 Evas_Event_Flags *event_flags)
1356 API_ENTRY return EINA_FALSE; //TODO reduce.
1357 if (!_elm_widget_is(obj)) return EINA_FALSE;
1358 Evas_Object *parent = obj;
1359 Elm_Event_Cb_Data *ecd;
1360 Eina_List *l, *l_prev;
1363 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1365 sd = evas_object_smart_data_get(parent);
1366 if ((!sd) || (!_elm_widget_is(obj)))
1367 return EINA_FALSE; //Not Elm Widget
1369 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1372 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1374 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1375 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1378 parent = sd->parent_obj;
1387 * Set custom focus chain.
1389 * This function i set one new and overwrite any previous custom focus chain
1390 * with the list of objects. The previous list will be deleted and this list
1391 * will be managed. After setted, don't modity it.
1393 * @note On focus cycle, only will be evaluated children of this container.
1395 * @param obj The container widget
1396 * @param objs Chain of objects to pass focus
1400 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1404 if (!sd->focus_next_func)
1407 elm_widget_focus_custom_chain_unset(obj);
1412 EINA_LIST_FOREACH(objs, l, o)
1414 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1415 _elm_object_focus_chain_del_cb, sd);
1418 sd->focus_chain = objs;
1424 * Get custom focus chain
1426 * @param obj The container widget
1429 EAPI const Eina_List *
1430 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1432 API_ENTRY return NULL;
1433 return (const Eina_List *)sd->focus_chain;
1439 * Unset custom focus chain
1441 * @param obj The container widget
1445 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1448 Eina_List *l, *l_next;
1451 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1453 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1454 _elm_object_focus_chain_del_cb, sd);
1455 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1462 * Append object to custom focus chain.
1464 * @note If relative_child equal to NULL or not in custom chain, the object
1465 * will be added in end.
1467 * @note On focus cycle, only will be evaluated children of this container.
1469 * @param obj The container widget
1470 * @param child The child to be added in custom chain
1471 * @param relative_child The relative object to position the child
1475 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1477 Evas_Object *relative_child)
1480 EINA_SAFETY_ON_NULL_RETURN(child);
1481 if (!sd->focus_next_func)
1484 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1485 _elm_object_focus_chain_del_cb, sd);
1487 if (!relative_child)
1489 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1493 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1500 * Prepend object to custom focus chain.
1502 * @note If relative_child equal to NULL or not in custom chain, the object
1503 * will be added in begin.
1505 * @note On focus cycle, only will be evaluated children of this container.
1507 * @param obj The container widget
1508 * @param child The child to be added in custom chain
1509 * @param relative_child The relative object to position the child
1513 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1515 Evas_Object *relative_child)
1518 EINA_SAFETY_ON_NULL_RETURN(child);
1519 if (!sd->focus_next_func)
1522 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1523 _elm_object_focus_chain_del_cb, sd);
1525 if (!relative_child)
1527 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1531 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1538 * Give focus to next object in object tree.
1540 * Give focus to next object in focus chain of one object sub-tree.
1541 * If the last object of chain already have focus, the focus will go to the
1542 * first object of chain.
1544 * @param obj The widget root of sub-tree
1545 * @param dir Direction to cycle the focus
1550 elm_widget_focus_cycle(Evas_Object *obj,
1551 Elm_Focus_Direction dir)
1553 Evas_Object *target = NULL;
1554 if (!_elm_widget_is(obj))
1556 elm_widget_focus_next_get(obj, dir, &target);
1558 elm_widget_focus_steal(target);
1564 * Give focus to near object in one direction.
1566 * Give focus to near object in direction of one object.
1567 * If none focusable object in given direction, the focus will not change.
1569 * @param obj The reference widget
1570 * @param x Horizontal component of direction to focus
1571 * @param y Vertical component of direction to focus
1576 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1586 * Get next object in focus chain of object tree.
1588 * Get next object in focus chain of one object sub-tree.
1589 * Return the next object by reference. If don't have any candidate to receive
1590 * focus before chain end, the first candidate will be returned.
1592 * @param obj The widget root of sub-tree
1593 * @param dir Direction os focus chain
1594 * @param next The next object in focus chain
1595 * @return EINA_TRUE if don't need focus chain restart/loop back
1596 * to use 'next' obj.
1601 elm_widget_focus_next_get(const Evas_Object *obj,
1602 Elm_Focus_Direction dir,
1609 API_ENTRY return EINA_FALSE;
1611 /* Ignore if disabled */
1612 if ((!evas_object_visible_get(obj))
1613 || (elm_widget_disabled_get(obj))
1614 || (elm_widget_tree_unfocusable_get(obj)))
1618 if (sd->focus_next_func)
1619 return sd->focus_next_func(obj, dir, next);
1621 if (!elm_widget_can_focus_get(obj))
1625 *next = (Evas_Object *)obj;
1626 return !elm_widget_focus_get(obj);
1632 * Get next object in focus chain of object tree in list.
1634 * Get next object in focus chain of one object sub-tree ordered by one list.
1635 * Return the next object by reference. If don't have any candidate to receive
1636 * focus before list end, the first candidate will be returned.
1638 * @param obj The widget root of sub-tree
1639 * @param dir Direction os focus chain
1640 * @param items list with ordered objects
1641 * @param list_data_get function to get the object from one item of list
1642 * @param next The next object in focus chain
1643 * @return EINA_TRUE if don't need focus chain restart/loop back
1644 * to use 'next' obj.
1649 elm_widget_focus_list_next_get(const Evas_Object *obj,
1650 const Eina_List *items,
1651 void *(*list_data_get)(const Eina_List * list),
1652 Elm_Focus_Direction dir,
1655 Eina_List *(*list_next)(const Eina_List * list);
1661 if (!_elm_widget_is(obj))
1668 if (dir == ELM_FOCUS_PREVIOUS)
1670 items = eina_list_last(items);
1671 list_next = eina_list_prev;
1673 else if (dir == ELM_FOCUS_NEXT)
1674 list_next = eina_list_next;
1678 const Eina_List *l = items;
1680 /* Recovery last focused sub item */
1681 if (elm_widget_focus_get(obj))
1682 for (; l; l = list_next(l))
1684 Evas_Object *cur = list_data_get(l);
1685 if (elm_widget_focus_get(cur)) break;
1688 const Eina_List *start = l;
1689 Evas_Object *to_focus = NULL;
1691 /* Interate sub items */
1692 /* Go to end of list */
1693 for (; l; l = list_next(l))
1695 Evas_Object *tmp = NULL;
1696 Evas_Object *cur = list_data_get(l);
1698 if (elm_widget_parent_get(cur) != obj)
1701 /* Try Focus cycle in subitem */
1702 if (elm_widget_focus_next_get(cur, dir, &tmp))
1707 else if ((tmp) && (!to_focus))
1713 /* Get First possible */
1714 for (; l != start; l = list_next(l))
1716 Evas_Object *tmp = NULL;
1717 Evas_Object *cur = list_data_get(l);
1719 if (elm_widget_parent_get(cur) != obj)
1722 /* Try Focus cycle in subitem */
1723 elm_widget_focus_next_get(cur, dir, &tmp);
1736 elm_widget_signal_emit(Evas_Object *obj,
1737 const char *emission,
1741 if (!sd->signal_func) return;
1742 sd->signal_func(obj, emission, source);
1746 _edje_signal_callback(void *data,
1747 Evas_Object *obj __UNUSED__,
1748 const char *emission,
1751 Edje_Signal_Data *esd = data;
1752 esd->func(esd->data, esd->obj, emission, source);
1756 elm_widget_signal_callback_add(Evas_Object *obj,
1757 const char *emission,
1759 Edje_Signal_Cb func,
1762 Edje_Signal_Data *esd;
1764 if (!sd->callback_add_func) return;
1765 EINA_SAFETY_ON_NULL_RETURN(func);
1767 esd = ELM_NEW(Edje_Signal_Data);
1772 esd->emission = eina_stringshare_add(emission);
1773 esd->source = eina_stringshare_add(source);
1775 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1776 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1780 elm_widget_signal_callback_del(Evas_Object *obj,
1781 const char *emission,
1783 Edje_Signal_Cb func)
1785 Edje_Signal_Data *esd;
1788 API_ENTRY return NULL;
1789 if (!sd->callback_del_func) return NULL;
1791 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1793 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1794 (!strcmp(esd->source, source)))
1796 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1797 eina_stringshare_del(esd->emission);
1798 eina_stringshare_del(esd->source);
1804 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1809 elm_widget_focus_set(Evas_Object *obj,
1816 sd->focus_order = focus_order;
1817 sd->focused = EINA_TRUE;
1818 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1822 sd->focus_func(obj);
1829 if ((_is_focusable(sd->resize_obj)) &&
1830 (!elm_widget_disabled_get(sd->resize_obj)))
1832 elm_widget_focus_set(sd->resize_obj, first);
1838 EINA_LIST_FOREACH(sd->subobjs, l, child)
1840 if ((_is_focusable(child)) &&
1841 (!elm_widget_disabled_get(child)))
1843 elm_widget_focus_set(child, first);
1853 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1855 if ((_is_focusable(child)) &&
1856 (!elm_widget_disabled_get(child)))
1858 elm_widget_focus_set(child, first);
1864 if ((_is_focusable(sd->resize_obj)) &&
1865 (!elm_widget_disabled_get(sd->resize_obj)))
1867 elm_widget_focus_set(sd->resize_obj, first);
1875 elm_widget_parent_get(const Evas_Object *obj)
1877 API_ENTRY return NULL;
1878 return sd->parent_obj;
1882 elm_widget_focused_object_clear(Evas_Object *obj)
1885 if (!sd->focused) return;
1886 if (elm_widget_focus_get(sd->resize_obj))
1887 elm_widget_focused_object_clear(sd->resize_obj);
1892 EINA_LIST_FOREACH(sd->subobjs, l, child)
1894 if (elm_widget_focus_get(child))
1896 elm_widget_focused_object_clear(child);
1901 sd->focused = EINA_FALSE;
1902 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1903 if (sd->focus_func) sd->focus_func(obj);
1907 elm_widget_focus_steal(Evas_Object *obj)
1909 Evas_Object *parent, *o;
1912 if (sd->focused) return;
1913 if (sd->disabled) return;
1914 if (!sd->can_focus) return;
1915 if (sd->tree_unfocusable) return;
1919 o = elm_widget_parent_get(parent);
1921 sd = evas_object_smart_data_get(o);
1922 if (sd->disabled || sd->tree_unfocusable) return;
1923 if (sd->focused) break;
1926 if (!elm_widget_parent_get(parent))
1927 elm_widget_focused_object_clear(parent);
1930 parent = elm_widget_parent_get(parent);
1931 sd = evas_object_smart_data_get(parent);
1932 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1933 elm_widget_focused_object_clear(sd->resize_obj);
1938 EINA_LIST_FOREACH(sd->subobjs, l, child)
1940 if (elm_widget_focus_get(child))
1942 elm_widget_focused_object_clear(child);
1953 elm_widget_focus_restore(Evas_Object *obj)
1955 Evas_Object *newest = NULL;
1956 unsigned int newest_focus_order = 0;
1959 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1962 elm_object_unfocus(newest);
1963 elm_object_focus(newest);
1968 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1974 if (sd->top_win_focused == top_win_focused) return;
1976 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1977 EINA_LIST_FOREACH(sd->subobjs, l, child)
1979 _elm_widget_top_win_focused_set(child, top_win_focused);
1981 sd->top_win_focused = top_win_focused;
1985 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1987 API_ENTRY return EINA_FALSE;
1988 return sd->top_win_focused;
1992 elm_widget_activate(Evas_Object *obj)
1995 elm_widget_change(obj);
1996 if (sd->activate_func) sd->activate_func(obj);
2000 elm_widget_change(Evas_Object *obj)
2003 elm_widget_change(elm_widget_parent_get(obj));
2004 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2008 elm_widget_disabled_set(Evas_Object *obj,
2013 if (sd->disabled == disabled) return;
2014 sd->disabled = !!disabled;
2015 elm_widget_focus_disabled_handle(obj);
2016 if (sd->disable_func) sd->disable_func(obj);
2020 elm_widget_disabled_get(const Evas_Object *obj)
2023 return sd->disabled;
2027 elm_widget_show_region_set(Evas_Object *obj,
2032 Eina_Bool forceshow)
2034 Evas_Object *parent_obj, *child_obj;
2035 Evas_Coord px, py, cx, cy;
2037 evas_smart_objects_calculate(evas_object_evas_get(obj));
2040 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2041 && (w == sd->rw) && (h == sd->rh)) return;
2046 if (sd->on_show_region_func)
2047 sd->on_show_region_func(sd->on_show_region_data, obj);
2051 parent_obj = sd->parent_obj;
2052 child_obj = sd->obj;
2053 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2054 sd = evas_object_smart_data_get(parent_obj);
2057 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2058 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2067 if (sd->on_show_region_func)
2069 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2076 elm_widget_show_region_get(const Evas_Object *obj,
2092 * Get the focus region of the given widget.
2094 * The focus region is the area of a widget that should brought into the
2095 * visible area when the widget is focused. Mostly used to show the part of
2096 * an entry where the cursor is, for example. The area returned is relative
2097 * to the object @p obj.
2098 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2099 * function will return the full size of the object.
2101 * @param obj The widget object
2102 * @param x Where to store the x coordinate of the area
2103 * @param y Where to store the y coordinate of the area
2104 * @param w Where to store the width of the area
2105 * @param h Where to store the height of the area
2110 elm_widget_focus_region_get(const Evas_Object *obj,
2120 sd = evas_object_smart_data_get(obj);
2121 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2123 evas_object_geometry_get(obj, NULL, NULL, w, h);
2128 sd->on_focus_region_func(obj, x, y, w, h);
2132 elm_widget_scroll_hold_push(Evas_Object *obj)
2136 if (sd->scroll_hold == 1)
2137 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2138 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2139 // FIXME: on delete/reparent hold pop
2143 elm_widget_scroll_hold_pop(Evas_Object *obj)
2147 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2148 if (!sd->scroll_hold)
2149 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2150 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2154 elm_widget_scroll_hold_get(const Evas_Object *obj)
2157 return sd->scroll_hold;
2161 elm_widget_scroll_freeze_push(Evas_Object *obj)
2164 sd->scroll_freeze++;
2165 if (sd->scroll_freeze == 1)
2166 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2167 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2168 // FIXME: on delete/reparent freeze pop
2172 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2175 sd->scroll_freeze--;
2176 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2177 if (!sd->scroll_freeze)
2178 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2179 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2183 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2186 return sd->scroll_freeze;
2190 elm_widget_scale_set(Evas_Object *obj,
2194 if (scale <= 0.0) scale = 0.0;
2195 if (sd->scale != scale)
2198 elm_widget_theme(obj);
2203 elm_widget_scale_get(const Evas_Object *obj)
2205 API_ENTRY return 1.0;
2206 // FIXME: save walking up the tree by storing/caching parent scale
2207 if (sd->scale == 0.0)
2210 return elm_widget_scale_get(sd->parent_obj);
2218 elm_widget_theme_set(Evas_Object *obj,
2222 if (sd->theme != th)
2224 if (sd->theme) elm_theme_free(sd->theme);
2227 elm_widget_theme(obj);
2232 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2236 if (!sd->on_text_set_func)
2239 sd->on_text_set_func(obj, item, label);
2243 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2245 API_ENTRY return NULL;
2247 if (!sd->on_text_get_func)
2250 return sd->on_text_get_func(obj, item);
2254 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2258 Elm_Translate_String_Data *ts = NULL;
2261 str = eina_stringshare_add(part);
2262 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2269 eina_stringshare_del(str);
2272 ts = malloc(sizeof(Elm_Translate_String_Data));
2276 ts->domain = eina_stringshare_add(domain);
2277 ts->string = eina_stringshare_add(label);
2278 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2284 eina_stringshare_replace(&ts->domain, domain);
2285 eina_stringshare_replace(&ts->string, label);
2289 sd->translate_strings = eina_list_remove_list(
2290 sd->translate_strings, l);
2291 eina_stringshare_del(ts->id);
2292 eina_stringshare_del(ts->domain);
2293 eina_stringshare_del(ts->string);
2296 eina_stringshare_del(str);
2300 if (label && label[0])
2301 label = dgettext(domain, label);
2303 elm_widget_text_part_set(obj, part, label);
2307 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2309 const char *str, *ret = NULL;
2311 Elm_Translate_String_Data *ts;
2312 API_ENTRY return NULL;
2314 str = eina_stringshare_add(part);
2315 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2321 eina_stringshare_del(str);
2326 elm_widget_translate(Evas_Object *obj)
2330 Elm_Translate_String_Data *ts;
2333 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2334 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2335 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2336 if (sd->translate_func) sd->translate_func(obj);
2339 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2341 const char *s = dgettext(ts->domain, ts->string);
2342 elm_widget_text_part_set(obj, ts->id, s);
2348 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2352 if (!sd->on_content_set_func) return;
2353 sd->on_content_set_func(obj, part, content);
2357 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2359 API_ENTRY return NULL;
2361 if (!sd->on_content_get_func) return NULL;
2362 return sd->on_content_get_func(obj, part);
2366 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2368 API_ENTRY return NULL;
2370 if (!sd->on_content_unset_func) return NULL;
2371 return sd->on_content_unset_func(obj, part);
2375 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2378 if (sd->access_info) eina_stringshare_del(sd->access_info);
2379 if (!txt) sd->access_info = NULL;
2380 else sd->access_info = eina_stringshare_add(txt);
2384 elm_widget_access_info_get(Evas_Object *obj)
2386 API_ENTRY return NULL;
2387 return sd->access_info;
2392 elm_widget_theme_get(const Evas_Object *obj)
2394 API_ENTRY return NULL;
2398 return elm_widget_theme_get(sd->parent_obj);
2406 elm_widget_style_set(Evas_Object *obj,
2411 if (eina_stringshare_replace(&sd->style, style))
2412 elm_widget_theme(obj);
2416 elm_widget_style_get(const Evas_Object *obj)
2418 API_ENTRY return NULL;
2419 if (sd->style) return sd->style;
2424 elm_widget_type_set(Evas_Object *obj,
2428 eina_stringshare_replace(&sd->type, type);
2432 elm_widget_type_get(const Evas_Object *obj)
2434 API_ENTRY return NULL;
2435 if (sd->type) return sd->type;
2440 elm_widget_tooltip_add(Evas_Object *obj,
2444 sd->tooltips = eina_list_append(sd->tooltips, tt);
2448 elm_widget_tooltip_del(Evas_Object *obj,
2452 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2456 elm_widget_cursor_add(Evas_Object *obj,
2460 sd->cursors = eina_list_append(sd->cursors, cur);
2464 elm_widget_cursor_del(Evas_Object *obj,
2468 sd->cursors = eina_list_remove(sd->cursors, cur);
2472 elm_widget_drag_lock_x_set(Evas_Object *obj,
2476 if (sd->drag_x_locked == lock) return;
2477 sd->drag_x_locked = lock;
2478 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2479 else _propagate_x_drag_lock(obj, -1);
2483 elm_widget_drag_lock_y_set(Evas_Object *obj,
2487 if (sd->drag_y_locked == lock) return;
2488 sd->drag_y_locked = lock;
2489 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2490 else _propagate_y_drag_lock(obj, -1);
2494 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2496 API_ENTRY return EINA_FALSE;
2497 return sd->drag_x_locked;
2501 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2503 API_ENTRY return EINA_FALSE;
2504 return sd->drag_y_locked;
2508 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2511 return sd->child_drag_x_locked;
2515 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2518 return sd->child_drag_y_locked;
2522 elm_widget_theme_object_set(Evas_Object *obj,
2525 const char *welement,
2528 API_ENTRY return EINA_FALSE;
2529 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2533 elm_widget_is_check(const Evas_Object *obj)
2535 static int abort_on_warn = -1;
2536 if (elm_widget_is(obj))
2539 ERR("Passing Object: %p.", obj);
2540 if (abort_on_warn == -1)
2542 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2543 else abort_on_warn = 0;
2545 if (abort_on_warn == 1) abort();
2550 elm_widget_type_check(const Evas_Object *obj,
2553 const char *provided, *expected = "(unknown)";
2554 static int abort_on_warn = -1;
2555 provided = elm_widget_type_get(obj);
2556 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2557 if (type) expected = type;
2558 if ((!provided) || (!provided[0]))
2560 provided = evas_object_type_get(obj);
2561 if ((!provided) || (!provided[0]))
2562 provided = "(unknown)";
2564 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2565 if (abort_on_warn == -1)
2567 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2568 else abort_on_warn = 0;
2570 if (abort_on_warn == 1) abort();
2577 * Split string in words
2579 * @param str Source string
2580 * @return List of const words
2582 * @see elm_widget_stringlist_free()
2586 elm_widget_stringlist_get(const char *str)
2588 Eina_List *list = NULL;
2590 if (!str) return NULL;
2591 for (b = s = str; 1; s++)
2593 if ((*s == ' ') || (!*s))
2595 char *t = malloc(s - b + 1);
2598 strncpy(t, b, s - b);
2600 list = eina_list_append(list, eina_stringshare_add(t));
2611 elm_widget_stringlist_free(Eina_List *list)
2614 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2618 elm_widget_focus_hide_handle(Evas_Object *obj)
2620 _if_focused_revert(obj, EINA_TRUE);
2624 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2626 Evas_Object *o = obj;
2629 if (_elm_widget_is(o)) break;
2630 o = evas_object_smart_parent_get(o);
2634 if (!_is_focusable(o)) return;
2635 elm_widget_focus_steal(o);
2639 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2643 if (!elm_widget_parent_get(obj))
2644 elm_widget_focused_object_clear(obj);
2646 _if_focused_revert(obj, EINA_TRUE);
2650 elm_widget_focus_disabled_handle(Evas_Object *obj)
2654 elm_widget_focus_tree_unfocusable_handle(obj);
2660 * Allocate a new Elm_Widget_Item-derived structure.
2662 * The goal of this structure is to provide common ground for actions
2663 * that a widget item have, such as the owner widget, callback to
2664 * notify deletion, data pointer and maybe more.
2666 * @param widget the owner widget that holds this item, must be an elm_widget!
2667 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2668 * be used to allocate memory.
2670 * @return allocated memory that is already zeroed out, or NULL on errors.
2672 * @see elm_widget_item_new() convenience macro.
2673 * @see elm_widget_item_del() to release memory.
2676 EAPI Elm_Widget_Item *
2677 _elm_widget_item_new(Evas_Object *widget,
2680 if (!_elm_widget_is(widget))
2683 Elm_Widget_Item *item;
2685 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2686 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2688 item = calloc(1, alloc_size);
2689 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2691 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2692 item->widget = widget;
2699 * Releases widget item memory, calling back del_cb() if it exists.
2701 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2702 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2703 * this function and then unset it, thus being useful for 2 step
2704 * cleanup whenever the del_cb may use any of the data that must be
2705 * deleted from item.
2707 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2710 * @param item a valid #Elm_Widget_Item to be deleted.
2711 * @see elm_widget_item_del() convenience macro.
2715 _elm_widget_item_del(Elm_Widget_Item *item)
2717 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2720 item->del_cb((void *)item->data, item->widget, item);
2723 evas_object_del(item->view);
2727 _elm_access_clear(item->access);
2729 item->access = NULL;
2731 if (item->access_info)
2733 eina_stringshare_del(item->access_info);
2734 item->access_info = NULL;
2737 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2744 * Notify object will be deleted without actually deleting it.
2746 * This function will callback Elm_Widget_Item::del_cb if it is set
2747 * and then unset it so it is not called twice (ie: from
2748 * elm_widget_item_del()).
2750 * @param item a valid #Elm_Widget_Item to be notified
2751 * @see elm_widget_item_pre_notify_del() convenience macro.
2755 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2757 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2758 if (!item->del_cb) return;
2759 item->del_cb((void *)item->data, item->widget, item);
2760 item->del_cb = NULL;
2766 * Set the function to notify when item is being deleted.
2768 * This function will complain if there was a callback set already,
2769 * however it will set the new one.
2771 * The callback will be called from elm_widget_item_pre_notify_del()
2772 * or elm_widget_item_del() will be called with:
2773 * - data: the Elm_Widget_Item::data value.
2774 * - obj: the Elm_Widget_Item::widget evas object.
2775 * - event_info: the item being deleted.
2777 * @param item a valid #Elm_Widget_Item to be notified
2778 * @see elm_widget_item_del_cb_set() convenience macro.
2782 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2783 Evas_Smart_Cb del_cb)
2785 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2787 if ((item->del_cb) && (item->del_cb != del_cb))
2788 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2789 item->del_cb, item, del_cb);
2791 item->del_cb = del_cb;
2797 * Set user-data in this item.
2799 * User data may be used to identify this item or just store any
2800 * application data. It is automatically given as the first parameter
2801 * of the deletion notify callback.
2803 * @param item a valid #Elm_Widget_Item to store data in.
2804 * @param data user data to store.
2805 * @see elm_widget_item_del_cb_set() convenience macro.
2809 _elm_widget_item_data_set(Elm_Widget_Item *item,
2812 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2813 if ((item->data) && (item->data != data))
2814 DBG("Replacing item %p data %p with %p", item, item->data, data);
2821 * Retrieves user-data of this item.
2823 * @param item a valid #Elm_Widget_Item to get data from.
2824 * @see elm_widget_item_data_set()
2828 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2830 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2831 return (void *)item->data;
2834 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2836 struct _Elm_Widget_Item_Tooltip
2838 Elm_Widget_Item *item;
2839 Elm_Tooltip_Item_Content_Cb func;
2840 Evas_Smart_Cb del_cb;
2844 static Evas_Object *
2845 _elm_widget_item_tooltip_label_create(void *data,
2846 Evas_Object *obj __UNUSED__,
2847 Evas_Object *tooltip,
2848 void *item __UNUSED__)
2850 Evas_Object *label = elm_label_add(tooltip);
2853 elm_object_style_set(label, "tooltip");
2854 elm_object_text_set(label, data);
2858 static Evas_Object *
2859 _elm_widget_item_tooltip_trans_label_create(void *data,
2860 Evas_Object *obj __UNUSED__,
2861 Evas_Object *tooltip,
2862 void *item __UNUSED__)
2864 Evas_Object *label = elm_label_add(tooltip);
2867 elm_object_style_set(label, "tooltip");
2868 elm_object_translatable_text_set(label, data);
2873 _elm_widget_item_tooltip_label_del_cb(void *data,
2874 Evas_Object *obj __UNUSED__,
2875 void *event_info __UNUSED__)
2877 eina_stringshare_del(data);
2883 * Set the text to be shown in the widget item.
2885 * @param item Target item
2886 * @param text The text to set in the content
2888 * Setup the text as tooltip to object. The item can have only one tooltip,
2889 * so any previous tooltip data is removed.
2894 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2897 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2898 EINA_SAFETY_ON_NULL_RETURN(text);
2900 text = eina_stringshare_add(text);
2901 _elm_widget_item_tooltip_content_cb_set
2902 (item, _elm_widget_item_tooltip_label_create, text,
2903 _elm_widget_item_tooltip_label_del_cb);
2907 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2910 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2911 EINA_SAFETY_ON_NULL_RETURN(text);
2913 text = eina_stringshare_add(text);
2914 _elm_widget_item_tooltip_content_cb_set
2915 (item, _elm_widget_item_tooltip_trans_label_create, text,
2916 _elm_widget_item_tooltip_label_del_cb);
2919 static Evas_Object *
2920 _elm_widget_item_tooltip_create(void *data,
2922 Evas_Object *tooltip)
2924 Elm_Widget_Item_Tooltip *wit = data;
2925 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2929 _elm_widget_item_tooltip_del_cb(void *data,
2931 void *event_info __UNUSED__)
2933 Elm_Widget_Item_Tooltip *wit = data;
2934 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2941 * Set the content to be shown in the tooltip item
2943 * Setup the tooltip to item. The item can have only one tooltip,
2944 * so any previous tooltip data is removed. @p func(with @p data) will
2945 * be called every time that need show the tooltip and it should
2946 * return a valid Evas_Object. This object is then managed fully by
2947 * tooltip system and is deleted when the tooltip is gone.
2949 * @param item the widget item being attached a tooltip.
2950 * @param func the function used to create the tooltip contents.
2951 * @param data what to provide to @a func as callback data/context.
2952 * @param del_cb called when data is not needed anymore, either when
2953 * another callback replaces @func, the tooltip is unset with
2954 * elm_widget_item_tooltip_unset() or the owner @a item
2955 * dies. This callback receives as the first parameter the
2956 * given @a data, and @c event_info is the item.
2961 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2962 Elm_Tooltip_Item_Content_Cb func,
2964 Evas_Smart_Cb del_cb)
2966 Elm_Widget_Item_Tooltip *wit;
2968 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2972 _elm_widget_item_tooltip_unset(item);
2976 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2977 if (!wit) goto error;
2981 wit->del_cb = del_cb;
2983 elm_object_sub_tooltip_content_cb_set
2984 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2985 _elm_widget_item_tooltip_del_cb);
2990 if (del_cb) del_cb((void *)data, NULL, item);
2993 if (del_cb) del_cb((void *)data, item->widget, item);
2999 * Unset tooltip from item
3001 * @param item widget item to remove previously set tooltip.
3003 * Remove tooltip from item. The callback provided as del_cb to
3004 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3005 * it is not used anymore.
3007 * @see elm_widget_item_tooltip_content_cb_set()
3012 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3014 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3015 elm_object_tooltip_unset(item->view);
3021 * Sets a different style for this item tooltip.
3023 * @note before you set a style you should define a tooltip with
3024 * elm_widget_item_tooltip_content_cb_set() or
3025 * elm_widget_item_tooltip_text_set()
3027 * @param item widget item with tooltip already set.
3028 * @param style the theme style to use (default, transparent, ...)
3033 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3036 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3037 elm_object_tooltip_style_set(item->view, style);
3041 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
3043 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3044 return elm_tooltip_size_restrict_disable(item->view, disable);
3048 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
3050 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3051 return elm_tooltip_size_restrict_disabled_get(item->view);
3057 * Get the style for this item tooltip.
3059 * @param item widget item with tooltip already set.
3060 * @return style the theme style in use, defaults to "default". If the
3061 * object does not have a tooltip set, then NULL is returned.
3066 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3068 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3069 return elm_object_tooltip_style_get(item->view);
3073 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3076 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3077 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3081 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3083 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3084 return elm_object_cursor_get(item->view);
3088 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3090 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3091 elm_object_cursor_unset(item->view);
3097 * Sets a different style for this item cursor.
3099 * @note before you set a style you should define a cursor with
3100 * elm_widget_item_cursor_set()
3102 * @param item widget item with cursor already set.
3103 * @param style the theme style to use (default, transparent, ...)
3108 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3111 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3112 elm_object_cursor_style_set(item->view, style);
3118 * Get the style for this item cursor.
3120 * @param item widget item with cursor already set.
3121 * @return style the theme style in use, defaults to "default". If the
3122 * object does not have a cursor set, then NULL is returned.
3127 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3129 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3130 return elm_object_cursor_style_get(item->view);
3136 * Set if the cursor set should be searched on the theme or should use
3137 * the provided by the engine, only.
3139 * @note before you set if should look on theme you should define a cursor
3140 * with elm_object_cursor_set(). By default it will only look for cursors
3141 * provided by the engine.
3143 * @param item widget item with cursor already set.
3144 * @param engine_only boolean to define it cursors should be looked only
3145 * between the provided by the engine or searched on widget's theme as well.
3150 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3151 Eina_Bool engine_only)
3153 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3154 elm_object_cursor_engine_only_set(item->view, engine_only);
3160 * Get the cursor engine only usage for this item cursor.
3162 * @param item widget item with cursor already set.
3163 * @return engine_only boolean to define it cursors should be looked only
3164 * between the provided by the engine or searched on widget's theme as well. If
3165 * the object does not have a cursor set, then EINA_FALSE is returned.
3170 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3172 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3173 return elm_object_cursor_engine_only_get(item->view);
3176 // smart object funcs
3178 _smart_reconfigure(Smart_Data *sd)
3182 evas_object_move(sd->resize_obj, sd->x, sd->y);
3183 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3187 evas_object_move(sd->hover_obj, sd->x, sd->y);
3188 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3193 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3195 Evas_Object *content)
3197 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3198 if (!item->on_content_set_func) return;
3199 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3203 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3206 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3207 if (!item->on_content_get_func) return NULL;
3208 return item->on_content_get_func((Elm_Object_Item *) item, part);
3212 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3215 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3216 if (!item->on_content_unset_func) return NULL;
3217 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3221 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3225 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3226 if (!item->on_text_set_func) return;
3227 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3231 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3232 const char *emission,
3235 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3236 if (item->on_signal_emit_func)
3237 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3241 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3244 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3245 if (!item->on_text_get_func) return NULL;
3246 return item->on_text_get_func((Elm_Object_Item *) item, part);
3250 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3251 Elm_Widget_On_Content_Set_Cb func)
3253 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3254 item->on_content_set_func = func;
3258 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3259 Elm_Widget_On_Content_Get_Cb func)
3261 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3262 item->on_content_get_func = func;
3266 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3267 Elm_Widget_On_Content_Unset_Cb func)
3269 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3270 item->on_content_unset_func = func;
3274 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3275 Elm_Widget_On_Text_Set_Cb func)
3277 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3278 item->on_text_set_func = func;
3282 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3283 Elm_Widget_On_Text_Get_Cb func)
3285 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3286 item->on_text_get_func = func;
3290 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3291 Elm_Widget_On_Signal_Emit_Cb func)
3293 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3294 item->on_signal_emit_func = func;
3298 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3300 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3301 if (item->access_info) eina_stringshare_del(item->access_info);
3302 if (!txt) item->access_info = NULL;
3303 else item->access_info = eina_stringshare_add(txt);
3308 _smart_add(Evas_Object *obj)
3312 sd = calloc(1, sizeof(Smart_Data));
3315 sd->x = sd->y = sd->w = sd->h = 0;
3317 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3318 evas_object_smart_data_set(obj, sd);
3321 static Evas_Object *
3322 _newest_focus_order_get(Evas_Object *obj,
3323 unsigned int *newest_focus_order,
3324 Eina_Bool can_focus_only)
3327 Evas_Object *child, *ret, *best;
3329 API_ENTRY return NULL;
3331 if (!evas_object_visible_get(obj)
3332 || (elm_widget_disabled_get(obj))
3333 || (elm_widget_tree_unfocusable_get(obj)))
3337 if (*newest_focus_order < sd->focus_order)
3339 *newest_focus_order = sd->focus_order;
3342 EINA_LIST_FOREACH(sd->subobjs, l, child)
3344 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3350 if ((!best) || (!elm_widget_can_focus_get(best)))
3357 _if_focused_revert(Evas_Object *obj,
3358 Eina_Bool can_focus_only)
3361 Evas_Object *newest = NULL;
3362 unsigned int newest_focus_order = 0;
3366 if (!sd->focused) return;
3367 if (!sd->parent_obj) return;
3369 top = elm_widget_top_get(sd->parent_obj);
3372 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3375 elm_object_focus_set(newest, EINA_FALSE);
3376 elm_object_focus_set(newest, EINA_TRUE);
3382 _smart_del(Evas_Object *obj)
3385 Edje_Signal_Data *esd;
3386 Elm_Translate_String_Data *ts;
3390 if (sd->del_pre_func) sd->del_pre_func(obj);
3393 sobj = sd->resize_obj;
3394 sd->resize_obj = NULL;
3395 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3396 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3397 evas_object_del(sobj);
3401 sobj = sd->hover_obj;
3402 sd->hover_obj = NULL;
3403 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3404 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3405 evas_object_del(sobj);
3407 EINA_LIST_FREE(sd->subobjs, sobj)
3409 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3410 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3411 evas_object_del(sobj);
3413 eina_list_free(sd->tooltips); /* should be empty anyway */
3414 eina_list_free(sd->cursors); /* should be empty anyway */
3415 EINA_LIST_FREE(sd->edje_signals, esd)
3417 eina_stringshare_del(esd->emission);
3418 eina_stringshare_del(esd->source);
3421 EINA_LIST_FREE(sd->translate_strings, ts)
3423 eina_stringshare_del(ts->id);
3424 eina_stringshare_del(ts->domain);
3425 eina_stringshare_del(ts->string);
3428 eina_list_free(sd->event_cb); /* should be empty anyway */
3429 if (sd->del_func) sd->del_func(obj);
3430 if (sd->style) eina_stringshare_del(sd->style);
3431 if (sd->type) eina_stringshare_del(sd->type);
3432 if (sd->theme) elm_theme_free(sd->theme);
3433 _if_focused_revert(obj, EINA_TRUE);
3434 if (sd->access_info) eina_stringshare_del(sd->access_info);
3439 _smart_move(Evas_Object *obj,
3446 _smart_reconfigure(sd);
3450 _smart_resize(Evas_Object *obj,
3457 _smart_reconfigure(sd);
3461 _smart_show(Evas_Object *obj)
3466 if ((list = evas_object_smart_members_get(obj)))
3468 EINA_LIST_FREE(list, o)
3470 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3471 evas_object_show(o);
3477 _smart_hide(Evas_Object *obj)
3483 list = evas_object_smart_members_get(obj);
3484 EINA_LIST_FREE(list, o)
3486 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3487 evas_object_hide(o);
3492 _smart_color_set(Evas_Object *obj,
3501 if ((list = evas_object_smart_members_get(obj)))
3503 EINA_LIST_FREE(list, o)
3505 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3506 evas_object_color_set(o, r, g, b, a);
3512 _smart_clip_set(Evas_Object *obj,
3518 if ((list = evas_object_smart_members_get(obj)))
3520 EINA_LIST_FREE(list, o)
3522 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3523 evas_object_clip_set(o, clip);
3529 _smart_clip_unset(Evas_Object *obj)
3534 if ((list = evas_object_smart_members_get(obj)))
3536 EINA_LIST_FREE(list, o)
3538 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3539 evas_object_clip_unset(o);
3545 _smart_calculate(Evas_Object *obj)
3548 if (sd->changed_func) sd->changed_func(obj);
3551 /* never need to touch this */
3555 if (_e_smart) return;
3557 static const Evas_Smart_Class sc =
3560 EVAS_SMART_CLASS_VERSION,
3578 _e_smart = evas_smart_class_new(&sc);
3582 /* happy debug functions */
3585 _sub_obj_tree_dump(const Evas_Object *obj,
3590 for (i = 0; i < lvl * 3; i++)
3593 if (_elm_widget_is(obj))
3597 printf("+ %s(%p)\n",
3601 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3602 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3604 if (obj != sd->resize_obj)
3605 _sub_obj_tree_dump(obj, lvl + 1);
3609 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3613 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3616 if (!_elm_widget_is(obj))
3620 Eina_Bool visible = evas_object_visible_get(obj);
3621 Eina_Bool disabled = elm_widget_disabled_get(obj);
3622 Eina_Bool focused = elm_widget_focus_get(obj);
3623 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3627 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3630 fprintf(output, ", style=bold");
3633 fprintf(output, ", color=gray28");
3635 fprintf(output, " ];\n");
3638 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3639 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3640 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3644 fprintf(output, ", style=bold");
3647 fprintf(output, ", fontcolor=gray28");
3649 if ((disabled) || (!visible))
3650 fprintf(output, ", color=gray");
3652 fprintf(output, " ];\n");
3656 EINA_LIST_FOREACH(sd->subobjs, l, o)
3657 _sub_obj_tree_dot_dump(o, output);
3662 elm_widget_tree_dump(const Evas_Object *top)
3665 _sub_obj_tree_dump(top, 0);
3673 elm_widget_tree_dot_dump(const Evas_Object *top,
3677 if (!_elm_widget_is(top))
3679 fprintf(output, "graph " " { node [shape=record];\n");
3680 _sub_obj_tree_dot_dump(top, output);
3681 fprintf(output, "}\n");