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 */
117 Eina_Bool still_in : 1;
119 Eina_List *focus_chain;
123 struct _Edje_Signal_Data
127 const char *emission;
132 struct _Elm_Event_Cb_Data
138 struct _Elm_Translate_String_Data
145 /* local subsystem functions */
146 static void _smart_reconfigure(Smart_Data *sd);
147 static void _smart_add(Evas_Object *obj);
148 static void _smart_del(Evas_Object *obj);
149 static void _smart_move(Evas_Object *obj,
152 static void _smart_resize(Evas_Object *obj,
155 static void _smart_show(Evas_Object *obj);
156 static void _smart_hide(Evas_Object *obj);
157 static void _smart_color_set(Evas_Object *obj,
162 static void _smart_clip_set(Evas_Object *obj,
164 static void _smart_clip_unset(Evas_Object *obj);
165 static void _smart_calculate(Evas_Object *obj);
166 static void _smart_init(void);
168 static void _if_focused_revert(Evas_Object *obj,
169 Eina_Bool can_focus_only);
170 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
171 unsigned int *newest_focus_order,
172 Eina_Bool can_focus_only);
174 /* local subsystem globals */
175 static Evas_Smart *_e_smart = NULL;
176 static Eina_List *widtypes = NULL;
178 static unsigned int focus_order = 0;
181 static inline Eina_Bool
182 _elm_widget_is(const Evas_Object *obj)
184 const char *type = evas_object_type_get(obj);
185 return type == SMART_NAME;
188 static inline Eina_Bool
189 _is_focusable(Evas_Object *obj)
191 API_ENTRY return EINA_FALSE;
192 return sd->can_focus || (sd->child_can_focus);
196 _unfocus_parents(Evas_Object *obj)
198 for (; obj; obj = elm_widget_parent_get(obj))
201 if (!sd->focused) return;
207 _focus_parents(Evas_Object *obj)
209 for (; obj; obj = elm_widget_parent_get(obj))
212 if (sd->focused) return;
218 _sub_obj_del(void *data,
221 void *event_info __UNUSED__)
223 Smart_Data *sd = data;
225 if (_elm_widget_is(obj))
227 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
229 if (obj == sd->resize_obj)
230 sd->resize_obj = NULL;
231 else if (obj == sd->hover_obj)
232 sd->hover_obj = NULL;
234 sd->subobjs = eina_list_remove(sd->subobjs, obj);
235 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
239 _sub_obj_hide(void *data __UNUSED__,
242 void *event_info __UNUSED__)
244 elm_widget_focus_hide_handle(obj);
248 _sub_obj_mouse_down(void *data,
250 Evas_Object *obj __UNUSED__,
253 Smart_Data *sd = data;
254 Evas_Event_Mouse_Down *ev = event_info;
255 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
256 sd->still_in = EINA_TRUE;
260 _sub_obj_mouse_move(void *data,
265 Smart_Data *sd = data;
266 Evas_Event_Mouse_Move *ev = event_info;
269 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
270 sd->still_in = EINA_FALSE;
273 Evas_Coord x, y, w, h;
274 evas_object_geometry_get(obj, &x, &y, &w, &h);
275 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
276 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
277 sd->still_in = EINA_FALSE;
283 _sub_obj_mouse_up(void *data,
286 void *event_info __UNUSED__)
288 Smart_Data *sd = data;
290 elm_widget_focus_mouse_up_handle(obj);
291 sd->still_in = EINA_FALSE;
295 _propagate_x_drag_lock(Evas_Object *obj,
301 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
304 sd2->child_drag_x_locked += dir;
305 _propagate_x_drag_lock(sd->parent_obj, dir);
311 _propagate_y_drag_lock(Evas_Object *obj,
317 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
320 sd2->child_drag_y_locked += dir;
321 _propagate_y_drag_lock(sd->parent_obj, dir);
327 _propagate_event(void *data,
333 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
334 Evas_Event_Flags *event_flags = NULL;
338 case EVAS_CALLBACK_KEY_DOWN:
340 Evas_Event_Key_Down *ev = event_info;
341 event_flags = &(ev->event_flags);
345 case EVAS_CALLBACK_KEY_UP:
347 Evas_Event_Key_Up *ev = event_info;
348 event_flags = &(ev->event_flags);
352 case EVAS_CALLBACK_MOUSE_WHEEL:
354 Evas_Event_Mouse_Wheel *ev = event_info;
355 event_flags = &(ev->event_flags);
363 elm_widget_event_propagate(obj, type, event_info, event_flags);
367 _parent_focus(Evas_Object *obj)
370 if (sd->focused) return;
372 Evas_Object *o = elm_widget_parent_get(obj);
373 sd->focus_order_on_calc = EINA_TRUE;
375 if (o) _parent_focus(o);
377 if (!sd->focus_order_on_calc)
378 return; /* we don't want to override it if by means of any of the
379 callbacks below one gets to calculate our order
383 sd->focus_order = focus_order;
384 if (sd->top_win_focused)
386 sd->focused = EINA_TRUE;
387 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
388 if (sd->focus_func) sd->focus_func(obj);
389 _elm_widget_focus_region_show(obj);
391 sd->focus_order_on_calc = EINA_FALSE;
395 _elm_object_focus_chain_del_cb(void *data,
398 void *event_info __UNUSED__)
400 Smart_Data *sd = data;
402 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
405 // exposed util funcs to elm
407 _elm_widget_type_clear(void)
411 EINA_LIST_FREE(widtypes, ptr)
413 eina_stringshare_del(*ptr);
419 _elm_widget_focus_region_show(const Evas_Object *obj)
421 Evas_Coord x, y, w, h, ox, oy;
427 o = elm_widget_parent_get(obj);
430 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
431 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
435 sd2 = evas_object_smart_data_get(o);
436 if (sd2->focus_region_func)
438 sd2->focus_region_func(o, x, y, w, h);
439 elm_widget_focus_region_get(o, &x, &y, &w, &h);
443 evas_object_geometry_get(o, &px, &py, NULL, NULL);
449 o = elm_widget_parent_get(o);
454 * @defgroup Widget Widget
457 * Exposed api for making widgets
460 elm_widget_type_register(const char **ptr)
462 widtypes = eina_list_append(widtypes, (void *)ptr);
466 * @defgroup Widget Widget
469 * Disposed api for making widgets
472 elm_widget_type_unregister(const char **ptr)
474 widtypes = eina_list_remove(widtypes, (void *)ptr);
478 elm_widget_api_check(int ver)
480 if (ver != ELM_INTERNAL_API_VERSION)
482 CRITICAL("Elementary widget api versions do not match");
489 elm_widget_add(Evas *evas)
493 obj = evas_object_smart_add(evas, _e_smart);
494 elm_widget_mirrored_set(obj, elm_mirrored_get());
499 elm_widget_del_hook_set(Evas_Object *obj,
500 void (*func)(Evas_Object *obj))
507 elm_widget_del_pre_hook_set(Evas_Object *obj,
508 void (*func)(Evas_Object *obj))
511 sd->del_pre_func = func;
515 elm_widget_focus_hook_set(Evas_Object *obj,
516 void (*func)(Evas_Object *obj))
519 sd->focus_func = func;
523 elm_widget_activate_hook_set(Evas_Object *obj,
524 void (*func)(Evas_Object *obj))
527 sd->activate_func = func;
531 elm_widget_disable_hook_set(Evas_Object *obj,
532 void (*func)(Evas_Object *obj))
535 sd->disable_func = func;
539 elm_widget_theme_hook_set(Evas_Object *obj,
540 void (*func)(Evas_Object *obj))
543 sd->theme_func = func;
547 elm_widget_translate_hook_set(Evas_Object *obj,
548 void (*func)(Evas_Object *obj))
551 sd->translate_func = func;
555 elm_widget_event_hook_set(Evas_Object *obj,
556 Eina_Bool (*func)(Evas_Object *obj,
558 Evas_Callback_Type type,
562 sd->event_func = func;
566 elm_widget_text_set_hook_set(Evas_Object *obj,
567 Elm_Widget_On_Text_Set_Cb func)
570 sd->on_text_set_func = func;
574 elm_widget_text_get_hook_set(Evas_Object *obj,
575 Elm_Widget_On_Text_Get_Cb func)
578 sd->on_text_get_func = func;
582 elm_widget_content_set_hook_set(Evas_Object *obj,
583 Elm_Widget_On_Content_Set_Cb func)
586 sd->on_content_set_func = func;
590 elm_widget_content_get_hook_set(Evas_Object *obj,
591 Elm_Widget_On_Content_Get_Cb func)
594 sd->on_content_get_func = func;
598 elm_widget_content_unset_hook_set(Evas_Object *obj,
599 Elm_Widget_On_Content_Unset_Cb func)
602 sd->on_content_unset_func = func;
606 elm_widget_changed_hook_set(Evas_Object *obj,
607 void (*func)(Evas_Object *obj))
610 sd->changed_func = func;
614 elm_widget_signal_emit_hook_set(Evas_Object *obj,
615 void (*func)(Evas_Object *obj,
616 const char *emission,
620 sd->signal_func = func;
624 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
625 void (*func)(Evas_Object *obj,
626 const char *emission,
628 Edje_Signal_Cb func_cb,
632 sd->callback_add_func = func;
636 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
637 void (*func)(Evas_Object *obj,
638 const char *emission,
640 Edje_Signal_Cb func_cb,
644 sd->callback_del_func = func;
648 elm_widget_theme(Evas_Object *obj)
656 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
657 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
658 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
659 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
660 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
661 if (sd->theme_func) sd->theme_func(obj);
665 elm_widget_theme_specific(Evas_Object *obj,
673 Elm_Theme *th2, *thdef;
676 thdef = elm_theme_default_get();
681 if (!th2) th2 = thdef;
689 if (th2 == thdef) break;
690 th2 = th2->ref_theme;
691 if (!th2) th2 = thdef;
695 EINA_LIST_FOREACH(sd->subobjs, l, child)
696 elm_widget_theme_specific(child, th, force);
697 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
698 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
699 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
700 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
701 if (sd->theme_func) sd->theme_func(obj);
707 * Set hook to get next object in object focus chain.
709 * @param obj The widget object.
710 * @param func The hook to be used with this widget.
715 elm_widget_focus_next_hook_set(Evas_Object *obj,
716 Eina_Bool (*func)(const Evas_Object *obj,
717 Elm_Focus_Direction dir,
721 sd->focus_next_func = func;
725 * Returns the widget's mirrored mode.
727 * @param obj The widget.
728 * @return mirrored mode of the object.
732 elm_widget_mirrored_get(const Evas_Object *obj)
734 API_ENTRY return EINA_FALSE;
735 return sd->is_mirrored;
739 * Sets the widget's mirrored mode.
741 * @param obj The widget.
742 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
745 elm_widget_mirrored_set(Evas_Object *obj,
749 if (sd->is_mirrored != mirrored)
751 sd->is_mirrored = mirrored;
752 elm_widget_theme(obj);
758 * Resets the mirrored mode from the system mirror mode for widgets that are in
759 * automatic mirroring mode. This function does not call elm_widget_theme.
761 * @param obj The widget.
762 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
765 _elm_widget_mirrored_reload(Evas_Object *obj)
768 Eina_Bool mirrored = elm_mirrored_get();
769 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
771 sd->is_mirrored = mirrored;
776 * Returns the widget's mirrored mode setting.
778 * @param obj The widget.
779 * @return mirrored mode setting of the object.
783 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
785 API_ENTRY return EINA_FALSE;
786 return sd->mirrored_auto_mode;
790 * Sets the widget's mirrored mode setting.
791 * When widget in automatic mode, it follows the system mirrored mode set by
792 * elm_mirrored_set().
793 * @param obj The widget.
794 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
797 elm_widget_mirrored_automatic_set(Evas_Object *obj,
801 if (sd->mirrored_auto_mode != automatic)
803 sd->mirrored_auto_mode = automatic;
807 elm_widget_mirrored_set(obj, elm_mirrored_get());
813 elm_widget_on_focus_hook_set(Evas_Object *obj,
814 void (*func)(void *data,
819 sd->on_focus_func = func;
820 sd->on_focus_data = data;
824 elm_widget_on_change_hook_set(Evas_Object *obj,
825 void (*func)(void *data,
830 sd->on_change_func = func;
831 sd->on_change_data = data;
835 elm_widget_on_show_region_hook_set(Evas_Object *obj,
836 void (*func)(void *data,
841 sd->on_show_region_func = func;
842 sd->on_show_region_data = data;
848 * Set the hook to use to show the focused region.
850 * Whenever a new widget gets focused or it's needed to show the focused
851 * area of the current one, this hook will be called on objects that may
852 * want to move their children into their visible area.
853 * The area given in the hook function is relative to the @p obj widget.
855 * @param obj The widget object
856 * @param func The function to call to show the specified area.
861 elm_widget_focus_region_hook_set(Evas_Object *obj,
862 void (*func)(Evas_Object *obj,
869 sd->focus_region_func = func;
875 * Set the hook to retrieve the focused region of a widget.
877 * This hook will be called by elm_widget_focus_region_get() whenever
878 * it's needed to get the focused area of a widget. The area must be relative
879 * to the widget itself and if no hook is set, it will default to the entire
882 * @param obj The widget object
883 * @param func The function used to retrieve the focus region.
888 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
889 void (*func)(const Evas_Object *obj,
896 sd->on_focus_region_func = func;
900 elm_widget_data_set(Evas_Object *obj,
908 elm_widget_data_get(const Evas_Object *obj)
910 API_ENTRY return NULL;
915 elm_widget_sub_object_add(Evas_Object *obj,
919 double scale, pscale = elm_widget_scale_get(sobj);
920 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
921 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
923 if (_elm_widget_is(sobj))
925 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
928 if (sd2->parent_obj == obj)
931 elm_widget_sub_object_del(sd2->parent_obj, sobj);
932 sd2->parent_obj = obj;
933 sd2->top_win_focused = sd->top_win_focused;
934 if (!sd->child_can_focus && (_is_focusable(sobj)))
935 sd->child_can_focus = EINA_TRUE;
940 void *data = evas_object_data_get(sobj, "elm-parent");
943 if (data == obj) return;
944 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
949 sd->subobjs = eina_list_append(sd->subobjs, sobj);
950 evas_object_data_set(sobj, "elm-parent", obj);
951 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
952 if (_elm_widget_is(sobj))
953 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
954 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
955 scale = elm_widget_scale_get(sobj);
956 th = elm_widget_theme_get(sobj);
957 mirrored = elm_widget_mirrored_get(sobj);
958 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
959 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
963 elm_widget_sub_object_del(Evas_Object *obj,
966 Evas_Object *sobj_parent;
970 sobj_parent = evas_object_data_del(sobj, "elm-parent");
971 if (sobj_parent != obj)
973 static int abort_on_warn = -1;
974 ERR("removing sub object %p from parent %p, "
975 "but elm-parent is different %p!",
976 sobj, obj, sobj_parent);
977 if (EINA_UNLIKELY(abort_on_warn == -1))
979 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
980 else abort_on_warn = 0;
982 if (abort_on_warn == 1) abort();
984 if (_elm_widget_is(sobj))
986 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
989 sd2->parent_obj = NULL;
990 if (sd2->resize_obj == sobj)
991 sd2->resize_obj = NULL;
993 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
996 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
997 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
998 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1000 Evas_Object *subobj;
1002 sd->child_can_focus = EINA_FALSE;
1003 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1005 if (_is_focusable(subobj))
1007 sd->child_can_focus = EINA_TRUE;
1014 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1015 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1017 if (_elm_widget_is(sobj))
1018 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1020 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1024 elm_widget_resize_object_set(Evas_Object *obj,
1028 // orphan previous resize obj
1031 evas_object_clip_unset(sd->resize_obj);
1032 evas_object_data_del(sd->resize_obj, "elm-parent");
1033 if (_elm_widget_is(sd->resize_obj))
1035 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1036 if (sd2) sd2->parent_obj = NULL;
1037 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1040 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1042 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1043 _sub_obj_mouse_down, sd);
1044 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1045 _sub_obj_mouse_move, sd);
1046 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1047 _sub_obj_mouse_up, sd);
1048 evas_object_smart_member_del(sd->resize_obj);
1049 if (_elm_widget_is(sd->resize_obj))
1051 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1055 sd->resize_obj = sobj;
1058 // orphan new resize obj
1059 evas_object_data_del(sobj, "elm-parent");
1060 if (_elm_widget_is(sobj))
1062 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1063 if (sd2) sd2->parent_obj = NULL;
1064 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1067 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1069 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1070 _sub_obj_mouse_down, sd);
1071 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1072 _sub_obj_mouse_move, sd);
1073 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1074 _sub_obj_mouse_up, sd);
1075 evas_object_smart_member_del(sobj);
1076 if (_elm_widget_is(sobj))
1078 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1081 // set the resize obj up
1082 if (_elm_widget_is(sobj))
1084 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1087 sd2->parent_obj = obj;
1088 sd2->top_win_focused = sd->top_win_focused;
1090 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1093 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1094 evas_object_smart_member_add(sobj, obj);
1095 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1097 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1098 _sub_obj_mouse_down, sd);
1099 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1100 _sub_obj_mouse_move, sd);
1101 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1102 _sub_obj_mouse_up, sd);
1103 _smart_reconfigure(sd);
1104 evas_object_data_set(sobj, "elm-parent", obj);
1105 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1106 if (_elm_widget_is(sobj))
1108 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1113 elm_widget_hover_object_set(Evas_Object *obj,
1119 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1122 sd->hover_obj = sobj;
1125 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1127 _smart_reconfigure(sd);
1132 elm_widget_can_focus_set(Evas_Object *obj,
1133 Eina_Bool can_focus)
1136 sd->can_focus = can_focus;
1139 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1141 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1142 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1144 (void *)(long)EVAS_CALLBACK_KEY_UP);
1145 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1147 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1151 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1153 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1155 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1161 elm_widget_can_focus_get(const Evas_Object *obj)
1163 API_ENTRY return EINA_FALSE;
1164 return sd->can_focus;
1168 elm_widget_child_can_focus_get(const Evas_Object *obj)
1170 API_ENTRY return EINA_FALSE;
1171 return sd->child_can_focus;
1177 * This API makes the widget object and its children to be unfocusable.
1179 * This API can be helpful for an object to be deleted.
1180 * When an object will be deleted soon, it and its children may not
1181 * want to get focus (by focus reverting or by other focus controls).
1182 * Then, just use this API before deleting.
1184 * @param obj The widget root of sub-tree
1185 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1190 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1191 Eina_Bool tree_unfocusable)
1195 if (sd->tree_unfocusable == tree_unfocusable) return;
1196 sd->tree_unfocusable = !!tree_unfocusable;
1197 elm_widget_focus_tree_unfocusable_handle(obj);
1203 * This returns true, if the object sub-tree is unfocusable.
1205 * @param obj The widget root of sub-tree
1206 * @return EINA_TRUE if the object sub-tree is unfocusable
1211 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1213 API_ENTRY return EINA_FALSE;
1214 return sd->tree_unfocusable;
1220 * Get the list of focusable child objects.
1222 * This function retruns list of child objects which can get focus.
1224 * @param obj The parent widget
1225 * @retrun list of focusable child objects.
1230 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1232 API_ENTRY return NULL;
1235 Eina_List *child_list = NULL;
1240 EINA_LIST_FOREACH(sd->subobjs, l, child)
1242 if ((elm_widget_can_focus_get(child)) &&
1243 (evas_object_visible_get(child)) &&
1244 (!elm_widget_disabled_get(child)))
1245 child_list = eina_list_append(child_list, child);
1246 else if (elm_widget_is(child))
1248 Eina_List *can_focus_list;
1249 can_focus_list = elm_widget_can_focus_child_list_get(child);
1251 child_list = eina_list_merge(child_list, can_focus_list);
1259 elm_widget_highlight_ignore_set(Evas_Object *obj,
1263 sd->highlight_ignore = !!ignore;
1267 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1269 API_ENTRY return EINA_FALSE;
1270 return sd->highlight_ignore;
1274 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1275 Eina_Bool highlight)
1278 sd->highlight_in_theme = !!highlight;
1279 /* FIXME: if focused, it should switch from one mode to the other */
1283 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1285 API_ENTRY return EINA_FALSE;
1286 return sd->highlight_in_theme;
1290 elm_widget_focus_get(const Evas_Object *obj)
1292 API_ENTRY return EINA_FALSE;
1297 elm_widget_focused_object_get(const Evas_Object *obj)
1299 const Evas_Object *subobj;
1301 API_ENTRY return NULL;
1303 if (!sd->focused) return NULL;
1304 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1306 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1307 if (fobj) return fobj;
1309 return (Evas_Object *)obj;
1313 elm_widget_top_get(const Evas_Object *obj)
1315 API_ENTRY return NULL;
1316 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1317 return (Evas_Object *)obj;
1321 elm_widget_is(const Evas_Object *obj)
1323 return _elm_widget_is(obj);
1327 elm_widget_parent_widget_get(const Evas_Object *obj)
1329 Evas_Object *parent;
1331 if (_elm_widget_is(obj))
1333 Smart_Data *sd = evas_object_smart_data_get(obj);
1334 if (!sd) return NULL;
1335 parent = sd->parent_obj;
1339 parent = evas_object_data_get(obj, "elm-parent");
1340 if (!parent) parent = evas_object_smart_parent_get(obj);
1345 Evas_Object *elm_parent;
1346 if (_elm_widget_is(parent)) break;
1347 elm_parent = evas_object_data_get(parent, "elm-parent");
1348 if (elm_parent) parent = elm_parent;
1349 else parent = evas_object_smart_parent_get(parent);
1355 elm_widget_parent2_get(const Evas_Object *obj)
1357 if (_elm_widget_is(obj))
1359 Smart_Data *sd = evas_object_smart_data_get(obj);
1360 if (sd) return sd->parent2;
1366 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1369 sd->parent2 = parent;
1373 elm_widget_event_callback_add(Evas_Object *obj,
1378 EINA_SAFETY_ON_NULL_RETURN(func);
1379 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1382 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1386 elm_widget_event_callback_del(Evas_Object *obj,
1390 API_ENTRY return NULL;
1391 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1393 Elm_Event_Cb_Data *ecd;
1394 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1395 if ((ecd->func == func) && (ecd->data == data))
1398 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1399 return (void *)data;
1405 elm_widget_event_propagate(Evas_Object *obj,
1406 Evas_Callback_Type type,
1408 Evas_Event_Flags *event_flags)
1410 API_ENTRY return EINA_FALSE; //TODO reduce.
1411 if (!_elm_widget_is(obj)) return EINA_FALSE;
1412 Evas_Object *parent = obj;
1413 Elm_Event_Cb_Data *ecd;
1414 Eina_List *l, *l_prev;
1417 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1419 sd = evas_object_smart_data_get(parent);
1420 if ((!sd) || (!_elm_widget_is(obj)))
1421 return EINA_FALSE; //Not Elm Widget
1423 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1426 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1428 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1429 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1432 parent = sd->parent_obj;
1441 * Set custom focus chain.
1443 * This function i set one new and overwrite any previous custom focus chain
1444 * with the list of objects. The previous list will be deleted and this list
1445 * will be managed. After setted, don't modity it.
1447 * @note On focus cycle, only will be evaluated children of this container.
1449 * @param obj The container widget
1450 * @param objs Chain of objects to pass focus
1454 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1458 if (!sd->focus_next_func)
1461 elm_widget_focus_custom_chain_unset(obj);
1466 EINA_LIST_FOREACH(objs, l, o)
1468 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1469 _elm_object_focus_chain_del_cb, sd);
1472 sd->focus_chain = objs;
1478 * Get custom focus chain
1480 * @param obj The container widget
1483 EAPI const Eina_List *
1484 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1486 API_ENTRY return NULL;
1487 return (const Eina_List *)sd->focus_chain;
1493 * Unset custom focus chain
1495 * @param obj The container widget
1499 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1502 Eina_List *l, *l_next;
1505 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1507 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1508 _elm_object_focus_chain_del_cb, sd);
1509 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1516 * Append object to custom focus chain.
1518 * @note If relative_child equal to NULL or not in custom chain, the object
1519 * will be added in end.
1521 * @note On focus cycle, only will be evaluated children of this container.
1523 * @param obj The container widget
1524 * @param child The child to be added in custom chain
1525 * @param relative_child The relative object to position the child
1529 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1531 Evas_Object *relative_child)
1534 EINA_SAFETY_ON_NULL_RETURN(child);
1535 if (!sd->focus_next_func)
1538 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1539 _elm_object_focus_chain_del_cb, sd);
1541 if (!relative_child)
1543 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1547 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1554 * Prepend object to custom focus chain.
1556 * @note If relative_child equal to NULL or not in custom chain, the object
1557 * will be added in begin.
1559 * @note On focus cycle, only will be evaluated children of this container.
1561 * @param obj The container widget
1562 * @param child The child to be added in custom chain
1563 * @param relative_child The relative object to position the child
1567 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1569 Evas_Object *relative_child)
1572 EINA_SAFETY_ON_NULL_RETURN(child);
1573 if (!sd->focus_next_func)
1576 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1577 _elm_object_focus_chain_del_cb, sd);
1579 if (!relative_child)
1581 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1585 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1592 * Give focus to next object in object tree.
1594 * Give focus to next object in focus chain of one object sub-tree.
1595 * If the last object of chain already have focus, the focus will go to the
1596 * first object of chain.
1598 * @param obj The widget root of sub-tree
1599 * @param dir Direction to cycle the focus
1604 elm_widget_focus_cycle(Evas_Object *obj,
1605 Elm_Focus_Direction dir)
1607 Evas_Object *target = NULL;
1608 if (!_elm_widget_is(obj))
1610 elm_widget_focus_next_get(obj, dir, &target);
1612 elm_widget_focus_steal(target);
1618 * Give focus to near object in one direction.
1620 * Give focus to near object in direction of one object.
1621 * If none focusable object in given direction, the focus will not change.
1623 * @param obj The reference widget
1624 * @param x Horizontal component of direction to focus
1625 * @param y Vertical component of direction to focus
1630 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1640 * Get next object in focus chain of object tree.
1642 * Get next object in focus chain of one object sub-tree.
1643 * Return the next object by reference. If don't have any candidate to receive
1644 * focus before chain end, the first candidate will be returned.
1646 * @param obj The widget root of sub-tree
1647 * @param dir Direction os focus chain
1648 * @param next The next object in focus chain
1649 * @return EINA_TRUE if don't need focus chain restart/loop back
1650 * to use 'next' obj.
1655 elm_widget_focus_next_get(const Evas_Object *obj,
1656 Elm_Focus_Direction dir,
1663 API_ENTRY return EINA_FALSE;
1665 /* Ignore if disabled */
1666 if ((!evas_object_visible_get(obj))
1667 || (elm_widget_disabled_get(obj))
1668 || (elm_widget_tree_unfocusable_get(obj)))
1672 if (sd->focus_next_func)
1673 return sd->focus_next_func(obj, dir, next);
1675 if (!elm_widget_can_focus_get(obj))
1679 *next = (Evas_Object *)obj;
1680 return !elm_widget_focus_get(obj);
1686 * Get next object in focus chain of object tree in list.
1688 * Get next object in focus chain of one object sub-tree ordered by one list.
1689 * Return the next object by reference. If don't have any candidate to receive
1690 * focus before list end, the first candidate will be returned.
1692 * @param obj The widget root of sub-tree
1693 * @param dir Direction os focus chain
1694 * @param items list with ordered objects
1695 * @param list_data_get function to get the object from one item of list
1696 * @param next The next object in focus chain
1697 * @return EINA_TRUE if don't need focus chain restart/loop back
1698 * to use 'next' obj.
1703 elm_widget_focus_list_next_get(const Evas_Object *obj,
1704 const Eina_List *items,
1705 void *(*list_data_get)(const Eina_List * list),
1706 Elm_Focus_Direction dir,
1709 Eina_List *(*list_next)(const Eina_List * list) = NULL;
1715 if (!_elm_widget_is(obj))
1722 if (dir == ELM_FOCUS_PREVIOUS)
1724 items = eina_list_last(items);
1725 list_next = eina_list_prev;
1727 else if (dir == ELM_FOCUS_NEXT)
1728 list_next = eina_list_next;
1732 const Eina_List *l = items;
1734 /* Recovery last focused sub item */
1735 if (elm_widget_focus_get(obj))
1736 for (; l; l = list_next(l))
1738 Evas_Object *cur = list_data_get(l);
1739 if (elm_widget_focus_get(cur)) break;
1742 const Eina_List *start = l;
1743 Evas_Object *to_focus = NULL;
1745 /* Interate sub items */
1746 /* Go to end of list */
1747 for (; l; l = list_next(l))
1749 Evas_Object *tmp = NULL;
1750 Evas_Object *cur = list_data_get(l);
1752 if (elm_widget_parent_get(cur) != obj)
1755 /* Try Focus cycle in subitem */
1756 if (elm_widget_focus_next_get(cur, dir, &tmp))
1761 else if ((tmp) && (!to_focus))
1767 /* Get First possible */
1768 for (; l != start; l = list_next(l))
1770 Evas_Object *tmp = NULL;
1771 Evas_Object *cur = list_data_get(l);
1773 if (elm_widget_parent_get(cur) != obj)
1776 /* Try Focus cycle in subitem */
1777 elm_widget_focus_next_get(cur, dir, &tmp);
1790 elm_widget_signal_emit(Evas_Object *obj,
1791 const char *emission,
1795 if (!sd->signal_func) return;
1796 sd->signal_func(obj, emission, source);
1800 _edje_signal_callback(void *data,
1801 Evas_Object *obj __UNUSED__,
1802 const char *emission,
1805 Edje_Signal_Data *esd = data;
1806 esd->func(esd->data, esd->obj, emission, source);
1810 elm_widget_signal_callback_add(Evas_Object *obj,
1811 const char *emission,
1813 Edje_Signal_Cb func,
1816 Edje_Signal_Data *esd;
1818 if (!sd->callback_add_func) return;
1819 EINA_SAFETY_ON_NULL_RETURN(func);
1821 esd = ELM_NEW(Edje_Signal_Data);
1826 esd->emission = eina_stringshare_add(emission);
1827 esd->source = eina_stringshare_add(source);
1829 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1830 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1834 elm_widget_signal_callback_del(Evas_Object *obj,
1835 const char *emission,
1837 Edje_Signal_Cb func)
1839 Edje_Signal_Data *esd;
1842 API_ENTRY return NULL;
1843 if (!sd->callback_del_func) return NULL;
1845 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1847 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1848 (!strcmp(esd->source, source)))
1850 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1851 eina_stringshare_del(esd->emission);
1852 eina_stringshare_del(esd->source);
1858 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1863 elm_widget_focus_set(Evas_Object *obj,
1870 sd->focus_order = focus_order;
1871 sd->focused = EINA_TRUE;
1872 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1876 sd->focus_func(obj);
1883 if ((_is_focusable(sd->resize_obj)) &&
1884 (!elm_widget_disabled_get(sd->resize_obj)))
1886 elm_widget_focus_set(sd->resize_obj, first);
1892 EINA_LIST_FOREACH(sd->subobjs, l, child)
1894 if ((_is_focusable(child)) &&
1895 (!elm_widget_disabled_get(child)))
1897 elm_widget_focus_set(child, first);
1907 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1909 if ((_is_focusable(child)) &&
1910 (!elm_widget_disabled_get(child)))
1912 elm_widget_focus_set(child, first);
1918 if ((_is_focusable(sd->resize_obj)) &&
1919 (!elm_widget_disabled_get(sd->resize_obj)))
1921 elm_widget_focus_set(sd->resize_obj, first);
1929 elm_widget_parent_get(const Evas_Object *obj)
1931 API_ENTRY return NULL;
1932 return sd->parent_obj;
1936 elm_widget_focused_object_clear(Evas_Object *obj)
1939 if (!sd->focused) return;
1940 if (elm_widget_focus_get(sd->resize_obj))
1941 elm_widget_focused_object_clear(sd->resize_obj);
1946 EINA_LIST_FOREACH(sd->subobjs, l, child)
1948 if (elm_widget_focus_get(child))
1950 elm_widget_focused_object_clear(child);
1955 sd->focused = EINA_FALSE;
1956 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1957 if (sd->focus_func) sd->focus_func(obj);
1961 elm_widget_focus_steal(Evas_Object *obj)
1963 Evas_Object *parent, *parent2, *o;
1966 if (sd->focused) return;
1967 if (sd->disabled) return;
1968 if (!sd->can_focus) return;
1969 if (sd->tree_unfocusable) return;
1973 o = elm_widget_parent_get(parent);
1975 sd = evas_object_smart_data_get(o);
1976 if (sd->disabled || sd->tree_unfocusable) return;
1977 if (sd->focused) break;
1980 if ((!elm_widget_parent_get(parent)) &&
1981 (!elm_widget_parent2_get(parent)))
1982 elm_widget_focused_object_clear(parent);
1985 parent2 = elm_widget_parent_get(parent);
1986 if (!parent2) parent2 = elm_widget_parent2_get(parent);
1988 sd = evas_object_smart_data_get(parent);
1991 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1992 elm_widget_focused_object_clear(sd->resize_obj);
1997 EINA_LIST_FOREACH(sd->subobjs, l, child)
1999 if (elm_widget_focus_get(child))
2001 elm_widget_focused_object_clear(child);
2013 elm_widget_focus_restore(Evas_Object *obj)
2015 Evas_Object *newest = NULL;
2016 unsigned int newest_focus_order = 0;
2019 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2022 elm_object_focus_set(newest, EINA_FALSE);
2023 elm_object_focus_set(newest, EINA_TRUE);
2028 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
2034 if (sd->top_win_focused == top_win_focused) return;
2036 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2037 EINA_LIST_FOREACH(sd->subobjs, l, child)
2039 _elm_widget_top_win_focused_set(child, top_win_focused);
2041 sd->top_win_focused = top_win_focused;
2045 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2047 API_ENTRY return EINA_FALSE;
2048 return sd->top_win_focused;
2052 elm_widget_activate(Evas_Object *obj)
2055 elm_widget_change(obj);
2056 if (sd->activate_func) sd->activate_func(obj);
2060 elm_widget_change(Evas_Object *obj)
2063 elm_widget_change(elm_widget_parent_get(obj));
2064 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2068 elm_widget_disabled_set(Evas_Object *obj,
2073 if (sd->disabled == disabled) return;
2074 sd->disabled = !!disabled;
2075 elm_widget_focus_disabled_handle(obj);
2076 if (sd->disable_func) sd->disable_func(obj);
2080 elm_widget_disabled_get(const Evas_Object *obj)
2083 return sd->disabled;
2087 elm_widget_show_region_set(Evas_Object *obj,
2092 Eina_Bool forceshow)
2094 Evas_Object *parent_obj, *child_obj;
2095 Evas_Coord px, py, cx, cy;
2098 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2099 && (w == sd->rw) && (h == sd->rh)) return;
2104 if (sd->on_show_region_func)
2105 sd->on_show_region_func(sd->on_show_region_data, obj);
2109 parent_obj = sd->parent_obj;
2110 child_obj = sd->obj;
2111 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2112 sd = evas_object_smart_data_get(parent_obj);
2115 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2116 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2125 if (sd->on_show_region_func)
2127 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2134 elm_widget_show_region_get(const Evas_Object *obj,
2150 * Get the focus region of the given widget.
2152 * The focus region is the area of a widget that should brought into the
2153 * visible area when the widget is focused. Mostly used to show the part of
2154 * an entry where the cursor is, for example. The area returned is relative
2155 * to the object @p obj.
2156 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2157 * function will return the full size of the object.
2159 * @param obj The widget object
2160 * @param x Where to store the x coordinate of the area
2161 * @param y Where to store the y coordinate of the area
2162 * @param w Where to store the width of the area
2163 * @param h Where to store the height of the area
2168 elm_widget_focus_region_get(const Evas_Object *obj,
2178 sd = evas_object_smart_data_get(obj);
2179 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2181 evas_object_geometry_get(obj, NULL, NULL, w, h);
2186 sd->on_focus_region_func(obj, x, y, w, h);
2190 elm_widget_scroll_hold_push(Evas_Object *obj)
2194 if (sd->scroll_hold == 1)
2195 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2196 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2197 // FIXME: on delete/reparent hold pop
2201 elm_widget_scroll_hold_pop(Evas_Object *obj)
2205 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2206 if (!sd->scroll_hold)
2207 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2208 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2212 elm_widget_scroll_hold_get(const Evas_Object *obj)
2215 return sd->scroll_hold;
2219 elm_widget_scroll_freeze_push(Evas_Object *obj)
2222 sd->scroll_freeze++;
2223 if (sd->scroll_freeze == 1)
2224 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2225 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2226 // FIXME: on delete/reparent freeze pop
2230 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2233 sd->scroll_freeze--;
2234 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2235 if (!sd->scroll_freeze)
2236 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2237 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2241 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2244 return sd->scroll_freeze;
2248 elm_widget_scale_set(Evas_Object *obj,
2252 if (scale <= 0.0) scale = 0.0;
2253 if (sd->scale != scale)
2256 elm_widget_theme(obj);
2261 elm_widget_scale_get(const Evas_Object *obj)
2263 API_ENTRY return 1.0;
2264 // FIXME: save walking up the tree by storing/caching parent scale
2265 if (sd->scale == 0.0)
2268 return elm_widget_scale_get(sd->parent_obj);
2276 elm_widget_theme_set(Evas_Object *obj,
2280 if (sd->theme != th)
2282 if (sd->theme) elm_theme_free(sd->theme);
2285 elm_widget_theme(obj);
2290 elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label)
2294 if (!sd->on_text_set_func)
2297 sd->on_text_set_func(obj, part, label);
2301 elm_widget_text_part_get(const Evas_Object *obj, const char *part)
2303 API_ENTRY return NULL;
2305 if (!sd->on_text_get_func)
2308 return sd->on_text_get_func(obj, part);
2312 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2316 Elm_Translate_String_Data *ts = NULL;
2319 str = eina_stringshare_add(part);
2320 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2327 eina_stringshare_del(str);
2330 ts = malloc(sizeof(Elm_Translate_String_Data));
2334 ts->domain = eina_stringshare_add(domain);
2335 ts->string = eina_stringshare_add(label);
2336 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2342 eina_stringshare_replace(&ts->domain, domain);
2343 eina_stringshare_replace(&ts->string, label);
2347 sd->translate_strings = eina_list_remove_list(
2348 sd->translate_strings, l);
2349 eina_stringshare_del(ts->id);
2350 eina_stringshare_del(ts->domain);
2351 eina_stringshare_del(ts->string);
2354 eina_stringshare_del(str);
2358 if (label && label[0])
2359 label = dgettext(domain, label);
2361 elm_widget_text_part_set(obj, part, label);
2365 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2367 const char *str, *ret = NULL;
2369 Elm_Translate_String_Data *ts;
2370 API_ENTRY return NULL;
2372 str = eina_stringshare_add(part);
2373 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2379 eina_stringshare_del(str);
2384 elm_widget_translate(Evas_Object *obj)
2388 Elm_Translate_String_Data *ts;
2391 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2392 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2393 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2394 if (sd->translate_func) sd->translate_func(obj);
2397 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2399 const char *s = dgettext(ts->domain, ts->string);
2400 elm_widget_text_part_set(obj, ts->id, s);
2406 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2410 if (!sd->on_content_set_func) return;
2411 sd->on_content_set_func(obj, part, content);
2415 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2417 API_ENTRY return NULL;
2419 if (!sd->on_content_get_func) return NULL;
2420 return sd->on_content_get_func(obj, part);
2424 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2426 API_ENTRY return NULL;
2428 if (!sd->on_content_unset_func) return NULL;
2429 return sd->on_content_unset_func(obj, part);
2433 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2436 if (sd->access_info) eina_stringshare_del(sd->access_info);
2437 if (!txt) sd->access_info = NULL;
2438 else sd->access_info = eina_stringshare_add(txt);
2442 elm_widget_access_info_get(Evas_Object *obj)
2444 API_ENTRY return NULL;
2445 return sd->access_info;
2449 elm_widget_theme_get(const Evas_Object *obj)
2451 API_ENTRY return NULL;
2455 return elm_widget_theme_get(sd->parent_obj);
2463 elm_widget_style_set(Evas_Object *obj,
2468 if (eina_stringshare_replace(&sd->style, style))
2469 elm_widget_theme(obj);
2473 elm_widget_style_get(const Evas_Object *obj)
2475 API_ENTRY return NULL;
2476 if (sd->style) return sd->style;
2481 elm_widget_type_set(Evas_Object *obj,
2485 eina_stringshare_replace(&sd->type, type);
2489 elm_widget_type_get(const Evas_Object *obj)
2491 API_ENTRY return NULL;
2492 if (sd->type) return sd->type;
2497 elm_widget_tooltip_add(Evas_Object *obj,
2501 sd->tooltips = eina_list_append(sd->tooltips, tt);
2505 elm_widget_tooltip_del(Evas_Object *obj,
2509 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2513 elm_widget_cursor_add(Evas_Object *obj,
2517 sd->cursors = eina_list_append(sd->cursors, cur);
2521 elm_widget_cursor_del(Evas_Object *obj,
2525 sd->cursors = eina_list_remove(sd->cursors, cur);
2529 elm_widget_drag_lock_x_set(Evas_Object *obj,
2533 if (sd->drag_x_locked == lock) return;
2534 sd->drag_x_locked = lock;
2535 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2536 else _propagate_x_drag_lock(obj, -1);
2540 elm_widget_drag_lock_y_set(Evas_Object *obj,
2544 if (sd->drag_y_locked == lock) return;
2545 sd->drag_y_locked = lock;
2546 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2547 else _propagate_y_drag_lock(obj, -1);
2551 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2553 API_ENTRY return EINA_FALSE;
2554 return sd->drag_x_locked;
2558 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2560 API_ENTRY return EINA_FALSE;
2561 return sd->drag_y_locked;
2565 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2568 return sd->child_drag_x_locked;
2572 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2575 return sd->child_drag_y_locked;
2579 elm_widget_theme_object_set(Evas_Object *obj,
2582 const char *welement,
2585 API_ENTRY return EINA_FALSE;
2586 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2590 elm_widget_is_check(const Evas_Object *obj)
2592 static int abort_on_warn = -1;
2593 if (elm_widget_is(obj))
2596 ERR("Passing Object: %p.", obj);
2597 if (abort_on_warn == -1)
2599 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2600 else abort_on_warn = 0;
2602 if (abort_on_warn == 1) abort();
2607 elm_widget_type_check(const Evas_Object *obj,
2611 const char *provided, *expected = "(unknown)";
2612 static int abort_on_warn = -1;
2613 provided = elm_widget_type_get(obj);
2614 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2615 if (type) expected = type;
2616 if ((!provided) || (!provided[0]))
2618 provided = evas_object_type_get(obj);
2619 if ((!provided) || (!provided[0]))
2620 provided = "(unknown)";
2622 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting type: '%s'", obj, func, provided, expected);
2623 if (abort_on_warn == -1)
2625 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2626 else abort_on_warn = 0;
2628 if (abort_on_warn == 1) abort();
2635 * Split string in words
2637 * @param str Source string
2638 * @return List of const words
2640 * @see elm_widget_stringlist_free()
2644 elm_widget_stringlist_get(const char *str)
2646 Eina_List *list = NULL;
2648 if (!str) return NULL;
2649 for (b = s = str; 1; s++)
2651 if ((*s == ' ') || (!*s))
2653 char *t = malloc(s - b + 1);
2656 strncpy(t, b, s - b);
2658 list = eina_list_append(list, eina_stringshare_add(t));
2669 elm_widget_stringlist_free(Eina_List *list)
2672 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2676 elm_widget_focus_hide_handle(Evas_Object *obj)
2678 _if_focused_revert(obj, EINA_TRUE);
2682 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2684 Evas_Object *o = obj;
2687 if (_elm_widget_is(o)) break;
2688 o = evas_object_smart_parent_get(o);
2692 if (!_is_focusable(o)) return;
2693 elm_widget_focus_steal(o);
2697 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2701 if (!elm_widget_parent_get(obj))
2702 elm_widget_focused_object_clear(obj);
2704 _if_focused_revert(obj, EINA_TRUE);
2708 elm_widget_focus_disabled_handle(Evas_Object *obj)
2712 elm_widget_focus_tree_unfocusable_handle(obj);
2718 * Allocate a new Elm_Widget_Item-derived structure.
2720 * The goal of this structure is to provide common ground for actions
2721 * that a widget item have, such as the owner widget, callback to
2722 * notify deletion, data pointer and maybe more.
2724 * @param widget the owner widget that holds this item, must be an elm_widget!
2725 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2726 * be used to allocate memory.
2728 * @return allocated memory that is already zeroed out, or NULL on errors.
2730 * @see elm_widget_item_new() convenience macro.
2731 * @see elm_widget_item_del() to release memory.
2734 EAPI Elm_Widget_Item *
2735 _elm_widget_item_new(Evas_Object *widget,
2738 if (!_elm_widget_is(widget))
2741 Elm_Widget_Item *item;
2743 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2744 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2746 item = calloc(1, alloc_size);
2747 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2749 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2750 item->widget = widget;
2757 * Releases widget item memory, calling back del_cb() if it exists.
2759 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2760 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2761 * this function and then unset it, thus being useful for 2 step
2762 * cleanup whenever the del_cb may use any of the data that must be
2763 * deleted from item.
2765 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2768 * @param item a valid #Elm_Widget_Item to be deleted.
2769 * @see elm_widget_item_del() convenience macro.
2773 _elm_widget_item_del(Elm_Widget_Item *item)
2775 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2778 item->del_cb((void *)item->data, item->widget, item);
2781 evas_object_del(item->view);
2785 _elm_access_clear(item->access);
2787 item->access = NULL;
2789 if (item->access_info)
2791 eina_stringshare_del(item->access_info);
2792 item->access_info = NULL;
2795 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2802 * Notify object will be deleted without actually deleting it.
2804 * This function will callback Elm_Widget_Item::del_cb if it is set
2805 * and then unset it so it is not called twice (ie: from
2806 * elm_widget_item_del()).
2808 * @param item a valid #Elm_Widget_Item to be notified
2809 * @see elm_widget_item_pre_notify_del() convenience macro.
2813 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2815 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2816 if (!item->del_cb) return;
2817 item->del_cb((void *)item->data, item->widget, item);
2818 item->del_cb = NULL;
2824 * Set the function to notify when item is being deleted.
2826 * This function will complain if there was a callback set already,
2827 * however it will set the new one.
2829 * The callback will be called from elm_widget_item_pre_notify_del()
2830 * or elm_widget_item_del() will be called with:
2831 * - data: the Elm_Widget_Item::data value.
2832 * - obj: the Elm_Widget_Item::widget evas object.
2833 * - event_info: the item being deleted.
2835 * @param item a valid #Elm_Widget_Item to be notified
2836 * @see elm_widget_item_del_cb_set() convenience macro.
2840 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2841 Evas_Smart_Cb del_cb)
2843 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2845 if ((item->del_cb) && (item->del_cb != del_cb))
2846 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2847 item->del_cb, item, del_cb);
2849 item->del_cb = del_cb;
2855 * Set user-data in this item.
2857 * User data may be used to identify this item or just store any
2858 * application data. It is automatically given as the first parameter
2859 * of the deletion notify callback.
2861 * @param item a valid #Elm_Widget_Item to store data in.
2862 * @param data user data to store.
2863 * @see elm_widget_item_del_cb_set() convenience macro.
2867 _elm_widget_item_data_set(Elm_Widget_Item *item,
2870 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2871 if ((item->data) && (item->data != data))
2872 DBG("Replacing item %p data %p with %p", item, item->data, data);
2879 * Retrieves user-data of this item.
2881 * @param item a valid #Elm_Widget_Item to get data from.
2882 * @see elm_widget_item_data_set()
2886 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2888 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2889 return (void *)item->data;
2892 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2894 struct _Elm_Widget_Item_Tooltip
2896 Elm_Widget_Item *item;
2897 Elm_Tooltip_Item_Content_Cb func;
2898 Evas_Smart_Cb del_cb;
2902 static Evas_Object *
2903 _elm_widget_item_tooltip_label_create(void *data,
2904 Evas_Object *obj __UNUSED__,
2905 Evas_Object *tooltip,
2906 void *item __UNUSED__)
2908 Evas_Object *label = elm_label_add(tooltip);
2911 elm_object_style_set(label, "tooltip");
2912 elm_object_text_set(label, data);
2916 static Evas_Object *
2917 _elm_widget_item_tooltip_trans_label_create(void *data,
2918 Evas_Object *obj __UNUSED__,
2919 Evas_Object *tooltip,
2920 void *item __UNUSED__)
2922 Evas_Object *label = elm_label_add(tooltip);
2925 elm_object_style_set(label, "tooltip");
2926 elm_object_translatable_text_set(label, data);
2931 _elm_widget_item_tooltip_label_del_cb(void *data,
2932 Evas_Object *obj __UNUSED__,
2933 void *event_info __UNUSED__)
2935 eina_stringshare_del(data);
2941 * Set the text to be shown in the widget item.
2943 * @param item Target item
2944 * @param text The text to set in the content
2946 * Setup the text as tooltip to object. The item can have only one tooltip,
2947 * so any previous tooltip data is removed.
2952 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2955 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2956 EINA_SAFETY_ON_NULL_RETURN(text);
2958 text = eina_stringshare_add(text);
2959 _elm_widget_item_tooltip_content_cb_set
2960 (item, _elm_widget_item_tooltip_label_create, text,
2961 _elm_widget_item_tooltip_label_del_cb);
2965 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2968 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2969 EINA_SAFETY_ON_NULL_RETURN(text);
2971 text = eina_stringshare_add(text);
2972 _elm_widget_item_tooltip_content_cb_set
2973 (item, _elm_widget_item_tooltip_trans_label_create, text,
2974 _elm_widget_item_tooltip_label_del_cb);
2977 static Evas_Object *
2978 _elm_widget_item_tooltip_create(void *data,
2980 Evas_Object *tooltip)
2982 Elm_Widget_Item_Tooltip *wit = data;
2983 return wit->func((void *)wit->data, obj, tooltip, wit->item);
2987 _elm_widget_item_tooltip_del_cb(void *data,
2989 void *event_info __UNUSED__)
2991 Elm_Widget_Item_Tooltip *wit = data;
2992 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2999 * Set the content to be shown in the tooltip item
3001 * Setup the tooltip to item. The item can have only one tooltip,
3002 * so any previous tooltip data is removed. @p func(with @p data) will
3003 * be called every time that need show the tooltip and it should
3004 * return a valid Evas_Object. This object is then managed fully by
3005 * tooltip system and is deleted when the tooltip is gone.
3007 * @param item the widget item being attached a tooltip.
3008 * @param func the function used to create the tooltip contents.
3009 * @param data what to provide to @a func as callback data/context.
3010 * @param del_cb called when data is not needed anymore, either when
3011 * another callback replaces @func, the tooltip is unset with
3012 * elm_widget_item_tooltip_unset() or the owner @a item
3013 * dies. This callback receives as the first parameter the
3014 * given @a data, and @c event_info is the item.
3019 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
3020 Elm_Tooltip_Item_Content_Cb func,
3022 Evas_Smart_Cb del_cb)
3024 Elm_Widget_Item_Tooltip *wit;
3026 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
3030 _elm_widget_item_tooltip_unset(item);
3034 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
3035 if (!wit) goto error;
3039 wit->del_cb = del_cb;
3041 elm_object_sub_tooltip_content_cb_set
3042 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
3043 _elm_widget_item_tooltip_del_cb);
3048 if (del_cb) del_cb((void *)data, NULL, item);
3051 if (del_cb) del_cb((void *)data, item->widget, item);
3057 * Unset tooltip from item
3059 * @param item widget item to remove previously set tooltip.
3061 * Remove tooltip from item. The callback provided as del_cb to
3062 * elm_widget_item_tooltip_content_cb_set() will be called to notify
3063 * it is not used anymore.
3065 * @see elm_widget_item_tooltip_content_cb_set()
3070 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3072 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3073 elm_object_tooltip_unset(item->view);
3079 * Sets a different style for this item tooltip.
3081 * @note before you set a style you should define a tooltip with
3082 * elm_widget_item_tooltip_content_cb_set() or
3083 * elm_widget_item_tooltip_text_set()
3085 * @param item widget item with tooltip already set.
3086 * @param style the theme style to use (default, transparent, ...)
3091 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3094 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3095 elm_object_tooltip_style_set(item->view, style);
3099 _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable)
3101 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3102 return elm_tooltip_size_restrict_disable(item->view, disable);
3106 _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item)
3108 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3109 return elm_tooltip_size_restrict_disabled_get(item->view);
3115 * Get the style for this item tooltip.
3117 * @param item widget item with tooltip already set.
3118 * @return style the theme style in use, defaults to "default". If the
3119 * object does not have a tooltip set, then NULL is returned.
3124 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3126 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3127 return elm_object_tooltip_style_get(item->view);
3131 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3134 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3135 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3139 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3141 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3142 return elm_object_cursor_get(item->view);
3146 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3148 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3149 elm_object_cursor_unset(item->view);
3155 * Sets a different style for this item cursor.
3157 * @note before you set a style you should define a cursor with
3158 * elm_widget_item_cursor_set()
3160 * @param item widget item with cursor already set.
3161 * @param style the theme style to use (default, transparent, ...)
3166 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3169 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3170 elm_object_cursor_style_set(item->view, style);
3176 * Get the style for this item cursor.
3178 * @param item widget item with cursor already set.
3179 * @return style the theme style in use, defaults to "default". If the
3180 * object does not have a cursor set, then NULL is returned.
3185 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3187 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3188 return elm_object_cursor_style_get(item->view);
3194 * Set if the cursor set should be searched on the theme or should use
3195 * the provided by the engine, only.
3197 * @note before you set if should look on theme you should define a cursor
3198 * with elm_object_cursor_set(). By default it will only look for cursors
3199 * provided by the engine.
3201 * @param item widget item with cursor already set.
3202 * @param engine_only boolean to define it cursors should be looked only
3203 * between the provided by the engine or searched on widget's theme as well.
3208 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3209 Eina_Bool engine_only)
3211 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3212 elm_object_cursor_engine_only_set(item->view, engine_only);
3218 * Get the cursor engine only usage for this item cursor.
3220 * @param item widget item with cursor already set.
3221 * @return engine_only boolean to define it cursors should be looked only
3222 * between the provided by the engine or searched on widget's theme as well. If
3223 * the object does not have a cursor set, then EINA_FALSE is returned.
3228 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3230 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3231 return elm_object_cursor_engine_only_get(item->view);
3234 // smart object funcs
3236 _smart_reconfigure(Smart_Data *sd)
3240 evas_object_move(sd->resize_obj, sd->x, sd->y);
3241 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3245 evas_object_move(sd->hover_obj, sd->x, sd->y);
3246 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3251 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3253 Evas_Object *content)
3255 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3256 if (!item->on_content_set_func) return;
3257 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3261 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3264 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3265 if (!item->on_content_get_func) return NULL;
3266 return item->on_content_get_func((Elm_Object_Item *) item, part);
3270 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3273 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3274 if (!item->on_content_unset_func) return NULL;
3275 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3279 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3283 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3284 if (!item->on_text_set_func) return;
3285 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3289 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3290 const char *emission,
3293 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3294 if (item->on_signal_emit_func)
3295 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3299 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3302 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3303 if (!item->on_text_get_func) return NULL;
3304 return item->on_text_get_func((Elm_Object_Item *) item, part);
3308 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3309 Elm_Widget_On_Content_Set_Cb func)
3311 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3312 item->on_content_set_func = func;
3316 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3317 Elm_Widget_On_Content_Get_Cb func)
3319 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3320 item->on_content_get_func = func;
3324 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3325 Elm_Widget_On_Content_Unset_Cb func)
3327 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3328 item->on_content_unset_func = func;
3332 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3333 Elm_Widget_On_Text_Set_Cb func)
3335 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3336 item->on_text_set_func = func;
3340 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3341 Elm_Widget_On_Text_Get_Cb func)
3343 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3344 item->on_text_get_func = func;
3348 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3349 Elm_Widget_On_Signal_Emit_Cb func)
3351 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3352 item->on_signal_emit_func = func;
3356 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3358 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3359 if (item->access_info) eina_stringshare_del(item->access_info);
3360 if (!txt) item->access_info = NULL;
3361 else item->access_info = eina_stringshare_add(txt);
3366 _smart_add(Evas_Object *obj)
3370 sd = calloc(1, sizeof(Smart_Data));
3373 sd->x = sd->y = sd->w = sd->h = 0;
3375 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3376 evas_object_smart_data_set(obj, sd);
3379 static Evas_Object *
3380 _newest_focus_order_get(Evas_Object *obj,
3381 unsigned int *newest_focus_order,
3382 Eina_Bool can_focus_only)
3385 Evas_Object *child, *ret, *best;
3387 API_ENTRY return NULL;
3389 if (!evas_object_visible_get(obj)
3390 || (elm_widget_disabled_get(obj))
3391 || (elm_widget_tree_unfocusable_get(obj)))
3395 if (*newest_focus_order < sd->focus_order)
3397 *newest_focus_order = sd->focus_order;
3400 EINA_LIST_FOREACH(sd->subobjs, l, child)
3402 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3408 if ((!best) || (!elm_widget_can_focus_get(best)))
3415 _if_focused_revert(Evas_Object *obj,
3416 Eina_Bool can_focus_only)
3419 Evas_Object *newest = NULL;
3420 unsigned int newest_focus_order = 0;
3424 if (!sd->focused) return;
3425 if (!sd->parent_obj) return;
3427 top = elm_widget_top_get(sd->parent_obj);
3430 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3433 elm_object_focus_set(newest, EINA_FALSE);
3434 elm_object_focus_set(newest, EINA_TRUE);
3440 _smart_del(Evas_Object *obj)
3443 Edje_Signal_Data *esd;
3444 Elm_Translate_String_Data *ts;
3448 if (sd->del_pre_func) sd->del_pre_func(obj);
3451 sobj = sd->resize_obj;
3452 sd->resize_obj = NULL;
3453 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3454 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3455 evas_object_del(sobj);
3456 sd->resize_obj = NULL;
3460 sobj = sd->hover_obj;
3461 sd->hover_obj = NULL;
3462 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3463 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3464 evas_object_del(sobj);
3465 sd->hover_obj = NULL;
3467 EINA_LIST_FREE(sd->subobjs, sobj)
3469 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3470 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3471 evas_object_del(sobj);
3473 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
3474 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
3475 EINA_LIST_FREE(sd->edje_signals, esd)
3477 eina_stringshare_del(esd->emission);
3478 eina_stringshare_del(esd->source);
3481 EINA_LIST_FREE(sd->translate_strings, ts)
3483 eina_stringshare_del(ts->id);
3484 eina_stringshare_del(ts->domain);
3485 eina_stringshare_del(ts->string);
3488 sd->event_cb = eina_list_free(sd->event_cb); /* should be empty anyway */
3489 if (sd->del_func) sd->del_func(obj);
3490 if (sd->style) eina_stringshare_del(sd->style);
3491 if (sd->type) eina_stringshare_del(sd->type);
3492 if (sd->theme) elm_theme_free(sd->theme);
3494 _if_focused_revert(obj, EINA_TRUE);
3495 if (sd->access_info) eina_stringshare_del(sd->access_info);
3497 evas_object_smart_data_set(obj, NULL);
3501 _smart_move(Evas_Object *obj,
3508 _smart_reconfigure(sd);
3512 _smart_resize(Evas_Object *obj,
3519 _smart_reconfigure(sd);
3523 _smart_show(Evas_Object *obj)
3528 if ((list = evas_object_smart_members_get(obj)))
3530 EINA_LIST_FREE(list, o)
3532 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3533 evas_object_show(o);
3539 _smart_hide(Evas_Object *obj)
3545 list = evas_object_smart_members_get(obj);
3546 EINA_LIST_FREE(list, o)
3548 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3549 evas_object_hide(o);
3554 _smart_color_set(Evas_Object *obj,
3563 if ((list = evas_object_smart_members_get(obj)))
3565 EINA_LIST_FREE(list, o)
3567 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3568 evas_object_color_set(o, r, g, b, a);
3574 _smart_clip_set(Evas_Object *obj,
3580 if ((list = evas_object_smart_members_get(obj)))
3582 EINA_LIST_FREE(list, o)
3584 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3585 evas_object_clip_set(o, clip);
3591 _smart_clip_unset(Evas_Object *obj)
3596 if ((list = evas_object_smart_members_get(obj)))
3598 EINA_LIST_FREE(list, o)
3600 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3601 evas_object_clip_unset(o);
3607 _smart_calculate(Evas_Object *obj)
3610 if (sd->changed_func) sd->changed_func(obj);
3613 /* never need to touch this */
3617 if (_e_smart) return;
3619 static const Evas_Smart_Class sc =
3622 EVAS_SMART_CLASS_VERSION,
3640 _e_smart = evas_smart_class_new(&sc);
3644 /* happy debug functions */
3647 _sub_obj_tree_dump(const Evas_Object *obj,
3652 for (i = 0; i < lvl * 3; i++)
3655 if (_elm_widget_is(obj))
3659 printf("+ %s(%p)\n",
3663 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3664 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3666 if (obj != sd->resize_obj)
3667 _sub_obj_tree_dump(obj, lvl + 1);
3671 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3675 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3678 if (!_elm_widget_is(obj))
3682 Eina_Bool visible = evas_object_visible_get(obj);
3683 Eina_Bool disabled = elm_widget_disabled_get(obj);
3684 Eina_Bool focused = elm_widget_focus_get(obj);
3685 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3689 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3692 fprintf(output, ", style=bold");
3695 fprintf(output, ", color=gray28");
3697 fprintf(output, " ];\n");
3700 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3701 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3702 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3706 fprintf(output, ", style=bold");
3709 fprintf(output, ", fontcolor=gray28");
3711 if ((disabled) || (!visible))
3712 fprintf(output, ", color=gray");
3714 fprintf(output, " ];\n");
3718 EINA_LIST_FOREACH(sd->subobjs, l, o)
3719 _sub_obj_tree_dot_dump(o, output);
3724 elm_widget_tree_dump(const Evas_Object *top)
3727 _sub_obj_tree_dump(top, 0);
3735 elm_widget_tree_dot_dump(const Evas_Object *top,
3739 if (!_elm_widget_is(top))
3741 fprintf(output, "graph " " { node [shape=record];\n");
3742 _sub_obj_tree_dot_dump(top, output);
3743 fprintf(output, "}\n");