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 unsigned int focus_order;
94 Eina_Bool focus_order_on_calc;
96 int child_drag_x_locked;
97 int child_drag_y_locked;
99 Eina_List *edje_signals;
100 Eina_List *translate_strings;
102 Eina_Bool drag_x_locked : 1;
103 Eina_Bool drag_y_locked : 1;
105 Eina_Bool can_focus : 1;
106 Eina_Bool child_can_focus : 1;
107 Eina_Bool focused : 1;
108 Eina_Bool top_win_focused : 1;
109 Eina_Bool tree_unfocusable : 1;
110 Eina_Bool highlight_ignore : 1;
111 Eina_Bool highlight_in_theme : 1;
112 Eina_Bool disabled : 1;
113 Eina_Bool is_mirrored : 1;
114 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
115 Eina_Bool still_in : 1;
117 Eina_List *focus_chain;
121 struct _Edje_Signal_Data
125 const char *emission;
130 struct _Elm_Event_Cb_Data
136 struct _Elm_Translate_String_Data
143 /* local subsystem functions */
144 static void _smart_reconfigure(Smart_Data *sd);
145 static void _smart_add(Evas_Object *obj);
146 static void _smart_del(Evas_Object *obj);
147 static void _smart_move(Evas_Object *obj,
150 static void _smart_resize(Evas_Object *obj,
153 static void _smart_show(Evas_Object *obj);
154 static void _smart_hide(Evas_Object *obj);
155 static void _smart_color_set(Evas_Object *obj,
160 static void _smart_clip_set(Evas_Object *obj,
162 static void _smart_clip_unset(Evas_Object *obj);
163 static void _smart_calculate(Evas_Object *obj);
164 static void _smart_init(void);
166 static void _if_focused_revert(Evas_Object *obj,
167 Eina_Bool can_focus_only);
168 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
169 unsigned int *newest_focus_order,
170 Eina_Bool can_focus_only);
172 /* local subsystem globals */
173 static Evas_Smart *_e_smart = NULL;
174 static Eina_List *widtypes = NULL;
176 static unsigned int focus_order = 0;
179 static inline Eina_Bool
180 _elm_widget_is(const Evas_Object *obj)
182 const char *type = evas_object_type_get(obj);
183 return type == SMART_NAME;
186 static inline Eina_Bool
187 _is_focusable(Evas_Object *obj)
189 API_ENTRY return EINA_FALSE;
190 return sd->can_focus || (sd->child_can_focus);
194 _unfocus_parents(Evas_Object *obj)
196 for (; obj; obj = elm_widget_parent_get(obj))
199 if (!sd->focused) return;
205 _focus_parents(Evas_Object *obj)
207 for (; obj; obj = elm_widget_parent_get(obj))
210 if (sd->focused) return;
216 _sub_obj_del(void *data,
219 void *event_info __UNUSED__)
221 Smart_Data *sd = data;
223 if (_elm_widget_is(obj))
225 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
227 if (obj == sd->resize_obj)
228 sd->resize_obj = NULL;
229 else if (obj == sd->hover_obj)
230 sd->hover_obj = NULL;
232 sd->subobjs = eina_list_remove(sd->subobjs, obj);
233 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
237 _sub_obj_hide(void *data __UNUSED__,
240 void *event_info __UNUSED__)
242 elm_widget_focus_hide_handle(obj);
246 _sub_obj_mouse_down(void *data,
248 Evas_Object *obj __UNUSED__,
251 Smart_Data *sd = data;
252 Evas_Event_Mouse_Down *ev = event_info;
253 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
254 sd->still_in = EINA_TRUE;
258 _sub_obj_mouse_move(void *data,
263 Smart_Data *sd = data;
264 Evas_Event_Mouse_Move *ev = event_info;
267 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
268 sd->still_in = EINA_FALSE;
271 Evas_Coord x, y, w, h;
272 evas_object_geometry_get(obj, &x, &y, &w, &h);
273 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
274 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
275 sd->still_in = EINA_FALSE;
281 _sub_obj_mouse_up(void *data,
284 void *event_info __UNUSED__)
286 Smart_Data *sd = data;
288 elm_widget_focus_mouse_up_handle(obj);
289 sd->still_in = EINA_FALSE;
293 _propagate_x_drag_lock(Evas_Object *obj,
299 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
302 sd2->child_drag_x_locked += dir;
303 _propagate_x_drag_lock(sd->parent_obj, dir);
309 _propagate_y_drag_lock(Evas_Object *obj,
315 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
318 sd2->child_drag_y_locked += dir;
319 _propagate_y_drag_lock(sd->parent_obj, dir);
325 _propagate_event(void *data,
331 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
332 Evas_Event_Flags *event_flags = NULL;
336 case EVAS_CALLBACK_KEY_DOWN:
338 Evas_Event_Key_Down *ev = event_info;
339 event_flags = &(ev->event_flags);
343 case EVAS_CALLBACK_KEY_UP:
345 Evas_Event_Key_Up *ev = event_info;
346 event_flags = &(ev->event_flags);
350 case EVAS_CALLBACK_MOUSE_WHEEL:
352 Evas_Event_Mouse_Wheel *ev = event_info;
353 event_flags = &(ev->event_flags);
361 elm_widget_event_propagate(obj, type, event_info, event_flags);
365 _parent_focus(Evas_Object *obj)
368 if (sd->focused) return;
370 Evas_Object *o = elm_widget_parent_get(obj);
371 sd->focus_order_on_calc = EINA_TRUE;
373 if (o) _parent_focus(o);
375 if (!sd->focus_order_on_calc)
376 return; /* we don't want to override it if by means of any of the
377 callbacks below one gets to calculate our order
381 sd->focus_order = focus_order;
382 if (sd->top_win_focused)
384 sd->focused = EINA_TRUE;
385 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
386 if (sd->focus_func) sd->focus_func(obj);
387 _elm_widget_focus_region_show(obj);
389 sd->focus_order_on_calc = EINA_FALSE;
393 _elm_object_focus_chain_del_cb(void *data,
396 void *event_info __UNUSED__)
398 Smart_Data *sd = data;
400 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
403 // exposed util funcs to elm
405 _elm_widget_type_clear(void)
409 EINA_LIST_FREE(widtypes, ptr)
411 eina_stringshare_del(*ptr);
417 _elm_widget_focus_region_show(const Evas_Object *obj)
419 Evas_Coord x, y, w, h, ox, oy;
425 o = elm_widget_parent_get(obj);
428 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
429 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
433 sd2 = evas_object_smart_data_get(o);
434 if (sd2->focus_region_func)
436 sd2->focus_region_func(o, x, y, w, h);
437 elm_widget_focus_region_get(o, &x, &y, &w, &h);
441 evas_object_geometry_get(o, &px, &py, NULL, NULL);
447 o = elm_widget_parent_get(o);
452 * @defgroup Widget Widget
455 * Exposed api for making widgets
458 elm_widget_type_register(const char **ptr)
460 widtypes = eina_list_append(widtypes, (void *)ptr);
464 * @defgroup Widget Widget
467 * Disposed api for making widgets
470 elm_widget_type_unregister(const char **ptr)
472 widtypes = eina_list_remove(widtypes, (void *)ptr);
476 elm_widget_api_check(int ver)
478 if (ver != ELM_INTERNAL_API_VERSION)
480 CRITICAL("Elementary widget api versions do not match");
487 elm_widget_add(Evas *evas)
491 obj = evas_object_smart_add(evas, _e_smart);
492 elm_widget_mirrored_set(obj, elm_mirrored_get());
497 elm_widget_del_hook_set(Evas_Object *obj,
498 void (*func)(Evas_Object *obj))
505 elm_widget_del_pre_hook_set(Evas_Object *obj,
506 void (*func)(Evas_Object *obj))
509 sd->del_pre_func = func;
513 elm_widget_focus_hook_set(Evas_Object *obj,
514 void (*func)(Evas_Object *obj))
517 sd->focus_func = func;
521 elm_widget_activate_hook_set(Evas_Object *obj,
522 void (*func)(Evas_Object *obj))
525 sd->activate_func = func;
529 elm_widget_disable_hook_set(Evas_Object *obj,
530 void (*func)(Evas_Object *obj))
533 sd->disable_func = func;
537 elm_widget_theme_hook_set(Evas_Object *obj,
538 void (*func)(Evas_Object *obj))
541 sd->theme_func = func;
545 elm_widget_translate_hook_set(Evas_Object *obj,
546 void (*func)(Evas_Object *obj))
549 sd->translate_func = func;
553 elm_widget_event_hook_set(Evas_Object *obj,
554 Eina_Bool (*func)(Evas_Object *obj,
556 Evas_Callback_Type type,
560 sd->event_func = func;
564 elm_widget_text_set_hook_set(Evas_Object *obj,
565 Elm_Widget_On_Text_Set_Cb func)
568 sd->on_text_set_func = func;
572 elm_widget_text_get_hook_set(Evas_Object *obj,
573 Elm_Widget_On_Text_Get_Cb func)
576 sd->on_text_get_func = func;
580 elm_widget_content_set_hook_set(Evas_Object *obj,
581 Elm_Widget_On_Content_Set_Cb func)
584 sd->on_content_set_func = func;
588 elm_widget_content_get_hook_set(Evas_Object *obj,
589 Elm_Widget_On_Content_Get_Cb func)
592 sd->on_content_get_func = func;
596 elm_widget_content_unset_hook_set(Evas_Object *obj,
597 Elm_Widget_On_Content_Unset_Cb func)
600 sd->on_content_unset_func = func;
604 elm_widget_changed_hook_set(Evas_Object *obj,
605 void (*func)(Evas_Object *obj))
608 sd->changed_func = func;
612 elm_widget_signal_emit_hook_set(Evas_Object *obj,
613 void (*func)(Evas_Object *obj,
614 const char *emission,
618 sd->signal_func = func;
622 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
623 void (*func)(Evas_Object *obj,
624 const char *emission,
626 Edje_Signal_Cb func_cb,
630 sd->callback_add_func = func;
634 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
635 void (*func)(Evas_Object *obj,
636 const char *emission,
638 Edje_Signal_Cb func_cb,
642 sd->callback_del_func = func;
646 elm_widget_theme(Evas_Object *obj)
654 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
655 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
656 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
657 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
658 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
659 if (sd->theme_func) sd->theme_func(obj);
663 elm_widget_theme_specific(Evas_Object *obj,
671 Elm_Theme *th2, *thdef;
674 thdef = elm_theme_default_get();
679 if (!th2) th2 = thdef;
687 if (th2 == thdef) break;
688 th2 = th2->ref_theme;
689 if (!th2) th2 = thdef;
693 EINA_LIST_FOREACH(sd->subobjs, l, child)
694 elm_widget_theme_specific(child, th, force);
695 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
696 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
697 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
698 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
699 if (sd->theme_func) sd->theme_func(obj);
705 * Set hook to get next object in object focus chain.
707 * @param obj The widget object.
708 * @param func The hook to be used with this widget.
713 elm_widget_focus_next_hook_set(Evas_Object *obj,
714 Eina_Bool (*func)(const Evas_Object *obj,
715 Elm_Focus_Direction dir,
719 sd->focus_next_func = func;
723 * Returns the widget's mirrored mode.
725 * @param obj The widget.
726 * @return mirrored mode of the object.
730 elm_widget_mirrored_get(const Evas_Object *obj)
732 API_ENTRY return EINA_FALSE;
733 return sd->is_mirrored;
737 * Sets the widget's mirrored mode.
739 * @param obj The widget.
740 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
743 elm_widget_mirrored_set(Evas_Object *obj,
747 if (sd->is_mirrored != mirrored)
749 sd->is_mirrored = mirrored;
750 elm_widget_theme(obj);
756 * Resets the mirrored mode from the system mirror mode for widgets that are in
757 * automatic mirroring mode. This function does not call elm_widget_theme.
759 * @param obj The widget.
760 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
763 _elm_widget_mirrored_reload(Evas_Object *obj)
766 Eina_Bool mirrored = elm_mirrored_get();
767 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
769 sd->is_mirrored = mirrored;
774 * Returns the widget's mirrored mode setting.
776 * @param obj The widget.
777 * @return mirrored mode setting of the object.
781 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
783 API_ENTRY return EINA_FALSE;
784 return sd->mirrored_auto_mode;
788 * Sets the widget's mirrored mode setting.
789 * When widget in automatic mode, it follows the system mirrored mode set by
790 * elm_mirrored_set().
791 * @param obj The widget.
792 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
795 elm_widget_mirrored_automatic_set(Evas_Object *obj,
799 if (sd->mirrored_auto_mode != automatic)
801 sd->mirrored_auto_mode = automatic;
805 elm_widget_mirrored_set(obj, elm_mirrored_get());
811 elm_widget_on_focus_hook_set(Evas_Object *obj,
812 void (*func)(void *data,
817 sd->on_focus_func = func;
818 sd->on_focus_data = data;
822 elm_widget_on_change_hook_set(Evas_Object *obj,
823 void (*func)(void *data,
828 sd->on_change_func = func;
829 sd->on_change_data = data;
833 elm_widget_on_show_region_hook_set(Evas_Object *obj,
834 void (*func)(void *data,
839 sd->on_show_region_func = func;
840 sd->on_show_region_data = data;
846 * Set the hook to use to show the focused region.
848 * Whenever a new widget gets focused or it's needed to show the focused
849 * area of the current one, this hook will be called on objects that may
850 * want to move their children into their visible area.
851 * The area given in the hook function is relative to the @p obj widget.
853 * @param obj The widget object
854 * @param func The function to call to show the specified area.
859 elm_widget_focus_region_hook_set(Evas_Object *obj,
860 void (*func)(Evas_Object *obj,
867 sd->focus_region_func = func;
873 * Set the hook to retrieve the focused region of a widget.
875 * This hook will be called by elm_widget_focus_region_get() whenever
876 * it's needed to get the focused area of a widget. The area must be relative
877 * to the widget itself and if no hook is set, it will default to the entire
880 * @param obj The widget object
881 * @param func The function used to retrieve the focus region.
886 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
887 void (*func)(const Evas_Object *obj,
894 sd->on_focus_region_func = func;
898 elm_widget_data_set(Evas_Object *obj,
906 elm_widget_data_get(const Evas_Object *obj)
908 API_ENTRY return NULL;
913 elm_widget_sub_object_add(Evas_Object *obj,
917 double scale, pscale = elm_widget_scale_get(sobj);
918 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
919 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
921 if (_elm_widget_is(sobj))
923 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
926 if (sd2->parent_obj == obj)
929 elm_widget_sub_object_del(sd2->parent_obj, sobj);
930 sd2->parent_obj = obj;
931 sd2->top_win_focused = sd->top_win_focused;
932 if (!sd->child_can_focus && (_is_focusable(sobj)))
933 sd->child_can_focus = EINA_TRUE;
938 void *data = evas_object_data_get(sobj, "elm-parent");
941 if (data == obj) return;
942 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
947 sd->subobjs = eina_list_append(sd->subobjs, sobj);
948 evas_object_data_set(sobj, "elm-parent", obj);
949 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
950 if (_elm_widget_is(sobj))
951 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
952 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
953 scale = elm_widget_scale_get(sobj);
954 th = elm_widget_theme_get(sobj);
955 mirrored = elm_widget_mirrored_get(sobj);
956 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
957 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
961 elm_widget_sub_object_del(Evas_Object *obj,
964 Evas_Object *sobj_parent;
968 sobj_parent = evas_object_data_del(sobj, "elm-parent");
969 if (sobj_parent != obj)
971 static int abort_on_warn = -1;
972 ERR("removing sub object %p from parent %p, "
973 "but elm-parent is different %p!",
974 sobj, obj, sobj_parent);
975 if (EINA_UNLIKELY(abort_on_warn == -1))
977 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
978 else abort_on_warn = 0;
980 if (abort_on_warn == 1) abort();
982 if (_elm_widget_is(sobj))
984 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
987 sd2->parent_obj = NULL;
988 if (sd2->resize_obj == sobj)
989 sd2->resize_obj = NULL;
991 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
994 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
995 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
996 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1000 sd->child_can_focus = EINA_FALSE;
1001 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1003 if (_is_focusable(subobj))
1005 sd->child_can_focus = EINA_TRUE;
1012 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1013 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1015 if (_elm_widget_is(sobj))
1016 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1018 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1022 elm_widget_resize_object_set(Evas_Object *obj,
1026 // orphan previous resize obj
1029 evas_object_clip_unset(sd->resize_obj);
1030 evas_object_data_del(sd->resize_obj, "elm-parent");
1031 if (_elm_widget_is(sd->resize_obj))
1033 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1034 if (sd2) sd2->parent_obj = NULL;
1035 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1038 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1040 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1041 _sub_obj_mouse_down, sd);
1042 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1043 _sub_obj_mouse_move, sd);
1044 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1045 _sub_obj_mouse_up, sd);
1046 evas_object_smart_member_del(sd->resize_obj);
1047 if (_elm_widget_is(sd->resize_obj))
1049 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1052 // orphan new resize obj
1055 evas_object_data_del(sobj, "elm-parent");
1056 if (_elm_widget_is(sobj))
1058 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1059 if (sd2) sd2->parent_obj = NULL;
1060 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1063 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1065 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1066 _sub_obj_mouse_down, sd);
1067 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1068 _sub_obj_mouse_move, sd);
1069 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1070 _sub_obj_mouse_up, sd);
1071 evas_object_smart_member_del(sobj);
1072 if (_elm_widget_is(sobj))
1074 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1077 // set the resize obj up
1078 sd->resize_obj = sobj;
1081 if (_elm_widget_is(sd->resize_obj))
1083 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1086 sd2->parent_obj = obj;
1087 sd2->top_win_focused = sd->top_win_focused;
1089 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1092 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1093 evas_object_smart_member_add(sobj, obj);
1094 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1096 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1097 _sub_obj_mouse_down, sd);
1098 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1099 _sub_obj_mouse_move, sd);
1100 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1101 _sub_obj_mouse_up, sd);
1102 _smart_reconfigure(sd);
1103 evas_object_data_set(sobj, "elm-parent", obj);
1104 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1105 if (_elm_widget_is(sobj))
1107 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;
1218 elm_widget_highlight_ignore_set(Evas_Object *obj,
1222 sd->highlight_ignore = !!ignore;
1226 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1228 API_ENTRY return EINA_FALSE;
1229 return sd->highlight_ignore;
1233 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1234 Eina_Bool highlight)
1237 sd->highlight_in_theme = !!highlight;
1238 /* FIXME: if focused, it should switch from one mode to the other */
1242 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1244 API_ENTRY return EINA_FALSE;
1245 return sd->highlight_in_theme;
1249 elm_widget_focus_get(const Evas_Object *obj)
1251 API_ENTRY return EINA_FALSE;
1256 elm_widget_focused_object_get(const Evas_Object *obj)
1258 const Evas_Object *subobj;
1260 API_ENTRY return NULL;
1262 if (!sd->focused) return NULL;
1263 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1265 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1266 if (fobj) return fobj;
1268 return (Evas_Object *)obj;
1272 elm_widget_top_get(const Evas_Object *obj)
1274 API_ENTRY return NULL;
1275 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1276 return (Evas_Object *)obj;
1280 elm_widget_is(const Evas_Object *obj)
1282 return _elm_widget_is(obj);
1286 elm_widget_parent_widget_get(const Evas_Object *obj)
1288 Evas_Object *parent;
1290 if (_elm_widget_is(obj))
1292 Smart_Data *sd = evas_object_smart_data_get(obj);
1293 if (!sd) return NULL;
1294 parent = sd->parent_obj;
1298 parent = evas_object_data_get(obj, "elm-parent");
1299 if (!parent) parent = evas_object_smart_parent_get(obj);
1304 Evas_Object *elm_parent;
1305 if (_elm_widget_is(parent)) break;
1306 elm_parent = evas_object_data_get(parent, "elm-parent");
1307 if (elm_parent) parent = elm_parent;
1308 else parent = evas_object_smart_parent_get(parent);
1314 elm_widget_event_callback_add(Evas_Object *obj,
1319 EINA_SAFETY_ON_NULL_RETURN(func);
1320 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1323 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1327 elm_widget_event_callback_del(Evas_Object *obj,
1331 API_ENTRY return NULL;
1332 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1334 Elm_Event_Cb_Data *ecd;
1335 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1336 if ((ecd->func == func) && (ecd->data == data))
1339 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1340 return (void *)data;
1346 elm_widget_event_propagate(Evas_Object *obj,
1347 Evas_Callback_Type type,
1349 Evas_Event_Flags *event_flags)
1351 API_ENTRY return EINA_FALSE; //TODO reduce.
1352 if (!_elm_widget_is(obj)) return EINA_FALSE;
1353 Evas_Object *parent = obj;
1354 Elm_Event_Cb_Data *ecd;
1355 Eina_List *l, *l_prev;
1358 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1360 sd = evas_object_smart_data_get(parent);
1361 if ((!sd) || (!_elm_widget_is(obj)))
1362 return EINA_FALSE; //Not Elm Widget
1364 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1367 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1369 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1370 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1373 parent = sd->parent_obj;
1382 * Set custom focus chain.
1384 * This function i set one new and overwrite any previous custom focus chain
1385 * with the list of objects. The previous list will be deleted and this list
1386 * will be managed. After setted, don't modity it.
1388 * @note On focus cycle, only will be evaluated children of this container.
1390 * @param obj The container widget
1391 * @param objs Chain of objects to pass focus
1395 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1399 if (!sd->focus_next_func)
1402 elm_widget_focus_custom_chain_unset(obj);
1407 EINA_LIST_FOREACH(objs, l, o)
1409 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1410 _elm_object_focus_chain_del_cb, sd);
1413 sd->focus_chain = objs;
1419 * Get custom focus chain
1421 * @param obj The container widget
1424 EAPI const Eina_List *
1425 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1427 API_ENTRY return NULL;
1428 return (const Eina_List *)sd->focus_chain;
1434 * Unset custom focus chain
1436 * @param obj The container widget
1440 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1443 Eina_List *l, *l_next;
1446 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1448 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1449 _elm_object_focus_chain_del_cb, sd);
1450 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1457 * Append object to custom focus chain.
1459 * @note If relative_child equal to NULL or not in custom chain, the object
1460 * will be added in end.
1462 * @note On focus cycle, only will be evaluated children of this container.
1464 * @param obj The container widget
1465 * @param child The child to be added in custom chain
1466 * @param relative_child The relative object to position the child
1470 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1472 Evas_Object *relative_child)
1475 EINA_SAFETY_ON_NULL_RETURN(child);
1476 if (!sd->focus_next_func)
1479 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1480 _elm_object_focus_chain_del_cb, sd);
1482 if (!relative_child)
1484 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1488 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1495 * Prepend object to custom focus chain.
1497 * @note If relative_child equal to NULL or not in custom chain, the object
1498 * will be added in begin.
1500 * @note On focus cycle, only will be evaluated children of this container.
1502 * @param obj The container widget
1503 * @param child The child to be added in custom chain
1504 * @param relative_child The relative object to position the child
1508 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1510 Evas_Object *relative_child)
1513 EINA_SAFETY_ON_NULL_RETURN(child);
1514 if (!sd->focus_next_func)
1517 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1518 _elm_object_focus_chain_del_cb, sd);
1520 if (!relative_child)
1522 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1526 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1533 * Give focus to next object in object tree.
1535 * Give focus to next object in focus chain of one object sub-tree.
1536 * If the last object of chain already have focus, the focus will go to the
1537 * first object of chain.
1539 * @param obj The widget root of sub-tree
1540 * @param dir Direction to cycle the focus
1545 elm_widget_focus_cycle(Evas_Object *obj,
1546 Elm_Focus_Direction dir)
1548 Evas_Object *target = NULL;
1549 if (!_elm_widget_is(obj))
1551 elm_widget_focus_next_get(obj, dir, &target);
1553 elm_widget_focus_steal(target);
1559 * Give focus to near object in one direction.
1561 * Give focus to near object in direction of one object.
1562 * If none focusable object in given direction, the focus will not change.
1564 * @param obj The reference widget
1565 * @param x Horizontal component of direction to focus
1566 * @param y Vertical component of direction to focus
1571 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1581 * Get next object in focus chain of object tree.
1583 * Get next object in focus chain of one object sub-tree.
1584 * Return the next object by reference. If don't have any candidate to receive
1585 * focus before chain end, the first candidate will be returned.
1587 * @param obj The widget root of sub-tree
1588 * @param dir Direction os focus chain
1589 * @param next The next object in focus chain
1590 * @return EINA_TRUE if don't need focus chain restart/loop back
1591 * to use 'next' obj.
1596 elm_widget_focus_next_get(const Evas_Object *obj,
1597 Elm_Focus_Direction dir,
1604 API_ENTRY return EINA_FALSE;
1606 /* Ignore if disabled */
1607 if ((!evas_object_visible_get(obj))
1608 || (elm_widget_disabled_get(obj))
1609 || (elm_widget_tree_unfocusable_get(obj)))
1613 if (sd->focus_next_func)
1614 return sd->focus_next_func(obj, dir, next);
1616 if (!elm_widget_can_focus_get(obj))
1620 *next = (Evas_Object *)obj;
1621 return !elm_widget_focus_get(obj);
1627 * Get next object in focus chain of object tree in list.
1629 * Get next object in focus chain of one object sub-tree ordered by one list.
1630 * Return the next object by reference. If don't have any candidate to receive
1631 * focus before list end, the first candidate will be returned.
1633 * @param obj The widget root of sub-tree
1634 * @param dir Direction os focus chain
1635 * @param items list with ordered objects
1636 * @param list_data_get function to get the object from one item of list
1637 * @param next The next object in focus chain
1638 * @return EINA_TRUE if don't need focus chain restart/loop back
1639 * to use 'next' obj.
1644 elm_widget_focus_list_next_get(const Evas_Object *obj,
1645 const Eina_List *items,
1646 void *(*list_data_get)(const Eina_List * list),
1647 Elm_Focus_Direction dir,
1650 Eina_List *(*list_next)(const Eina_List * list);
1656 if (!_elm_widget_is(obj))
1663 if (dir == ELM_FOCUS_PREVIOUS)
1665 items = eina_list_last(items);
1666 list_next = eina_list_prev;
1668 else if (dir == ELM_FOCUS_NEXT)
1669 list_next = eina_list_next;
1673 const Eina_List *l = items;
1675 /* Recovery last focused sub item */
1676 if (elm_widget_focus_get(obj))
1677 for (; l; l = list_next(l))
1679 Evas_Object *cur = list_data_get(l);
1680 if (elm_widget_focus_get(cur)) break;
1683 const Eina_List *start = l;
1684 Evas_Object *to_focus = NULL;
1686 /* Interate sub items */
1687 /* Go to end of list */
1688 for (; l; l = list_next(l))
1690 Evas_Object *tmp = NULL;
1691 Evas_Object *cur = list_data_get(l);
1693 if (elm_widget_parent_get(cur) != obj)
1696 /* Try Focus cycle in subitem */
1697 if (elm_widget_focus_next_get(cur, dir, &tmp))
1702 else if ((tmp) && (!to_focus))
1708 /* Get First possible */
1709 for (; l != start; l = list_next(l))
1711 Evas_Object *tmp = NULL;
1712 Evas_Object *cur = list_data_get(l);
1714 if (elm_widget_parent_get(cur) != obj)
1717 /* Try Focus cycle in subitem */
1718 elm_widget_focus_next_get(cur, dir, &tmp);
1731 elm_widget_signal_emit(Evas_Object *obj,
1732 const char *emission,
1736 if (!sd->signal_func) return;
1737 sd->signal_func(obj, emission, source);
1741 _edje_signal_callback(void *data,
1742 Evas_Object *obj __UNUSED__,
1743 const char *emission,
1746 Edje_Signal_Data *esd = data;
1747 esd->func(esd->data, esd->obj, emission, source);
1751 elm_widget_signal_callback_add(Evas_Object *obj,
1752 const char *emission,
1754 Edje_Signal_Cb func,
1757 Edje_Signal_Data *esd;
1759 if (!sd->callback_add_func) return;
1760 EINA_SAFETY_ON_NULL_RETURN(func);
1762 esd = ELM_NEW(Edje_Signal_Data);
1767 esd->emission = eina_stringshare_add(emission);
1768 esd->source = eina_stringshare_add(source);
1770 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1771 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1775 elm_widget_signal_callback_del(Evas_Object *obj,
1776 const char *emission,
1778 Edje_Signal_Cb func)
1780 Edje_Signal_Data *esd;
1783 API_ENTRY return NULL;
1784 if (!sd->callback_del_func) return NULL;
1786 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1788 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1789 (!strcmp(esd->source, source)))
1791 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1792 eina_stringshare_del(esd->emission);
1793 eina_stringshare_del(esd->source);
1799 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1804 elm_widget_focus_set(Evas_Object *obj,
1811 sd->focus_order = focus_order;
1812 sd->focused = EINA_TRUE;
1813 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1817 sd->focus_func(obj);
1824 if ((_is_focusable(sd->resize_obj)) &&
1825 (!elm_widget_disabled_get(sd->resize_obj)))
1827 elm_widget_focus_set(sd->resize_obj, first);
1833 EINA_LIST_FOREACH(sd->subobjs, l, child)
1835 if ((_is_focusable(child)) &&
1836 (!elm_widget_disabled_get(child)))
1838 elm_widget_focus_set(child, first);
1848 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1850 if ((_is_focusable(child)) &&
1851 (!elm_widget_disabled_get(child)))
1853 elm_widget_focus_set(child, first);
1859 if ((_is_focusable(sd->resize_obj)) &&
1860 (!elm_widget_disabled_get(sd->resize_obj)))
1862 elm_widget_focus_set(sd->resize_obj, first);
1870 elm_widget_parent_get(const Evas_Object *obj)
1872 API_ENTRY return NULL;
1873 return sd->parent_obj;
1877 elm_widget_focused_object_clear(Evas_Object *obj)
1880 if (!sd->focused) return;
1881 if (elm_widget_focus_get(sd->resize_obj))
1882 elm_widget_focused_object_clear(sd->resize_obj);
1887 EINA_LIST_FOREACH(sd->subobjs, l, child)
1889 if (elm_widget_focus_get(child))
1891 elm_widget_focused_object_clear(child);
1896 sd->focused = EINA_FALSE;
1897 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1898 if (sd->focus_func) sd->focus_func(obj);
1902 elm_widget_focus_steal(Evas_Object *obj)
1904 Evas_Object *parent, *o;
1907 if (sd->focused) return;
1908 if (sd->disabled) return;
1909 if (!sd->can_focus) return;
1910 if (sd->tree_unfocusable) return;
1914 o = elm_widget_parent_get(parent);
1916 sd = evas_object_smart_data_get(o);
1917 if (sd->disabled || sd->tree_unfocusable) return;
1918 if (sd->focused) break;
1921 if (!elm_widget_parent_get(parent))
1922 elm_widget_focused_object_clear(parent);
1925 parent = elm_widget_parent_get(parent);
1926 sd = evas_object_smart_data_get(parent);
1927 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1928 elm_widget_focused_object_clear(sd->resize_obj);
1933 EINA_LIST_FOREACH(sd->subobjs, l, child)
1935 if (elm_widget_focus_get(child))
1937 elm_widget_focused_object_clear(child);
1948 elm_widget_focus_restore(Evas_Object *obj)
1950 Evas_Object *newest = NULL;
1951 unsigned int newest_focus_order = 0;
1954 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1957 elm_object_unfocus(newest);
1958 elm_object_focus(newest);
1963 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1969 if (sd->top_win_focused == top_win_focused) return;
1971 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1972 EINA_LIST_FOREACH(sd->subobjs, l, child)
1974 _elm_widget_top_win_focused_set(child, top_win_focused);
1976 sd->top_win_focused = top_win_focused;
1980 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1982 API_ENTRY return EINA_FALSE;
1983 return sd->top_win_focused;
1987 elm_widget_activate(Evas_Object *obj)
1990 elm_widget_change(obj);
1991 if (sd->activate_func) sd->activate_func(obj);
1995 elm_widget_change(Evas_Object *obj)
1998 elm_widget_change(elm_widget_parent_get(obj));
1999 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2003 elm_widget_disabled_set(Evas_Object *obj,
2008 if (sd->disabled == disabled) return;
2009 sd->disabled = !!disabled;
2010 elm_widget_focus_disabled_handle(obj);
2011 if (sd->disable_func) sd->disable_func(obj);
2015 elm_widget_disabled_get(const Evas_Object *obj)
2018 return sd->disabled;
2022 elm_widget_show_region_set(Evas_Object *obj,
2027 Eina_Bool forceshow)
2029 Evas_Object *parent_obj, *child_obj;
2030 Evas_Coord px, py, cx, cy;
2033 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2034 && (w == sd->rw) && (h == sd->rh)) return;
2039 if (sd->on_show_region_func)
2040 sd->on_show_region_func(sd->on_show_region_data, obj);
2044 parent_obj = sd->parent_obj;
2045 child_obj = sd->obj;
2046 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2047 sd = evas_object_smart_data_get(parent_obj);
2050 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2051 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2060 if (sd->on_show_region_func)
2062 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2069 elm_widget_show_region_get(const Evas_Object *obj,
2085 * Get the focus region of the given widget.
2087 * The focus region is the area of a widget that should brought into the
2088 * visible area when the widget is focused. Mostly used to show the part of
2089 * an entry where the cursor is, for example. The area returned is relative
2090 * to the object @p obj.
2091 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2092 * function will return the full size of the object.
2094 * @param obj The widget object
2095 * @param x Where to store the x coordinate of the area
2096 * @param y Where to store the y coordinate of the area
2097 * @param w Where to store the width of the area
2098 * @param h Where to store the height of the area
2103 elm_widget_focus_region_get(const Evas_Object *obj,
2113 sd = evas_object_smart_data_get(obj);
2114 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2116 evas_object_geometry_get(obj, NULL, NULL, w, h);
2121 sd->on_focus_region_func(obj, x, y, w, h);
2125 elm_widget_scroll_hold_push(Evas_Object *obj)
2129 if (sd->scroll_hold == 1)
2130 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2131 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2132 // FIXME: on delete/reparent hold pop
2136 elm_widget_scroll_hold_pop(Evas_Object *obj)
2140 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2141 if (!sd->scroll_hold)
2142 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2143 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2147 elm_widget_scroll_hold_get(const Evas_Object *obj)
2150 return sd->scroll_hold;
2154 elm_widget_scroll_freeze_push(Evas_Object *obj)
2157 sd->scroll_freeze++;
2158 if (sd->scroll_freeze == 1)
2159 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2160 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2161 // FIXME: on delete/reparent freeze pop
2165 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2168 sd->scroll_freeze--;
2169 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2170 if (!sd->scroll_freeze)
2171 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2172 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2176 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2179 return sd->scroll_freeze;
2183 elm_widget_scale_set(Evas_Object *obj,
2187 if (scale <= 0.0) scale = 0.0;
2188 if (sd->scale != scale)
2191 elm_widget_theme(obj);
2196 elm_widget_scale_get(const Evas_Object *obj)
2198 API_ENTRY return 1.0;
2199 // FIXME: save walking up the tree by storing/caching parent scale
2200 if (sd->scale == 0.0)
2203 return elm_widget_scale_get(sd->parent_obj);
2211 elm_widget_theme_set(Evas_Object *obj,
2215 if (sd->theme != th)
2217 if (sd->theme) elm_theme_free(sd->theme);
2220 elm_widget_theme(obj);
2225 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2229 if (!sd->on_text_set_func)
2232 sd->on_text_set_func(obj, item, label);
2236 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2238 API_ENTRY return NULL;
2240 if (!sd->on_text_get_func)
2243 return sd->on_text_get_func(obj, item);
2247 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2251 Elm_Translate_String_Data *ts = NULL;
2254 str = eina_stringshare_add(part);
2255 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2262 eina_stringshare_del(str);
2265 ts = malloc(sizeof(Elm_Translate_String_Data));
2269 ts->domain = eina_stringshare_add(domain);
2270 ts->string = eina_stringshare_add(label);
2271 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2277 eina_stringshare_replace(&ts->domain, domain);
2278 eina_stringshare_replace(&ts->string, label);
2282 sd->translate_strings = eina_list_remove_list(
2283 sd->translate_strings, l);
2284 eina_stringshare_del(ts->id);
2285 eina_stringshare_del(ts->domain);
2286 eina_stringshare_del(ts->string);
2289 eina_stringshare_del(str);
2293 if (label && label[0])
2294 label = dgettext(domain, label);
2296 elm_widget_text_part_set(obj, part, label);
2300 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2302 const char *str, *ret = NULL;
2304 Elm_Translate_String_Data *ts;
2305 API_ENTRY return NULL;
2307 str = eina_stringshare_add(part);
2308 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2314 eina_stringshare_del(str);
2319 elm_widget_translate(Evas_Object *obj)
2323 Elm_Translate_String_Data *ts;
2326 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2327 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2328 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2329 if (sd->translate_func) sd->translate_func(obj);
2332 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2334 const char *s = dgettext(ts->domain, ts->string);
2335 elm_widget_text_part_set(obj, ts->id, s);
2341 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2345 if (!sd->on_content_set_func) return;
2346 sd->on_content_set_func(obj, part, content);
2350 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2352 API_ENTRY return NULL;
2354 if (!sd->on_content_get_func) return NULL;
2355 return sd->on_content_get_func(obj, part);
2359 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2361 API_ENTRY return NULL;
2363 if (!sd->on_content_unset_func) return NULL;
2364 return sd->on_content_unset_func(obj, part);
2368 elm_widget_theme_get(const Evas_Object *obj)
2370 API_ENTRY return NULL;
2374 return elm_widget_theme_get(sd->parent_obj);
2382 elm_widget_style_set(Evas_Object *obj,
2387 if (eina_stringshare_replace(&sd->style, style))
2388 elm_widget_theme(obj);
2392 elm_widget_style_get(const Evas_Object *obj)
2394 API_ENTRY return NULL;
2395 if (sd->style) return sd->style;
2400 elm_widget_type_set(Evas_Object *obj,
2404 eina_stringshare_replace(&sd->type, type);
2408 elm_widget_type_get(const Evas_Object *obj)
2410 API_ENTRY return NULL;
2411 if (sd->type) return sd->type;
2416 elm_widget_tooltip_add(Evas_Object *obj,
2420 sd->tooltips = eina_list_append(sd->tooltips, tt);
2424 elm_widget_tooltip_del(Evas_Object *obj,
2428 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2432 elm_widget_cursor_add(Evas_Object *obj,
2436 sd->cursors = eina_list_append(sd->cursors, cur);
2440 elm_widget_cursor_del(Evas_Object *obj,
2444 sd->cursors = eina_list_remove(sd->cursors, cur);
2448 elm_widget_drag_lock_x_set(Evas_Object *obj,
2452 if (sd->drag_x_locked == lock) return;
2453 sd->drag_x_locked = lock;
2454 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2455 else _propagate_x_drag_lock(obj, -1);
2459 elm_widget_drag_lock_y_set(Evas_Object *obj,
2463 if (sd->drag_y_locked == lock) return;
2464 sd->drag_y_locked = lock;
2465 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2466 else _propagate_y_drag_lock(obj, -1);
2470 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2472 API_ENTRY return EINA_FALSE;
2473 return sd->drag_x_locked;
2477 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2479 API_ENTRY return EINA_FALSE;
2480 return sd->drag_y_locked;
2484 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2487 return sd->child_drag_x_locked;
2491 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2494 return sd->child_drag_y_locked;
2498 elm_widget_theme_object_set(Evas_Object *obj,
2501 const char *welement,
2504 API_ENTRY return EINA_FALSE;
2505 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2509 elm_widget_type_check(const Evas_Object *obj,
2512 const char *provided, *expected = "(unknown)";
2513 static int abort_on_warn = -1;
2514 provided = elm_widget_type_get(obj);
2515 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2516 if (type) expected = type;
2517 if ((!provided) || (!provided[0]))
2519 provided = evas_object_type_get(obj);
2520 if ((!provided) || (!provided[0]))
2521 provided = "(unknown)";
2523 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2524 if (abort_on_warn == -1)
2526 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2527 else abort_on_warn = 0;
2529 if (abort_on_warn == 1) abort();
2536 * Split string in words
2538 * @param str Source string
2539 * @return List of const words
2541 * @see elm_widget_stringlist_free()
2545 elm_widget_stringlist_get(const char *str)
2547 Eina_List *list = NULL;
2549 if (!str) return NULL;
2550 for (b = s = str; 1; s++)
2552 if ((*s == ' ') || (!*s))
2554 char *t = malloc(s - b + 1);
2557 strncpy(t, b, s - b);
2559 list = eina_list_append(list, eina_stringshare_add(t));
2570 elm_widget_stringlist_free(Eina_List *list)
2573 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2577 elm_widget_focus_hide_handle(Evas_Object *obj)
2579 _if_focused_revert(obj, EINA_TRUE);
2583 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2585 Evas_Object *o = obj;
2588 if (_elm_widget_is(o)) break;
2589 o = evas_object_smart_parent_get(o);
2593 if (!_is_focusable(o)) return;
2594 elm_widget_focus_steal(o);
2598 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2602 if (!elm_widget_parent_get(obj))
2603 elm_widget_focused_object_clear(obj);
2605 _if_focused_revert(obj, EINA_TRUE);
2609 elm_widget_focus_disabled_handle(Evas_Object *obj)
2613 elm_widget_focus_tree_unfocusable_handle(obj);
2619 * Allocate a new Elm_Widget_Item-derived structure.
2621 * The goal of this structure is to provide common ground for actions
2622 * that a widget item have, such as the owner widget, callback to
2623 * notify deletion, data pointer and maybe more.
2625 * @param widget the owner widget that holds this item, must be an elm_widget!
2626 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2627 * be used to allocate memory.
2629 * @return allocated memory that is already zeroed out, or NULL on errors.
2631 * @see elm_widget_item_new() convenience macro.
2632 * @see elm_widget_item_del() to release memory.
2635 EAPI Elm_Widget_Item *
2636 _elm_widget_item_new(Evas_Object *widget,
2639 if (!_elm_widget_is(widget))
2642 Elm_Widget_Item *item;
2644 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2645 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2647 item = calloc(1, alloc_size);
2648 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2650 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2651 item->widget = widget;
2658 * Releases widget item memory, calling back del_cb() if it exists.
2660 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2661 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2662 * this function and then unset it, thus being useful for 2 step
2663 * cleanup whenever the del_cb may use any of the data that must be
2664 * deleted from item.
2666 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2669 * @param item a valid #Elm_Widget_Item to be deleted.
2670 * @see elm_widget_item_del() convenience macro.
2674 _elm_widget_item_del(Elm_Widget_Item *item)
2676 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2679 item->del_cb((void *)item->data, item->widget, item);
2682 evas_object_del(item->view);
2684 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2691 * Notify object will be deleted without actually deleting it.
2693 * This function will callback Elm_Widget_Item::del_cb if it is set
2694 * and then unset it so it is not called twice (ie: from
2695 * elm_widget_item_del()).
2697 * @param item a valid #Elm_Widget_Item to be notified
2698 * @see elm_widget_item_pre_notify_del() convenience macro.
2702 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2704 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2705 if (!item->del_cb) return;
2706 item->del_cb((void *)item->data, item->widget, item);
2707 item->del_cb = NULL;
2713 * Set the function to notify when item is being deleted.
2715 * This function will complain if there was a callback set already,
2716 * however it will set the new one.
2718 * The callback will be called from elm_widget_item_pre_notify_del()
2719 * or elm_widget_item_del() will be called with:
2720 * - data: the Elm_Widget_Item::data value.
2721 * - obj: the Elm_Widget_Item::widget evas object.
2722 * - event_info: the item being deleted.
2724 * @param item a valid #Elm_Widget_Item to be notified
2725 * @see elm_widget_item_del_cb_set() convenience macro.
2729 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2730 Evas_Smart_Cb del_cb)
2732 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2734 if ((item->del_cb) && (item->del_cb != del_cb))
2735 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2736 item->del_cb, item, del_cb);
2738 item->del_cb = del_cb;
2744 * Set user-data in this item.
2746 * User data may be used to identify this item or just store any
2747 * application data. It is automatically given as the first parameter
2748 * of the deletion notify callback.
2750 * @param item a valid #Elm_Widget_Item to store data in.
2751 * @param data user data to store.
2752 * @see elm_widget_item_del_cb_set() convenience macro.
2756 _elm_widget_item_data_set(Elm_Widget_Item *item,
2759 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2760 if ((item->data) && (item->data != data))
2761 DBG("Replacing item %p data %p with %p", item, item->data, data);
2768 * Retrieves user-data of this item.
2770 * @param item a valid #Elm_Widget_Item to get data from.
2771 * @see elm_widget_item_data_set()
2775 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2777 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2778 return (void *)item->data;
2781 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2783 struct _Elm_Widget_Item_Tooltip
2785 Elm_Widget_Item *item;
2786 Elm_Tooltip_Item_Content_Cb func;
2787 Evas_Smart_Cb del_cb;
2791 static Evas_Object *
2792 _elm_widget_item_tooltip_label_create(void *data,
2794 void *item __UNUSED__)
2796 Evas_Object *label = elm_label_add(obj);
2799 elm_object_style_set(label, "tooltip");
2800 elm_object_text_set(label, data);
2804 static Evas_Object *
2805 _elm_widget_item_tooltip_trans_label_create(void *data,
2806 Evas_Object *obj __UNUSED__,
2807 Evas_Object *tooltip,
2808 void *item __UNUSED__)
2810 Evas_Object *label = elm_label_add(tooltip);
2813 elm_object_style_set(label, "tooltip");
2814 elm_object_translatable_text_set(label, data);
2819 _elm_widget_item_tooltip_label_del_cb(void *data,
2820 Evas_Object *obj __UNUSED__,
2821 void *event_info __UNUSED__)
2823 eina_stringshare_del(data);
2829 * Set the text to be shown in the widget item.
2831 * @param item Target item
2832 * @param text The text to set in the content
2834 * Setup the text as tooltip to object. The item can have only one tooltip,
2835 * so any previous tooltip data is removed.
2840 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2843 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2844 EINA_SAFETY_ON_NULL_RETURN(text);
2846 text = eina_stringshare_add(text);
2847 _elm_widget_item_tooltip_content_cb_set
2848 (item, _elm_widget_item_tooltip_label_create, text,
2849 _elm_widget_item_tooltip_label_del_cb);
2853 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2856 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2857 EINA_SAFETY_ON_NULL_RETURN(text);
2859 text = eina_stringshare_add(text);
2860 _elm_widget_item_tooltip_content_cb_set
2861 (item, _elm_widget_item_tooltip_trans_label_create, text,
2862 _elm_widget_item_tooltip_label_del_cb);
2865 static Evas_Object *
2866 _elm_widget_item_tooltip_create(void *data,
2869 Elm_Widget_Item_Tooltip *wit = data;
2870 return wit->func((void *)wit->data, obj, wit->item);
2874 _elm_widget_item_tooltip_del_cb(void *data,
2876 void *event_info __UNUSED__)
2878 Elm_Widget_Item_Tooltip *wit = data;
2879 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2886 * Set the content to be shown in the tooltip item
2888 * Setup the tooltip to item. The item can have only one tooltip,
2889 * so any previous tooltip data is removed. @p func(with @p data) will
2890 * be called every time that need show the tooltip and it should
2891 * return a valid Evas_Object. This object is then managed fully by
2892 * tooltip system and is deleted when the tooltip is gone.
2894 * @param item the widget item being attached a tooltip.
2895 * @param func the function used to create the tooltip contents.
2896 * @param data what to provide to @a func as callback data/context.
2897 * @param del_cb called when data is not needed anymore, either when
2898 * another callback replaces @func, the tooltip is unset with
2899 * elm_widget_item_tooltip_unset() or the owner @a item
2900 * dies. This callback receives as the first parameter the
2901 * given @a data, and @c event_info is the item.
2906 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2907 Elm_Tooltip_Item_Content_Cb func,
2909 Evas_Smart_Cb del_cb)
2911 Elm_Widget_Item_Tooltip *wit;
2913 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2917 _elm_widget_item_tooltip_unset(item);
2921 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2922 if (!wit) goto error;
2926 wit->del_cb = del_cb;
2928 elm_object_sub_tooltip_content_cb_set
2929 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2930 _elm_widget_item_tooltip_del_cb);
2935 if (del_cb) del_cb((void *)data, NULL, item);
2938 if (del_cb) del_cb((void *)data, item->widget, item);
2944 * Unset tooltip from item
2946 * @param item widget item to remove previously set tooltip.
2948 * Remove tooltip from item. The callback provided as del_cb to
2949 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2950 * it is not used anymore.
2952 * @see elm_widget_item_tooltip_content_cb_set()
2957 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2959 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2960 elm_object_tooltip_unset(item->view);
2966 * Sets a different style for this item tooltip.
2968 * @note before you set a style you should define a tooltip with
2969 * elm_widget_item_tooltip_content_cb_set() or
2970 * elm_widget_item_tooltip_text_set()
2972 * @param item widget item with tooltip already set.
2973 * @param style the theme style to use (default, transparent, ...)
2978 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2981 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2982 elm_object_tooltip_style_set(item->view, style);
2988 * Get the style for this item tooltip.
2990 * @param item widget item with tooltip already set.
2991 * @return style the theme style in use, defaults to "default". If the
2992 * object does not have a tooltip set, then NULL is returned.
2997 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2999 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3000 return elm_object_tooltip_style_get(item->view);
3004 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3007 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3008 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3012 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3014 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3015 return elm_object_cursor_get(item->view);
3019 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3021 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3022 elm_object_cursor_unset(item->view);
3028 * Sets a different style for this item cursor.
3030 * @note before you set a style you should define a cursor with
3031 * elm_widget_item_cursor_set()
3033 * @param item widget item with cursor already set.
3034 * @param style the theme style to use (default, transparent, ...)
3039 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3042 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3043 elm_object_cursor_style_set(item->view, style);
3049 * Get the style for this item cursor.
3051 * @param item widget item with cursor already set.
3052 * @return style the theme style in use, defaults to "default". If the
3053 * object does not have a cursor set, then NULL is returned.
3058 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3060 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3061 return elm_object_cursor_style_get(item->view);
3067 * Set if the cursor set should be searched on the theme or should use
3068 * the provided by the engine, only.
3070 * @note before you set if should look on theme you should define a cursor
3071 * with elm_object_cursor_set(). By default it will only look for cursors
3072 * provided by the engine.
3074 * @param item widget item with cursor already set.
3075 * @param engine_only boolean to define it cursors should be looked only
3076 * between the provided by the engine or searched on widget's theme as well.
3081 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3082 Eina_Bool engine_only)
3084 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3085 elm_object_cursor_engine_only_set(item->view, engine_only);
3091 * Get the cursor engine only usage for this item cursor.
3093 * @param item widget item with cursor already set.
3094 * @return engine_only boolean to define it cursors should be looked only
3095 * between the provided by the engine or searched on widget's theme as well. If
3096 * the object does not have a cursor set, then EINA_FALSE is returned.
3101 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3103 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3104 return elm_object_cursor_engine_only_get(item->view);
3107 // smart object funcs
3109 _smart_reconfigure(Smart_Data *sd)
3113 evas_object_move(sd->resize_obj, sd->x, sd->y);
3114 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3118 evas_object_move(sd->hover_obj, sd->x, sd->y);
3119 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3124 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3126 Evas_Object *content)
3128 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3129 if (!item->on_content_set_func) return;
3130 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3134 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3137 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3138 if (!item->on_content_get_func) return NULL;
3139 return item->on_content_get_func((Elm_Object_Item *) item, part);
3143 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3146 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3147 if (!item->on_content_unset_func) return NULL;
3148 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3152 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3156 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3157 if (!item->on_text_set_func) return;
3158 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3162 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3163 const char *emission,
3166 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3167 if (item->on_signal_emit_func)
3168 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3172 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3175 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3176 if (!item->on_text_get_func) return NULL;
3177 return item->on_text_get_func((Elm_Object_Item *) item, part);
3181 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3182 Elm_Widget_On_Content_Set_Cb func)
3184 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3185 item->on_content_set_func = func;
3189 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3190 Elm_Widget_On_Content_Get_Cb func)
3192 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3193 item->on_content_get_func = func;
3197 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3198 Elm_Widget_On_Content_Unset_Cb func)
3200 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3201 item->on_content_unset_func = func;
3205 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3206 Elm_Widget_On_Text_Set_Cb func)
3208 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3209 item->on_text_set_func = func;
3213 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3214 Elm_Widget_On_Text_Get_Cb func)
3216 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3217 item->on_text_get_func = func;
3221 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3222 Elm_Widget_On_Signal_Emit_Cb func)
3224 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3225 item->on_signal_emit_func = func;
3229 _smart_add(Evas_Object *obj)
3233 sd = calloc(1, sizeof(Smart_Data));
3236 sd->x = sd->y = sd->w = sd->h = 0;
3238 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3239 evas_object_smart_data_set(obj, sd);
3242 static Evas_Object *
3243 _newest_focus_order_get(Evas_Object *obj,
3244 unsigned int *newest_focus_order,
3245 Eina_Bool can_focus_only)
3248 Evas_Object *child, *ret, *best;
3250 API_ENTRY return NULL;
3252 if (!evas_object_visible_get(obj)
3253 || (elm_widget_disabled_get(obj))
3254 || (elm_widget_tree_unfocusable_get(obj)))
3258 if (*newest_focus_order < sd->focus_order)
3260 *newest_focus_order = sd->focus_order;
3263 EINA_LIST_FOREACH(sd->subobjs, l, child)
3265 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3271 if ((!best) || (!elm_widget_can_focus_get(best)))
3278 _if_focused_revert(Evas_Object *obj,
3279 Eina_Bool can_focus_only)
3282 Evas_Object *newest = NULL;
3283 unsigned int newest_focus_order = 0;
3287 if (!sd->focused) return;
3288 if (!sd->parent_obj) return;
3290 top = elm_widget_top_get(sd->parent_obj);
3293 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3296 elm_object_focus_set(newest, EINA_FALSE);
3297 elm_object_focus_set(newest, EINA_TRUE);
3303 _smart_del(Evas_Object *obj)
3306 Edje_Signal_Data *esd;
3307 Elm_Translate_String_Data *ts;
3311 if (sd->del_pre_func) sd->del_pre_func(obj);
3314 sobj = sd->resize_obj;
3315 sd->resize_obj = NULL;
3316 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3317 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3318 evas_object_del(sobj);
3322 sobj = sd->hover_obj;
3323 sd->hover_obj = NULL;
3324 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3325 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3326 evas_object_del(sobj);
3328 EINA_LIST_FREE(sd->subobjs, sobj)
3330 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3331 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3332 evas_object_del(sobj);
3334 eina_list_free(sd->tooltips); /* should be empty anyway */
3335 eina_list_free(sd->cursors); /* should be empty anyway */
3336 EINA_LIST_FREE(sd->edje_signals, esd)
3338 eina_stringshare_del(esd->emission);
3339 eina_stringshare_del(esd->source);
3342 EINA_LIST_FREE(sd->translate_strings, ts)
3344 eina_stringshare_del(ts->id);
3345 eina_stringshare_del(ts->domain);
3346 eina_stringshare_del(ts->string);
3349 eina_list_free(sd->event_cb); /* should be empty anyway */
3350 if (sd->del_func) sd->del_func(obj);
3351 if (sd->style) eina_stringshare_del(sd->style);
3352 if (sd->type) eina_stringshare_del(sd->type);
3353 if (sd->theme) elm_theme_free(sd->theme);
3354 _if_focused_revert(obj, EINA_TRUE);
3359 _smart_move(Evas_Object *obj,
3366 _smart_reconfigure(sd);
3370 _smart_resize(Evas_Object *obj,
3377 _smart_reconfigure(sd);
3381 _smart_show(Evas_Object *obj)
3386 if ((list = evas_object_smart_members_get(obj)))
3388 EINA_LIST_FREE(list, o)
3390 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3391 evas_object_show(o);
3397 _smart_hide(Evas_Object *obj)
3403 list = evas_object_smart_members_get(obj);
3404 EINA_LIST_FREE(list, o)
3406 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3407 evas_object_hide(o);
3412 _smart_color_set(Evas_Object *obj,
3421 if ((list = evas_object_smart_members_get(obj)))
3423 EINA_LIST_FREE(list, o)
3425 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3426 evas_object_color_set(o, r, g, b, a);
3432 _smart_clip_set(Evas_Object *obj,
3438 if ((list = evas_object_smart_members_get(obj)))
3440 EINA_LIST_FREE(list, o)
3442 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3443 evas_object_clip_set(o, clip);
3449 _smart_clip_unset(Evas_Object *obj)
3454 if ((list = evas_object_smart_members_get(obj)))
3456 EINA_LIST_FREE(list, o)
3458 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3459 evas_object_clip_unset(o);
3465 _smart_calculate(Evas_Object *obj)
3468 if (sd->changed_func) sd->changed_func(obj);
3471 /* never need to touch this */
3475 if (_e_smart) return;
3477 static const Evas_Smart_Class sc =
3480 EVAS_SMART_CLASS_VERSION,
3498 _e_smart = evas_smart_class_new(&sc);
3502 /* happy debug functions */
3505 _sub_obj_tree_dump(const Evas_Object *obj,
3510 for (i = 0; i < lvl * 3; i++)
3513 if (_elm_widget_is(obj))
3517 printf("+ %s(%p)\n",
3521 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3522 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3524 if (obj != sd->resize_obj)
3525 _sub_obj_tree_dump(obj, lvl + 1);
3529 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3533 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3536 if (!_elm_widget_is(obj))
3540 Eina_Bool visible = evas_object_visible_get(obj);
3541 Eina_Bool disabled = elm_widget_disabled_get(obj);
3542 Eina_Bool focused = elm_widget_focus_get(obj);
3543 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3547 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3550 fprintf(output, ", style=bold");
3553 fprintf(output, ", color=gray28");
3555 fprintf(output, " ];\n");
3558 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3559 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3560 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3564 fprintf(output, ", style=bold");
3567 fprintf(output, ", fontcolor=gray28");
3569 if ((disabled) || (!visible))
3570 fprintf(output, ", color=gray");
3572 fprintf(output, " ];\n");
3576 EINA_LIST_FOREACH(sd->subobjs, l, o)
3577 _sub_obj_tree_dot_dump(o, output);
3582 elm_widget_tree_dump(const Evas_Object *top)
3585 _sub_obj_tree_dump(top, 0);
3593 elm_widget_tree_dot_dump(const Evas_Object *top,
3597 if (!_elm_widget_is(top))
3599 fprintf(output, "graph " " { node [shape=record];\n");
3600 _sub_obj_tree_dot_dump(top, output);
3601 fprintf(output, "}\n");