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;
27 Evas_Object *parent_obj;
28 Evas_Coord x, y, w, h;
30 Evas_Object *resize_obj;
31 Evas_Object *hover_obj;
32 Eina_List *tooltips, *cursors;
33 void (*del_func)(Evas_Object *obj);
34 void (*del_pre_func)(Evas_Object *obj);
35 void (*focus_func)(Evas_Object *obj);
36 void (*activate_func)(Evas_Object *obj);
37 void (*disable_func)(Evas_Object *obj);
38 void (*theme_func)(Evas_Object *obj);
39 Eina_Bool (*event_func)(Evas_Object *obj,
41 Evas_Callback_Type type,
43 void (*signal_func)(Evas_Object *obj,
46 void (*callback_add_func)(Evas_Object *obj,
51 void (*callback_del_func)(Evas_Object *obj,
56 void (*changed_func)(Evas_Object *obj);
57 Eina_Bool (*focus_next_func)(const Evas_Object *obj,
58 Elm_Focus_Direction dir,
60 void (*on_focus_func)(void *data,
63 void (*on_change_func)(void *data,
66 void (*on_show_region_func)(void *data,
68 void *on_show_region_data;
69 void (*focus_region_func)(Evas_Object *obj,
74 void (*on_focus_region_func)(const Evas_Object *obj,
79 Elm_Widget_On_Text_Set_Cb on_text_set_func;
80 Elm_Widget_On_Text_Get_Cb on_text_get_func;
81 Elm_Widget_On_Content_Set_Cb on_content_set_func;
82 Elm_Widget_On_Content_Get_Cb on_content_get_func;
83 Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
85 Evas_Coord rx, ry, rw, rh;
91 unsigned int focus_order;
92 Eina_Bool focus_order_on_calc;
94 int child_drag_x_locked;
95 int child_drag_y_locked;
97 Eina_List *edje_signals;
99 Eina_Bool drag_x_locked : 1;
100 Eina_Bool drag_y_locked : 1;
102 Eina_Bool can_focus : 1;
103 Eina_Bool child_can_focus : 1;
104 Eina_Bool focused : 1;
105 Eina_Bool tree_unfocusable : 1;
106 Eina_Bool highlight_ignore : 1;
107 Eina_Bool highlight_in_theme : 1;
108 Eina_Bool disabled : 1;
109 Eina_Bool is_mirrored : 1;
110 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
112 Eina_List *focus_chain;
116 struct _Edje_Signal_Data
120 const char *emission;
125 struct _Elm_Event_Cb_Data
131 /* local subsystem functions */
132 static void _smart_reconfigure(Smart_Data *sd);
133 static void _smart_add(Evas_Object *obj);
134 static void _smart_del(Evas_Object *obj);
135 static void _smart_move(Evas_Object *obj,
138 static void _smart_resize(Evas_Object *obj,
141 static void _smart_show(Evas_Object *obj);
142 static void _smart_hide(Evas_Object *obj);
143 static void _smart_color_set(Evas_Object *obj,
148 static void _smart_clip_set(Evas_Object *obj,
150 static void _smart_clip_unset(Evas_Object *obj);
151 static void _smart_calculate(Evas_Object *obj);
152 static void _smart_init(void);
154 static void _if_focused_revert(Evas_Object *obj,
155 Eina_Bool can_focus_only);
156 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
157 unsigned int *newest_focus_order,
158 Eina_Bool can_focus_only);
160 /* local subsystem globals */
161 static Evas_Smart *_e_smart = NULL;
162 static Eina_List *widtypes = NULL;
164 static unsigned int focus_order = 0;
167 static inline Eina_Bool
168 _elm_widget_is(const Evas_Object *obj)
170 const char *type = evas_object_type_get(obj);
171 return type == SMART_NAME;
174 static inline Eina_Bool
175 _is_focusable(Evas_Object *obj)
177 API_ENTRY return EINA_FALSE;
178 return sd->can_focus || (sd->child_can_focus);
182 _unfocus_parents(Evas_Object *obj)
184 for (; obj; obj = elm_widget_parent_get(obj))
187 if (!sd->focused) return;
193 _focus_parents(Evas_Object *obj)
195 for (; obj; obj = elm_widget_parent_get(obj))
198 if (sd->focused) return;
204 _sub_obj_del(void *data,
207 void *event_info __UNUSED__)
209 Smart_Data *sd = data;
211 if (_elm_widget_is(obj))
213 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
215 if (obj == sd->resize_obj)
216 sd->resize_obj = NULL;
217 else if (obj == sd->hover_obj)
218 sd->hover_obj = NULL;
220 sd->subobjs = eina_list_remove(sd->subobjs, obj);
221 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
225 _sub_obj_hide(void *data __UNUSED__,
228 void *event_info __UNUSED__)
230 elm_widget_focus_hide_handle(obj);
234 _sub_obj_mouse_down(void *data __UNUSED__,
237 void *event_info __UNUSED__)
239 elm_widget_focus_mouse_down_handle(obj);
243 _propagate_x_drag_lock(Evas_Object *obj,
249 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
252 sd2->child_drag_x_locked += dir;
253 _propagate_x_drag_lock(sd->parent_obj, dir);
259 _propagate_y_drag_lock(Evas_Object *obj,
265 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
268 sd2->child_drag_y_locked += dir;
269 _propagate_y_drag_lock(sd->parent_obj, dir);
275 _propagate_event(void *data,
281 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
282 Evas_Event_Flags *event_flags = NULL;
286 case EVAS_CALLBACK_KEY_DOWN:
288 Evas_Event_Key_Down *ev = event_info;
289 event_flags = &(ev->event_flags);
293 case EVAS_CALLBACK_KEY_UP:
295 Evas_Event_Key_Up *ev = event_info;
296 event_flags = &(ev->event_flags);
300 case EVAS_CALLBACK_MOUSE_WHEEL:
302 Evas_Event_Mouse_Wheel *ev = event_info;
303 event_flags = &(ev->event_flags);
311 elm_widget_event_propagate(obj, type, event_info, event_flags);
315 _parent_focus(Evas_Object *obj)
318 if (sd->focused) return;
320 Evas_Object *o = elm_widget_parent_get(obj);
321 sd->focus_order_on_calc = EINA_TRUE;
323 if (o) _parent_focus(o);
325 if (!sd->focus_order_on_calc)
326 return; /* we don't want to override it if by means of any of the
327 callbacks below one gets to calculate our order
331 sd->focus_order = focus_order;
332 sd->focused = EINA_TRUE;
333 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
334 if (sd->focus_func) sd->focus_func(obj);
336 _elm_widget_focus_region_show(obj);
338 sd->focus_order_on_calc = EINA_FALSE;
342 _elm_object_focus_chain_del_cb(void *data,
345 void *event_info __UNUSED__)
347 Smart_Data *sd = data;
349 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
352 // exposed util funcs to elm
354 _elm_widget_type_clear(void)
358 EINA_LIST_FREE(widtypes, ptr)
360 eina_stringshare_del(*ptr);
366 _elm_widget_focus_region_show(const Evas_Object *obj)
368 Evas_Coord x, y, w, h, ox, oy;
374 o = elm_widget_parent_get(obj);
377 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
378 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
382 sd2 = evas_object_smart_data_get(o);
383 if (sd2->focus_region_func)
385 sd2->focus_region_func(o, x, y, w, h);
386 elm_widget_focus_region_get(o, &x, &y, &w, &h);
390 evas_object_geometry_get(o, &px, &py, NULL, NULL);
396 o = elm_widget_parent_get(o);
401 * @defgroup Widget Widget
404 * Exposed api for making widgets
407 elm_widget_type_register(const char **ptr)
409 widtypes = eina_list_append(widtypes, (void *)ptr);
413 * @defgroup Widget Widget
416 * Disposed api for making widgets
419 elm_widget_type_unregister(const char **ptr)
421 widtypes = eina_list_remove(widtypes, (void *)ptr);
425 elm_widget_api_check(int ver)
427 if (ver != ELM_INTERNAL_API_VERSION)
429 CRITICAL("Elementary widget api versions do not match");
436 elm_widget_add(Evas *evas)
440 obj = evas_object_smart_add(evas, _e_smart);
441 elm_widget_mirrored_set(obj, elm_mirrored_get());
446 elm_widget_del_hook_set(Evas_Object *obj,
447 void (*func)(Evas_Object *obj))
454 elm_widget_del_pre_hook_set(Evas_Object *obj,
455 void (*func)(Evas_Object *obj))
458 sd->del_pre_func = func;
462 elm_widget_focus_hook_set(Evas_Object *obj,
463 void (*func)(Evas_Object *obj))
466 sd->focus_func = func;
470 elm_widget_activate_hook_set(Evas_Object *obj,
471 void (*func)(Evas_Object *obj))
474 sd->activate_func = func;
478 elm_widget_disable_hook_set(Evas_Object *obj,
479 void (*func)(Evas_Object *obj))
482 sd->disable_func = func;
486 elm_widget_theme_hook_set(Evas_Object *obj,
487 void (*func)(Evas_Object *obj))
490 sd->theme_func = func;
494 elm_widget_event_hook_set(Evas_Object *obj,
495 Eina_Bool (*func)(Evas_Object *obj,
497 Evas_Callback_Type type,
501 sd->event_func = func;
505 elm_widget_text_set_hook_set(Evas_Object *obj,
506 Elm_Widget_On_Text_Set_Cb func)
509 sd->on_text_set_func = func;
513 elm_widget_text_get_hook_set(Evas_Object *obj,
514 Elm_Widget_On_Text_Get_Cb func)
517 sd->on_text_get_func = func;
521 elm_widget_content_set_hook_set(Evas_Object *obj,
522 Elm_Widget_On_Content_Set_Cb func)
525 sd->on_content_set_func = func;
529 elm_widget_content_get_hook_set(Evas_Object *obj,
530 Elm_Widget_On_Content_Get_Cb func)
533 sd->on_content_get_func = func;
537 elm_widget_content_unset_hook_set(Evas_Object *obj,
538 Elm_Widget_On_Content_Unset_Cb func)
541 sd->on_content_unset_func = func;
545 elm_widget_changed_hook_set(Evas_Object *obj,
546 void (*func)(Evas_Object *obj))
549 sd->changed_func = func;
553 elm_widget_signal_emit_hook_set(Evas_Object *obj,
554 void (*func)(Evas_Object *obj,
555 const char *emission,
559 sd->signal_func = func;
563 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
564 void (*func)(Evas_Object *obj,
565 const char *emission,
567 Edje_Signal_Cb func_cb,
571 sd->callback_add_func = func;
575 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
576 void (*func)(Evas_Object *obj,
577 const char *emission,
579 Edje_Signal_Cb func_cb,
583 sd->callback_del_func = func;
587 elm_widget_theme(Evas_Object *obj)
595 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
596 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
597 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
598 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
599 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
600 if (sd->theme_func) sd->theme_func(obj);
604 elm_widget_theme_specific(Evas_Object *obj,
612 Elm_Theme *th2, *thdef;
615 thdef = elm_theme_default_get();
620 if (!th2) th2 = thdef;
628 if (th2 == thdef) break;
629 th2 = th2->ref_theme;
630 if (!th2) th2 = thdef;
634 EINA_LIST_FOREACH(sd->subobjs, l, child)
635 elm_widget_theme_specific(child, th, force);
636 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
637 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
638 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
639 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
640 if (sd->theme_func) sd->theme_func(obj);
646 * Set hook to get next object in object focus chain.
648 * @param obj The widget object.
649 * @param func The hook to be used with this widget.
654 elm_widget_focus_next_hook_set(Evas_Object *obj,
655 Eina_Bool (*func)(const Evas_Object *obj,
656 Elm_Focus_Direction dir,
660 sd->focus_next_func = func;
664 * Returns the widget's mirrored mode.
666 * @param obj The widget.
667 * @return mirrored mode of the object.
671 elm_widget_mirrored_get(const Evas_Object *obj)
673 API_ENTRY return EINA_FALSE;
674 return sd->is_mirrored;
678 * Sets the widget's mirrored mode.
680 * @param obj The widget.
681 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
684 elm_widget_mirrored_set(Evas_Object *obj,
688 if (sd->is_mirrored != mirrored)
690 sd->is_mirrored = mirrored;
691 elm_widget_theme(obj);
697 * Resets the mirrored mode from the system mirror mode for widgets that are in
698 * automatic mirroring mode. This function does not call elm_widget_theme.
700 * @param obj The widget.
701 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
704 _elm_widget_mirrored_reload(Evas_Object *obj)
707 Eina_Bool mirrored = elm_mirrored_get();
708 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
710 sd->is_mirrored = mirrored;
715 * Returns the widget's mirrored mode setting.
717 * @param obj The widget.
718 * @return mirrored mode setting of the object.
722 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
724 API_ENTRY return EINA_FALSE;
725 return sd->mirrored_auto_mode;
729 * Sets the widget's mirrored mode setting.
730 * When widget in automatic mode, it follows the system mirrored mode set by
731 * elm_mirrored_set().
732 * @param obj The widget.
733 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
736 elm_widget_mirrored_automatic_set(Evas_Object *obj,
740 if (sd->mirrored_auto_mode != automatic)
742 sd->mirrored_auto_mode = automatic;
746 elm_widget_mirrored_set(obj, elm_mirrored_get());
752 elm_widget_on_focus_hook_set(Evas_Object *obj,
753 void (*func)(void *data,
758 sd->on_focus_func = func;
759 sd->on_focus_data = data;
763 elm_widget_on_change_hook_set(Evas_Object *obj,
764 void (*func)(void *data,
769 sd->on_change_func = func;
770 sd->on_change_data = data;
774 elm_widget_on_show_region_hook_set(Evas_Object *obj,
775 void (*func)(void *data,
780 sd->on_show_region_func = func;
781 sd->on_show_region_data = data;
787 * Set the hook to use to show the focused region.
789 * Whenever a new widget gets focused or it's needed to show the focused
790 * area of the current one, this hook will be called on objects that may
791 * want to move their children into their visible area.
792 * The area given in the hook function is relative to the @p obj widget.
794 * @param obj The widget object
795 * @param func The function to call to show the specified area.
800 elm_widget_focus_region_hook_set(Evas_Object *obj,
801 void (*func)(Evas_Object *obj,
808 sd->focus_region_func = func;
814 * Set the hook to retrieve the focused region of a widget.
816 * This hook will be called by elm_widget_focus_region_get() whenever
817 * it's needed to get the focused area of a widget. The area must be relative
818 * to the widget itself and if no hook is set, it will default to the entire
821 * @param obj The widget object
822 * @param func The function used to retrieve the focus region.
827 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
828 void (*func)(const Evas_Object *obj,
835 sd->on_focus_region_func = func;
839 elm_widget_data_set(Evas_Object *obj,
847 elm_widget_data_get(const Evas_Object *obj)
849 API_ENTRY return NULL;
854 elm_widget_sub_object_add(Evas_Object *obj,
858 double scale, pscale = elm_widget_scale_get(sobj);
859 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
860 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
862 if (_elm_widget_is(sobj))
864 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
867 if (sd2->parent_obj == obj)
870 elm_widget_sub_object_del(sd2->parent_obj, sobj);
871 sd2->parent_obj = obj;
872 if (!sd->child_can_focus && (_is_focusable(sobj)))
873 sd->child_can_focus = EINA_TRUE;
878 void *data = evas_object_data_get(sobj, "elm-parent");
881 if (data == obj) return;
882 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
887 sd->subobjs = eina_list_append(sd->subobjs, sobj);
888 evas_object_data_set(sobj, "elm-parent", obj);
889 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
890 if (_elm_widget_is(sobj))
891 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
892 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
893 scale = elm_widget_scale_get(sobj);
894 th = elm_widget_theme_get(sobj);
895 mirrored = elm_widget_mirrored_get(sobj);
896 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
897 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
901 elm_widget_sub_object_del(Evas_Object *obj,
904 Evas_Object *sobj_parent;
908 sobj_parent = evas_object_data_del(sobj, "elm-parent");
909 if (sobj_parent != obj)
911 static int abort_on_warn = -1;
912 ERR("removing sub object %p from parent %p, "
913 "but elm-parent is different %p!",
914 sobj, obj, sobj_parent);
915 if (EINA_UNLIKELY(abort_on_warn == -1))
917 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
918 else abort_on_warn = 0;
920 if (abort_on_warn == 1) abort();
922 if (_elm_widget_is(sobj))
924 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
927 sd2->parent_obj = NULL;
928 if (sd2->resize_obj == sobj)
929 sd2->resize_obj = NULL;
931 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
934 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
935 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
936 if ((sd->child_can_focus) && (_is_focusable(sobj)))
940 sd->child_can_focus = EINA_FALSE;
941 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
943 if (_is_focusable(subobj))
945 sd->child_can_focus = EINA_TRUE;
952 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
953 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
955 if (_elm_widget_is(sobj))
956 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
958 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
962 elm_widget_resize_object_set(Evas_Object *obj,
966 // orphan previous resize obj
969 evas_object_clip_unset(sd->resize_obj);
970 evas_object_data_del(sd->resize_obj, "elm-parent");
971 if (_elm_widget_is(sd->resize_obj))
973 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
974 if (sd2) sd2->parent_obj = NULL;
975 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
978 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
980 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
981 _sub_obj_mouse_down, sd);
982 evas_object_smart_member_del(sd->resize_obj);
983 if (_elm_widget_is(sd->resize_obj))
985 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
988 // orphan new resize obj
991 evas_object_data_del(sobj, "elm-parent");
992 if (_elm_widget_is(sobj))
994 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
995 if (sd2) sd2->parent_obj = NULL;
996 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
999 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1001 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1002 _sub_obj_mouse_down, sd);
1003 evas_object_smart_member_del(sobj);
1004 if (_elm_widget_is(sobj))
1006 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1009 // set the resize obj up
1010 sd->resize_obj = sobj;
1013 if (_elm_widget_is(sd->resize_obj))
1015 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1016 if (sd2) sd2->parent_obj = obj;
1017 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1020 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1021 evas_object_smart_member_add(sobj, obj);
1022 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1024 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1025 _sub_obj_mouse_down, sd);
1026 _smart_reconfigure(sd);
1027 evas_object_data_set(sobj, "elm-parent", obj);
1028 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1029 if (_elm_widget_is(sobj))
1031 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1037 elm_widget_hover_object_set(Evas_Object *obj,
1043 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1046 sd->hover_obj = sobj;
1049 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1051 _smart_reconfigure(sd);
1056 elm_widget_can_focus_set(Evas_Object *obj,
1057 Eina_Bool can_focus)
1060 sd->can_focus = can_focus;
1063 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1065 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1066 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1068 (void *)(long)EVAS_CALLBACK_KEY_UP);
1069 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1071 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1075 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1077 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1079 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1085 elm_widget_can_focus_get(const Evas_Object *obj)
1087 API_ENTRY return EINA_FALSE;
1088 return sd->can_focus;
1092 elm_widget_child_can_focus_get(const Evas_Object *obj)
1094 API_ENTRY return EINA_FALSE;
1095 return sd->child_can_focus;
1101 * This API makes the widget object and its children to be unfocusable.
1103 * This API can be helpful for an object to be deleted.
1104 * When an object will be deleted soon, it and its children may not
1105 * want to get focus (by focus reverting or by other focus controls).
1106 * Then, just use this API before deleting.
1108 * @param obj The widget root of sub-tree
1109 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1114 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1115 Eina_Bool tree_unfocusable)
1119 if (sd->tree_unfocusable == tree_unfocusable) return;
1120 sd->tree_unfocusable = !!tree_unfocusable;
1121 elm_widget_focus_tree_unfocusable_handle(obj);
1127 * This returns true, if the object sub-tree is unfocusable.
1129 * @param obj The widget root of sub-tree
1130 * @return EINA_TRUE if the object sub-tree is unfocusable
1135 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1137 API_ENTRY return EINA_FALSE;
1138 return sd->tree_unfocusable;
1142 elm_widget_highlight_ignore_set(Evas_Object *obj,
1146 sd->highlight_ignore = !!ignore;
1150 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1152 API_ENTRY return EINA_FALSE;
1153 return sd->highlight_ignore;
1157 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1158 Eina_Bool highlight)
1161 sd->highlight_in_theme = !!highlight;
1162 /* FIXME: if focused, it should switch from one mode to the other */
1166 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1168 API_ENTRY return EINA_FALSE;
1169 return sd->highlight_in_theme;
1173 elm_widget_focus_get(const Evas_Object *obj)
1175 API_ENTRY return EINA_FALSE;
1180 elm_widget_focused_object_get(const Evas_Object *obj)
1182 const Evas_Object *subobj;
1184 API_ENTRY return NULL;
1186 if (!sd->focused) return NULL;
1187 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1189 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1190 if (fobj) return fobj;
1192 return (Evas_Object *)obj;
1196 elm_widget_top_get(const Evas_Object *obj)
1198 API_ENTRY return NULL;
1199 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1200 return (Evas_Object *)obj;
1204 elm_widget_is(const Evas_Object *obj)
1206 return _elm_widget_is(obj);
1210 elm_widget_parent_widget_get(const Evas_Object *obj)
1212 Evas_Object *parent;
1214 if (_elm_widget_is(obj))
1216 Smart_Data *sd = evas_object_smart_data_get(obj);
1217 if (!sd) return NULL;
1218 parent = sd->parent_obj;
1222 parent = evas_object_data_get(obj, "elm-parent");
1223 if (!parent) parent = evas_object_smart_parent_get(obj);
1228 Evas_Object *elm_parent;
1229 if (_elm_widget_is(parent)) break;
1230 elm_parent = evas_object_data_get(parent, "elm-parent");
1231 if (elm_parent) parent = elm_parent;
1232 else parent = evas_object_smart_parent_get(parent);
1238 elm_widget_event_callback_add(Evas_Object *obj,
1243 EINA_SAFETY_ON_NULL_RETURN(func);
1244 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1247 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1251 elm_widget_event_callback_del(Evas_Object *obj,
1255 API_ENTRY return NULL;
1256 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1258 Elm_Event_Cb_Data *ecd;
1259 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1260 if ((ecd->func == func) && (ecd->data == data))
1263 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1264 return (void *)data;
1270 elm_widget_event_propagate(Evas_Object *obj,
1271 Evas_Callback_Type type,
1273 Evas_Event_Flags *event_flags)
1275 API_ENTRY return EINA_FALSE; //TODO reduce.
1276 if (!_elm_widget_is(obj)) return EINA_FALSE;
1277 Evas_Object *parent = obj;
1278 Elm_Event_Cb_Data *ecd;
1279 Eina_List *l, *l_prev;
1282 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1284 sd = evas_object_smart_data_get(parent);
1285 if ((!sd) || (!_elm_widget_is(obj)))
1286 return EINA_FALSE; //Not Elm Widget
1288 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1291 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1293 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1294 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1297 parent = sd->parent_obj;
1306 * Set custom focus chain.
1308 * This function i set one new and overwrite any previous custom focus chain
1309 * with the list of objects. The previous list will be deleted and this list
1310 * will be managed. After setted, don't modity it.
1312 * @note On focus cycle, only will be evaluated children of this container.
1314 * @param obj The container widget
1315 * @param objs Chain of objects to pass focus
1319 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1323 if (!sd->focus_next_func)
1326 elm_widget_focus_custom_chain_unset(obj);
1331 EINA_LIST_FOREACH(objs, l, o)
1333 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1334 _elm_object_focus_chain_del_cb, sd);
1337 sd->focus_chain = objs;
1343 * Get custom focus chain
1345 * @param obj The container widget
1348 EAPI const Eina_List *
1349 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1351 API_ENTRY return NULL;
1352 return (const Eina_List *)sd->focus_chain;
1358 * Unset custom focus chain
1360 * @param obj The container widget
1364 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1367 Eina_List *l, *l_next;
1370 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1372 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1373 _elm_object_focus_chain_del_cb, sd);
1374 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1381 * Append object to custom focus chain.
1383 * @note If relative_child equal to NULL or not in custom chain, the object
1384 * will be added in end.
1386 * @note On focus cycle, only will be evaluated children of this container.
1388 * @param obj The container widget
1389 * @param child The child to be added in custom chain
1390 * @param relative_child The relative object to position the child
1394 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1396 Evas_Object *relative_child)
1399 EINA_SAFETY_ON_NULL_RETURN(child);
1400 if (!sd->focus_next_func)
1403 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1404 _elm_object_focus_chain_del_cb, sd);
1406 if (!relative_child)
1408 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1412 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1419 * Prepend object to custom focus chain.
1421 * @note If relative_child equal to NULL or not in custom chain, the object
1422 * will be added in begin.
1424 * @note On focus cycle, only will be evaluated children of this container.
1426 * @param obj The container widget
1427 * @param child The child to be added in custom chain
1428 * @param relative_child The relative object to position the child
1432 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1434 Evas_Object *relative_child)
1437 EINA_SAFETY_ON_NULL_RETURN(child);
1438 if (!sd->focus_next_func)
1441 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1442 _elm_object_focus_chain_del_cb, sd);
1444 if (!relative_child)
1446 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1450 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1457 * Give focus to next object in object tree.
1459 * Give focus to next object in focus chain of one object sub-tree.
1460 * If the last object of chain already have focus, the focus will go to the
1461 * first object of chain.
1463 * @param obj The widget root of sub-tree
1464 * @param dir Direction to cycle the focus
1469 elm_widget_focus_cycle(Evas_Object *obj,
1470 Elm_Focus_Direction dir)
1472 Evas_Object *target = NULL;
1473 if (!_elm_widget_is(obj))
1475 elm_widget_focus_next_get(obj, dir, &target);
1477 elm_widget_focus_steal(target);
1483 * Give focus to near object in one direction.
1485 * Give focus to near object in direction of one object.
1486 * If none focusable object in given direction, the focus will not change.
1488 * @param obj The reference widget
1489 * @param x Horizontal component of direction to focus
1490 * @param y Vertical component of direction to focus
1495 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1505 * Get next object in focus chain of object tree.
1507 * Get next object in focus chain of one object sub-tree.
1508 * Return the next object by reference. If don't have any candidate to receive
1509 * focus before chain end, the first candidate will be returned.
1511 * @param obj The widget root of sub-tree
1512 * @param dir Direction os focus chain
1513 * @param next The next object in focus chain
1514 * @return EINA_TRUE if don't need focus chain restart/loop back
1515 * to use 'next' obj.
1520 elm_widget_focus_next_get(const Evas_Object *obj,
1521 Elm_Focus_Direction dir,
1528 API_ENTRY return EINA_FALSE;
1530 /* Ignore if disabled */
1531 if ((!evas_object_visible_get(obj))
1532 || (elm_widget_disabled_get(obj))
1533 || (elm_widget_tree_unfocusable_get(obj)))
1537 if (sd->focus_next_func)
1538 return sd->focus_next_func(obj, dir, next);
1540 if (!elm_widget_can_focus_get(obj))
1544 *next = (Evas_Object *)obj;
1545 return !elm_widget_focus_get(obj);
1551 * Get next object in focus chain of object tree in list.
1553 * Get next object in focus chain of one object sub-tree ordered by one list.
1554 * Return the next object by reference. If don't have any candidate to receive
1555 * focus before list end, the first candidate will be returned.
1557 * @param obj The widget root of sub-tree
1558 * @param dir Direction os focus chain
1559 * @param items list with ordered objects
1560 * @param list_data_get function to get the object from one item of list
1561 * @param next The next object in focus chain
1562 * @return EINA_TRUE if don't need focus chain restart/loop back
1563 * to use 'next' obj.
1568 elm_widget_focus_list_next_get(const Evas_Object *obj,
1569 const Eina_List *items,
1570 void *(*list_data_get)(const Eina_List * list),
1571 Elm_Focus_Direction dir,
1574 Eina_List *(*list_next)(const Eina_List * list);
1580 if (!_elm_widget_is(obj))
1587 if (dir == ELM_FOCUS_PREVIOUS)
1589 items = eina_list_last(items);
1590 list_next = eina_list_prev;
1592 else if (dir == ELM_FOCUS_NEXT)
1593 list_next = eina_list_next;
1597 const Eina_List *l = items;
1599 /* Recovery last focused sub item */
1600 if (elm_widget_focus_get(obj))
1601 for (; l; l = list_next(l))
1603 Evas_Object *cur = list_data_get(l);
1604 if (elm_widget_focus_get(cur)) break;
1607 const Eina_List *start = l;
1608 Evas_Object *to_focus = NULL;
1610 /* Interate sub items */
1611 /* Go to end of list */
1612 for (; l; l = list_next(l))
1614 Evas_Object *tmp = NULL;
1615 Evas_Object *cur = list_data_get(l);
1617 if (elm_widget_parent_get(cur) != obj)
1620 /* Try Focus cycle in subitem */
1621 if (elm_widget_focus_next_get(cur, dir, &tmp))
1626 else if ((tmp) && (!to_focus))
1632 /* Get First possible */
1633 for (; l != start; l = list_next(l))
1635 Evas_Object *tmp = NULL;
1636 Evas_Object *cur = list_data_get(l);
1638 if (elm_widget_parent_get(cur) != obj)
1641 /* Try Focus cycle in subitem */
1642 elm_widget_focus_next_get(cur, dir, &tmp);
1655 elm_widget_signal_emit(Evas_Object *obj,
1656 const char *emission,
1660 if (!sd->signal_func) return;
1661 sd->signal_func(obj, emission, source);
1665 _edje_signal_callback(void *data,
1666 Evas_Object *obj __UNUSED__,
1667 const char *emission,
1670 Edje_Signal_Data *esd = data;
1671 esd->func(esd->data, esd->obj, emission, source);
1675 elm_widget_signal_callback_add(Evas_Object *obj,
1676 const char *emission,
1678 Edje_Signal_Cb func,
1681 Edje_Signal_Data *esd;
1683 if (!sd->callback_add_func) return;
1684 EINA_SAFETY_ON_NULL_RETURN(func);
1686 esd = ELM_NEW(Edje_Signal_Data);
1691 esd->emission = eina_stringshare_add(emission);
1692 esd->source = eina_stringshare_add(source);
1694 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1695 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1699 elm_widget_signal_callback_del(Evas_Object *obj,
1700 const char *emission,
1702 Edje_Signal_Cb func)
1704 Edje_Signal_Data *esd;
1707 API_ENTRY return NULL;
1708 if (!sd->callback_del_func) return NULL;
1710 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1712 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1713 (!strcmp(esd->source, source)))
1715 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1716 eina_stringshare_del(esd->emission);
1717 eina_stringshare_del(esd->source);
1723 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1728 elm_widget_focus_set(Evas_Object *obj,
1735 sd->focus_order = focus_order;
1736 sd->focused = EINA_TRUE;
1737 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1741 sd->focus_func(obj);
1748 if ((_is_focusable(sd->resize_obj)) &&
1749 (!elm_widget_disabled_get(sd->resize_obj)))
1751 elm_widget_focus_set(sd->resize_obj, first);
1757 EINA_LIST_FOREACH(sd->subobjs, l, child)
1759 if ((_is_focusable(child)) &&
1760 (!elm_widget_disabled_get(child)))
1762 elm_widget_focus_set(child, first);
1772 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1774 if ((_is_focusable(child)) &&
1775 (!elm_widget_disabled_get(child)))
1777 elm_widget_focus_set(child, first);
1783 if ((_is_focusable(sd->resize_obj)) &&
1784 (!elm_widget_disabled_get(sd->resize_obj)))
1786 elm_widget_focus_set(sd->resize_obj, first);
1794 elm_widget_parent_get(const Evas_Object *obj)
1796 API_ENTRY return NULL;
1797 return sd->parent_obj;
1801 elm_widget_focused_object_clear(Evas_Object *obj)
1804 if (!sd->focused) return;
1805 if (elm_widget_focus_get(sd->resize_obj))
1806 elm_widget_focused_object_clear(sd->resize_obj);
1811 EINA_LIST_FOREACH(sd->subobjs, l, child)
1813 if (elm_widget_focus_get(child))
1815 elm_widget_focused_object_clear(child);
1820 sd->focused = EINA_FALSE;
1821 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1822 if (sd->focus_func) sd->focus_func(obj);
1826 elm_widget_focus_steal(Evas_Object *obj)
1828 Evas_Object *parent, *o;
1831 if (sd->focused) return;
1832 if (sd->disabled) return;
1833 if (!sd->can_focus) return;
1834 if (sd->tree_unfocusable) return;
1838 o = elm_widget_parent_get(parent);
1840 sd = evas_object_smart_data_get(o);
1841 if (sd->disabled || sd->tree_unfocusable) return;
1842 if (sd->focused) break;
1845 if (!elm_widget_parent_get(parent))
1846 elm_widget_focused_object_clear(parent);
1849 parent = elm_widget_parent_get(parent);
1850 sd = evas_object_smart_data_get(parent);
1851 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1852 elm_widget_focused_object_clear(sd->resize_obj);
1857 EINA_LIST_FOREACH(sd->subobjs, l, child)
1859 if (elm_widget_focus_get(child))
1861 elm_widget_focused_object_clear(child);
1872 elm_widget_focus_restore(Evas_Object *obj)
1874 Evas_Object *newest = NULL;
1875 unsigned int newest_focus_order = 0;
1878 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1881 elm_object_unfocus(newest);
1882 elm_object_focus(newest);
1887 elm_widget_activate(Evas_Object *obj)
1890 elm_widget_change(obj);
1891 if (sd->activate_func) sd->activate_func(obj);
1895 elm_widget_change(Evas_Object *obj)
1898 elm_widget_change(elm_widget_parent_get(obj));
1899 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
1903 elm_widget_disabled_set(Evas_Object *obj,
1908 if (sd->disabled == disabled) return;
1909 sd->disabled = !!disabled;
1910 elm_widget_focus_disabled_handle(obj);
1911 if (sd->disable_func) sd->disable_func(obj);
1915 elm_widget_disabled_get(const Evas_Object *obj)
1918 return sd->disabled;
1922 elm_widget_show_region_set(Evas_Object *obj,
1927 Eina_Bool forceshow)
1929 Evas_Object *parent_obj, *child_obj;
1930 Evas_Coord px, py, cx, cy;
1933 if (!forceshow && (x == sd->rx) && (y == sd->ry)
1934 && (w == sd->rw) && (h == sd->rh)) return;
1939 if (sd->on_show_region_func)
1940 sd->on_show_region_func(sd->on_show_region_data, obj);
1944 parent_obj = sd->parent_obj;
1945 child_obj = sd->obj;
1946 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
1947 sd = evas_object_smart_data_get(parent_obj);
1950 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
1951 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
1960 if (sd->on_show_region_func)
1962 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
1969 elm_widget_show_region_get(const Evas_Object *obj,
1985 * Get the focus region of the given widget.
1987 * The focus region is the area of a widget that should brought into the
1988 * visible area when the widget is focused. Mostly used to show the part of
1989 * an entry where the cursor is, for example. The area returned is relative
1990 * to the object @p obj.
1991 * If the @p obj doesn't have the proper on_focus_region_hook set, this
1992 * function will return the full size of the object.
1994 * @param obj The widget object
1995 * @param x Where to store the x coordinate of the area
1996 * @param y Where to store the y coordinate of the area
1997 * @param w Where to store the width of the area
1998 * @param h Where to store the height of the area
2003 elm_widget_focus_region_get(const Evas_Object *obj,
2013 sd = evas_object_smart_data_get(obj);
2014 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2016 evas_object_geometry_get(obj, NULL, NULL, w, h);
2021 sd->on_focus_region_func(obj, x, y, w, h);
2025 elm_widget_scroll_hold_push(Evas_Object *obj)
2029 if (sd->scroll_hold == 1)
2030 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2031 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2032 // FIXME: on delete/reparent hold pop
2036 elm_widget_scroll_hold_pop(Evas_Object *obj)
2040 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2041 if (!sd->scroll_hold)
2042 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2043 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2047 elm_widget_scroll_hold_get(const Evas_Object *obj)
2050 return sd->scroll_hold;
2054 elm_widget_scroll_freeze_push(Evas_Object *obj)
2057 sd->scroll_freeze++;
2058 if (sd->scroll_freeze == 1)
2059 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2060 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2061 // FIXME: on delete/reparent freeze pop
2065 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2068 sd->scroll_freeze--;
2069 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2070 if (!sd->scroll_freeze)
2071 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2072 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2076 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2079 return sd->scroll_freeze;
2083 elm_widget_scale_set(Evas_Object *obj,
2087 if (scale <= 0.0) scale = 0.0;
2088 if (sd->scale != scale)
2091 elm_widget_theme(obj);
2096 elm_widget_scale_get(const Evas_Object *obj)
2098 API_ENTRY return 1.0;
2099 // FIXME: save walking up the tree by storing/caching parent scale
2100 if (sd->scale == 0.0)
2103 return elm_widget_scale_get(sd->parent_obj);
2111 elm_widget_theme_set(Evas_Object *obj,
2115 if (sd->theme != th)
2117 if (sd->theme) elm_theme_free(sd->theme);
2120 elm_widget_theme(obj);
2125 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2129 if (!sd->on_text_set_func)
2132 sd->on_text_set_func(obj, item, label);
2136 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2138 API_ENTRY return NULL;
2140 if (!sd->on_text_get_func)
2143 return sd->on_text_get_func(obj, item);
2147 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2151 if (!sd->on_content_set_func) return;
2152 sd->on_content_set_func(obj, part, content);
2156 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2158 API_ENTRY return NULL;
2160 if (!sd->on_content_get_func) return NULL;
2161 return sd->on_content_get_func(obj, part);
2165 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2167 API_ENTRY return NULL;
2169 if (!sd->on_content_unset_func) return NULL;
2170 return sd->on_content_unset_func(obj, part);
2174 elm_widget_theme_get(const Evas_Object *obj)
2176 API_ENTRY return NULL;
2180 return elm_widget_theme_get(sd->parent_obj);
2188 elm_widget_style_set(Evas_Object *obj,
2193 if (eina_stringshare_replace(&sd->style, style))
2194 elm_widget_theme(obj);
2198 elm_widget_style_get(const Evas_Object *obj)
2200 API_ENTRY return NULL;
2201 if (sd->style) return sd->style;
2206 elm_widget_type_set(Evas_Object *obj,
2210 eina_stringshare_replace(&sd->type, type);
2214 elm_widget_type_get(const Evas_Object *obj)
2216 API_ENTRY return NULL;
2217 if (sd->type) return sd->type;
2222 elm_widget_tooltip_add(Evas_Object *obj,
2226 sd->tooltips = eina_list_append(sd->tooltips, tt);
2230 elm_widget_tooltip_del(Evas_Object *obj,
2234 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2238 elm_widget_cursor_add(Evas_Object *obj,
2242 sd->cursors = eina_list_append(sd->cursors, cur);
2246 elm_widget_cursor_del(Evas_Object *obj,
2250 sd->cursors = eina_list_remove(sd->cursors, cur);
2254 elm_widget_drag_lock_x_set(Evas_Object *obj,
2258 if (sd->drag_x_locked == lock) return;
2259 sd->drag_x_locked = lock;
2260 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2261 else _propagate_x_drag_lock(obj, -1);
2265 elm_widget_drag_lock_y_set(Evas_Object *obj,
2269 if (sd->drag_y_locked == lock) return;
2270 sd->drag_y_locked = lock;
2271 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2272 else _propagate_y_drag_lock(obj, -1);
2276 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2278 API_ENTRY return EINA_FALSE;
2279 return sd->drag_x_locked;
2283 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2285 API_ENTRY return EINA_FALSE;
2286 return sd->drag_y_locked;
2290 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2293 return sd->child_drag_x_locked;
2297 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2300 return sd->child_drag_y_locked;
2304 elm_widget_theme_object_set(Evas_Object *obj,
2307 const char *welement,
2310 API_ENTRY return EINA_FALSE;
2311 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2315 elm_widget_type_check(const Evas_Object *obj,
2318 const char *provided, *expected = "(unknown)";
2319 static int abort_on_warn = -1;
2320 provided = elm_widget_type_get(obj);
2321 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2322 if (type) expected = type;
2323 if ((!provided) || (!provided[0]))
2325 provided = evas_object_type_get(obj);
2326 if ((!provided) || (!provided[0]))
2327 provided = "(unknown)";
2329 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2330 if (abort_on_warn == -1)
2332 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2333 else abort_on_warn = 0;
2335 if (abort_on_warn == 1) abort();
2342 * Split string in words
2344 * @param str Source string
2345 * @return List of const words
2347 * @see elm_widget_stringlist_free()
2351 elm_widget_stringlist_get(const char *str)
2353 Eina_List *list = NULL;
2355 if (!str) return NULL;
2356 for (b = s = str; 1; s++)
2358 if ((*s == ' ') || (!*s))
2360 char *t = malloc(s - b + 1);
2363 strncpy(t, b, s - b);
2365 list = eina_list_append(list, eina_stringshare_add(t));
2376 elm_widget_stringlist_free(Eina_List *list)
2379 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2383 elm_widget_focus_hide_handle(Evas_Object *obj)
2385 _if_focused_revert(obj, EINA_TRUE);
2389 elm_widget_focus_mouse_down_handle(Evas_Object *obj)
2391 Evas_Object *o = obj;
2394 if (_elm_widget_is(o)) break;
2395 o = evas_object_smart_parent_get(o);
2399 if (!_is_focusable(o)) return;
2400 elm_widget_focus_steal(o);
2404 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2408 if (!elm_widget_parent_get(obj))
2409 elm_widget_focused_object_clear(obj);
2411 _if_focused_revert(obj, EINA_TRUE);
2415 elm_widget_focus_disabled_handle(Evas_Object *obj)
2419 elm_widget_focus_tree_unfocusable_handle(obj);
2425 * Allocate a new Elm_Widget_Item-derived structure.
2427 * The goal of this structure is to provide common ground for actions
2428 * that a widget item have, such as the owner widget, callback to
2429 * notify deletion, data pointer and maybe more.
2431 * @param widget the owner widget that holds this item, must be an elm_widget!
2432 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2433 * be used to allocate memory.
2435 * @return allocated memory that is already zeroed out, or NULL on errors.
2437 * @see elm_widget_item_new() convenience macro.
2438 * @see elm_widget_item_del() to release memory.
2441 EAPI Elm_Widget_Item *
2442 _elm_widget_item_new(Evas_Object *widget,
2445 if (!_elm_widget_is(widget))
2448 Elm_Widget_Item *item;
2450 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2451 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2453 item = calloc(1, alloc_size);
2454 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2456 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2457 item->widget = widget;
2464 * Releases widget item memory, calling back del_cb() if it exists.
2466 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2467 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2468 * this function and then unset it, thus being useful for 2 step
2469 * cleanup whenever the del_cb may use any of the data that must be
2470 * deleted from item.
2472 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2475 * @param item a valid #Elm_Widget_Item to be deleted.
2476 * @see elm_widget_item_del() convenience macro.
2480 _elm_widget_item_del(Elm_Widget_Item *item)
2482 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2485 item->del_cb((void *)item->data, item->widget, item);
2488 evas_object_del(item->view);
2490 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2497 * Notify object will be deleted without actually deleting it.
2499 * This function will callback Elm_Widget_Item::del_cb if it is set
2500 * and then unset it so it is not called twice (ie: from
2501 * elm_widget_item_del()).
2503 * @param item a valid #Elm_Widget_Item to be notified
2504 * @see elm_widget_item_pre_notify_del() convenience macro.
2508 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2510 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2511 if (!item->del_cb) return;
2512 item->del_cb((void *)item->data, item->widget, item);
2513 item->del_cb = NULL;
2519 * Set the function to notify when item is being deleted.
2521 * This function will complain if there was a callback set already,
2522 * however it will set the new one.
2524 * The callback will be called from elm_widget_item_pre_notify_del()
2525 * or elm_widget_item_del() will be called with:
2526 * - data: the Elm_Widget_Item::data value.
2527 * - obj: the Elm_Widget_Item::widget evas object.
2528 * - event_info: the item being deleted.
2530 * @param item a valid #Elm_Widget_Item to be notified
2531 * @see elm_widget_item_del_cb_set() convenience macro.
2535 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2536 Evas_Smart_Cb del_cb)
2538 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2540 if ((item->del_cb) && (item->del_cb != del_cb))
2541 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2542 item->del_cb, item, del_cb);
2544 item->del_cb = del_cb;
2550 * Set user-data in this item.
2552 * User data may be used to identify this item or just store any
2553 * application data. It is automatically given as the first parameter
2554 * of the deletion notify callback.
2556 * @param item a valid #Elm_Widget_Item to store data in.
2557 * @param data user data to store.
2558 * @see elm_widget_item_del_cb_set() convenience macro.
2562 _elm_widget_item_data_set(Elm_Widget_Item *item,
2565 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2566 if ((item->data) && (item->data != data))
2567 DBG("Replacing item %p data %p with %p", item, item->data, data);
2574 * Retrieves user-data of this item.
2576 * @param item a valid #Elm_Widget_Item to get data from.
2577 * @see elm_widget_item_data_set()
2581 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2583 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2584 return (void *)item->data;
2587 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2589 struct _Elm_Widget_Item_Tooltip
2591 Elm_Widget_Item *item;
2592 Elm_Tooltip_Item_Content_Cb func;
2593 Evas_Smart_Cb del_cb;
2597 static Evas_Object *
2598 _elm_widget_item_tooltip_label_create(void *data,
2600 void *item __UNUSED__)
2602 Evas_Object *label = elm_label_add(obj);
2605 elm_object_style_set(label, "tooltip");
2606 elm_object_text_set(label, data);
2611 _elm_widget_item_tooltip_label_del_cb(void *data,
2612 Evas_Object *obj __UNUSED__,
2613 void *event_info __UNUSED__)
2615 eina_stringshare_del(data);
2621 * Set the text to be shown in the widget item.
2623 * @param item Target item
2624 * @param text The text to set in the content
2626 * Setup the text as tooltip to object. The item can have only one tooltip,
2627 * so any previous tooltip data is removed.
2632 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2635 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2636 EINA_SAFETY_ON_NULL_RETURN(text);
2638 text = eina_stringshare_add(text);
2639 _elm_widget_item_tooltip_content_cb_set
2640 (item, _elm_widget_item_tooltip_label_create, text,
2641 _elm_widget_item_tooltip_label_del_cb);
2644 static Evas_Object *
2645 _elm_widget_item_tooltip_create(void *data,
2648 Elm_Widget_Item_Tooltip *wit = data;
2649 return wit->func((void *)wit->data, obj, wit->item);
2653 _elm_widget_item_tooltip_del_cb(void *data,
2655 void *event_info __UNUSED__)
2657 Elm_Widget_Item_Tooltip *wit = data;
2658 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2665 * Set the content to be shown in the tooltip item
2667 * Setup the tooltip to item. The item can have only one tooltip,
2668 * so any previous tooltip data is removed. @p func(with @p data) will
2669 * be called every time that need show the tooltip and it should
2670 * return a valid Evas_Object. This object is then managed fully by
2671 * tooltip system and is deleted when the tooltip is gone.
2673 * @param item the widget item being attached a tooltip.
2674 * @param func the function used to create the tooltip contents.
2675 * @param data what to provide to @a func as callback data/context.
2676 * @param del_cb called when data is not needed anymore, either when
2677 * another callback replaces @func, the tooltip is unset with
2678 * elm_widget_item_tooltip_unset() or the owner @a item
2679 * dies. This callback receives as the first parameter the
2680 * given @a data, and @c event_info is the item.
2685 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2686 Elm_Tooltip_Item_Content_Cb func,
2688 Evas_Smart_Cb del_cb)
2690 Elm_Widget_Item_Tooltip *wit;
2692 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2696 _elm_widget_item_tooltip_unset(item);
2700 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2701 if (!wit) goto error;
2705 wit->del_cb = del_cb;
2707 elm_object_sub_tooltip_content_cb_set
2708 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2709 _elm_widget_item_tooltip_del_cb);
2714 if (del_cb) del_cb((void *)data, NULL, item);
2717 if (del_cb) del_cb((void *)data, item->widget, item);
2723 * Unset tooltip from item
2725 * @param item widget item to remove previously set tooltip.
2727 * Remove tooltip from item. The callback provided as del_cb to
2728 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2729 * it is not used anymore.
2731 * @see elm_widget_item_tooltip_content_cb_set()
2736 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2738 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2739 elm_object_tooltip_unset(item->view);
2745 * Sets a different style for this item tooltip.
2747 * @note before you set a style you should define a tooltip with
2748 * elm_widget_item_tooltip_content_cb_set() or
2749 * elm_widget_item_tooltip_text_set()
2751 * @param item widget item with tooltip already set.
2752 * @param style the theme style to use (default, transparent, ...)
2757 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2760 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2761 elm_object_tooltip_style_set(item->view, style);
2767 * Get the style for this item tooltip.
2769 * @param item widget item with tooltip already set.
2770 * @return style the theme style in use, defaults to "default". If the
2771 * object does not have a tooltip set, then NULL is returned.
2776 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2778 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2779 return elm_object_tooltip_style_get(item->view);
2783 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2786 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2787 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2791 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2793 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2794 return elm_object_cursor_get(item->view);
2798 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2800 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2801 elm_object_cursor_unset(item->view);
2807 * Sets a different style for this item cursor.
2809 * @note before you set a style you should define a cursor with
2810 * elm_widget_item_cursor_set()
2812 * @param item widget item with cursor already set.
2813 * @param style the theme style to use (default, transparent, ...)
2818 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2821 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2822 elm_object_cursor_style_set(item->view, style);
2828 * Get the style for this item cursor.
2830 * @param item widget item with cursor already set.
2831 * @return style the theme style in use, defaults to "default". If the
2832 * object does not have a cursor set, then NULL is returned.
2837 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2839 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2840 return elm_object_cursor_style_get(item->view);
2846 * Set if the cursor set should be searched on the theme or should use
2847 * the provided by the engine, only.
2849 * @note before you set if should look on theme you should define a cursor
2850 * with elm_object_cursor_set(). By default it will only look for cursors
2851 * provided by the engine.
2853 * @param item widget item with cursor already set.
2854 * @param engine_only boolean to define it cursors should be looked only
2855 * between the provided by the engine or searched on widget's theme as well.
2860 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
2861 Eina_Bool engine_only)
2863 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2864 elm_object_cursor_engine_only_set(item->view, engine_only);
2870 * Get the cursor engine only usage for this item cursor.
2872 * @param item widget item with cursor already set.
2873 * @return engine_only boolean to define it cursors should be looked only
2874 * between the provided by the engine or searched on widget's theme as well. If
2875 * the object does not have a cursor set, then EINA_FALSE is returned.
2880 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
2882 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2883 return elm_object_cursor_engine_only_get(item->view);
2886 // smart object funcs
2888 _smart_reconfigure(Smart_Data *sd)
2892 evas_object_move(sd->resize_obj, sd->x, sd->y);
2893 evas_object_resize(sd->resize_obj, sd->w, sd->h);
2897 evas_object_move(sd->hover_obj, sd->x, sd->y);
2898 evas_object_resize(sd->hover_obj, sd->w, sd->h);
2903 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
2905 Evas_Object *content)
2907 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2908 if (!item->on_content_set_func) return;
2909 item->on_content_set_func((Elm_Object_Item *) item, part, content);
2913 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
2916 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2917 if (!item->on_content_get_func) return NULL;
2918 return item->on_content_get_func((Elm_Object_Item *) item, part);
2922 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
2925 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2926 if (!item->on_content_unset_func) return NULL;
2927 return item->on_content_unset_func((Elm_Object_Item *) item, part);
2931 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
2935 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2936 if (!item->on_text_set_func) return;
2937 item->on_text_set_func((Elm_Object_Item *) item, part, label);
2941 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
2942 const char *emission,
2945 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2946 if (item->on_signal_emit_func)
2947 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
2951 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
2954 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2955 if (!item->on_text_get_func) return NULL;
2956 return item->on_text_get_func((Elm_Object_Item *) item, part);
2960 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
2961 Elm_Widget_On_Content_Set_Cb func)
2963 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2964 item->on_content_set_func = func;
2968 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
2969 Elm_Widget_On_Content_Get_Cb func)
2971 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2972 item->on_content_get_func = func;
2976 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
2977 Elm_Widget_On_Content_Unset_Cb func)
2979 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2980 item->on_content_unset_func = func;
2984 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
2985 Elm_Widget_On_Text_Set_Cb func)
2987 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2988 item->on_text_set_func = func;
2992 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
2993 Elm_Widget_On_Text_Get_Cb func)
2995 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2996 item->on_text_get_func = func;
3000 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3001 Elm_Widget_On_Signal_Emit_Cb func)
3003 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3004 item->on_signal_emit_func = func;
3008 _smart_add(Evas_Object *obj)
3012 sd = calloc(1, sizeof(Smart_Data));
3015 sd->x = sd->y = sd->w = sd->h = 0;
3017 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3018 evas_object_smart_data_set(obj, sd);
3021 static Evas_Object *
3022 _newest_focus_order_get(Evas_Object *obj,
3023 unsigned int *newest_focus_order,
3024 Eina_Bool can_focus_only)
3027 Evas_Object *child, *ret, *best;
3029 API_ENTRY return NULL;
3031 if (!evas_object_visible_get(obj)
3032 || (elm_widget_disabled_get(obj))
3033 || (elm_widget_tree_unfocusable_get(obj)))
3037 if (*newest_focus_order < sd->focus_order)
3039 *newest_focus_order = sd->focus_order;
3042 EINA_LIST_FOREACH(sd->subobjs, l, child)
3044 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3050 if ((!best) || (!elm_widget_can_focus_get(best)))
3057 _if_focused_revert(Evas_Object *obj,
3058 Eina_Bool can_focus_only)
3061 Evas_Object *newest = NULL;
3062 unsigned int newest_focus_order = 0;
3066 if (!sd->focused) return;
3067 if (!sd->parent_obj) return;
3069 top = elm_widget_top_get(sd->parent_obj);
3072 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3075 elm_object_unfocus(newest);
3076 elm_object_focus(newest);
3082 _smart_del(Evas_Object *obj)
3085 Edje_Signal_Data *esd;
3089 if (sd->del_pre_func) sd->del_pre_func(obj);
3092 sobj = sd->resize_obj;
3093 sd->resize_obj = NULL;
3094 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3095 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3096 evas_object_del(sobj);
3100 sobj = sd->hover_obj;
3101 sd->hover_obj = NULL;
3102 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3103 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3104 evas_object_del(sobj);
3106 EINA_LIST_FREE(sd->subobjs, sobj)
3108 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3109 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3110 evas_object_del(sobj);
3112 eina_list_free(sd->tooltips); /* should be empty anyway */
3113 eina_list_free(sd->cursors); /* should be empty anyway */
3114 EINA_LIST_FREE(sd->edje_signals, esd)
3116 eina_stringshare_del(esd->emission);
3117 eina_stringshare_del(esd->source);
3120 eina_list_free(sd->event_cb); /* should be empty anyway */
3121 if (sd->del_func) sd->del_func(obj);
3122 if (sd->style) eina_stringshare_del(sd->style);
3123 if (sd->type) eina_stringshare_del(sd->type);
3124 if (sd->theme) elm_theme_free(sd->theme);
3125 _if_focused_revert(obj, EINA_TRUE);
3130 _smart_move(Evas_Object *obj,
3137 _smart_reconfigure(sd);
3141 _smart_resize(Evas_Object *obj,
3148 _smart_reconfigure(sd);
3152 _smart_show(Evas_Object *obj)
3157 if ((list = evas_object_smart_members_get(obj)))
3159 EINA_LIST_FREE(list, o)
3161 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3162 evas_object_show(o);
3168 _smart_hide(Evas_Object *obj)
3174 list = evas_object_smart_members_get(obj);
3175 EINA_LIST_FREE(list, o)
3177 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3178 evas_object_hide(o);
3183 _smart_color_set(Evas_Object *obj,
3192 if ((list = evas_object_smart_members_get(obj)))
3194 EINA_LIST_FREE(list, o)
3196 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3197 evas_object_color_set(o, r, g, b, a);
3203 _smart_clip_set(Evas_Object *obj,
3209 if ((list = evas_object_smart_members_get(obj)))
3211 EINA_LIST_FREE(list, o)
3213 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3214 evas_object_clip_set(o, clip);
3220 _smart_clip_unset(Evas_Object *obj)
3225 if ((list = evas_object_smart_members_get(obj)))
3227 EINA_LIST_FREE(list, o)
3229 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3230 evas_object_clip_unset(o);
3236 _smart_calculate(Evas_Object *obj)
3239 if (sd->changed_func) sd->changed_func(obj);
3242 /* never need to touch this */
3246 if (_e_smart) return;
3248 static const Evas_Smart_Class sc =
3251 EVAS_SMART_CLASS_VERSION,
3269 _e_smart = evas_smart_class_new(&sc);
3273 /* happy debug functions */
3276 _sub_obj_tree_dump(const Evas_Object *obj,
3281 for (i = 0; i < lvl * 3; i++)
3284 if (_elm_widget_is(obj))
3288 printf("+ %s(%p)\n",
3292 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3293 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3295 if (obj != sd->resize_obj)
3296 _sub_obj_tree_dump(obj, lvl + 1);
3300 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3304 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3307 if (!_elm_widget_is(obj))
3311 Eina_Bool visible = evas_object_visible_get(obj);
3312 Eina_Bool disabled = elm_widget_disabled_get(obj);
3313 Eina_Bool focused = elm_widget_focus_get(obj);
3314 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3318 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3321 fprintf(output, ", style=bold");
3324 fprintf(output, ", color=gray28");
3326 fprintf(output, " ];\n");
3329 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3330 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3331 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3335 fprintf(output, ", style=bold");
3338 fprintf(output, ", fontcolor=gray28");
3340 if ((disabled) || (!visible))
3341 fprintf(output, ", color=gray");
3343 fprintf(output, " ];\n");
3347 EINA_LIST_FOREACH(sd->subobjs, l, o)
3348 _sub_obj_tree_dot_dump(o, output);
3353 elm_widget_tree_dump(const Evas_Object *top)
3356 _sub_obj_tree_dump(top, 0);
3364 elm_widget_tree_dot_dump(const Evas_Object *top,
3368 if (!_elm_widget_is(top))
3370 fprintf(output, "graph " " { node [shape=record];\n");
3371 _sub_obj_tree_dot_dump(top, output);
3372 fprintf(output, "}\n");