1 #include <Elementary.h>
4 static const char SMART_NAME[] = "elm_widget";
7 Smart_Data * sd = evas_object_smart_data_get(obj); \
8 if ((!obj) || (!sd) || (!_elm_widget_is(obj)))
9 #define INTERNAL_ENTRY \
10 Smart_Data * sd = evas_object_smart_data_get(obj); \
13 #undef elm_widget_text_set_hook_set
14 #undef elm_widget_text_get_hook_set
15 #undef elm_widget_content_set_hook_set
16 #undef elm_widget_content_get_hook_set
17 #undef elm_widget_content_unset_hook_set
19 typedef struct _Smart_Data Smart_Data;
20 typedef struct _Edje_Signal_Data Edje_Signal_Data;
21 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
22 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
28 Evas_Object *parent_obj;
29 Evas_Coord x, y, w, h;
31 Evas_Object *resize_obj;
32 Evas_Object *hover_obj;
33 Eina_List *tooltips, *cursors;
34 void (*del_func)(Evas_Object *obj);
35 void (*del_pre_func)(Evas_Object *obj);
36 void (*focus_func)(Evas_Object *obj);
37 void (*activate_func)(Evas_Object *obj);
38 void (*disable_func)(Evas_Object *obj);
39 void (*theme_func)(Evas_Object *obj);
40 void (*translate_func)(Evas_Object *obj);
41 Eina_Bool (*event_func)(Evas_Object *obj,
43 Evas_Callback_Type type,
45 void (*signal_func)(Evas_Object *obj,
48 void (*callback_add_func)(Evas_Object *obj,
53 void (*callback_del_func)(Evas_Object *obj,
58 void (*changed_func)(Evas_Object *obj);
59 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
60 Elm_Focus_Direction dir,
62 void (*on_focus_func)(void *data,
65 void (*on_change_func)(void *data,
68 void (*on_show_region_func)(void *data,
70 void *on_show_region_data;
71 void (*focus_region_func)(Evas_Object *obj,
76 void (*on_focus_region_func)(const Evas_Object *obj,
81 Elm_Widget_On_Text_Set_Cb on_text_set_func;
82 Elm_Widget_On_Text_Get_Cb on_text_get_func;
83 Elm_Widget_On_Content_Set_Cb on_content_set_func;
84 Elm_Widget_On_Content_Get_Cb on_content_get_func;
85 Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
87 Evas_Coord rx, ry, rw, rh;
93 const char *access_info;
94 unsigned int focus_order;
95 Eina_Bool focus_order_on_calc;
97 int child_drag_x_locked;
98 int child_drag_y_locked;
100 Eina_List *edje_signals;
101 Eina_List *translate_strings;
103 Eina_Bool drag_x_locked : 1;
104 Eina_Bool drag_y_locked : 1;
106 Eina_Bool can_focus : 1;
107 Eina_Bool child_can_focus : 1;
108 Eina_Bool focused : 1;
109 Eina_Bool top_win_focused : 1;
110 Eina_Bool tree_unfocusable : 1;
111 Eina_Bool highlight_ignore : 1;
112 Eina_Bool highlight_in_theme : 1;
113 Eina_Bool disabled : 1;
114 Eina_Bool is_mirrored : 1;
115 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
116 Eina_Bool still_in : 1;
118 Eina_List *focus_chain;
122 struct _Edje_Signal_Data
126 const char *emission;
131 struct _Elm_Event_Cb_Data
137 struct _Elm_Translate_String_Data
144 /* local subsystem functions */
145 static void _smart_reconfigure(Smart_Data *sd);
146 static void _smart_add(Evas_Object *obj);
147 static void _smart_del(Evas_Object *obj);
148 static void _smart_move(Evas_Object *obj,
151 static void _smart_resize(Evas_Object *obj,
154 static void _smart_show(Evas_Object *obj);
155 static void _smart_hide(Evas_Object *obj);
156 static void _smart_color_set(Evas_Object *obj,
161 static void _smart_clip_set(Evas_Object *obj,
163 static void _smart_clip_unset(Evas_Object *obj);
164 static void _smart_calculate(Evas_Object *obj);
165 static void _smart_init(void);
167 static void _if_focused_revert(Evas_Object *obj,
168 Eina_Bool can_focus_only);
169 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
170 unsigned int *newest_focus_order,
171 Eina_Bool can_focus_only);
173 /* local subsystem globals */
174 static Evas_Smart *_e_smart = NULL;
175 static Eina_List *widtypes = NULL;
177 static unsigned int focus_order = 0;
180 static inline Eina_Bool
181 _elm_widget_is(const Evas_Object *obj)
183 const char *type = evas_object_type_get(obj);
184 return type == SMART_NAME;
187 static inline Eina_Bool
188 _is_focusable(Evas_Object *obj)
190 API_ENTRY return EINA_FALSE;
191 return sd->can_focus || (sd->child_can_focus);
195 _unfocus_parents(Evas_Object *obj)
197 for (; obj; obj = elm_widget_parent_get(obj))
200 if (!sd->focused) return;
206 _focus_parents(Evas_Object *obj)
208 for (; obj; obj = elm_widget_parent_get(obj))
211 if (sd->focused) return;
217 _sub_obj_del(void *data,
220 void *event_info __UNUSED__)
222 Smart_Data *sd = data;
224 if (_elm_widget_is(obj))
226 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
228 if (obj == sd->resize_obj)
229 sd->resize_obj = NULL;
230 else if (obj == sd->hover_obj)
231 sd->hover_obj = NULL;
233 sd->subobjs = eina_list_remove(sd->subobjs, obj);
234 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
238 _sub_obj_hide(void *data __UNUSED__,
241 void *event_info __UNUSED__)
243 elm_widget_focus_hide_handle(obj);
247 _sub_obj_mouse_down(void *data,
249 Evas_Object *obj __UNUSED__,
252 Smart_Data *sd = data;
253 Evas_Event_Mouse_Down *ev = event_info;
254 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
255 sd->still_in = EINA_TRUE;
259 _sub_obj_mouse_move(void *data,
264 Smart_Data *sd = data;
265 Evas_Event_Mouse_Move *ev = event_info;
268 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
269 sd->still_in = EINA_FALSE;
272 Evas_Coord x, y, w, h;
273 evas_object_geometry_get(obj, &x, &y, &w, &h);
274 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
275 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
276 sd->still_in = EINA_FALSE;
282 _sub_obj_mouse_up(void *data,
285 void *event_info __UNUSED__)
287 Smart_Data *sd = data;
289 elm_widget_focus_mouse_up_handle(obj);
290 sd->still_in = EINA_FALSE;
294 _propagate_x_drag_lock(Evas_Object *obj,
300 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
303 sd2->child_drag_x_locked += dir;
304 _propagate_x_drag_lock(sd->parent_obj, dir);
310 _propagate_y_drag_lock(Evas_Object *obj,
316 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
319 sd2->child_drag_y_locked += dir;
320 _propagate_y_drag_lock(sd->parent_obj, dir);
326 _propagate_event(void *data,
332 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
333 Evas_Event_Flags *event_flags = NULL;
337 case EVAS_CALLBACK_KEY_DOWN:
339 Evas_Event_Key_Down *ev = event_info;
340 event_flags = &(ev->event_flags);
344 case EVAS_CALLBACK_KEY_UP:
346 Evas_Event_Key_Up *ev = event_info;
347 event_flags = &(ev->event_flags);
351 case EVAS_CALLBACK_MOUSE_WHEEL:
353 Evas_Event_Mouse_Wheel *ev = event_info;
354 event_flags = &(ev->event_flags);
362 elm_widget_event_propagate(obj, type, event_info, event_flags);
366 _parent_focus(Evas_Object *obj)
369 if (sd->focused) return;
371 Evas_Object *o = elm_widget_parent_get(obj);
372 sd->focus_order_on_calc = EINA_TRUE;
374 if (o) _parent_focus(o);
376 if (!sd->focus_order_on_calc)
377 return; /* we don't want to override it if by means of any of the
378 callbacks below one gets to calculate our order
382 sd->focus_order = focus_order;
383 if (sd->top_win_focused)
385 sd->focused = EINA_TRUE;
386 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
387 if (sd->focus_func) sd->focus_func(obj);
388 _elm_widget_focus_region_show(obj);
390 sd->focus_order_on_calc = EINA_FALSE;
394 _elm_object_focus_chain_del_cb(void *data,
397 void *event_info __UNUSED__)
399 Smart_Data *sd = data;
401 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
404 // exposed util funcs to elm
406 _elm_widget_type_clear(void)
410 EINA_LIST_FREE(widtypes, ptr)
412 eina_stringshare_del(*ptr);
418 _elm_widget_focus_region_show(const Evas_Object *obj)
420 Evas_Coord x, y, w, h, ox, oy;
426 o = elm_widget_parent_get(obj);
429 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
430 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
434 sd2 = evas_object_smart_data_get(o);
435 if (sd2->focus_region_func)
437 sd2->focus_region_func(o, x, y, w, h);
438 elm_widget_focus_region_get(o, &x, &y, &w, &h);
442 evas_object_geometry_get(o, &px, &py, NULL, NULL);
448 o = elm_widget_parent_get(o);
453 * @defgroup Widget Widget
456 * Exposed api for making widgets
459 elm_widget_type_register(const char **ptr)
461 widtypes = eina_list_append(widtypes, (void *)ptr);
465 * @defgroup Widget Widget
468 * Disposed api for making widgets
471 elm_widget_type_unregister(const char **ptr)
473 widtypes = eina_list_remove(widtypes, (void *)ptr);
477 elm_widget_api_check(int ver)
479 if (ver != ELM_INTERNAL_API_VERSION)
481 CRITICAL("Elementary widget api versions do not match");
488 elm_widget_add(Evas *evas)
492 obj = evas_object_smart_add(evas, _e_smart);
493 elm_widget_mirrored_set(obj, elm_mirrored_get());
498 elm_widget_del_hook_set(Evas_Object *obj,
499 void (*func)(Evas_Object *obj))
506 elm_widget_del_pre_hook_set(Evas_Object *obj,
507 void (*func)(Evas_Object *obj))
510 sd->del_pre_func = func;
514 elm_widget_focus_hook_set(Evas_Object *obj,
515 void (*func)(Evas_Object *obj))
518 sd->focus_func = func;
522 elm_widget_activate_hook_set(Evas_Object *obj,
523 void (*func)(Evas_Object *obj))
526 sd->activate_func = func;
530 elm_widget_disable_hook_set(Evas_Object *obj,
531 void (*func)(Evas_Object *obj))
534 sd->disable_func = func;
538 elm_widget_theme_hook_set(Evas_Object *obj,
539 void (*func)(Evas_Object *obj))
542 sd->theme_func = func;
546 elm_widget_translate_hook_set(Evas_Object *obj,
547 void (*func)(Evas_Object *obj))
550 sd->translate_func = func;
554 elm_widget_event_hook_set(Evas_Object *obj,
555 Eina_Bool (*func)(Evas_Object *obj,
557 Evas_Callback_Type type,
561 sd->event_func = func;
565 elm_widget_text_set_hook_set(Evas_Object *obj,
566 Elm_Widget_On_Text_Set_Cb func)
569 sd->on_text_set_func = func;
573 elm_widget_text_get_hook_set(Evas_Object *obj,
574 Elm_Widget_On_Text_Get_Cb func)
577 sd->on_text_get_func = func;
581 elm_widget_content_set_hook_set(Evas_Object *obj,
582 Elm_Widget_On_Content_Set_Cb func)
585 sd->on_content_set_func = func;
589 elm_widget_content_get_hook_set(Evas_Object *obj,
590 Elm_Widget_On_Content_Get_Cb func)
593 sd->on_content_get_func = func;
597 elm_widget_content_unset_hook_set(Evas_Object *obj,
598 Elm_Widget_On_Content_Unset_Cb func)
601 sd->on_content_unset_func = func;
605 elm_widget_changed_hook_set(Evas_Object *obj,
606 void (*func)(Evas_Object *obj))
609 sd->changed_func = func;
613 elm_widget_signal_emit_hook_set(Evas_Object *obj,
614 void (*func)(Evas_Object *obj,
615 const char *emission,
619 sd->signal_func = func;
623 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
624 void (*func)(Evas_Object *obj,
625 const char *emission,
627 Edje_Signal_Cb func_cb,
631 sd->callback_add_func = func;
635 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
636 void (*func)(Evas_Object *obj,
637 const char *emission,
639 Edje_Signal_Cb func_cb,
643 sd->callback_del_func = func;
647 elm_widget_theme(Evas_Object *obj)
655 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
656 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
657 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
658 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
659 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
660 if (sd->theme_func) sd->theme_func(obj);
664 elm_widget_theme_specific(Evas_Object *obj,
672 Elm_Theme *th2, *thdef;
675 thdef = elm_theme_default_get();
680 if (!th2) th2 = thdef;
688 if (th2 == thdef) break;
689 th2 = th2->ref_theme;
690 if (!th2) th2 = thdef;
694 EINA_LIST_FOREACH(sd->subobjs, l, child)
695 elm_widget_theme_specific(child, th, force);
696 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
697 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
698 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
699 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
700 if (sd->theme_func) sd->theme_func(obj);
706 * Set hook to get next object in object focus chain.
708 * @param obj The widget object.
709 * @param func The hook to be used with this widget.
714 elm_widget_focus_next_hook_set(Evas_Object *obj,
715 Eina_Bool (*func)(const Evas_Object *obj,
716 Elm_Focus_Direction dir,
720 sd->focus_next_func = func;
724 * Returns the widget's mirrored mode.
726 * @param obj The widget.
727 * @return mirrored mode of the object.
731 elm_widget_mirrored_get(const Evas_Object *obj)
733 API_ENTRY return EINA_FALSE;
734 return sd->is_mirrored;
738 * Sets the widget's mirrored mode.
740 * @param obj The widget.
741 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
744 elm_widget_mirrored_set(Evas_Object *obj,
748 if (sd->is_mirrored != mirrored)
750 sd->is_mirrored = mirrored;
751 elm_widget_theme(obj);
757 * Resets the mirrored mode from the system mirror mode for widgets that are in
758 * automatic mirroring mode. This function does not call elm_widget_theme.
760 * @param obj The widget.
761 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
764 _elm_widget_mirrored_reload(Evas_Object *obj)
767 Eina_Bool mirrored = elm_mirrored_get();
768 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
770 sd->is_mirrored = mirrored;
775 * Returns the widget's mirrored mode setting.
777 * @param obj The widget.
778 * @return mirrored mode setting of the object.
782 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
784 API_ENTRY return EINA_FALSE;
785 return sd->mirrored_auto_mode;
789 * Sets the widget's mirrored mode setting.
790 * When widget in automatic mode, it follows the system mirrored mode set by
791 * elm_mirrored_set().
792 * @param obj The widget.
793 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
796 elm_widget_mirrored_automatic_set(Evas_Object *obj,
800 if (sd->mirrored_auto_mode != automatic)
802 sd->mirrored_auto_mode = automatic;
806 elm_widget_mirrored_set(obj, elm_mirrored_get());
812 elm_widget_on_focus_hook_set(Evas_Object *obj,
813 void (*func)(void *data,
818 sd->on_focus_func = func;
819 sd->on_focus_data = data;
823 elm_widget_on_change_hook_set(Evas_Object *obj,
824 void (*func)(void *data,
829 sd->on_change_func = func;
830 sd->on_change_data = data;
834 elm_widget_on_show_region_hook_set(Evas_Object *obj,
835 void (*func)(void *data,
840 sd->on_show_region_func = func;
841 sd->on_show_region_data = data;
847 * Set the hook to use to show the focused region.
849 * Whenever a new widget gets focused or it's needed to show the focused
850 * area of the current one, this hook will be called on objects that may
851 * want to move their children into their visible area.
852 * The area given in the hook function is relative to the @p obj widget.
854 * @param obj The widget object
855 * @param func The function to call to show the specified area.
860 elm_widget_focus_region_hook_set(Evas_Object *obj,
861 void (*func)(Evas_Object *obj,
868 sd->focus_region_func = func;
874 * Set the hook to retrieve the focused region of a widget.
876 * This hook will be called by elm_widget_focus_region_get() whenever
877 * it's needed to get the focused area of a widget. The area must be relative
878 * to the widget itself and if no hook is set, it will default to the entire
881 * @param obj The widget object
882 * @param func The function used to retrieve the focus region.
887 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
888 void (*func)(const Evas_Object *obj,
895 sd->on_focus_region_func = func;
899 elm_widget_data_set(Evas_Object *obj,
907 elm_widget_data_get(const Evas_Object *obj)
909 API_ENTRY return NULL;
914 elm_widget_sub_object_add(Evas_Object *obj,
918 double scale, pscale = elm_widget_scale_get(sobj);
919 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
920 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
922 if (_elm_widget_is(sobj))
924 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
927 if (sd2->parent_obj == obj)
930 elm_widget_sub_object_del(sd2->parent_obj, sobj);
931 sd2->parent_obj = obj;
932 sd2->top_win_focused = sd->top_win_focused;
933 if (!sd->child_can_focus && (_is_focusable(sobj)))
934 sd->child_can_focus = EINA_TRUE;
939 void *data = evas_object_data_get(sobj, "elm-parent");
942 if (data == obj) return;
943 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
948 sd->subobjs = eina_list_append(sd->subobjs, sobj);
949 evas_object_data_set(sobj, "elm-parent", obj);
950 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
951 if (_elm_widget_is(sobj))
952 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
953 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
954 scale = elm_widget_scale_get(sobj);
955 th = elm_widget_theme_get(sobj);
956 mirrored = elm_widget_mirrored_get(sobj);
957 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
958 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
962 elm_widget_sub_object_del(Evas_Object *obj,
965 Evas_Object *sobj_parent;
969 sobj_parent = evas_object_data_del(sobj, "elm-parent");
970 if (sobj_parent != obj)
972 static int abort_on_warn = -1;
973 ERR("removing sub object %p from parent %p, "
974 "but elm-parent is different %p!",
975 sobj, obj, sobj_parent);
976 if (EINA_UNLIKELY(abort_on_warn == -1))
978 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
979 else abort_on_warn = 0;
981 if (abort_on_warn == 1) abort();
983 if (_elm_widget_is(sobj))
985 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
988 sd2->parent_obj = NULL;
989 if (sd2->resize_obj == sobj)
990 sd2->resize_obj = NULL;
992 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
995 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
996 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
997 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1001 sd->child_can_focus = EINA_FALSE;
1002 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1004 if (_is_focusable(subobj))
1006 sd->child_can_focus = EINA_TRUE;
1013 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1014 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1016 if (_elm_widget_is(sobj))
1017 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1019 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1023 elm_widget_resize_object_set(Evas_Object *obj,
1027 // orphan previous resize obj
1030 evas_object_clip_unset(sd->resize_obj);
1031 evas_object_data_del(sd->resize_obj, "elm-parent");
1032 if (_elm_widget_is(sd->resize_obj))
1034 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1035 if (sd2) sd2->parent_obj = NULL;
1036 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1039 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1041 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1042 _sub_obj_mouse_down, sd);
1043 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1044 _sub_obj_mouse_move, sd);
1045 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1046 _sub_obj_mouse_up, sd);
1047 evas_object_smart_member_del(sd->resize_obj);
1048 if (_elm_widget_is(sd->resize_obj))
1050 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1053 // orphan new resize obj
1056 evas_object_data_del(sobj, "elm-parent");
1057 if (_elm_widget_is(sobj))
1059 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1060 if (sd2) sd2->parent_obj = NULL;
1061 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1064 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1066 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1067 _sub_obj_mouse_down, sd);
1068 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1069 _sub_obj_mouse_move, sd);
1070 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1071 _sub_obj_mouse_up, sd);
1072 evas_object_smart_member_del(sobj);
1073 if (_elm_widget_is(sobj))
1075 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1078 // set the resize obj up
1079 sd->resize_obj = sobj;
1082 if (_elm_widget_is(sd->resize_obj))
1084 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
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);
1114 elm_widget_hover_object_set(Evas_Object *obj,
1120 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1123 sd->hover_obj = sobj;
1126 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1128 _smart_reconfigure(sd);
1133 elm_widget_can_focus_set(Evas_Object *obj,
1134 Eina_Bool can_focus)
1137 sd->can_focus = can_focus;
1140 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1142 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1143 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1145 (void *)(long)EVAS_CALLBACK_KEY_UP);
1146 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1148 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1152 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1154 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1156 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1162 elm_widget_can_focus_get(const Evas_Object *obj)
1164 API_ENTRY return EINA_FALSE;
1165 return sd->can_focus;
1169 elm_widget_child_can_focus_get(const Evas_Object *obj)
1171 API_ENTRY return EINA_FALSE;
1172 return sd->child_can_focus;
1178 * This API makes the widget object and its children to be unfocusable.
1180 * This API can be helpful for an object to be deleted.
1181 * When an object will be deleted soon, it and its children may not
1182 * want to get focus (by focus reverting or by other focus controls).
1183 * Then, just use this API before deleting.
1185 * @param obj The widget root of sub-tree
1186 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1191 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1192 Eina_Bool tree_unfocusable)
1196 if (sd->tree_unfocusable == tree_unfocusable) return;
1197 sd->tree_unfocusable = !!tree_unfocusable;
1198 elm_widget_focus_tree_unfocusable_handle(obj);
1204 * This returns true, if the object sub-tree is unfocusable.
1206 * @param obj The widget root of sub-tree
1207 * @return EINA_TRUE if the object sub-tree is unfocusable
1212 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1214 API_ENTRY return EINA_FALSE;
1215 return sd->tree_unfocusable;
1219 elm_widget_highlight_ignore_set(Evas_Object *obj,
1223 sd->highlight_ignore = !!ignore;
1227 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1229 API_ENTRY return EINA_FALSE;
1230 return sd->highlight_ignore;
1234 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1235 Eina_Bool highlight)
1238 sd->highlight_in_theme = !!highlight;
1239 /* FIXME: if focused, it should switch from one mode to the other */
1243 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1245 API_ENTRY return EINA_FALSE;
1246 return sd->highlight_in_theme;
1250 elm_widget_focus_get(const Evas_Object *obj)
1252 API_ENTRY return EINA_FALSE;
1257 elm_widget_focused_object_get(const Evas_Object *obj)
1259 const Evas_Object *subobj;
1261 API_ENTRY return NULL;
1263 if (!sd->focused) return NULL;
1264 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1266 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1267 if (fobj) return fobj;
1269 return (Evas_Object *)obj;
1273 elm_widget_top_get(const Evas_Object *obj)
1275 API_ENTRY return NULL;
1276 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1277 return (Evas_Object *)obj;
1281 elm_widget_is(const Evas_Object *obj)
1283 return _elm_widget_is(obj);
1287 elm_widget_parent_widget_get(const Evas_Object *obj)
1289 Evas_Object *parent;
1291 if (_elm_widget_is(obj))
1293 Smart_Data *sd = evas_object_smart_data_get(obj);
1294 if (!sd) return NULL;
1295 parent = sd->parent_obj;
1299 parent = evas_object_data_get(obj, "elm-parent");
1300 if (!parent) parent = evas_object_smart_parent_get(obj);
1305 Evas_Object *elm_parent;
1306 if (_elm_widget_is(parent)) break;
1307 elm_parent = evas_object_data_get(parent, "elm-parent");
1308 if (elm_parent) parent = elm_parent;
1309 else parent = evas_object_smart_parent_get(parent);
1315 elm_widget_event_callback_add(Evas_Object *obj,
1320 EINA_SAFETY_ON_NULL_RETURN(func);
1321 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1324 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1328 elm_widget_event_callback_del(Evas_Object *obj,
1332 API_ENTRY return NULL;
1333 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1335 Elm_Event_Cb_Data *ecd;
1336 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1337 if ((ecd->func == func) && (ecd->data == data))
1340 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1341 return (void *)data;
1347 elm_widget_event_propagate(Evas_Object *obj,
1348 Evas_Callback_Type type,
1350 Evas_Event_Flags *event_flags)
1352 API_ENTRY return EINA_FALSE; //TODO reduce.
1353 if (!_elm_widget_is(obj)) return EINA_FALSE;
1354 Evas_Object *parent = obj;
1355 Elm_Event_Cb_Data *ecd;
1356 Eina_List *l, *l_prev;
1359 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1361 sd = evas_object_smart_data_get(parent);
1362 if ((!sd) || (!_elm_widget_is(obj)))
1363 return EINA_FALSE; //Not Elm Widget
1365 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1368 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1370 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1371 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1374 parent = sd->parent_obj;
1383 * Set custom focus chain.
1385 * This function i set one new and overwrite any previous custom focus chain
1386 * with the list of objects. The previous list will be deleted and this list
1387 * will be managed. After setted, don't modity it.
1389 * @note On focus cycle, only will be evaluated children of this container.
1391 * @param obj The container widget
1392 * @param objs Chain of objects to pass focus
1396 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1400 if (!sd->focus_next_func)
1403 elm_widget_focus_custom_chain_unset(obj);
1408 EINA_LIST_FOREACH(objs, l, o)
1410 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1411 _elm_object_focus_chain_del_cb, sd);
1414 sd->focus_chain = objs;
1420 * Get custom focus chain
1422 * @param obj The container widget
1425 EAPI const Eina_List *
1426 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1428 API_ENTRY return NULL;
1429 return (const Eina_List *)sd->focus_chain;
1435 * Unset custom focus chain
1437 * @param obj The container widget
1441 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1444 Eina_List *l, *l_next;
1447 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1449 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1450 _elm_object_focus_chain_del_cb, sd);
1451 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1458 * Append object to custom focus chain.
1460 * @note If relative_child equal to NULL or not in custom chain, the object
1461 * will be added in end.
1463 * @note On focus cycle, only will be evaluated children of this container.
1465 * @param obj The container widget
1466 * @param child The child to be added in custom chain
1467 * @param relative_child The relative object to position the child
1471 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1473 Evas_Object *relative_child)
1476 EINA_SAFETY_ON_NULL_RETURN(child);
1477 if (!sd->focus_next_func)
1480 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1481 _elm_object_focus_chain_del_cb, sd);
1483 if (!relative_child)
1485 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1489 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1496 * Prepend object to custom focus chain.
1498 * @note If relative_child equal to NULL or not in custom chain, the object
1499 * will be added in begin.
1501 * @note On focus cycle, only will be evaluated children of this container.
1503 * @param obj The container widget
1504 * @param child The child to be added in custom chain
1505 * @param relative_child The relative object to position the child
1509 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1511 Evas_Object *relative_child)
1514 EINA_SAFETY_ON_NULL_RETURN(child);
1515 if (!sd->focus_next_func)
1518 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1519 _elm_object_focus_chain_del_cb, sd);
1521 if (!relative_child)
1523 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1527 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1534 * Give focus to next object in object tree.
1536 * Give focus to next object in focus chain of one object sub-tree.
1537 * If the last object of chain already have focus, the focus will go to the
1538 * first object of chain.
1540 * @param obj The widget root of sub-tree
1541 * @param dir Direction to cycle the focus
1546 elm_widget_focus_cycle(Evas_Object *obj,
1547 Elm_Focus_Direction dir)
1549 Evas_Object *target = NULL;
1550 if (!_elm_widget_is(obj))
1552 elm_widget_focus_next_get(obj, dir, &target);
1554 elm_widget_focus_steal(target);
1560 * Give focus to near object in one direction.
1562 * Give focus to near object in direction of one object.
1563 * If none focusable object in given direction, the focus will not change.
1565 * @param obj The reference widget
1566 * @param x Horizontal component of direction to focus
1567 * @param y Vertical component of direction to focus
1572 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1582 * Get next object in focus chain of object tree.
1584 * Get next object in focus chain of one object sub-tree.
1585 * Return the next object by reference. If don't have any candidate to receive
1586 * focus before chain end, the first candidate will be returned.
1588 * @param obj The widget root of sub-tree
1589 * @param dir Direction os focus chain
1590 * @param next The next object in focus chain
1591 * @return EINA_TRUE if don't need focus chain restart/loop back
1592 * to use 'next' obj.
1597 elm_widget_focus_next_get(const Evas_Object *obj,
1598 Elm_Focus_Direction dir,
1605 API_ENTRY return EINA_FALSE;
1607 /* Ignore if disabled */
1608 if ((!evas_object_visible_get(obj))
1609 || (elm_widget_disabled_get(obj))
1610 || (elm_widget_tree_unfocusable_get(obj)))
1614 if (sd->focus_next_func)
1615 return sd->focus_next_func(obj, dir, next);
1617 if (!elm_widget_can_focus_get(obj))
1621 *next = (Evas_Object *)obj;
1622 return !elm_widget_focus_get(obj);
1628 * Get next object in focus chain of object tree in list.
1630 * Get next object in focus chain of one object sub-tree ordered by one list.
1631 * Return the next object by reference. If don't have any candidate to receive
1632 * focus before list end, the first candidate will be returned.
1634 * @param obj The widget root of sub-tree
1635 * @param dir Direction os focus chain
1636 * @param items list with ordered objects
1637 * @param list_data_get function to get the object from one item of list
1638 * @param next The next object in focus chain
1639 * @return EINA_TRUE if don't need focus chain restart/loop back
1640 * to use 'next' obj.
1645 elm_widget_focus_list_next_get(const Evas_Object *obj,
1646 const Eina_List *items,
1647 void *(*list_data_get)(const Eina_List * list),
1648 Elm_Focus_Direction dir,
1651 Eina_List *(*list_next)(const Eina_List * list);
1657 if (!_elm_widget_is(obj))
1664 if (dir == ELM_FOCUS_PREVIOUS)
1666 items = eina_list_last(items);
1667 list_next = eina_list_prev;
1669 else if (dir == ELM_FOCUS_NEXT)
1670 list_next = eina_list_next;
1674 const Eina_List *l = items;
1676 /* Recovery last focused sub item */
1677 if (elm_widget_focus_get(obj))
1678 for (; l; l = list_next(l))
1680 Evas_Object *cur = list_data_get(l);
1681 if (elm_widget_focus_get(cur)) break;
1684 const Eina_List *start = l;
1685 Evas_Object *to_focus = NULL;
1687 /* Interate sub items */
1688 /* Go to end of list */
1689 for (; l; l = list_next(l))
1691 Evas_Object *tmp = NULL;
1692 Evas_Object *cur = list_data_get(l);
1694 if (elm_widget_parent_get(cur) != obj)
1697 /* Try Focus cycle in subitem */
1698 if (elm_widget_focus_next_get(cur, dir, &tmp))
1703 else if ((tmp) && (!to_focus))
1709 /* Get First possible */
1710 for (; l != start; l = list_next(l))
1712 Evas_Object *tmp = NULL;
1713 Evas_Object *cur = list_data_get(l);
1715 if (elm_widget_parent_get(cur) != obj)
1718 /* Try Focus cycle in subitem */
1719 elm_widget_focus_next_get(cur, dir, &tmp);
1732 elm_widget_signal_emit(Evas_Object *obj,
1733 const char *emission,
1737 if (!sd->signal_func) return;
1738 sd->signal_func(obj, emission, source);
1742 _edje_signal_callback(void *data,
1743 Evas_Object *obj __UNUSED__,
1744 const char *emission,
1747 Edje_Signal_Data *esd = data;
1748 esd->func(esd->data, esd->obj, emission, source);
1752 elm_widget_signal_callback_add(Evas_Object *obj,
1753 const char *emission,
1755 Edje_Signal_Cb func,
1758 Edje_Signal_Data *esd;
1760 if (!sd->callback_add_func) return;
1761 EINA_SAFETY_ON_NULL_RETURN(func);
1763 esd = ELM_NEW(Edje_Signal_Data);
1768 esd->emission = eina_stringshare_add(emission);
1769 esd->source = eina_stringshare_add(source);
1771 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1772 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1776 elm_widget_signal_callback_del(Evas_Object *obj,
1777 const char *emission,
1779 Edje_Signal_Cb func)
1781 Edje_Signal_Data *esd;
1784 API_ENTRY return NULL;
1785 if (!sd->callback_del_func) return NULL;
1787 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1789 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1790 (!strcmp(esd->source, source)))
1792 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1793 eina_stringshare_del(esd->emission);
1794 eina_stringshare_del(esd->source);
1800 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1805 elm_widget_focus_set(Evas_Object *obj,
1812 sd->focus_order = focus_order;
1813 sd->focused = EINA_TRUE;
1814 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1818 sd->focus_func(obj);
1825 if ((_is_focusable(sd->resize_obj)) &&
1826 (!elm_widget_disabled_get(sd->resize_obj)))
1828 elm_widget_focus_set(sd->resize_obj, first);
1834 EINA_LIST_FOREACH(sd->subobjs, l, child)
1836 if ((_is_focusable(child)) &&
1837 (!elm_widget_disabled_get(child)))
1839 elm_widget_focus_set(child, first);
1849 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1851 if ((_is_focusable(child)) &&
1852 (!elm_widget_disabled_get(child)))
1854 elm_widget_focus_set(child, first);
1860 if ((_is_focusable(sd->resize_obj)) &&
1861 (!elm_widget_disabled_get(sd->resize_obj)))
1863 elm_widget_focus_set(sd->resize_obj, first);
1871 elm_widget_parent_get(const Evas_Object *obj)
1873 API_ENTRY return NULL;
1874 return sd->parent_obj;
1878 elm_widget_focused_object_clear(Evas_Object *obj)
1881 if (!sd->focused) return;
1882 if (elm_widget_focus_get(sd->resize_obj))
1883 elm_widget_focused_object_clear(sd->resize_obj);
1888 EINA_LIST_FOREACH(sd->subobjs, l, child)
1890 if (elm_widget_focus_get(child))
1892 elm_widget_focused_object_clear(child);
1897 sd->focused = EINA_FALSE;
1898 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1899 if (sd->focus_func) sd->focus_func(obj);
1903 elm_widget_focus_steal(Evas_Object *obj)
1905 Evas_Object *parent, *o;
1908 if (sd->focused) return;
1909 if (sd->disabled) return;
1910 if (!sd->can_focus) return;
1911 if (sd->tree_unfocusable) return;
1915 o = elm_widget_parent_get(parent);
1917 sd = evas_object_smart_data_get(o);
1918 if (sd->disabled || sd->tree_unfocusable) return;
1919 if (sd->focused) break;
1922 if (!elm_widget_parent_get(parent))
1923 elm_widget_focused_object_clear(parent);
1926 parent = elm_widget_parent_get(parent);
1927 sd = evas_object_smart_data_get(parent);
1928 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1929 elm_widget_focused_object_clear(sd->resize_obj);
1934 EINA_LIST_FOREACH(sd->subobjs, l, child)
1936 if (elm_widget_focus_get(child))
1938 elm_widget_focused_object_clear(child);
1949 elm_widget_focus_restore(Evas_Object *obj)
1951 Evas_Object *newest = NULL;
1952 unsigned int newest_focus_order = 0;
1955 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1958 elm_object_unfocus(newest);
1959 elm_object_focus(newest);
1964 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1970 if (sd->top_win_focused == top_win_focused) return;
1972 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1973 EINA_LIST_FOREACH(sd->subobjs, l, child)
1975 _elm_widget_top_win_focused_set(child, top_win_focused);
1977 sd->top_win_focused = top_win_focused;
1981 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1983 API_ENTRY return EINA_FALSE;
1984 return sd->top_win_focused;
1988 elm_widget_activate(Evas_Object *obj)
1991 elm_widget_change(obj);
1992 if (sd->activate_func) sd->activate_func(obj);
1996 elm_widget_change(Evas_Object *obj)
1999 elm_widget_change(elm_widget_parent_get(obj));
2000 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
2004 elm_widget_disabled_set(Evas_Object *obj,
2009 if (sd->disabled == disabled) return;
2010 sd->disabled = !!disabled;
2011 elm_widget_focus_disabled_handle(obj);
2012 if (sd->disable_func) sd->disable_func(obj);
2016 elm_widget_disabled_get(const Evas_Object *obj)
2019 return sd->disabled;
2023 elm_widget_show_region_set(Evas_Object *obj,
2028 Eina_Bool forceshow)
2030 Evas_Object *parent_obj, *child_obj;
2031 Evas_Coord px, py, cx, cy;
2034 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2035 && (w == sd->rw) && (h == sd->rh)) return;
2040 if (sd->on_show_region_func)
2041 sd->on_show_region_func(sd->on_show_region_data, obj);
2045 parent_obj = sd->parent_obj;
2046 child_obj = sd->obj;
2047 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2048 sd = evas_object_smart_data_get(parent_obj);
2051 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2052 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2061 if (sd->on_show_region_func)
2063 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2070 elm_widget_show_region_get(const Evas_Object *obj,
2086 * Get the focus region of the given widget.
2088 * The focus region is the area of a widget that should brought into the
2089 * visible area when the widget is focused. Mostly used to show the part of
2090 * an entry where the cursor is, for example. The area returned is relative
2091 * to the object @p obj.
2092 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2093 * function will return the full size of the object.
2095 * @param obj The widget object
2096 * @param x Where to store the x coordinate of the area
2097 * @param y Where to store the y coordinate of the area
2098 * @param w Where to store the width of the area
2099 * @param h Where to store the height of the area
2104 elm_widget_focus_region_get(const Evas_Object *obj,
2114 sd = evas_object_smart_data_get(obj);
2115 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2117 evas_object_geometry_get(obj, NULL, NULL, w, h);
2122 sd->on_focus_region_func(obj, x, y, w, h);
2126 elm_widget_scroll_hold_push(Evas_Object *obj)
2130 if (sd->scroll_hold == 1)
2131 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2132 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2133 // FIXME: on delete/reparent hold pop
2137 elm_widget_scroll_hold_pop(Evas_Object *obj)
2141 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2142 if (!sd->scroll_hold)
2143 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2144 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2148 elm_widget_scroll_hold_get(const Evas_Object *obj)
2151 return sd->scroll_hold;
2155 elm_widget_scroll_freeze_push(Evas_Object *obj)
2158 sd->scroll_freeze++;
2159 if (sd->scroll_freeze == 1)
2160 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2161 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2162 // FIXME: on delete/reparent freeze pop
2166 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2169 sd->scroll_freeze--;
2170 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2171 if (!sd->scroll_freeze)
2172 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2173 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2177 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2180 return sd->scroll_freeze;
2184 elm_widget_scale_set(Evas_Object *obj,
2188 if (scale <= 0.0) scale = 0.0;
2189 if (sd->scale != scale)
2192 elm_widget_theme(obj);
2197 elm_widget_scale_get(const Evas_Object *obj)
2199 API_ENTRY return 1.0;
2200 // FIXME: save walking up the tree by storing/caching parent scale
2201 if (sd->scale == 0.0)
2204 return elm_widget_scale_get(sd->parent_obj);
2212 elm_widget_theme_set(Evas_Object *obj,
2216 if (sd->theme != th)
2218 if (sd->theme) elm_theme_free(sd->theme);
2221 elm_widget_theme(obj);
2226 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2230 if (!sd->on_text_set_func)
2233 sd->on_text_set_func(obj, item, label);
2237 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2239 API_ENTRY return NULL;
2241 if (!sd->on_text_get_func)
2244 return sd->on_text_get_func(obj, item);
2248 elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *label)
2252 Elm_Translate_String_Data *ts = NULL;
2255 str = eina_stringshare_add(part);
2256 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2263 eina_stringshare_del(str);
2266 ts = malloc(sizeof(Elm_Translate_String_Data));
2270 ts->domain = eina_stringshare_add(domain);
2271 ts->string = eina_stringshare_add(label);
2272 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
2278 eina_stringshare_replace(&ts->domain, domain);
2279 eina_stringshare_replace(&ts->string, label);
2283 sd->translate_strings = eina_list_remove_list(
2284 sd->translate_strings, l);
2285 eina_stringshare_del(ts->id);
2286 eina_stringshare_del(ts->domain);
2287 eina_stringshare_del(ts->string);
2290 eina_stringshare_del(str);
2294 if (label && label[0])
2295 label = dgettext(domain, label);
2297 elm_widget_text_part_set(obj, part, label);
2301 elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part)
2303 const char *str, *ret = NULL;
2305 Elm_Translate_String_Data *ts;
2306 API_ENTRY return NULL;
2308 str = eina_stringshare_add(part);
2309 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2315 eina_stringshare_del(str);
2320 elm_widget_translate(Evas_Object *obj)
2324 Elm_Translate_String_Data *ts;
2327 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_translate(child);
2328 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
2329 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
2330 if (sd->translate_func) sd->translate_func(obj);
2333 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
2335 const char *s = dgettext(ts->domain, ts->string);
2336 elm_widget_text_part_set(obj, ts->id, s);
2342 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2346 if (!sd->on_content_set_func) return;
2347 sd->on_content_set_func(obj, part, content);
2351 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2353 API_ENTRY return NULL;
2355 if (!sd->on_content_get_func) return NULL;
2356 return sd->on_content_get_func(obj, part);
2360 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2362 API_ENTRY return NULL;
2364 if (!sd->on_content_unset_func) return NULL;
2365 return sd->on_content_unset_func(obj, part);
2369 elm_widget_access_info_set(Evas_Object *obj, const char *txt)
2372 if (sd->access_info) eina_stringshare_del(sd->access_info);
2373 if (!txt) sd->access_info = NULL;
2374 else sd->access_info = eina_stringshare_add(txt);
2378 elm_widget_access_info_get(Evas_Object *obj)
2380 API_ENTRY return NULL;
2381 return sd->access_info;
2386 elm_widget_theme_get(const Evas_Object *obj)
2388 API_ENTRY return NULL;
2392 return elm_widget_theme_get(sd->parent_obj);
2400 elm_widget_style_set(Evas_Object *obj,
2405 if (eina_stringshare_replace(&sd->style, style))
2406 elm_widget_theme(obj);
2410 elm_widget_style_get(const Evas_Object *obj)
2412 API_ENTRY return NULL;
2413 if (sd->style) return sd->style;
2418 elm_widget_type_set(Evas_Object *obj,
2422 eina_stringshare_replace(&sd->type, type);
2426 elm_widget_type_get(const Evas_Object *obj)
2428 API_ENTRY return NULL;
2429 if (sd->type) return sd->type;
2434 elm_widget_tooltip_add(Evas_Object *obj,
2438 sd->tooltips = eina_list_append(sd->tooltips, tt);
2442 elm_widget_tooltip_del(Evas_Object *obj,
2446 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2450 elm_widget_cursor_add(Evas_Object *obj,
2454 sd->cursors = eina_list_append(sd->cursors, cur);
2458 elm_widget_cursor_del(Evas_Object *obj,
2462 sd->cursors = eina_list_remove(sd->cursors, cur);
2466 elm_widget_drag_lock_x_set(Evas_Object *obj,
2470 if (sd->drag_x_locked == lock) return;
2471 sd->drag_x_locked = lock;
2472 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2473 else _propagate_x_drag_lock(obj, -1);
2477 elm_widget_drag_lock_y_set(Evas_Object *obj,
2481 if (sd->drag_y_locked == lock) return;
2482 sd->drag_y_locked = lock;
2483 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2484 else _propagate_y_drag_lock(obj, -1);
2488 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2490 API_ENTRY return EINA_FALSE;
2491 return sd->drag_x_locked;
2495 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2497 API_ENTRY return EINA_FALSE;
2498 return sd->drag_y_locked;
2502 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2505 return sd->child_drag_x_locked;
2509 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2512 return sd->child_drag_y_locked;
2516 elm_widget_theme_object_set(Evas_Object *obj,
2519 const char *welement,
2522 API_ENTRY return EINA_FALSE;
2523 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2527 elm_widget_type_check(const Evas_Object *obj,
2530 const char *provided, *expected = "(unknown)";
2531 static int abort_on_warn = -1;
2532 provided = elm_widget_type_get(obj);
2533 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2534 if (type) expected = type;
2535 if ((!provided) || (!provided[0]))
2537 provided = evas_object_type_get(obj);
2538 if ((!provided) || (!provided[0]))
2539 provided = "(unknown)";
2541 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2542 if (abort_on_warn == -1)
2544 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2545 else abort_on_warn = 0;
2547 if (abort_on_warn == 1) abort();
2554 * Split string in words
2556 * @param str Source string
2557 * @return List of const words
2559 * @see elm_widget_stringlist_free()
2563 elm_widget_stringlist_get(const char *str)
2565 Eina_List *list = NULL;
2567 if (!str) return NULL;
2568 for (b = s = str; 1; s++)
2570 if ((*s == ' ') || (!*s))
2572 char *t = malloc(s - b + 1);
2575 strncpy(t, b, s - b);
2577 list = eina_list_append(list, eina_stringshare_add(t));
2588 elm_widget_stringlist_free(Eina_List *list)
2591 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2595 elm_widget_focus_hide_handle(Evas_Object *obj)
2597 _if_focused_revert(obj, EINA_TRUE);
2601 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2603 Evas_Object *o = obj;
2606 if (_elm_widget_is(o)) break;
2607 o = evas_object_smart_parent_get(o);
2611 if (!_is_focusable(o)) return;
2612 elm_widget_focus_steal(o);
2616 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2620 if (!elm_widget_parent_get(obj))
2621 elm_widget_focused_object_clear(obj);
2623 _if_focused_revert(obj, EINA_TRUE);
2627 elm_widget_focus_disabled_handle(Evas_Object *obj)
2631 elm_widget_focus_tree_unfocusable_handle(obj);
2637 * Allocate a new Elm_Widget_Item-derived structure.
2639 * The goal of this structure is to provide common ground for actions
2640 * that a widget item have, such as the owner widget, callback to
2641 * notify deletion, data pointer and maybe more.
2643 * @param widget the owner widget that holds this item, must be an elm_widget!
2644 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2645 * be used to allocate memory.
2647 * @return allocated memory that is already zeroed out, or NULL on errors.
2649 * @see elm_widget_item_new() convenience macro.
2650 * @see elm_widget_item_del() to release memory.
2653 EAPI Elm_Widget_Item *
2654 _elm_widget_item_new(Evas_Object *widget,
2657 if (!_elm_widget_is(widget))
2660 Elm_Widget_Item *item;
2662 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2663 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2665 item = calloc(1, alloc_size);
2666 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2668 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2669 item->widget = widget;
2676 * Releases widget item memory, calling back del_cb() if it exists.
2678 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2679 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2680 * this function and then unset it, thus being useful for 2 step
2681 * cleanup whenever the del_cb may use any of the data that must be
2682 * deleted from item.
2684 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2687 * @param item a valid #Elm_Widget_Item to be deleted.
2688 * @see elm_widget_item_del() convenience macro.
2692 _elm_widget_item_del(Elm_Widget_Item *item)
2694 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2697 item->del_cb((void *)item->data, item->widget, item);
2700 evas_object_del(item->view);
2704 _elm_access_clear(item->access);
2706 item->access = NULL;
2708 if (item->access_info)
2710 eina_stringshare_del(item->access_info);
2711 item->access_info = NULL;
2716 _elm_access_clear(item->access);
2718 item->access = NULL;
2720 if (item->access_info)
2722 eina_stringshare_del(item->access_info);
2723 item->access_info = NULL;
2726 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2733 * Notify object will be deleted without actually deleting it.
2735 * This function will callback Elm_Widget_Item::del_cb if it is set
2736 * and then unset it so it is not called twice (ie: from
2737 * elm_widget_item_del()).
2739 * @param item a valid #Elm_Widget_Item to be notified
2740 * @see elm_widget_item_pre_notify_del() convenience macro.
2744 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2746 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2747 if (!item->del_cb) return;
2748 item->del_cb((void *)item->data, item->widget, item);
2749 item->del_cb = NULL;
2755 * Set the function to notify when item is being deleted.
2757 * This function will complain if there was a callback set already,
2758 * however it will set the new one.
2760 * The callback will be called from elm_widget_item_pre_notify_del()
2761 * or elm_widget_item_del() will be called with:
2762 * - data: the Elm_Widget_Item::data value.
2763 * - obj: the Elm_Widget_Item::widget evas object.
2764 * - event_info: the item being deleted.
2766 * @param item a valid #Elm_Widget_Item to be notified
2767 * @see elm_widget_item_del_cb_set() convenience macro.
2771 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2772 Evas_Smart_Cb del_cb)
2774 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2776 if ((item->del_cb) && (item->del_cb != del_cb))
2777 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2778 item->del_cb, item, del_cb);
2780 item->del_cb = del_cb;
2786 * Set user-data in this item.
2788 * User data may be used to identify this item or just store any
2789 * application data. It is automatically given as the first parameter
2790 * of the deletion notify callback.
2792 * @param item a valid #Elm_Widget_Item to store data in.
2793 * @param data user data to store.
2794 * @see elm_widget_item_del_cb_set() convenience macro.
2798 _elm_widget_item_data_set(Elm_Widget_Item *item,
2801 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2802 if ((item->data) && (item->data != data))
2803 DBG("Replacing item %p data %p with %p", item, item->data, data);
2810 * Retrieves user-data of this item.
2812 * @param item a valid #Elm_Widget_Item to get data from.
2813 * @see elm_widget_item_data_set()
2817 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2819 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2820 return (void *)item->data;
2823 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2825 struct _Elm_Widget_Item_Tooltip
2827 Elm_Widget_Item *item;
2828 Elm_Tooltip_Item_Content_Cb func;
2829 Evas_Smart_Cb del_cb;
2833 static Evas_Object *
2834 _elm_widget_item_tooltip_label_create(void *data,
2836 void *item __UNUSED__)
2838 Evas_Object *label = elm_label_add(obj);
2841 elm_object_style_set(label, "tooltip");
2842 elm_object_text_set(label, data);
2846 static Evas_Object *
2847 _elm_widget_item_tooltip_trans_label_create(void *data,
2848 Evas_Object *obj __UNUSED__,
2849 void *item __UNUSED__)
2851 Evas_Object *label = elm_label_add(obj);
2854 elm_object_style_set(label, "tooltip");
2855 elm_object_translatable_text_set(label, data);
2860 _elm_widget_item_tooltip_label_del_cb(void *data,
2861 Evas_Object *obj __UNUSED__,
2862 void *event_info __UNUSED__)
2864 eina_stringshare_del(data);
2870 * Set the text to be shown in the widget item.
2872 * @param item Target item
2873 * @param text The text to set in the content
2875 * Setup the text as tooltip to object. The item can have only one tooltip,
2876 * so any previous tooltip data is removed.
2881 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2884 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2885 EINA_SAFETY_ON_NULL_RETURN(text);
2887 text = eina_stringshare_add(text);
2888 _elm_widget_item_tooltip_content_cb_set
2889 (item, _elm_widget_item_tooltip_label_create, text,
2890 _elm_widget_item_tooltip_label_del_cb);
2894 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
2897 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2898 EINA_SAFETY_ON_NULL_RETURN(text);
2900 text = eina_stringshare_add(text);
2901 _elm_widget_item_tooltip_content_cb_set
2902 (item, _elm_widget_item_tooltip_trans_label_create, text,
2903 _elm_widget_item_tooltip_label_del_cb);
2906 static Evas_Object *
2907 _elm_widget_item_tooltip_create(void *data,
2910 Elm_Widget_Item_Tooltip *wit = data;
2911 return wit->func((void *)wit->data, obj, wit->item);
2915 _elm_widget_item_tooltip_del_cb(void *data,
2917 void *event_info __UNUSED__)
2919 Elm_Widget_Item_Tooltip *wit = data;
2920 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2927 * Set the content to be shown in the tooltip item
2929 * Setup the tooltip to item. The item can have only one tooltip,
2930 * so any previous tooltip data is removed. @p func(with @p data) will
2931 * be called every time that need show the tooltip and it should
2932 * return a valid Evas_Object. This object is then managed fully by
2933 * tooltip system and is deleted when the tooltip is gone.
2935 * @param item the widget item being attached a tooltip.
2936 * @param func the function used to create the tooltip contents.
2937 * @param data what to provide to @a func as callback data/context.
2938 * @param del_cb called when data is not needed anymore, either when
2939 * another callback replaces @func, the tooltip is unset with
2940 * elm_widget_item_tooltip_unset() or the owner @a item
2941 * dies. This callback receives as the first parameter the
2942 * given @a data, and @c event_info is the item.
2947 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2948 Elm_Tooltip_Item_Content_Cb func,
2950 Evas_Smart_Cb del_cb)
2952 Elm_Widget_Item_Tooltip *wit;
2954 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2958 _elm_widget_item_tooltip_unset(item);
2962 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2963 if (!wit) goto error;
2967 wit->del_cb = del_cb;
2969 elm_object_sub_tooltip_content_cb_set
2970 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2971 _elm_widget_item_tooltip_del_cb);
2976 if (del_cb) del_cb((void *)data, NULL, item);
2979 if (del_cb) del_cb((void *)data, item->widget, item);
2985 * Unset tooltip from item
2987 * @param item widget item to remove previously set tooltip.
2989 * Remove tooltip from item. The callback provided as del_cb to
2990 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2991 * it is not used anymore.
2993 * @see elm_widget_item_tooltip_content_cb_set()
2998 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
3000 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3001 elm_object_tooltip_unset(item->view);
3007 * Sets a different style for this item tooltip.
3009 * @note before you set a style you should define a tooltip with
3010 * elm_widget_item_tooltip_content_cb_set() or
3011 * elm_widget_item_tooltip_text_set()
3013 * @param item widget item with tooltip already set.
3014 * @param style the theme style to use (default, transparent, ...)
3019 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
3022 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3023 elm_object_tooltip_style_set(item->view, style);
3029 * Get the style for this item tooltip.
3031 * @param item widget item with tooltip already set.
3032 * @return style the theme style in use, defaults to "default". If the
3033 * object does not have a tooltip set, then NULL is returned.
3038 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
3040 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3041 return elm_object_tooltip_style_get(item->view);
3045 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
3048 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3049 elm_object_sub_cursor_set(item->view, item->widget, cursor);
3053 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
3055 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3056 return elm_object_cursor_get(item->view);
3060 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
3062 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3063 elm_object_cursor_unset(item->view);
3069 * Sets a different style for this item cursor.
3071 * @note before you set a style you should define a cursor with
3072 * elm_widget_item_cursor_set()
3074 * @param item widget item with cursor already set.
3075 * @param style the theme style to use (default, transparent, ...)
3080 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
3083 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3084 elm_object_cursor_style_set(item->view, style);
3090 * Get the style for this item cursor.
3092 * @param item widget item with cursor already set.
3093 * @return style the theme style in use, defaults to "default". If the
3094 * object does not have a cursor set, then NULL is returned.
3099 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
3101 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3102 return elm_object_cursor_style_get(item->view);
3108 * Set if the cursor set should be searched on the theme or should use
3109 * the provided by the engine, only.
3111 * @note before you set if should look on theme you should define a cursor
3112 * with elm_object_cursor_set(). By default it will only look for cursors
3113 * provided by the engine.
3115 * @param item widget item with cursor already set.
3116 * @param engine_only boolean to define it cursors should be looked only
3117 * between the provided by the engine or searched on widget's theme as well.
3122 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
3123 Eina_Bool engine_only)
3125 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3126 elm_object_cursor_engine_only_set(item->view, engine_only);
3132 * Get the cursor engine only usage for this item cursor.
3134 * @param item widget item with cursor already set.
3135 * @return engine_only boolean to define it cursors should be looked only
3136 * between the provided by the engine or searched on widget's theme as well. If
3137 * the object does not have a cursor set, then EINA_FALSE is returned.
3142 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
3144 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3145 return elm_object_cursor_engine_only_get(item->view);
3148 // smart object funcs
3150 _smart_reconfigure(Smart_Data *sd)
3154 evas_object_move(sd->resize_obj, sd->x, sd->y);
3155 evas_object_resize(sd->resize_obj, sd->w, sd->h);
3159 evas_object_move(sd->hover_obj, sd->x, sd->y);
3160 evas_object_resize(sd->hover_obj, sd->w, sd->h);
3165 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
3167 Evas_Object *content)
3169 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3170 if (!item->on_content_set_func) return;
3171 item->on_content_set_func((Elm_Object_Item *) item, part, content);
3175 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
3178 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3179 if (!item->on_content_get_func) return NULL;
3180 return item->on_content_get_func((Elm_Object_Item *) item, part);
3184 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3187 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3188 if (!item->on_content_unset_func) return NULL;
3189 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3193 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3197 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3198 if (!item->on_text_set_func) return;
3199 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3203 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3204 const char *emission,
3207 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3208 if (item->on_signal_emit_func)
3209 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3213 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3216 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3217 if (!item->on_text_get_func) return NULL;
3218 return item->on_text_get_func((Elm_Object_Item *) item, part);
3222 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3223 Elm_Widget_On_Content_Set_Cb func)
3225 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3226 item->on_content_set_func = func;
3230 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3231 Elm_Widget_On_Content_Get_Cb func)
3233 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3234 item->on_content_get_func = func;
3238 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3239 Elm_Widget_On_Content_Unset_Cb func)
3241 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3242 item->on_content_unset_func = func;
3246 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3247 Elm_Widget_On_Text_Set_Cb func)
3249 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3250 item->on_text_set_func = func;
3254 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3255 Elm_Widget_On_Text_Get_Cb func)
3257 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3258 item->on_text_get_func = func;
3262 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3263 Elm_Widget_On_Signal_Emit_Cb func)
3265 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3266 item->on_signal_emit_func = func;
3270 _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt)
3272 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3273 if (item->access_info) eina_stringshare_del(item->access_info);
3274 if (!txt) item->access_info = NULL;
3275 else item->access_info = eina_stringshare_add(txt);
3280 _smart_add(Evas_Object *obj)
3284 sd = calloc(1, sizeof(Smart_Data));
3287 sd->x = sd->y = sd->w = sd->h = 0;
3289 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3290 evas_object_smart_data_set(obj, sd);
3293 static Evas_Object *
3294 _newest_focus_order_get(Evas_Object *obj,
3295 unsigned int *newest_focus_order,
3296 Eina_Bool can_focus_only)
3299 Evas_Object *child, *ret, *best;
3301 API_ENTRY return NULL;
3303 if (!evas_object_visible_get(obj)
3304 || (elm_widget_disabled_get(obj))
3305 || (elm_widget_tree_unfocusable_get(obj)))
3309 if (*newest_focus_order < sd->focus_order)
3311 *newest_focus_order = sd->focus_order;
3314 EINA_LIST_FOREACH(sd->subobjs, l, child)
3316 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3322 if ((!best) || (!elm_widget_can_focus_get(best)))
3329 _if_focused_revert(Evas_Object *obj,
3330 Eina_Bool can_focus_only)
3333 Evas_Object *newest = NULL;
3334 unsigned int newest_focus_order = 0;
3338 if (!sd->focused) return;
3339 if (!sd->parent_obj) return;
3341 top = elm_widget_top_get(sd->parent_obj);
3344 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3347 elm_object_focus_set(newest, EINA_FALSE);
3348 elm_object_focus_set(newest, EINA_TRUE);
3354 _smart_del(Evas_Object *obj)
3357 Edje_Signal_Data *esd;
3358 Elm_Translate_String_Data *ts;
3362 if (sd->del_pre_func) sd->del_pre_func(obj);
3365 sobj = sd->resize_obj;
3366 sd->resize_obj = NULL;
3367 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3368 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3369 evas_object_del(sobj);
3373 sobj = sd->hover_obj;
3374 sd->hover_obj = NULL;
3375 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3376 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3377 evas_object_del(sobj);
3379 EINA_LIST_FREE(sd->subobjs, sobj)
3381 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3382 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3383 evas_object_del(sobj);
3385 eina_list_free(sd->tooltips); /* should be empty anyway */
3386 eina_list_free(sd->cursors); /* should be empty anyway */
3387 EINA_LIST_FREE(sd->edje_signals, esd)
3389 eina_stringshare_del(esd->emission);
3390 eina_stringshare_del(esd->source);
3393 EINA_LIST_FREE(sd->translate_strings, ts)
3395 eina_stringshare_del(ts->id);
3396 eina_stringshare_del(ts->domain);
3397 eina_stringshare_del(ts->string);
3400 eina_list_free(sd->event_cb); /* should be empty anyway */
3401 if (sd->del_func) sd->del_func(obj);
3402 if (sd->style) eina_stringshare_del(sd->style);
3403 if (sd->type) eina_stringshare_del(sd->type);
3404 if (sd->theme) elm_theme_free(sd->theme);
3405 _if_focused_revert(obj, EINA_TRUE);
3406 if (sd->access_info) eina_stringshare_del(sd->access_info);
3411 _smart_move(Evas_Object *obj,
3418 _smart_reconfigure(sd);
3422 _smart_resize(Evas_Object *obj,
3429 _smart_reconfigure(sd);
3433 _smart_show(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_show(o);
3449 _smart_hide(Evas_Object *obj)
3455 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_hide(o);
3464 _smart_color_set(Evas_Object *obj,
3473 if ((list = evas_object_smart_members_get(obj)))
3475 EINA_LIST_FREE(list, o)
3477 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3478 evas_object_color_set(o, r, g, b, a);
3484 _smart_clip_set(Evas_Object *obj,
3490 if ((list = evas_object_smart_members_get(obj)))
3492 EINA_LIST_FREE(list, o)
3494 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3495 evas_object_clip_set(o, clip);
3501 _smart_clip_unset(Evas_Object *obj)
3506 if ((list = evas_object_smart_members_get(obj)))
3508 EINA_LIST_FREE(list, o)
3510 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3511 evas_object_clip_unset(o);
3517 _smart_calculate(Evas_Object *obj)
3520 if (sd->changed_func) sd->changed_func(obj);
3523 /* never need to touch this */
3527 if (_e_smart) return;
3529 static const Evas_Smart_Class sc =
3532 EVAS_SMART_CLASS_VERSION,
3550 _e_smart = evas_smart_class_new(&sc);
3554 /* happy debug functions */
3557 _sub_obj_tree_dump(const Evas_Object *obj,
3562 for (i = 0; i < lvl * 3; i++)
3565 if (_elm_widget_is(obj))
3569 printf("+ %s(%p)\n",
3573 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3574 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3576 if (obj != sd->resize_obj)
3577 _sub_obj_tree_dump(obj, lvl + 1);
3581 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3585 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3588 if (!_elm_widget_is(obj))
3592 Eina_Bool visible = evas_object_visible_get(obj);
3593 Eina_Bool disabled = elm_widget_disabled_get(obj);
3594 Eina_Bool focused = elm_widget_focus_get(obj);
3595 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3599 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3602 fprintf(output, ", style=bold");
3605 fprintf(output, ", color=gray28");
3607 fprintf(output, " ];\n");
3610 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3611 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3612 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3616 fprintf(output, ", style=bold");
3619 fprintf(output, ", fontcolor=gray28");
3621 if ((disabled) || (!visible))
3622 fprintf(output, ", color=gray");
3624 fprintf(output, " ];\n");
3628 EINA_LIST_FOREACH(sd->subobjs, l, o)
3629 _sub_obj_tree_dot_dump(o, output);
3634 elm_widget_tree_dump(const Evas_Object *top)
3637 _sub_obj_tree_dump(top, 0);
3645 elm_widget_tree_dot_dump(const Evas_Object *top,
3649 if (!_elm_widget_is(top))
3651 fprintf(output, "graph " " { node [shape=record];\n");
3652 _sub_obj_tree_dot_dump(top, output);
3653 fprintf(output, "}\n");