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 top_win_focused : 1;
106 Eina_Bool tree_unfocusable : 1;
107 Eina_Bool highlight_ignore : 1;
108 Eina_Bool highlight_in_theme : 1;
109 Eina_Bool disabled : 1;
110 Eina_Bool is_mirrored : 1;
111 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
113 Eina_List *focus_chain;
117 struct _Edje_Signal_Data
121 const char *emission;
126 struct _Elm_Event_Cb_Data
132 /* local subsystem functions */
133 static void _smart_reconfigure(Smart_Data *sd);
134 static void _smart_add(Evas_Object *obj);
135 static void _smart_del(Evas_Object *obj);
136 static void _smart_move(Evas_Object *obj,
139 static void _smart_resize(Evas_Object *obj,
142 static void _smart_show(Evas_Object *obj);
143 static void _smart_hide(Evas_Object *obj);
144 static void _smart_color_set(Evas_Object *obj,
149 static void _smart_clip_set(Evas_Object *obj,
151 static void _smart_clip_unset(Evas_Object *obj);
152 static void _smart_calculate(Evas_Object *obj);
153 static void _smart_init(void);
155 static void _if_focused_revert(Evas_Object *obj,
156 Eina_Bool can_focus_only);
157 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
158 unsigned int *newest_focus_order,
159 Eina_Bool can_focus_only);
161 /* local subsystem globals */
162 static Evas_Smart *_e_smart = NULL;
163 static Eina_List *widtypes = NULL;
165 static unsigned int focus_order = 0;
168 static inline Eina_Bool
169 _elm_widget_is(const Evas_Object *obj)
171 const char *type = evas_object_type_get(obj);
172 return type == SMART_NAME;
175 static inline Eina_Bool
176 _is_focusable(Evas_Object *obj)
178 API_ENTRY return EINA_FALSE;
179 return sd->can_focus || (sd->child_can_focus);
183 _unfocus_parents(Evas_Object *obj)
185 for (; obj; obj = elm_widget_parent_get(obj))
188 if (!sd->focused) return;
194 _focus_parents(Evas_Object *obj)
196 for (; obj; obj = elm_widget_parent_get(obj))
199 if (sd->focused) return;
205 _sub_obj_del(void *data,
208 void *event_info __UNUSED__)
210 Smart_Data *sd = data;
212 if (_elm_widget_is(obj))
214 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
216 if (obj == sd->resize_obj)
217 sd->resize_obj = NULL;
218 else if (obj == sd->hover_obj)
219 sd->hover_obj = NULL;
221 sd->subobjs = eina_list_remove(sd->subobjs, obj);
222 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
226 _sub_obj_hide(void *data __UNUSED__,
229 void *event_info __UNUSED__)
231 elm_widget_focus_hide_handle(obj);
235 _sub_obj_mouse_down(void *data __UNUSED__,
238 void *event_info __UNUSED__)
240 elm_widget_focus_mouse_down_handle(obj);
244 _propagate_x_drag_lock(Evas_Object *obj,
250 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
253 sd2->child_drag_x_locked += dir;
254 _propagate_x_drag_lock(sd->parent_obj, dir);
260 _propagate_y_drag_lock(Evas_Object *obj,
266 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
269 sd2->child_drag_y_locked += dir;
270 _propagate_y_drag_lock(sd->parent_obj, dir);
276 _propagate_event(void *data,
282 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
283 Evas_Event_Flags *event_flags = NULL;
287 case EVAS_CALLBACK_KEY_DOWN:
289 Evas_Event_Key_Down *ev = event_info;
290 event_flags = &(ev->event_flags);
294 case EVAS_CALLBACK_KEY_UP:
296 Evas_Event_Key_Up *ev = event_info;
297 event_flags = &(ev->event_flags);
301 case EVAS_CALLBACK_MOUSE_WHEEL:
303 Evas_Event_Mouse_Wheel *ev = event_info;
304 event_flags = &(ev->event_flags);
312 elm_widget_event_propagate(obj, type, event_info, event_flags);
316 _parent_focus(Evas_Object *obj)
319 if (sd->focused) return;
321 Evas_Object *o = elm_widget_parent_get(obj);
322 sd->focus_order_on_calc = EINA_TRUE;
324 if (o) _parent_focus(o);
326 if (!sd->focus_order_on_calc)
327 return; /* we don't want to override it if by means of any of the
328 callbacks below one gets to calculate our order
332 sd->focus_order = focus_order;
333 if (sd->top_win_focused)
335 sd->focused = EINA_TRUE;
336 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
337 if (sd->focus_func) sd->focus_func(obj);
338 _elm_widget_focus_region_show(obj);
340 sd->focus_order_on_calc = EINA_FALSE;
344 _elm_object_focus_chain_del_cb(void *data,
347 void *event_info __UNUSED__)
349 Smart_Data *sd = data;
351 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
354 // exposed util funcs to elm
356 _elm_widget_type_clear(void)
360 EINA_LIST_FREE(widtypes, ptr)
362 eina_stringshare_del(*ptr);
368 _elm_widget_focus_region_show(const Evas_Object *obj)
370 Evas_Coord x, y, w, h, ox, oy;
376 o = elm_widget_parent_get(obj);
379 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
380 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
384 sd2 = evas_object_smart_data_get(o);
385 if (sd2->focus_region_func)
387 sd2->focus_region_func(o, x, y, w, h);
388 elm_widget_focus_region_get(o, &x, &y, &w, &h);
392 evas_object_geometry_get(o, &px, &py, NULL, NULL);
398 o = elm_widget_parent_get(o);
403 * @defgroup Widget Widget
406 * Exposed api for making widgets
409 elm_widget_type_register(const char **ptr)
411 widtypes = eina_list_append(widtypes, (void *)ptr);
415 * @defgroup Widget Widget
418 * Disposed api for making widgets
421 elm_widget_type_unregister(const char **ptr)
423 widtypes = eina_list_remove(widtypes, (void *)ptr);
427 elm_widget_api_check(int ver)
429 if (ver != ELM_INTERNAL_API_VERSION)
431 CRITICAL("Elementary widget api versions do not match");
438 elm_widget_add(Evas *evas)
442 obj = evas_object_smart_add(evas, _e_smart);
443 elm_widget_mirrored_set(obj, elm_mirrored_get());
448 elm_widget_del_hook_set(Evas_Object *obj,
449 void (*func)(Evas_Object *obj))
456 elm_widget_del_pre_hook_set(Evas_Object *obj,
457 void (*func)(Evas_Object *obj))
460 sd->del_pre_func = func;
464 elm_widget_focus_hook_set(Evas_Object *obj,
465 void (*func)(Evas_Object *obj))
468 sd->focus_func = func;
472 elm_widget_activate_hook_set(Evas_Object *obj,
473 void (*func)(Evas_Object *obj))
476 sd->activate_func = func;
480 elm_widget_disable_hook_set(Evas_Object *obj,
481 void (*func)(Evas_Object *obj))
484 sd->disable_func = func;
488 elm_widget_theme_hook_set(Evas_Object *obj,
489 void (*func)(Evas_Object *obj))
492 sd->theme_func = func;
496 elm_widget_event_hook_set(Evas_Object *obj,
497 Eina_Bool (*func)(Evas_Object *obj,
499 Evas_Callback_Type type,
503 sd->event_func = func;
507 elm_widget_text_set_hook_set(Evas_Object *obj,
508 Elm_Widget_On_Text_Set_Cb func)
511 sd->on_text_set_func = func;
515 elm_widget_text_get_hook_set(Evas_Object *obj,
516 Elm_Widget_On_Text_Get_Cb func)
519 sd->on_text_get_func = func;
523 elm_widget_content_set_hook_set(Evas_Object *obj,
524 Elm_Widget_On_Content_Set_Cb func)
527 sd->on_content_set_func = func;
531 elm_widget_content_get_hook_set(Evas_Object *obj,
532 Elm_Widget_On_Content_Get_Cb func)
535 sd->on_content_get_func = func;
539 elm_widget_content_unset_hook_set(Evas_Object *obj,
540 Elm_Widget_On_Content_Unset_Cb func)
543 sd->on_content_unset_func = func;
547 elm_widget_changed_hook_set(Evas_Object *obj,
548 void (*func)(Evas_Object *obj))
551 sd->changed_func = func;
555 elm_widget_signal_emit_hook_set(Evas_Object *obj,
556 void (*func)(Evas_Object *obj,
557 const char *emission,
561 sd->signal_func = func;
565 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
566 void (*func)(Evas_Object *obj,
567 const char *emission,
569 Edje_Signal_Cb func_cb,
573 sd->callback_add_func = func;
577 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
578 void (*func)(Evas_Object *obj,
579 const char *emission,
581 Edje_Signal_Cb func_cb,
585 sd->callback_del_func = func;
589 elm_widget_theme(Evas_Object *obj)
597 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
598 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
599 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
600 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
601 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
602 if (sd->theme_func) sd->theme_func(obj);
606 elm_widget_theme_specific(Evas_Object *obj,
614 Elm_Theme *th2, *thdef;
617 thdef = elm_theme_default_get();
622 if (!th2) th2 = thdef;
630 if (th2 == thdef) break;
631 th2 = th2->ref_theme;
632 if (!th2) th2 = thdef;
636 EINA_LIST_FOREACH(sd->subobjs, l, child)
637 elm_widget_theme_specific(child, th, force);
638 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
639 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
640 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
641 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
642 if (sd->theme_func) sd->theme_func(obj);
648 * Set hook to get next object in object focus chain.
650 * @param obj The widget object.
651 * @param func The hook to be used with this widget.
656 elm_widget_focus_next_hook_set(Evas_Object *obj,
657 Eina_Bool (*func)(const Evas_Object *obj,
658 Elm_Focus_Direction dir,
662 sd->focus_next_func = func;
666 * Returns the widget's mirrored mode.
668 * @param obj The widget.
669 * @return mirrored mode of the object.
673 elm_widget_mirrored_get(const Evas_Object *obj)
675 API_ENTRY return EINA_FALSE;
676 return sd->is_mirrored;
680 * Sets the widget's mirrored mode.
682 * @param obj The widget.
683 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
686 elm_widget_mirrored_set(Evas_Object *obj,
690 if (sd->is_mirrored != mirrored)
692 sd->is_mirrored = mirrored;
693 elm_widget_theme(obj);
699 * Resets the mirrored mode from the system mirror mode for widgets that are in
700 * automatic mirroring mode. This function does not call elm_widget_theme.
702 * @param obj The widget.
703 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
706 _elm_widget_mirrored_reload(Evas_Object *obj)
709 Eina_Bool mirrored = elm_mirrored_get();
710 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
712 sd->is_mirrored = mirrored;
717 * Returns the widget's mirrored mode setting.
719 * @param obj The widget.
720 * @return mirrored mode setting of the object.
724 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
726 API_ENTRY return EINA_FALSE;
727 return sd->mirrored_auto_mode;
731 * Sets the widget's mirrored mode setting.
732 * When widget in automatic mode, it follows the system mirrored mode set by
733 * elm_mirrored_set().
734 * @param obj The widget.
735 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
738 elm_widget_mirrored_automatic_set(Evas_Object *obj,
742 if (sd->mirrored_auto_mode != automatic)
744 sd->mirrored_auto_mode = automatic;
748 elm_widget_mirrored_set(obj, elm_mirrored_get());
754 elm_widget_on_focus_hook_set(Evas_Object *obj,
755 void (*func)(void *data,
760 sd->on_focus_func = func;
761 sd->on_focus_data = data;
765 elm_widget_on_change_hook_set(Evas_Object *obj,
766 void (*func)(void *data,
771 sd->on_change_func = func;
772 sd->on_change_data = data;
776 elm_widget_on_show_region_hook_set(Evas_Object *obj,
777 void (*func)(void *data,
782 sd->on_show_region_func = func;
783 sd->on_show_region_data = data;
789 * Set the hook to use to show the focused region.
791 * Whenever a new widget gets focused or it's needed to show the focused
792 * area of the current one, this hook will be called on objects that may
793 * want to move their children into their visible area.
794 * The area given in the hook function is relative to the @p obj widget.
796 * @param obj The widget object
797 * @param func The function to call to show the specified area.
802 elm_widget_focus_region_hook_set(Evas_Object *obj,
803 void (*func)(Evas_Object *obj,
810 sd->focus_region_func = func;
816 * Set the hook to retrieve the focused region of a widget.
818 * This hook will be called by elm_widget_focus_region_get() whenever
819 * it's needed to get the focused area of a widget. The area must be relative
820 * to the widget itself and if no hook is set, it will default to the entire
823 * @param obj The widget object
824 * @param func The function used to retrieve the focus region.
829 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
830 void (*func)(const Evas_Object *obj,
837 sd->on_focus_region_func = func;
841 elm_widget_data_set(Evas_Object *obj,
849 elm_widget_data_get(const Evas_Object *obj)
851 API_ENTRY return NULL;
856 elm_widget_sub_object_add(Evas_Object *obj,
860 double scale, pscale = elm_widget_scale_get(sobj);
861 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
862 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
864 if (_elm_widget_is(sobj))
866 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
869 if (sd2->parent_obj == obj)
872 elm_widget_sub_object_del(sd2->parent_obj, sobj);
873 sd2->parent_obj = obj;
874 sd2->top_win_focused = sd->top_win_focused;
875 if (!sd->child_can_focus && (_is_focusable(sobj)))
876 sd->child_can_focus = EINA_TRUE;
881 void *data = evas_object_data_get(sobj, "elm-parent");
884 if (data == obj) return;
885 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
890 sd->subobjs = eina_list_append(sd->subobjs, sobj);
891 evas_object_data_set(sobj, "elm-parent", obj);
892 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
893 if (_elm_widget_is(sobj))
894 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
895 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
896 scale = elm_widget_scale_get(sobj);
897 th = elm_widget_theme_get(sobj);
898 mirrored = elm_widget_mirrored_get(sobj);
899 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
900 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
904 elm_widget_sub_object_del(Evas_Object *obj,
907 Evas_Object *sobj_parent;
911 sobj_parent = evas_object_data_del(sobj, "elm-parent");
912 if (sobj_parent != obj)
914 static int abort_on_warn = -1;
915 ERR("removing sub object %p from parent %p, "
916 "but elm-parent is different %p!",
917 sobj, obj, sobj_parent);
918 if (EINA_UNLIKELY(abort_on_warn == -1))
920 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
921 else abort_on_warn = 0;
923 if (abort_on_warn == 1) abort();
925 if (_elm_widget_is(sobj))
927 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
930 sd2->parent_obj = NULL;
931 if (sd2->resize_obj == sobj)
932 sd2->resize_obj = NULL;
934 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
937 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
938 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
939 if ((sd->child_can_focus) && (_is_focusable(sobj)))
943 sd->child_can_focus = EINA_FALSE;
944 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
946 if (_is_focusable(subobj))
948 sd->child_can_focus = EINA_TRUE;
955 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
956 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
958 if (_elm_widget_is(sobj))
959 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
961 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
965 elm_widget_resize_object_set(Evas_Object *obj,
969 // orphan previous resize obj
972 evas_object_clip_unset(sd->resize_obj);
973 evas_object_data_del(sd->resize_obj, "elm-parent");
974 if (_elm_widget_is(sd->resize_obj))
976 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
977 if (sd2) sd2->parent_obj = NULL;
978 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
981 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
983 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
984 _sub_obj_mouse_down, sd);
985 evas_object_smart_member_del(sd->resize_obj);
986 if (_elm_widget_is(sd->resize_obj))
988 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
991 // orphan new resize obj
994 evas_object_data_del(sobj, "elm-parent");
995 if (_elm_widget_is(sobj))
997 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
998 if (sd2) sd2->parent_obj = NULL;
999 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1002 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1004 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1005 _sub_obj_mouse_down, sd);
1006 evas_object_smart_member_del(sobj);
1007 if (_elm_widget_is(sobj))
1009 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1012 // set the resize obj up
1013 sd->resize_obj = sobj;
1016 if (_elm_widget_is(sd->resize_obj))
1018 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1021 sd2->parent_obj = obj;
1022 sd2->top_win_focused = sd->top_win_focused;
1024 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1027 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1028 evas_object_smart_member_add(sobj, obj);
1029 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1031 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1032 _sub_obj_mouse_down, sd);
1033 _smart_reconfigure(sd);
1034 evas_object_data_set(sobj, "elm-parent", obj);
1035 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1036 if (_elm_widget_is(sobj))
1038 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1044 elm_widget_hover_object_set(Evas_Object *obj,
1050 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1053 sd->hover_obj = sobj;
1056 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1058 _smart_reconfigure(sd);
1063 elm_widget_can_focus_set(Evas_Object *obj,
1064 Eina_Bool can_focus)
1067 sd->can_focus = can_focus;
1070 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1072 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1073 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1075 (void *)(long)EVAS_CALLBACK_KEY_UP);
1076 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1078 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1082 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1084 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1086 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1092 elm_widget_can_focus_get(const Evas_Object *obj)
1094 API_ENTRY return EINA_FALSE;
1095 return sd->can_focus;
1099 elm_widget_child_can_focus_get(const Evas_Object *obj)
1101 API_ENTRY return EINA_FALSE;
1102 return sd->child_can_focus;
1108 * This API makes the widget object and its children to be unfocusable.
1110 * This API can be helpful for an object to be deleted.
1111 * When an object will be deleted soon, it and its children may not
1112 * want to get focus (by focus reverting or by other focus controls).
1113 * Then, just use this API before deleting.
1115 * @param obj The widget root of sub-tree
1116 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1121 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1122 Eina_Bool tree_unfocusable)
1126 if (sd->tree_unfocusable == tree_unfocusable) return;
1127 sd->tree_unfocusable = !!tree_unfocusable;
1128 elm_widget_focus_tree_unfocusable_handle(obj);
1134 * This returns true, if the object sub-tree is unfocusable.
1136 * @param obj The widget root of sub-tree
1137 * @return EINA_TRUE if the object sub-tree is unfocusable
1142 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1144 API_ENTRY return EINA_FALSE;
1145 return sd->tree_unfocusable;
1149 elm_widget_highlight_ignore_set(Evas_Object *obj,
1153 sd->highlight_ignore = !!ignore;
1157 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1159 API_ENTRY return EINA_FALSE;
1160 return sd->highlight_ignore;
1164 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1165 Eina_Bool highlight)
1168 sd->highlight_in_theme = !!highlight;
1169 /* FIXME: if focused, it should switch from one mode to the other */
1173 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1175 API_ENTRY return EINA_FALSE;
1176 return sd->highlight_in_theme;
1180 elm_widget_focus_get(const Evas_Object *obj)
1182 API_ENTRY return EINA_FALSE;
1187 elm_widget_focused_object_get(const Evas_Object *obj)
1189 const Evas_Object *subobj;
1191 API_ENTRY return NULL;
1193 if (!sd->focused) return NULL;
1194 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1196 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1197 if (fobj) return fobj;
1199 return (Evas_Object *)obj;
1203 elm_widget_top_get(const Evas_Object *obj)
1205 API_ENTRY return NULL;
1206 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1207 return (Evas_Object *)obj;
1211 elm_widget_is(const Evas_Object *obj)
1213 return _elm_widget_is(obj);
1217 elm_widget_parent_widget_get(const Evas_Object *obj)
1219 Evas_Object *parent;
1221 if (_elm_widget_is(obj))
1223 Smart_Data *sd = evas_object_smart_data_get(obj);
1224 if (!sd) return NULL;
1225 parent = sd->parent_obj;
1229 parent = evas_object_data_get(obj, "elm-parent");
1230 if (!parent) parent = evas_object_smart_parent_get(obj);
1235 Evas_Object *elm_parent;
1236 if (_elm_widget_is(parent)) break;
1237 elm_parent = evas_object_data_get(parent, "elm-parent");
1238 if (elm_parent) parent = elm_parent;
1239 else parent = evas_object_smart_parent_get(parent);
1245 elm_widget_event_callback_add(Evas_Object *obj,
1250 EINA_SAFETY_ON_NULL_RETURN(func);
1251 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1254 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1258 elm_widget_event_callback_del(Evas_Object *obj,
1262 API_ENTRY return NULL;
1263 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1265 Elm_Event_Cb_Data *ecd;
1266 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1267 if ((ecd->func == func) && (ecd->data == data))
1270 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1271 return (void *)data;
1277 elm_widget_event_propagate(Evas_Object *obj,
1278 Evas_Callback_Type type,
1280 Evas_Event_Flags *event_flags)
1282 API_ENTRY return EINA_FALSE; //TODO reduce.
1283 if (!_elm_widget_is(obj)) return EINA_FALSE;
1284 Evas_Object *parent = obj;
1285 Elm_Event_Cb_Data *ecd;
1286 Eina_List *l, *l_prev;
1289 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1291 sd = evas_object_smart_data_get(parent);
1292 if ((!sd) || (!_elm_widget_is(obj)))
1293 return EINA_FALSE; //Not Elm Widget
1295 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1298 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1300 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1301 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1304 parent = sd->parent_obj;
1313 * Set custom focus chain.
1315 * This function i set one new and overwrite any previous custom focus chain
1316 * with the list of objects. The previous list will be deleted and this list
1317 * will be managed. After setted, don't modity it.
1319 * @note On focus cycle, only will be evaluated children of this container.
1321 * @param obj The container widget
1322 * @param objs Chain of objects to pass focus
1326 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1330 if (!sd->focus_next_func)
1333 elm_widget_focus_custom_chain_unset(obj);
1338 EINA_LIST_FOREACH(objs, l, o)
1340 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1341 _elm_object_focus_chain_del_cb, sd);
1344 sd->focus_chain = objs;
1350 * Get custom focus chain
1352 * @param obj The container widget
1355 EAPI const Eina_List *
1356 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1358 API_ENTRY return NULL;
1359 return (const Eina_List *)sd->focus_chain;
1365 * Unset custom focus chain
1367 * @param obj The container widget
1371 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1374 Eina_List *l, *l_next;
1377 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1379 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1380 _elm_object_focus_chain_del_cb, sd);
1381 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1388 * Append object to custom focus chain.
1390 * @note If relative_child equal to NULL or not in custom chain, the object
1391 * will be added in end.
1393 * @note On focus cycle, only will be evaluated children of this container.
1395 * @param obj The container widget
1396 * @param child The child to be added in custom chain
1397 * @param relative_child The relative object to position the child
1401 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1403 Evas_Object *relative_child)
1406 EINA_SAFETY_ON_NULL_RETURN(child);
1407 if (!sd->focus_next_func)
1410 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1411 _elm_object_focus_chain_del_cb, sd);
1413 if (!relative_child)
1415 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1419 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1426 * Prepend object to custom focus chain.
1428 * @note If relative_child equal to NULL or not in custom chain, the object
1429 * will be added in begin.
1431 * @note On focus cycle, only will be evaluated children of this container.
1433 * @param obj The container widget
1434 * @param child The child to be added in custom chain
1435 * @param relative_child The relative object to position the child
1439 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1441 Evas_Object *relative_child)
1444 EINA_SAFETY_ON_NULL_RETURN(child);
1445 if (!sd->focus_next_func)
1448 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1449 _elm_object_focus_chain_del_cb, sd);
1451 if (!relative_child)
1453 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1457 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1464 * Give focus to next object in object tree.
1466 * Give focus to next object in focus chain of one object sub-tree.
1467 * If the last object of chain already have focus, the focus will go to the
1468 * first object of chain.
1470 * @param obj The widget root of sub-tree
1471 * @param dir Direction to cycle the focus
1476 elm_widget_focus_cycle(Evas_Object *obj,
1477 Elm_Focus_Direction dir)
1479 Evas_Object *target = NULL;
1480 if (!_elm_widget_is(obj))
1482 elm_widget_focus_next_get(obj, dir, &target);
1484 elm_widget_focus_steal(target);
1490 * Give focus to near object in one direction.
1492 * Give focus to near object in direction of one object.
1493 * If none focusable object in given direction, the focus will not change.
1495 * @param obj The reference widget
1496 * @param x Horizontal component of direction to focus
1497 * @param y Vertical component of direction to focus
1502 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1512 * Get next object in focus chain of object tree.
1514 * Get next object in focus chain of one object sub-tree.
1515 * Return the next object by reference. If don't have any candidate to receive
1516 * focus before chain end, the first candidate will be returned.
1518 * @param obj The widget root of sub-tree
1519 * @param dir Direction os focus chain
1520 * @param next The next object in focus chain
1521 * @return EINA_TRUE if don't need focus chain restart/loop back
1522 * to use 'next' obj.
1527 elm_widget_focus_next_get(const Evas_Object *obj,
1528 Elm_Focus_Direction dir,
1535 API_ENTRY return EINA_FALSE;
1537 /* Ignore if disabled */
1538 if ((!evas_object_visible_get(obj))
1539 || (elm_widget_disabled_get(obj))
1540 || (elm_widget_tree_unfocusable_get(obj)))
1544 if (sd->focus_next_func)
1545 return sd->focus_next_func(obj, dir, next);
1547 if (!elm_widget_can_focus_get(obj))
1551 *next = (Evas_Object *)obj;
1552 return !elm_widget_focus_get(obj);
1558 * Get next object in focus chain of object tree in list.
1560 * Get next object in focus chain of one object sub-tree ordered by one list.
1561 * Return the next object by reference. If don't have any candidate to receive
1562 * focus before list end, the first candidate will be returned.
1564 * @param obj The widget root of sub-tree
1565 * @param dir Direction os focus chain
1566 * @param items list with ordered objects
1567 * @param list_data_get function to get the object from one item of list
1568 * @param next The next object in focus chain
1569 * @return EINA_TRUE if don't need focus chain restart/loop back
1570 * to use 'next' obj.
1575 elm_widget_focus_list_next_get(const Evas_Object *obj,
1576 const Eina_List *items,
1577 void *(*list_data_get)(const Eina_List * list),
1578 Elm_Focus_Direction dir,
1581 Eina_List *(*list_next)(const Eina_List * list);
1587 if (!_elm_widget_is(obj))
1594 if (dir == ELM_FOCUS_PREVIOUS)
1596 items = eina_list_last(items);
1597 list_next = eina_list_prev;
1599 else if (dir == ELM_FOCUS_NEXT)
1600 list_next = eina_list_next;
1604 const Eina_List *l = items;
1606 /* Recovery last focused sub item */
1607 if (elm_widget_focus_get(obj))
1608 for (; l; l = list_next(l))
1610 Evas_Object *cur = list_data_get(l);
1611 if (elm_widget_focus_get(cur)) break;
1614 const Eina_List *start = l;
1615 Evas_Object *to_focus = NULL;
1617 /* Interate sub items */
1618 /* Go to end of list */
1619 for (; l; l = list_next(l))
1621 Evas_Object *tmp = NULL;
1622 Evas_Object *cur = list_data_get(l);
1624 if (elm_widget_parent_get(cur) != obj)
1627 /* Try Focus cycle in subitem */
1628 if (elm_widget_focus_next_get(cur, dir, &tmp))
1633 else if ((tmp) && (!to_focus))
1639 /* Get First possible */
1640 for (; l != start; l = list_next(l))
1642 Evas_Object *tmp = NULL;
1643 Evas_Object *cur = list_data_get(l);
1645 if (elm_widget_parent_get(cur) != obj)
1648 /* Try Focus cycle in subitem */
1649 elm_widget_focus_next_get(cur, dir, &tmp);
1662 elm_widget_signal_emit(Evas_Object *obj,
1663 const char *emission,
1667 if (!sd->signal_func) return;
1668 sd->signal_func(obj, emission, source);
1672 _edje_signal_callback(void *data,
1673 Evas_Object *obj __UNUSED__,
1674 const char *emission,
1677 Edje_Signal_Data *esd = data;
1678 esd->func(esd->data, esd->obj, emission, source);
1682 elm_widget_signal_callback_add(Evas_Object *obj,
1683 const char *emission,
1685 Edje_Signal_Cb func,
1688 Edje_Signal_Data *esd;
1690 if (!sd->callback_add_func) return;
1691 EINA_SAFETY_ON_NULL_RETURN(func);
1693 esd = ELM_NEW(Edje_Signal_Data);
1698 esd->emission = eina_stringshare_add(emission);
1699 esd->source = eina_stringshare_add(source);
1701 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1702 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1706 elm_widget_signal_callback_del(Evas_Object *obj,
1707 const char *emission,
1709 Edje_Signal_Cb func)
1711 Edje_Signal_Data *esd;
1714 API_ENTRY return NULL;
1715 if (!sd->callback_del_func) return NULL;
1717 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1719 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1720 (!strcmp(esd->source, source)))
1722 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1723 eina_stringshare_del(esd->emission);
1724 eina_stringshare_del(esd->source);
1730 sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1735 elm_widget_focus_set(Evas_Object *obj,
1742 sd->focus_order = focus_order;
1743 sd->focused = EINA_TRUE;
1744 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1748 sd->focus_func(obj);
1755 if ((_is_focusable(sd->resize_obj)) &&
1756 (!elm_widget_disabled_get(sd->resize_obj)))
1758 elm_widget_focus_set(sd->resize_obj, first);
1764 EINA_LIST_FOREACH(sd->subobjs, l, child)
1766 if ((_is_focusable(child)) &&
1767 (!elm_widget_disabled_get(child)))
1769 elm_widget_focus_set(child, first);
1779 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1781 if ((_is_focusable(child)) &&
1782 (!elm_widget_disabled_get(child)))
1784 elm_widget_focus_set(child, first);
1790 if ((_is_focusable(sd->resize_obj)) &&
1791 (!elm_widget_disabled_get(sd->resize_obj)))
1793 elm_widget_focus_set(sd->resize_obj, first);
1801 elm_widget_parent_get(const Evas_Object *obj)
1803 API_ENTRY return NULL;
1804 return sd->parent_obj;
1808 elm_widget_focused_object_clear(Evas_Object *obj)
1811 if (!sd->focused) return;
1812 if (elm_widget_focus_get(sd->resize_obj))
1813 elm_widget_focused_object_clear(sd->resize_obj);
1818 EINA_LIST_FOREACH(sd->subobjs, l, child)
1820 if (elm_widget_focus_get(child))
1822 elm_widget_focused_object_clear(child);
1827 sd->focused = EINA_FALSE;
1828 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1829 if (sd->focus_func) sd->focus_func(obj);
1833 elm_widget_focus_steal(Evas_Object *obj)
1835 Evas_Object *parent, *o;
1838 if (sd->focused) return;
1839 if (sd->disabled) return;
1840 if (!sd->can_focus) return;
1841 if (sd->tree_unfocusable) return;
1845 o = elm_widget_parent_get(parent);
1847 sd = evas_object_smart_data_get(o);
1848 if (sd->disabled || sd->tree_unfocusable) return;
1849 if (sd->focused) break;
1852 if (!elm_widget_parent_get(parent))
1853 elm_widget_focused_object_clear(parent);
1856 parent = elm_widget_parent_get(parent);
1857 sd = evas_object_smart_data_get(parent);
1858 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1859 elm_widget_focused_object_clear(sd->resize_obj);
1864 EINA_LIST_FOREACH(sd->subobjs, l, child)
1866 if (elm_widget_focus_get(child))
1868 elm_widget_focused_object_clear(child);
1879 elm_widget_focus_restore(Evas_Object *obj)
1881 Evas_Object *newest = NULL;
1882 unsigned int newest_focus_order = 0;
1885 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1888 elm_object_unfocus(newest);
1889 elm_object_focus(newest);
1894 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1900 if (sd->top_win_focused == top_win_focused) return;
1902 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1903 EINA_LIST_FOREACH(sd->subobjs, l, child)
1905 _elm_widget_top_win_focused_set(child, top_win_focused);
1907 sd->top_win_focused = top_win_focused;
1911 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1913 API_ENTRY return EINA_FALSE;
1914 return sd->top_win_focused;
1918 elm_widget_activate(Evas_Object *obj)
1921 elm_widget_change(obj);
1922 if (sd->activate_func) sd->activate_func(obj);
1926 elm_widget_change(Evas_Object *obj)
1929 elm_widget_change(elm_widget_parent_get(obj));
1930 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
1934 elm_widget_disabled_set(Evas_Object *obj,
1939 if (sd->disabled == disabled) return;
1940 sd->disabled = !!disabled;
1941 elm_widget_focus_disabled_handle(obj);
1942 if (sd->disable_func) sd->disable_func(obj);
1946 elm_widget_disabled_get(const Evas_Object *obj)
1949 return sd->disabled;
1953 elm_widget_show_region_set(Evas_Object *obj,
1958 Eina_Bool forceshow)
1960 Evas_Object *parent_obj, *child_obj;
1961 Evas_Coord px, py, cx, cy;
1964 if (!forceshow && (x == sd->rx) && (y == sd->ry)
1965 && (w == sd->rw) && (h == sd->rh)) return;
1970 if (sd->on_show_region_func)
1971 sd->on_show_region_func(sd->on_show_region_data, obj);
1975 parent_obj = sd->parent_obj;
1976 child_obj = sd->obj;
1977 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
1978 sd = evas_object_smart_data_get(parent_obj);
1981 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
1982 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
1991 if (sd->on_show_region_func)
1993 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2000 elm_widget_show_region_get(const Evas_Object *obj,
2016 * Get the focus region of the given widget.
2018 * The focus region is the area of a widget that should brought into the
2019 * visible area when the widget is focused. Mostly used to show the part of
2020 * an entry where the cursor is, for example. The area returned is relative
2021 * to the object @p obj.
2022 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2023 * function will return the full size of the object.
2025 * @param obj The widget object
2026 * @param x Where to store the x coordinate of the area
2027 * @param y Where to store the y coordinate of the area
2028 * @param w Where to store the width of the area
2029 * @param h Where to store the height of the area
2034 elm_widget_focus_region_get(const Evas_Object *obj,
2044 sd = evas_object_smart_data_get(obj);
2045 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2047 evas_object_geometry_get(obj, NULL, NULL, w, h);
2052 sd->on_focus_region_func(obj, x, y, w, h);
2056 elm_widget_scroll_hold_push(Evas_Object *obj)
2060 if (sd->scroll_hold == 1)
2061 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2062 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2063 // FIXME: on delete/reparent hold pop
2067 elm_widget_scroll_hold_pop(Evas_Object *obj)
2071 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2072 if (!sd->scroll_hold)
2073 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2074 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2078 elm_widget_scroll_hold_get(const Evas_Object *obj)
2081 return sd->scroll_hold;
2085 elm_widget_scroll_freeze_push(Evas_Object *obj)
2088 sd->scroll_freeze++;
2089 if (sd->scroll_freeze == 1)
2090 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2091 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2092 // FIXME: on delete/reparent freeze pop
2096 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2099 sd->scroll_freeze--;
2100 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2101 if (!sd->scroll_freeze)
2102 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2103 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2107 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2110 return sd->scroll_freeze;
2114 elm_widget_scale_set(Evas_Object *obj,
2118 if (scale <= 0.0) scale = 0.0;
2119 if (sd->scale != scale)
2122 elm_widget_theme(obj);
2127 elm_widget_scale_get(const Evas_Object *obj)
2129 API_ENTRY return 1.0;
2130 // FIXME: save walking up the tree by storing/caching parent scale
2131 if (sd->scale == 0.0)
2134 return elm_widget_scale_get(sd->parent_obj);
2142 elm_widget_theme_set(Evas_Object *obj,
2146 if (sd->theme != th)
2148 if (sd->theme) elm_theme_free(sd->theme);
2151 elm_widget_theme(obj);
2156 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2160 if (!sd->on_text_set_func)
2163 sd->on_text_set_func(obj, item, label);
2167 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2169 API_ENTRY return NULL;
2171 if (!sd->on_text_get_func)
2174 return sd->on_text_get_func(obj, item);
2178 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2182 if (!sd->on_content_set_func) return;
2183 sd->on_content_set_func(obj, part, content);
2187 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2189 API_ENTRY return NULL;
2191 if (!sd->on_content_get_func) return NULL;
2192 return sd->on_content_get_func(obj, part);
2196 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2198 API_ENTRY return NULL;
2200 if (!sd->on_content_unset_func) return NULL;
2201 return sd->on_content_unset_func(obj, part);
2205 elm_widget_theme_get(const Evas_Object *obj)
2207 API_ENTRY return NULL;
2211 return elm_widget_theme_get(sd->parent_obj);
2219 elm_widget_style_set(Evas_Object *obj,
2224 if (eina_stringshare_replace(&sd->style, style))
2225 elm_widget_theme(obj);
2229 elm_widget_style_get(const Evas_Object *obj)
2231 API_ENTRY return NULL;
2232 if (sd->style) return sd->style;
2237 elm_widget_type_set(Evas_Object *obj,
2241 eina_stringshare_replace(&sd->type, type);
2245 elm_widget_type_get(const Evas_Object *obj)
2247 API_ENTRY return NULL;
2248 if (sd->type) return sd->type;
2253 elm_widget_tooltip_add(Evas_Object *obj,
2257 sd->tooltips = eina_list_append(sd->tooltips, tt);
2261 elm_widget_tooltip_del(Evas_Object *obj,
2265 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2269 elm_widget_cursor_add(Evas_Object *obj,
2273 sd->cursors = eina_list_append(sd->cursors, cur);
2277 elm_widget_cursor_del(Evas_Object *obj,
2281 sd->cursors = eina_list_remove(sd->cursors, cur);
2285 elm_widget_drag_lock_x_set(Evas_Object *obj,
2289 if (sd->drag_x_locked == lock) return;
2290 sd->drag_x_locked = lock;
2291 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2292 else _propagate_x_drag_lock(obj, -1);
2296 elm_widget_drag_lock_y_set(Evas_Object *obj,
2300 if (sd->drag_y_locked == lock) return;
2301 sd->drag_y_locked = lock;
2302 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2303 else _propagate_y_drag_lock(obj, -1);
2307 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2309 API_ENTRY return EINA_FALSE;
2310 return sd->drag_x_locked;
2314 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2316 API_ENTRY return EINA_FALSE;
2317 return sd->drag_y_locked;
2321 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2324 return sd->child_drag_x_locked;
2328 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2331 return sd->child_drag_y_locked;
2335 elm_widget_theme_object_set(Evas_Object *obj,
2338 const char *welement,
2341 API_ENTRY return EINA_FALSE;
2342 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2346 elm_widget_type_check(const Evas_Object *obj,
2349 const char *provided, *expected = "(unknown)";
2350 static int abort_on_warn = -1;
2351 provided = elm_widget_type_get(obj);
2352 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2353 if (type) expected = type;
2354 if ((!provided) || (!provided[0]))
2356 provided = evas_object_type_get(obj);
2357 if ((!provided) || (!provided[0]))
2358 provided = "(unknown)";
2360 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2361 if (abort_on_warn == -1)
2363 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2364 else abort_on_warn = 0;
2366 if (abort_on_warn == 1) abort();
2373 * Split string in words
2375 * @param str Source string
2376 * @return List of const words
2378 * @see elm_widget_stringlist_free()
2382 elm_widget_stringlist_get(const char *str)
2384 Eina_List *list = NULL;
2386 if (!str) return NULL;
2387 for (b = s = str; 1; s++)
2389 if ((*s == ' ') || (!*s))
2391 char *t = malloc(s - b + 1);
2394 strncpy(t, b, s - b);
2396 list = eina_list_append(list, eina_stringshare_add(t));
2407 elm_widget_stringlist_free(Eina_List *list)
2410 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2414 elm_widget_focus_hide_handle(Evas_Object *obj)
2416 _if_focused_revert(obj, EINA_TRUE);
2420 elm_widget_focus_mouse_down_handle(Evas_Object *obj)
2422 Evas_Object *o = obj;
2425 if (_elm_widget_is(o)) break;
2426 o = evas_object_smart_parent_get(o);
2430 if (!_is_focusable(o)) return;
2431 elm_widget_focus_steal(o);
2435 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2439 if (!elm_widget_parent_get(obj))
2440 elm_widget_focused_object_clear(obj);
2442 _if_focused_revert(obj, EINA_TRUE);
2446 elm_widget_focus_disabled_handle(Evas_Object *obj)
2450 elm_widget_focus_tree_unfocusable_handle(obj);
2456 * Allocate a new Elm_Widget_Item-derived structure.
2458 * The goal of this structure is to provide common ground for actions
2459 * that a widget item have, such as the owner widget, callback to
2460 * notify deletion, data pointer and maybe more.
2462 * @param widget the owner widget that holds this item, must be an elm_widget!
2463 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2464 * be used to allocate memory.
2466 * @return allocated memory that is already zeroed out, or NULL on errors.
2468 * @see elm_widget_item_new() convenience macro.
2469 * @see elm_widget_item_del() to release memory.
2472 EAPI Elm_Widget_Item *
2473 _elm_widget_item_new(Evas_Object *widget,
2476 if (!_elm_widget_is(widget))
2479 Elm_Widget_Item *item;
2481 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2482 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2484 item = calloc(1, alloc_size);
2485 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2487 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2488 item->widget = widget;
2495 * Releases widget item memory, calling back del_cb() if it exists.
2497 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2498 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2499 * this function and then unset it, thus being useful for 2 step
2500 * cleanup whenever the del_cb may use any of the data that must be
2501 * deleted from item.
2503 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2506 * @param item a valid #Elm_Widget_Item to be deleted.
2507 * @see elm_widget_item_del() convenience macro.
2511 _elm_widget_item_del(Elm_Widget_Item *item)
2513 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2516 item->del_cb((void *)item->data, item->widget, item);
2519 evas_object_del(item->view);
2521 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2528 * Notify object will be deleted without actually deleting it.
2530 * This function will callback Elm_Widget_Item::del_cb if it is set
2531 * and then unset it so it is not called twice (ie: from
2532 * elm_widget_item_del()).
2534 * @param item a valid #Elm_Widget_Item to be notified
2535 * @see elm_widget_item_pre_notify_del() convenience macro.
2539 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2541 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2542 if (!item->del_cb) return;
2543 item->del_cb((void *)item->data, item->widget, item);
2544 item->del_cb = NULL;
2550 * Set the function to notify when item is being deleted.
2552 * This function will complain if there was a callback set already,
2553 * however it will set the new one.
2555 * The callback will be called from elm_widget_item_pre_notify_del()
2556 * or elm_widget_item_del() will be called with:
2557 * - data: the Elm_Widget_Item::data value.
2558 * - obj: the Elm_Widget_Item::widget evas object.
2559 * - event_info: the item being deleted.
2561 * @param item a valid #Elm_Widget_Item to be notified
2562 * @see elm_widget_item_del_cb_set() convenience macro.
2566 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2567 Evas_Smart_Cb del_cb)
2569 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2571 if ((item->del_cb) && (item->del_cb != del_cb))
2572 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2573 item->del_cb, item, del_cb);
2575 item->del_cb = del_cb;
2581 * Set user-data in this item.
2583 * User data may be used to identify this item or just store any
2584 * application data. It is automatically given as the first parameter
2585 * of the deletion notify callback.
2587 * @param item a valid #Elm_Widget_Item to store data in.
2588 * @param data user data to store.
2589 * @see elm_widget_item_del_cb_set() convenience macro.
2593 _elm_widget_item_data_set(Elm_Widget_Item *item,
2596 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2597 if ((item->data) && (item->data != data))
2598 DBG("Replacing item %p data %p with %p", item, item->data, data);
2605 * Retrieves user-data of this item.
2607 * @param item a valid #Elm_Widget_Item to get data from.
2608 * @see elm_widget_item_data_set()
2612 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2614 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2615 return (void *)item->data;
2618 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2620 struct _Elm_Widget_Item_Tooltip
2622 Elm_Widget_Item *item;
2623 Elm_Tooltip_Item_Content_Cb func;
2624 Evas_Smart_Cb del_cb;
2628 static Evas_Object *
2629 _elm_widget_item_tooltip_label_create(void *data,
2631 void *item __UNUSED__)
2633 Evas_Object *label = elm_label_add(obj);
2636 elm_object_style_set(label, "tooltip");
2637 elm_object_text_set(label, data);
2642 _elm_widget_item_tooltip_label_del_cb(void *data,
2643 Evas_Object *obj __UNUSED__,
2644 void *event_info __UNUSED__)
2646 eina_stringshare_del(data);
2652 * Set the text to be shown in the widget item.
2654 * @param item Target item
2655 * @param text The text to set in the content
2657 * Setup the text as tooltip to object. The item can have only one tooltip,
2658 * so any previous tooltip data is removed.
2663 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2666 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2667 EINA_SAFETY_ON_NULL_RETURN(text);
2669 text = eina_stringshare_add(text);
2670 _elm_widget_item_tooltip_content_cb_set
2671 (item, _elm_widget_item_tooltip_label_create, text,
2672 _elm_widget_item_tooltip_label_del_cb);
2675 static Evas_Object *
2676 _elm_widget_item_tooltip_create(void *data,
2679 Elm_Widget_Item_Tooltip *wit = data;
2680 return wit->func((void *)wit->data, obj, wit->item);
2684 _elm_widget_item_tooltip_del_cb(void *data,
2686 void *event_info __UNUSED__)
2688 Elm_Widget_Item_Tooltip *wit = data;
2689 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2696 * Set the content to be shown in the tooltip item
2698 * Setup the tooltip to item. The item can have only one tooltip,
2699 * so any previous tooltip data is removed. @p func(with @p data) will
2700 * be called every time that need show the tooltip and it should
2701 * return a valid Evas_Object. This object is then managed fully by
2702 * tooltip system and is deleted when the tooltip is gone.
2704 * @param item the widget item being attached a tooltip.
2705 * @param func the function used to create the tooltip contents.
2706 * @param data what to provide to @a func as callback data/context.
2707 * @param del_cb called when data is not needed anymore, either when
2708 * another callback replaces @func, the tooltip is unset with
2709 * elm_widget_item_tooltip_unset() or the owner @a item
2710 * dies. This callback receives as the first parameter the
2711 * given @a data, and @c event_info is the item.
2716 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2717 Elm_Tooltip_Item_Content_Cb func,
2719 Evas_Smart_Cb del_cb)
2721 Elm_Widget_Item_Tooltip *wit;
2723 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2727 _elm_widget_item_tooltip_unset(item);
2731 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2732 if (!wit) goto error;
2736 wit->del_cb = del_cb;
2738 elm_object_sub_tooltip_content_cb_set
2739 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2740 _elm_widget_item_tooltip_del_cb);
2745 if (del_cb) del_cb((void *)data, NULL, item);
2748 if (del_cb) del_cb((void *)data, item->widget, item);
2754 * Unset tooltip from item
2756 * @param item widget item to remove previously set tooltip.
2758 * Remove tooltip from item. The callback provided as del_cb to
2759 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2760 * it is not used anymore.
2762 * @see elm_widget_item_tooltip_content_cb_set()
2767 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2769 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2770 elm_object_tooltip_unset(item->view);
2776 * Sets a different style for this item tooltip.
2778 * @note before you set a style you should define a tooltip with
2779 * elm_widget_item_tooltip_content_cb_set() or
2780 * elm_widget_item_tooltip_text_set()
2782 * @param item widget item with tooltip already set.
2783 * @param style the theme style to use (default, transparent, ...)
2788 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2791 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2792 elm_object_tooltip_style_set(item->view, style);
2798 * Get the style for this item tooltip.
2800 * @param item widget item with tooltip already set.
2801 * @return style the theme style in use, defaults to "default". If the
2802 * object does not have a tooltip set, then NULL is returned.
2807 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2809 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2810 return elm_object_tooltip_style_get(item->view);
2814 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2817 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2818 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2822 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2824 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2825 return elm_object_cursor_get(item->view);
2829 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2831 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2832 elm_object_cursor_unset(item->view);
2838 * Sets a different style for this item cursor.
2840 * @note before you set a style you should define a cursor with
2841 * elm_widget_item_cursor_set()
2843 * @param item widget item with cursor already set.
2844 * @param style the theme style to use (default, transparent, ...)
2849 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2852 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2853 elm_object_cursor_style_set(item->view, style);
2859 * Get the style for this item cursor.
2861 * @param item widget item with cursor already set.
2862 * @return style the theme style in use, defaults to "default". If the
2863 * object does not have a cursor set, then NULL is returned.
2868 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2870 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2871 return elm_object_cursor_style_get(item->view);
2877 * Set if the cursor set should be searched on the theme or should use
2878 * the provided by the engine, only.
2880 * @note before you set if should look on theme you should define a cursor
2881 * with elm_object_cursor_set(). By default it will only look for cursors
2882 * provided by the engine.
2884 * @param item widget item with cursor already set.
2885 * @param engine_only boolean to define it cursors should be looked only
2886 * between the provided by the engine or searched on widget's theme as well.
2891 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
2892 Eina_Bool engine_only)
2894 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2895 elm_object_cursor_engine_only_set(item->view, engine_only);
2901 * Get the cursor engine only usage for this item cursor.
2903 * @param item widget item with cursor already set.
2904 * @return engine_only boolean to define it cursors should be looked only
2905 * between the provided by the engine or searched on widget's theme as well. If
2906 * the object does not have a cursor set, then EINA_FALSE is returned.
2911 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
2913 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2914 return elm_object_cursor_engine_only_get(item->view);
2917 // smart object funcs
2919 _smart_reconfigure(Smart_Data *sd)
2923 evas_object_move(sd->resize_obj, sd->x, sd->y);
2924 evas_object_resize(sd->resize_obj, sd->w, sd->h);
2928 evas_object_move(sd->hover_obj, sd->x, sd->y);
2929 evas_object_resize(sd->hover_obj, sd->w, sd->h);
2934 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
2936 Evas_Object *content)
2938 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2939 if (!item->on_content_set_func) return;
2940 item->on_content_set_func((Elm_Object_Item *) item, part, content);
2944 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
2947 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2948 if (!item->on_content_get_func) return NULL;
2949 return item->on_content_get_func((Elm_Object_Item *) item, part);
2953 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
2956 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2957 if (!item->on_content_unset_func) return NULL;
2958 return item->on_content_unset_func((Elm_Object_Item *) item, part);
2962 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
2966 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2967 if (!item->on_text_set_func) return;
2968 item->on_text_set_func((Elm_Object_Item *) item, part, label);
2972 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
2975 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2976 if (!item->on_text_get_func) return NULL;
2977 return item->on_text_get_func((Elm_Object_Item *) item, part);
2981 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
2982 Elm_Widget_On_Content_Set_Cb func)
2984 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2985 item->on_content_set_func = func;
2989 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
2990 Elm_Widget_On_Content_Get_Cb func)
2992 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2993 item->on_content_get_func = func;
2997 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
2998 Elm_Widget_On_Content_Unset_Cb func)
3000 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3001 item->on_content_unset_func = func;
3005 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3006 Elm_Widget_On_Text_Set_Cb func)
3008 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3009 item->on_text_set_func = func;
3013 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3014 Elm_Widget_On_Text_Get_Cb func)
3016 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3017 item->on_text_get_func = func;
3021 _smart_add(Evas_Object *obj)
3025 sd = calloc(1, sizeof(Smart_Data));
3028 sd->x = sd->y = sd->w = sd->h = 0;
3030 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3031 evas_object_smart_data_set(obj, sd);
3034 static Evas_Object *
3035 _newest_focus_order_get(Evas_Object *obj,
3036 unsigned int *newest_focus_order,
3037 Eina_Bool can_focus_only)
3040 Evas_Object *child, *ret, *best;
3042 API_ENTRY return NULL;
3044 if (!evas_object_visible_get(obj)
3045 || (elm_widget_disabled_get(obj))
3046 || (elm_widget_tree_unfocusable_get(obj)))
3050 if (*newest_focus_order < sd->focus_order)
3052 *newest_focus_order = sd->focus_order;
3055 EINA_LIST_FOREACH(sd->subobjs, l, child)
3057 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3063 if ((!best) || (!elm_widget_can_focus_get(best)))
3070 _if_focused_revert(Evas_Object *obj,
3071 Eina_Bool can_focus_only)
3074 Evas_Object *newest = NULL;
3075 unsigned int newest_focus_order = 0;
3079 if (!sd->focused) return;
3080 if (!sd->parent_obj) return;
3082 top = elm_widget_top_get(sd->parent_obj);
3085 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3088 elm_object_unfocus(newest);
3089 elm_object_focus(newest);
3095 _smart_del(Evas_Object *obj)
3098 Edje_Signal_Data *esd;
3102 if (sd->del_pre_func) sd->del_pre_func(obj);
3105 sobj = sd->resize_obj;
3106 sd->resize_obj = NULL;
3107 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3108 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3109 evas_object_del(sobj);
3113 sobj = sd->hover_obj;
3114 sd->hover_obj = NULL;
3115 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3116 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3117 evas_object_del(sobj);
3119 EINA_LIST_FREE(sd->subobjs, sobj)
3121 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3122 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3123 evas_object_del(sobj);
3125 eina_list_free(sd->tooltips); /* should be empty anyway */
3126 eina_list_free(sd->cursors); /* should be empty anyway */
3127 EINA_LIST_FREE(sd->edje_signals, esd)
3129 eina_stringshare_del(esd->emission);
3130 eina_stringshare_del(esd->source);
3133 eina_list_free(sd->event_cb); /* should be empty anyway */
3134 if (sd->del_func) sd->del_func(obj);
3135 if (sd->style) eina_stringshare_del(sd->style);
3136 if (sd->type) eina_stringshare_del(sd->type);
3137 if (sd->theme) elm_theme_free(sd->theme);
3138 _if_focused_revert(obj, EINA_TRUE);
3143 _smart_move(Evas_Object *obj,
3150 _smart_reconfigure(sd);
3154 _smart_resize(Evas_Object *obj,
3161 _smart_reconfigure(sd);
3165 _smart_show(Evas_Object *obj)
3170 if ((list = evas_object_smart_members_get(obj)))
3172 EINA_LIST_FREE(list, o)
3174 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3175 evas_object_show(o);
3181 _smart_hide(Evas_Object *obj)
3187 list = evas_object_smart_members_get(obj);
3188 EINA_LIST_FREE(list, o)
3190 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3191 evas_object_hide(o);
3196 _smart_color_set(Evas_Object *obj,
3205 if ((list = evas_object_smart_members_get(obj)))
3207 EINA_LIST_FREE(list, o)
3209 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3210 evas_object_color_set(o, r, g, b, a);
3216 _smart_clip_set(Evas_Object *obj,
3222 if ((list = evas_object_smart_members_get(obj)))
3224 EINA_LIST_FREE(list, o)
3226 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3227 evas_object_clip_set(o, clip);
3233 _smart_clip_unset(Evas_Object *obj)
3238 if ((list = evas_object_smart_members_get(obj)))
3240 EINA_LIST_FREE(list, o)
3242 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3243 evas_object_clip_unset(o);
3249 _smart_calculate(Evas_Object *obj)
3252 if (sd->changed_func) sd->changed_func(obj);
3255 /* never need to touch this */
3259 if (_e_smart) return;
3261 static const Evas_Smart_Class sc =
3264 EVAS_SMART_CLASS_VERSION,
3282 _e_smart = evas_smart_class_new(&sc);
3286 /* happy debug functions */
3289 _sub_obj_tree_dump(const Evas_Object *obj,
3294 for (i = 0; i < lvl * 3; i++)
3297 if (_elm_widget_is(obj))
3301 printf("+ %s(%p)\n",
3305 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3306 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3308 if (obj != sd->resize_obj)
3309 _sub_obj_tree_dump(obj, lvl + 1);
3313 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3317 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3320 if (!_elm_widget_is(obj))
3324 Eina_Bool visible = evas_object_visible_get(obj);
3325 Eina_Bool disabled = elm_widget_disabled_get(obj);
3326 Eina_Bool focused = elm_widget_focus_get(obj);
3327 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3331 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3334 fprintf(output, ", style=bold");
3337 fprintf(output, ", color=gray28");
3339 fprintf(output, " ];\n");
3342 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3343 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3344 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3348 fprintf(output, ", style=bold");
3351 fprintf(output, ", fontcolor=gray28");
3353 if ((disabled) || (!visible))
3354 fprintf(output, ", color=gray");
3356 fprintf(output, " ];\n");
3360 EINA_LIST_FOREACH(sd->subobjs, l, o)
3361 _sub_obj_tree_dot_dump(o, output);
3366 elm_widget_tree_dump(const Evas_Object *top)
3369 _sub_obj_tree_dump(top, 0);
3377 elm_widget_tree_dot_dump(const Evas_Object *top,
3381 if (!_elm_widget_is(top))
3383 fprintf(output, "graph " " { node [shape=record];\n");
3384 _sub_obj_tree_dot_dump(top, output);
3385 fprintf(output, "}\n");