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 */
112 Eina_Bool still_in : 1;
114 Eina_List *focus_chain;
118 struct _Edje_Signal_Data
122 const char *emission;
127 struct _Elm_Event_Cb_Data
133 /* local subsystem functions */
134 static void _smart_reconfigure(Smart_Data *sd);
135 static void _smart_add(Evas_Object *obj);
136 static void _smart_del(Evas_Object *obj);
137 static void _smart_move(Evas_Object *obj,
140 static void _smart_resize(Evas_Object *obj,
143 static void _smart_show(Evas_Object *obj);
144 static void _smart_hide(Evas_Object *obj);
145 static void _smart_color_set(Evas_Object *obj,
150 static void _smart_clip_set(Evas_Object *obj,
152 static void _smart_clip_unset(Evas_Object *obj);
153 static void _smart_calculate(Evas_Object *obj);
154 static void _smart_init(void);
156 static void _if_focused_revert(Evas_Object *obj,
157 Eina_Bool can_focus_only);
158 static Evas_Object *_newest_focus_order_get(Evas_Object *obj,
159 unsigned int *newest_focus_order,
160 Eina_Bool can_focus_only);
162 /* local subsystem globals */
163 static Evas_Smart *_e_smart = NULL;
164 static Eina_List *widtypes = NULL;
166 static unsigned int focus_order = 0;
169 static inline Eina_Bool
170 _elm_widget_is(const Evas_Object *obj)
172 const char *type = evas_object_type_get(obj);
173 return type == SMART_NAME;
176 static inline Eina_Bool
177 _is_focusable(Evas_Object *obj)
179 API_ENTRY return EINA_FALSE;
180 return sd->can_focus || (sd->child_can_focus);
184 _unfocus_parents(Evas_Object *obj)
186 for (; obj; obj = elm_widget_parent_get(obj))
189 if (!sd->focused) return;
195 _focus_parents(Evas_Object *obj)
197 for (; obj; obj = elm_widget_parent_get(obj))
200 if (sd->focused) return;
206 _sub_obj_del(void *data,
209 void *event_info __UNUSED__)
211 Smart_Data *sd = data;
213 if (_elm_widget_is(obj))
215 if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
217 if (obj == sd->resize_obj)
218 sd->resize_obj = NULL;
219 else if (obj == sd->hover_obj)
220 sd->hover_obj = NULL;
222 sd->subobjs = eina_list_remove(sd->subobjs, obj);
223 evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
227 _sub_obj_hide(void *data __UNUSED__,
230 void *event_info __UNUSED__)
232 elm_widget_focus_hide_handle(obj);
236 _sub_obj_mouse_down(void *data,
238 Evas_Object *obj __UNUSED__,
241 Smart_Data *sd = data;
242 Evas_Event_Mouse_Down *ev = event_info;
243 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
244 sd->still_in = EINA_TRUE;
248 _sub_obj_mouse_move(void *data,
253 Smart_Data *sd = data;
254 Evas_Event_Mouse_Move *ev = event_info;
257 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
258 sd->still_in = EINA_FALSE;
261 Evas_Coord x, y, w, h;
262 evas_object_geometry_get(obj, &x, &y, &w, &h);
263 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
264 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
265 sd->still_in = EINA_FALSE;
271 _sub_obj_mouse_up(void *data,
274 void *event_info __UNUSED__)
276 Smart_Data *sd = data;
278 elm_widget_focus_mouse_up_handle(obj);
279 sd->still_in = EINA_FALSE;
283 _propagate_x_drag_lock(Evas_Object *obj,
289 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
292 sd2->child_drag_x_locked += dir;
293 _propagate_x_drag_lock(sd->parent_obj, dir);
299 _propagate_y_drag_lock(Evas_Object *obj,
305 Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
308 sd2->child_drag_y_locked += dir;
309 _propagate_y_drag_lock(sd->parent_obj, dir);
315 _propagate_event(void *data,
321 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
322 Evas_Event_Flags *event_flags = NULL;
326 case EVAS_CALLBACK_KEY_DOWN:
328 Evas_Event_Key_Down *ev = event_info;
329 event_flags = &(ev->event_flags);
333 case EVAS_CALLBACK_KEY_UP:
335 Evas_Event_Key_Up *ev = event_info;
336 event_flags = &(ev->event_flags);
340 case EVAS_CALLBACK_MOUSE_WHEEL:
342 Evas_Event_Mouse_Wheel *ev = event_info;
343 event_flags = &(ev->event_flags);
351 elm_widget_event_propagate(obj, type, event_info, event_flags);
355 _parent_focus(Evas_Object *obj)
358 if (sd->focused) return;
360 Evas_Object *o = elm_widget_parent_get(obj);
361 sd->focus_order_on_calc = EINA_TRUE;
363 if (o) _parent_focus(o);
365 if (!sd->focus_order_on_calc)
366 return; /* we don't want to override it if by means of any of the
367 callbacks below one gets to calculate our order
371 sd->focus_order = focus_order;
372 if (sd->top_win_focused)
374 sd->focused = EINA_TRUE;
375 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
376 if (sd->focus_func) sd->focus_func(obj);
377 _elm_widget_focus_region_show(obj);
379 sd->focus_order_on_calc = EINA_FALSE;
383 _elm_object_focus_chain_del_cb(void *data,
386 void *event_info __UNUSED__)
388 Smart_Data *sd = data;
390 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
393 // exposed util funcs to elm
395 _elm_widget_type_clear(void)
399 EINA_LIST_FREE(widtypes, ptr)
401 eina_stringshare_del(*ptr);
407 _elm_widget_focus_region_show(const Evas_Object *obj)
409 Evas_Coord x, y, w, h, ox, oy;
415 o = elm_widget_parent_get(obj);
418 elm_widget_focus_region_get(obj, &x, &y, &w, &h);
419 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
423 sd2 = evas_object_smart_data_get(o);
424 if (sd2->focus_region_func)
426 sd2->focus_region_func(o, x, y, w, h);
427 elm_widget_focus_region_get(o, &x, &y, &w, &h);
431 evas_object_geometry_get(o, &px, &py, NULL, NULL);
437 o = elm_widget_parent_get(o);
442 * @defgroup Widget Widget
445 * Exposed api for making widgets
448 elm_widget_type_register(const char **ptr)
450 widtypes = eina_list_append(widtypes, (void *)ptr);
454 * @defgroup Widget Widget
457 * Disposed api for making widgets
460 elm_widget_type_unregister(const char **ptr)
462 widtypes = eina_list_remove(widtypes, (void *)ptr);
466 elm_widget_api_check(int ver)
468 if (ver != ELM_INTERNAL_API_VERSION)
470 CRITICAL("Elementary widget api versions do not match");
477 elm_widget_add(Evas *evas)
481 obj = evas_object_smart_add(evas, _e_smart);
482 elm_widget_mirrored_set(obj, elm_mirrored_get());
487 elm_widget_del_hook_set(Evas_Object *obj,
488 void (*func)(Evas_Object *obj))
495 elm_widget_del_pre_hook_set(Evas_Object *obj,
496 void (*func)(Evas_Object *obj))
499 sd->del_pre_func = func;
503 elm_widget_focus_hook_set(Evas_Object *obj,
504 void (*func)(Evas_Object *obj))
507 sd->focus_func = func;
511 elm_widget_activate_hook_set(Evas_Object *obj,
512 void (*func)(Evas_Object *obj))
515 sd->activate_func = func;
519 elm_widget_disable_hook_set(Evas_Object *obj,
520 void (*func)(Evas_Object *obj))
523 sd->disable_func = func;
527 elm_widget_theme_hook_set(Evas_Object *obj,
528 void (*func)(Evas_Object *obj))
531 sd->theme_func = func;
535 elm_widget_event_hook_set(Evas_Object *obj,
536 Eina_Bool (*func)(Evas_Object *obj,
538 Evas_Callback_Type type,
542 sd->event_func = func;
546 elm_widget_text_set_hook_set(Evas_Object *obj,
547 Elm_Widget_On_Text_Set_Cb func)
550 sd->on_text_set_func = func;
554 elm_widget_text_get_hook_set(Evas_Object *obj,
555 Elm_Widget_On_Text_Get_Cb func)
558 sd->on_text_get_func = func;
562 elm_widget_content_set_hook_set(Evas_Object *obj,
563 Elm_Widget_On_Content_Set_Cb func)
566 sd->on_content_set_func = func;
570 elm_widget_content_get_hook_set(Evas_Object *obj,
571 Elm_Widget_On_Content_Get_Cb func)
574 sd->on_content_get_func = func;
578 elm_widget_content_unset_hook_set(Evas_Object *obj,
579 Elm_Widget_On_Content_Unset_Cb func)
582 sd->on_content_unset_func = func;
586 elm_widget_changed_hook_set(Evas_Object *obj,
587 void (*func)(Evas_Object *obj))
590 sd->changed_func = func;
594 elm_widget_signal_emit_hook_set(Evas_Object *obj,
595 void (*func)(Evas_Object *obj,
596 const char *emission,
600 sd->signal_func = func;
604 elm_widget_signal_callback_add_hook_set(Evas_Object *obj,
605 void (*func)(Evas_Object *obj,
606 const char *emission,
608 Edje_Signal_Cb func_cb,
612 sd->callback_add_func = func;
616 elm_widget_signal_callback_del_hook_set(Evas_Object *obj,
617 void (*func)(Evas_Object *obj,
618 const char *emission,
620 Edje_Signal_Cb func_cb,
624 sd->callback_del_func = func;
628 elm_widget_theme(Evas_Object *obj)
636 EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
637 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
638 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
639 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
640 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
641 if (sd->theme_func) sd->theme_func(obj);
645 elm_widget_theme_specific(Evas_Object *obj,
653 Elm_Theme *th2, *thdef;
656 thdef = elm_theme_default_get();
661 if (!th2) th2 = thdef;
669 if (th2 == thdef) break;
670 th2 = th2->ref_theme;
671 if (!th2) th2 = thdef;
675 EINA_LIST_FOREACH(sd->subobjs, l, child)
676 elm_widget_theme_specific(child, th, force);
677 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
678 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
679 EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
680 EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
681 if (sd->theme_func) sd->theme_func(obj);
687 * Set hook to get next object in object focus chain.
689 * @param obj The widget object.
690 * @param func The hook to be used with this widget.
695 elm_widget_focus_next_hook_set(Evas_Object *obj,
696 Eina_Bool (*func)(const Evas_Object *obj,
697 Elm_Focus_Direction dir,
701 sd->focus_next_func = func;
705 * Returns the widget's mirrored mode.
707 * @param obj The widget.
708 * @return mirrored mode of the object.
712 elm_widget_mirrored_get(const Evas_Object *obj)
714 API_ENTRY return EINA_FALSE;
715 return sd->is_mirrored;
719 * Sets the widget's mirrored mode.
721 * @param obj The widget.
722 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
725 elm_widget_mirrored_set(Evas_Object *obj,
729 if (sd->is_mirrored != mirrored)
731 sd->is_mirrored = mirrored;
732 elm_widget_theme(obj);
738 * Resets the mirrored mode from the system mirror mode for widgets that are in
739 * automatic mirroring mode. This function does not call elm_widget_theme.
741 * @param obj The widget.
742 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
745 _elm_widget_mirrored_reload(Evas_Object *obj)
748 Eina_Bool mirrored = elm_mirrored_get();
749 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
751 sd->is_mirrored = mirrored;
756 * Returns the widget's mirrored mode setting.
758 * @param obj The widget.
759 * @return mirrored mode setting of the object.
763 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
765 API_ENTRY return EINA_FALSE;
766 return sd->mirrored_auto_mode;
770 * Sets the widget's mirrored mode setting.
771 * When widget in automatic mode, it follows the system mirrored mode set by
772 * elm_mirrored_set().
773 * @param obj The widget.
774 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
777 elm_widget_mirrored_automatic_set(Evas_Object *obj,
781 if (sd->mirrored_auto_mode != automatic)
783 sd->mirrored_auto_mode = automatic;
787 elm_widget_mirrored_set(obj, elm_mirrored_get());
793 elm_widget_on_focus_hook_set(Evas_Object *obj,
794 void (*func)(void *data,
799 sd->on_focus_func = func;
800 sd->on_focus_data = data;
804 elm_widget_on_change_hook_set(Evas_Object *obj,
805 void (*func)(void *data,
810 sd->on_change_func = func;
811 sd->on_change_data = data;
815 elm_widget_on_show_region_hook_set(Evas_Object *obj,
816 void (*func)(void *data,
821 sd->on_show_region_func = func;
822 sd->on_show_region_data = data;
828 * Set the hook to use to show the focused region.
830 * Whenever a new widget gets focused or it's needed to show the focused
831 * area of the current one, this hook will be called on objects that may
832 * want to move their children into their visible area.
833 * The area given in the hook function is relative to the @p obj widget.
835 * @param obj The widget object
836 * @param func The function to call to show the specified area.
841 elm_widget_focus_region_hook_set(Evas_Object *obj,
842 void (*func)(Evas_Object *obj,
849 sd->focus_region_func = func;
855 * Set the hook to retrieve the focused region of a widget.
857 * This hook will be called by elm_widget_focus_region_get() whenever
858 * it's needed to get the focused area of a widget. The area must be relative
859 * to the widget itself and if no hook is set, it will default to the entire
862 * @param obj The widget object
863 * @param func The function used to retrieve the focus region.
868 elm_widget_on_focus_region_hook_set(Evas_Object *obj,
869 void (*func)(const Evas_Object *obj,
876 sd->on_focus_region_func = func;
880 elm_widget_data_set(Evas_Object *obj,
888 elm_widget_data_get(const Evas_Object *obj)
890 API_ENTRY return NULL;
895 elm_widget_sub_object_add(Evas_Object *obj,
899 double scale, pscale = elm_widget_scale_get(sobj);
900 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
901 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
903 if (_elm_widget_is(sobj))
905 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
908 if (sd2->parent_obj == obj)
911 elm_widget_sub_object_del(sd2->parent_obj, sobj);
912 sd2->parent_obj = obj;
913 sd2->top_win_focused = sd->top_win_focused;
914 if (!sd->child_can_focus && (_is_focusable(sobj)))
915 sd->child_can_focus = EINA_TRUE;
920 void *data = evas_object_data_get(sobj, "elm-parent");
923 if (data == obj) return;
924 evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
929 sd->subobjs = eina_list_append(sd->subobjs, sobj);
930 evas_object_data_set(sobj, "elm-parent", obj);
931 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
932 if (_elm_widget_is(sobj))
933 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd);
934 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
935 scale = elm_widget_scale_get(sobj);
936 th = elm_widget_theme_get(sobj);
937 mirrored = elm_widget_mirrored_get(sobj);
938 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
939 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
943 elm_widget_sub_object_del(Evas_Object *obj,
946 Evas_Object *sobj_parent;
950 sobj_parent = evas_object_data_del(sobj, "elm-parent");
951 if (sobj_parent != obj)
953 static int abort_on_warn = -1;
954 ERR("removing sub object %p from parent %p, "
955 "but elm-parent is different %p!",
956 sobj, obj, sobj_parent);
957 if (EINA_UNLIKELY(abort_on_warn == -1))
959 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
960 else abort_on_warn = 0;
962 if (abort_on_warn == 1) abort();
964 if (_elm_widget_is(sobj))
966 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
969 sd2->parent_obj = NULL;
970 if (sd2->resize_obj == sobj)
971 sd2->resize_obj = NULL;
973 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
976 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
977 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
978 if ((sd->child_can_focus) && (_is_focusable(sobj)))
982 sd->child_can_focus = EINA_FALSE;
983 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
985 if (_is_focusable(subobj))
987 sd->child_can_focus = EINA_TRUE;
994 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
995 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
997 if (_elm_widget_is(sobj))
998 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1000 evas_object_smart_callback_call(obj, "sub-object-del", sobj);
1004 elm_widget_resize_object_set(Evas_Object *obj,
1008 // orphan previous resize obj
1011 evas_object_clip_unset(sd->resize_obj);
1012 evas_object_data_del(sd->resize_obj, "elm-parent");
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 = NULL;
1017 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_HIDE,
1020 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
1022 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
1023 _sub_obj_mouse_down, sd);
1024 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_MOVE,
1025 _sub_obj_mouse_move, sd);
1026 evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
1027 _sub_obj_mouse_up, sd);
1028 evas_object_smart_member_del(sd->resize_obj);
1029 if (_elm_widget_is(sd->resize_obj))
1031 if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
1034 // orphan new resize obj
1037 evas_object_data_del(sobj, "elm-parent");
1038 if (_elm_widget_is(sobj))
1040 Smart_Data *sd2 = evas_object_smart_data_get(sobj);
1041 if (sd2) sd2->parent_obj = NULL;
1042 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_HIDE,
1045 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
1047 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1048 _sub_obj_mouse_down, sd);
1049 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1050 _sub_obj_mouse_move, sd);
1051 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_UP,
1052 _sub_obj_mouse_up, sd);
1053 evas_object_smart_member_del(sobj);
1054 if (_elm_widget_is(sobj))
1056 if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
1059 // set the resize obj up
1060 sd->resize_obj = sobj;
1063 if (_elm_widget_is(sd->resize_obj))
1065 Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
1068 sd2->parent_obj = obj;
1069 sd2->top_win_focused = sd->top_win_focused;
1071 evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
1074 evas_object_clip_set(sobj, evas_object_clip_get(obj));
1075 evas_object_smart_member_add(sobj, obj);
1076 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1078 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
1079 _sub_obj_mouse_down, sd);
1080 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_MOVE,
1081 _sub_obj_mouse_move, sd);
1082 evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_UP,
1083 _sub_obj_mouse_up, sd);
1084 _smart_reconfigure(sd);
1085 evas_object_data_set(sobj, "elm-parent", obj);
1086 evas_object_smart_callback_call(obj, "sub-object-add", sobj);
1087 if (_elm_widget_is(sobj))
1089 if (elm_widget_focus_get(sobj)) _focus_parents(obj);
1095 elm_widget_hover_object_set(Evas_Object *obj,
1101 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1104 sd->hover_obj = sobj;
1107 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1109 _smart_reconfigure(sd);
1114 elm_widget_can_focus_set(Evas_Object *obj,
1115 Eina_Bool can_focus)
1118 sd->can_focus = can_focus;
1121 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1123 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1124 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1126 (void *)(long)EVAS_CALLBACK_KEY_UP);
1127 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1129 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1133 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1135 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1137 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1143 elm_widget_can_focus_get(const Evas_Object *obj)
1145 API_ENTRY return EINA_FALSE;
1146 return sd->can_focus;
1150 elm_widget_child_can_focus_get(const Evas_Object *obj)
1152 API_ENTRY return EINA_FALSE;
1153 return sd->child_can_focus;
1159 * This API makes the widget object and its children to be unfocusable.
1161 * This API can be helpful for an object to be deleted.
1162 * When an object will be deleted soon, it and its children may not
1163 * want to get focus (by focus reverting or by other focus controls).
1164 * Then, just use this API before deleting.
1166 * @param obj The widget root of sub-tree
1167 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1172 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1173 Eina_Bool tree_unfocusable)
1177 if (sd->tree_unfocusable == tree_unfocusable) return;
1178 sd->tree_unfocusable = !!tree_unfocusable;
1179 elm_widget_focus_tree_unfocusable_handle(obj);
1185 * This returns true, if the object sub-tree is unfocusable.
1187 * @param obj The widget root of sub-tree
1188 * @return EINA_TRUE if the object sub-tree is unfocusable
1193 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1195 API_ENTRY return EINA_FALSE;
1196 return sd->tree_unfocusable;
1200 elm_widget_highlight_ignore_set(Evas_Object *obj,
1204 sd->highlight_ignore = !!ignore;
1208 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1210 API_ENTRY return EINA_FALSE;
1211 return sd->highlight_ignore;
1215 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1216 Eina_Bool highlight)
1219 sd->highlight_in_theme = !!highlight;
1220 /* FIXME: if focused, it should switch from one mode to the other */
1224 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1226 API_ENTRY return EINA_FALSE;
1227 return sd->highlight_in_theme;
1231 elm_widget_focus_get(const Evas_Object *obj)
1233 API_ENTRY return EINA_FALSE;
1238 elm_widget_focused_object_get(const Evas_Object *obj)
1240 const Evas_Object *subobj;
1242 API_ENTRY return NULL;
1244 if (!sd->focused) return NULL;
1245 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1247 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1248 if (fobj) return fobj;
1250 return (Evas_Object *)obj;
1254 elm_widget_top_get(const Evas_Object *obj)
1256 API_ENTRY return NULL;
1257 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1258 return (Evas_Object *)obj;
1262 elm_widget_is(const Evas_Object *obj)
1264 return _elm_widget_is(obj);
1268 elm_widget_parent_widget_get(const Evas_Object *obj)
1270 Evas_Object *parent;
1272 if (_elm_widget_is(obj))
1274 Smart_Data *sd = evas_object_smart_data_get(obj);
1275 if (!sd) return NULL;
1276 parent = sd->parent_obj;
1280 parent = evas_object_data_get(obj, "elm-parent");
1281 if (!parent) parent = evas_object_smart_parent_get(obj);
1286 Evas_Object *elm_parent;
1287 if (_elm_widget_is(parent)) break;
1288 elm_parent = evas_object_data_get(parent, "elm-parent");
1289 if (elm_parent) parent = elm_parent;
1290 else parent = evas_object_smart_parent_get(parent);
1296 elm_widget_event_callback_add(Evas_Object *obj,
1301 EINA_SAFETY_ON_NULL_RETURN(func);
1302 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1305 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1309 elm_widget_event_callback_del(Evas_Object *obj,
1313 API_ENTRY return NULL;
1314 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1316 Elm_Event_Cb_Data *ecd;
1317 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1318 if ((ecd->func == func) && (ecd->data == data))
1321 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1322 return (void *)data;
1328 elm_widget_event_propagate(Evas_Object *obj,
1329 Evas_Callback_Type type,
1331 Evas_Event_Flags *event_flags)
1333 API_ENTRY return EINA_FALSE; //TODO reduce.
1334 if (!_elm_widget_is(obj)) return EINA_FALSE;
1335 Evas_Object *parent = obj;
1336 Elm_Event_Cb_Data *ecd;
1337 Eina_List *l, *l_prev;
1340 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1342 sd = evas_object_smart_data_get(parent);
1343 if ((!sd) || (!_elm_widget_is(obj)))
1344 return EINA_FALSE; //Not Elm Widget
1346 if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1349 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1351 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1352 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1355 parent = sd->parent_obj;
1364 * Set custom focus chain.
1366 * This function i set one new and overwrite any previous custom focus chain
1367 * with the list of objects. The previous list will be deleted and this list
1368 * will be managed. After setted, don't modity it.
1370 * @note On focus cycle, only will be evaluated children of this container.
1372 * @param obj The container widget
1373 * @param objs Chain of objects to pass focus
1377 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1381 if (!sd->focus_next_func)
1384 elm_widget_focus_custom_chain_unset(obj);
1389 EINA_LIST_FOREACH(objs, l, o)
1391 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1392 _elm_object_focus_chain_del_cb, sd);
1395 sd->focus_chain = objs;
1401 * Get custom focus chain
1403 * @param obj The container widget
1406 EAPI const Eina_List *
1407 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1409 API_ENTRY return NULL;
1410 return (const Eina_List *)sd->focus_chain;
1416 * Unset custom focus chain
1418 * @param obj The container widget
1422 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1425 Eina_List *l, *l_next;
1428 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1430 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1431 _elm_object_focus_chain_del_cb, sd);
1432 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1439 * Append object to custom focus chain.
1441 * @note If relative_child equal to NULL or not in custom chain, the object
1442 * will be added in end.
1444 * @note On focus cycle, only will be evaluated children of this container.
1446 * @param obj The container widget
1447 * @param child The child to be added in custom chain
1448 * @param relative_child The relative object to position the child
1452 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1454 Evas_Object *relative_child)
1457 EINA_SAFETY_ON_NULL_RETURN(child);
1458 if (!sd->focus_next_func)
1461 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1462 _elm_object_focus_chain_del_cb, sd);
1464 if (!relative_child)
1466 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1470 sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1477 * Prepend object to custom focus chain.
1479 * @note If relative_child equal to NULL or not in custom chain, the object
1480 * will be added in begin.
1482 * @note On focus cycle, only will be evaluated children of this container.
1484 * @param obj The container widget
1485 * @param child The child to be added in custom chain
1486 * @param relative_child The relative object to position the child
1490 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1492 Evas_Object *relative_child)
1495 EINA_SAFETY_ON_NULL_RETURN(child);
1496 if (!sd->focus_next_func)
1499 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1500 _elm_object_focus_chain_del_cb, sd);
1502 if (!relative_child)
1504 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1508 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1515 * Give focus to next object in object tree.
1517 * Give focus to next object in focus chain of one object sub-tree.
1518 * If the last object of chain already have focus, the focus will go to the
1519 * first object of chain.
1521 * @param obj The widget root of sub-tree
1522 * @param dir Direction to cycle the focus
1527 elm_widget_focus_cycle(Evas_Object *obj,
1528 Elm_Focus_Direction dir)
1530 Evas_Object *target = NULL;
1531 if (!_elm_widget_is(obj))
1533 elm_widget_focus_next_get(obj, dir, &target);
1535 elm_widget_focus_steal(target);
1541 * Give focus to near object in one direction.
1543 * Give focus to near object in direction of one object.
1544 * If none focusable object in given direction, the focus will not change.
1546 * @param obj The reference widget
1547 * @param x Horizontal component of direction to focus
1548 * @param y Vertical component of direction to focus
1553 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__,
1563 * Get next object in focus chain of object tree.
1565 * Get next object in focus chain of one object sub-tree.
1566 * Return the next object by reference. If don't have any candidate to receive
1567 * focus before chain end, the first candidate will be returned.
1569 * @param obj The widget root of sub-tree
1570 * @param dir Direction os focus chain
1571 * @param next The next object in focus chain
1572 * @return EINA_TRUE if don't need focus chain restart/loop back
1573 * to use 'next' obj.
1578 elm_widget_focus_next_get(const Evas_Object *obj,
1579 Elm_Focus_Direction dir,
1586 API_ENTRY return EINA_FALSE;
1588 /* Ignore if disabled */
1589 if ((!evas_object_visible_get(obj))
1590 || (elm_widget_disabled_get(obj))
1591 || (elm_widget_tree_unfocusable_get(obj)))
1595 if (sd->focus_next_func)
1596 return sd->focus_next_func(obj, dir, next);
1598 if (!elm_widget_can_focus_get(obj))
1602 *next = (Evas_Object *)obj;
1603 return !elm_widget_focus_get(obj);
1609 * Get next object in focus chain of object tree in list.
1611 * Get next object in focus chain of one object sub-tree ordered by one list.
1612 * Return the next object by reference. If don't have any candidate to receive
1613 * focus before list end, the first candidate will be returned.
1615 * @param obj The widget root of sub-tree
1616 * @param dir Direction os focus chain
1617 * @param items list with ordered objects
1618 * @param list_data_get function to get the object from one item of list
1619 * @param next The next object in focus chain
1620 * @return EINA_TRUE if don't need focus chain restart/loop back
1621 * to use 'next' obj.
1626 elm_widget_focus_list_next_get(const Evas_Object *obj,
1627 const Eina_List *items,
1628 void *(*list_data_get)(const Eina_List * list),
1629 Elm_Focus_Direction dir,
1632 Eina_List *(*list_next)(const Eina_List * list);
1638 if (!_elm_widget_is(obj))
1645 if (dir == ELM_FOCUS_PREVIOUS)
1647 items = eina_list_last(items);
1648 list_next = eina_list_prev;
1650 else if (dir == ELM_FOCUS_NEXT)
1651 list_next = eina_list_next;
1655 const Eina_List *l = items;
1657 /* Recovery last focused sub item */
1658 if (elm_widget_focus_get(obj))
1659 for (; l; l = list_next(l))
1661 Evas_Object *cur = list_data_get(l);
1662 if (elm_widget_focus_get(cur)) break;
1665 const Eina_List *start = l;
1666 Evas_Object *to_focus = NULL;
1668 /* Interate sub items */
1669 /* Go to end of list */
1670 for (; l; l = list_next(l))
1672 Evas_Object *tmp = NULL;
1673 Evas_Object *cur = list_data_get(l);
1675 if (elm_widget_parent_get(cur) != obj)
1678 /* Try Focus cycle in subitem */
1679 if (elm_widget_focus_next_get(cur, dir, &tmp))
1684 else if ((tmp) && (!to_focus))
1690 /* Get First possible */
1691 for (; l != start; l = list_next(l))
1693 Evas_Object *tmp = NULL;
1694 Evas_Object *cur = list_data_get(l);
1696 if (elm_widget_parent_get(cur) != obj)
1699 /* Try Focus cycle in subitem */
1700 elm_widget_focus_next_get(cur, dir, &tmp);
1713 elm_widget_signal_emit(Evas_Object *obj,
1714 const char *emission,
1718 if (!sd->signal_func) return;
1719 sd->signal_func(obj, emission, source);
1723 _edje_signal_callback(void *data,
1724 Evas_Object *obj __UNUSED__,
1725 const char *emission,
1728 Edje_Signal_Data *esd = data;
1729 esd->func(esd->data, esd->obj, emission, source);
1733 elm_widget_signal_callback_add(Evas_Object *obj,
1734 const char *emission,
1736 Edje_Signal_Cb func,
1739 Edje_Signal_Data *esd;
1741 if (!sd->callback_add_func) return;
1742 EINA_SAFETY_ON_NULL_RETURN(func);
1744 esd = ELM_NEW(Edje_Signal_Data);
1749 esd->emission = eina_stringshare_add(emission);
1750 esd->source = eina_stringshare_add(source);
1752 sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1753 sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1757 elm_widget_signal_callback_del(Evas_Object *obj,
1758 const char *emission,
1760 Edje_Signal_Cb func)
1762 Edje_Signal_Data *esd;
1765 API_ENTRY return NULL;
1766 if (!sd->callback_del_func) return NULL;
1768 EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1770 if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1771 (!strcmp(esd->source, source)))
1773 sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1774 eina_stringshare_del(esd->emission);
1775 eina_stringshare_del(esd->source);
1781 sd->callback_del_func(obj, emission, source, _edje_signal_callback, data);
1786 elm_widget_focus_set(Evas_Object *obj,
1793 sd->focus_order = focus_order;
1794 sd->focused = EINA_TRUE;
1795 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1799 sd->focus_func(obj);
1806 if ((_is_focusable(sd->resize_obj)) &&
1807 (!elm_widget_disabled_get(sd->resize_obj)))
1809 elm_widget_focus_set(sd->resize_obj, first);
1815 EINA_LIST_FOREACH(sd->subobjs, l, child)
1817 if ((_is_focusable(child)) &&
1818 (!elm_widget_disabled_get(child)))
1820 elm_widget_focus_set(child, first);
1830 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1832 if ((_is_focusable(child)) &&
1833 (!elm_widget_disabled_get(child)))
1835 elm_widget_focus_set(child, first);
1841 if ((_is_focusable(sd->resize_obj)) &&
1842 (!elm_widget_disabled_get(sd->resize_obj)))
1844 elm_widget_focus_set(sd->resize_obj, first);
1852 elm_widget_parent_get(const Evas_Object *obj)
1854 API_ENTRY return NULL;
1855 return sd->parent_obj;
1859 elm_widget_focused_object_clear(Evas_Object *obj)
1862 if (!sd->focused) return;
1863 if (elm_widget_focus_get(sd->resize_obj))
1864 elm_widget_focused_object_clear(sd->resize_obj);
1869 EINA_LIST_FOREACH(sd->subobjs, l, child)
1871 if (elm_widget_focus_get(child))
1873 elm_widget_focused_object_clear(child);
1878 sd->focused = EINA_FALSE;
1879 if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1880 if (sd->focus_func) sd->focus_func(obj);
1884 elm_widget_focus_steal(Evas_Object *obj)
1886 Evas_Object *parent, *o;
1889 if (sd->focused) return;
1890 if (sd->disabled) return;
1891 if (!sd->can_focus) return;
1892 if (sd->tree_unfocusable) return;
1896 o = elm_widget_parent_get(parent);
1898 sd = evas_object_smart_data_get(o);
1899 if (sd->disabled || sd->tree_unfocusable) return;
1900 if (sd->focused) break;
1903 if (!elm_widget_parent_get(parent))
1904 elm_widget_focused_object_clear(parent);
1907 parent = elm_widget_parent_get(parent);
1908 sd = evas_object_smart_data_get(parent);
1909 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
1910 elm_widget_focused_object_clear(sd->resize_obj);
1915 EINA_LIST_FOREACH(sd->subobjs, l, child)
1917 if (elm_widget_focus_get(child))
1919 elm_widget_focused_object_clear(child);
1930 elm_widget_focus_restore(Evas_Object *obj)
1932 Evas_Object *newest = NULL;
1933 unsigned int newest_focus_order = 0;
1936 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
1939 elm_object_unfocus(newest);
1940 elm_object_focus(newest);
1945 _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
1951 if (sd->top_win_focused == top_win_focused) return;
1953 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
1954 EINA_LIST_FOREACH(sd->subobjs, l, child)
1956 _elm_widget_top_win_focused_set(child, top_win_focused);
1958 sd->top_win_focused = top_win_focused;
1962 _elm_widget_top_win_focused_get(const Evas_Object *obj)
1964 API_ENTRY return EINA_FALSE;
1965 return sd->top_win_focused;
1969 elm_widget_activate(Evas_Object *obj)
1972 elm_widget_change(obj);
1973 if (sd->activate_func) sd->activate_func(obj);
1977 elm_widget_change(Evas_Object *obj)
1980 elm_widget_change(elm_widget_parent_get(obj));
1981 if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
1985 elm_widget_disabled_set(Evas_Object *obj,
1990 if (sd->disabled == disabled) return;
1991 sd->disabled = !!disabled;
1992 elm_widget_focus_disabled_handle(obj);
1993 if (sd->disable_func) sd->disable_func(obj);
1997 elm_widget_disabled_get(const Evas_Object *obj)
2000 return sd->disabled;
2004 elm_widget_show_region_set(Evas_Object *obj,
2009 Eina_Bool forceshow)
2011 Evas_Object *parent_obj, *child_obj;
2012 Evas_Coord px, py, cx, cy;
2015 if (!forceshow && (x == sd->rx) && (y == sd->ry)
2016 && (w == sd->rw) && (h == sd->rh)) return;
2021 if (sd->on_show_region_func)
2022 sd->on_show_region_func(sd->on_show_region_data, obj);
2026 parent_obj = sd->parent_obj;
2027 child_obj = sd->obj;
2028 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2029 sd = evas_object_smart_data_get(parent_obj);
2032 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2033 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2042 if (sd->on_show_region_func)
2044 sd->on_show_region_func(sd->on_show_region_data, parent_obj);
2051 elm_widget_show_region_get(const Evas_Object *obj,
2067 * Get the focus region of the given widget.
2069 * The focus region is the area of a widget that should brought into the
2070 * visible area when the widget is focused. Mostly used to show the part of
2071 * an entry where the cursor is, for example. The area returned is relative
2072 * to the object @p obj.
2073 * If the @p obj doesn't have the proper on_focus_region_hook set, this
2074 * function will return the full size of the object.
2076 * @param obj The widget object
2077 * @param x Where to store the x coordinate of the area
2078 * @param y Where to store the y coordinate of the area
2079 * @param w Where to store the width of the area
2080 * @param h Where to store the height of the area
2085 elm_widget_focus_region_get(const Evas_Object *obj,
2095 sd = evas_object_smart_data_get(obj);
2096 if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
2098 evas_object_geometry_get(obj, NULL, NULL, w, h);
2103 sd->on_focus_region_func(obj, x, y, w, h);
2107 elm_widget_scroll_hold_push(Evas_Object *obj)
2111 if (sd->scroll_hold == 1)
2112 evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
2113 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2114 // FIXME: on delete/reparent hold pop
2118 elm_widget_scroll_hold_pop(Evas_Object *obj)
2122 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2123 if (!sd->scroll_hold)
2124 evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
2125 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2129 elm_widget_scroll_hold_get(const Evas_Object *obj)
2132 return sd->scroll_hold;
2136 elm_widget_scroll_freeze_push(Evas_Object *obj)
2139 sd->scroll_freeze++;
2140 if (sd->scroll_freeze == 1)
2141 evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
2142 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2143 // FIXME: on delete/reparent freeze pop
2147 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2150 sd->scroll_freeze--;
2151 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
2152 if (!sd->scroll_freeze)
2153 evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
2154 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2158 elm_widget_scroll_freeze_get(const Evas_Object *obj)
2161 return sd->scroll_freeze;
2165 elm_widget_scale_set(Evas_Object *obj,
2169 if (scale <= 0.0) scale = 0.0;
2170 if (sd->scale != scale)
2173 elm_widget_theme(obj);
2178 elm_widget_scale_get(const Evas_Object *obj)
2180 API_ENTRY return 1.0;
2181 // FIXME: save walking up the tree by storing/caching parent scale
2182 if (sd->scale == 0.0)
2185 return elm_widget_scale_get(sd->parent_obj);
2193 elm_widget_theme_set(Evas_Object *obj,
2197 if (sd->theme != th)
2199 if (sd->theme) elm_theme_free(sd->theme);
2202 elm_widget_theme(obj);
2207 elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label)
2211 if (!sd->on_text_set_func)
2214 sd->on_text_set_func(obj, item, label);
2218 elm_widget_text_part_get(const Evas_Object *obj, const char *item)
2220 API_ENTRY return NULL;
2222 if (!sd->on_text_get_func)
2225 return sd->on_text_get_func(obj, item);
2229 elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
2233 if (!sd->on_content_set_func) return;
2234 sd->on_content_set_func(obj, part, content);
2238 elm_widget_content_part_get(const Evas_Object *obj, const char *part)
2240 API_ENTRY return NULL;
2242 if (!sd->on_content_get_func) return NULL;
2243 return sd->on_content_get_func(obj, part);
2247 elm_widget_content_part_unset(Evas_Object *obj, const char *part)
2249 API_ENTRY return NULL;
2251 if (!sd->on_content_unset_func) return NULL;
2252 return sd->on_content_unset_func(obj, part);
2256 elm_widget_theme_get(const Evas_Object *obj)
2258 API_ENTRY return NULL;
2262 return elm_widget_theme_get(sd->parent_obj);
2270 elm_widget_style_set(Evas_Object *obj,
2275 if (eina_stringshare_replace(&sd->style, style))
2276 elm_widget_theme(obj);
2280 elm_widget_style_get(const Evas_Object *obj)
2282 API_ENTRY return NULL;
2283 if (sd->style) return sd->style;
2288 elm_widget_type_set(Evas_Object *obj,
2292 eina_stringshare_replace(&sd->type, type);
2296 elm_widget_type_get(const Evas_Object *obj)
2298 API_ENTRY return NULL;
2299 if (sd->type) return sd->type;
2304 elm_widget_tooltip_add(Evas_Object *obj,
2308 sd->tooltips = eina_list_append(sd->tooltips, tt);
2312 elm_widget_tooltip_del(Evas_Object *obj,
2316 sd->tooltips = eina_list_remove(sd->tooltips, tt);
2320 elm_widget_cursor_add(Evas_Object *obj,
2324 sd->cursors = eina_list_append(sd->cursors, cur);
2328 elm_widget_cursor_del(Evas_Object *obj,
2332 sd->cursors = eina_list_remove(sd->cursors, cur);
2336 elm_widget_drag_lock_x_set(Evas_Object *obj,
2340 if (sd->drag_x_locked == lock) return;
2341 sd->drag_x_locked = lock;
2342 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
2343 else _propagate_x_drag_lock(obj, -1);
2347 elm_widget_drag_lock_y_set(Evas_Object *obj,
2351 if (sd->drag_y_locked == lock) return;
2352 sd->drag_y_locked = lock;
2353 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
2354 else _propagate_y_drag_lock(obj, -1);
2358 elm_widget_drag_lock_x_get(const Evas_Object *obj)
2360 API_ENTRY return EINA_FALSE;
2361 return sd->drag_x_locked;
2365 elm_widget_drag_lock_y_get(const Evas_Object *obj)
2367 API_ENTRY return EINA_FALSE;
2368 return sd->drag_y_locked;
2372 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
2375 return sd->child_drag_x_locked;
2379 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
2382 return sd->child_drag_y_locked;
2386 elm_widget_theme_object_set(Evas_Object *obj,
2389 const char *welement,
2392 API_ENTRY return EINA_FALSE;
2393 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
2397 elm_widget_type_check(const Evas_Object *obj,
2400 const char *provided, *expected = "(unknown)";
2401 static int abort_on_warn = -1;
2402 provided = elm_widget_type_get(obj);
2403 if (EINA_LIKELY(provided == type)) return EINA_TRUE;
2404 if (type) expected = type;
2405 if ((!provided) || (!provided[0]))
2407 provided = evas_object_type_get(obj);
2408 if ((!provided) || (!provided[0]))
2409 provided = "(unknown)";
2411 ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
2412 if (abort_on_warn == -1)
2414 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
2415 else abort_on_warn = 0;
2417 if (abort_on_warn == 1) abort();
2424 * Split string in words
2426 * @param str Source string
2427 * @return List of const words
2429 * @see elm_widget_stringlist_free()
2433 elm_widget_stringlist_get(const char *str)
2435 Eina_List *list = NULL;
2437 if (!str) return NULL;
2438 for (b = s = str; 1; s++)
2440 if ((*s == ' ') || (!*s))
2442 char *t = malloc(s - b + 1);
2445 strncpy(t, b, s - b);
2447 list = eina_list_append(list, eina_stringshare_add(t));
2458 elm_widget_stringlist_free(Eina_List *list)
2461 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2465 elm_widget_focus_hide_handle(Evas_Object *obj)
2467 _if_focused_revert(obj, EINA_TRUE);
2471 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
2473 Evas_Object *o = obj;
2476 if (_elm_widget_is(o)) break;
2477 o = evas_object_smart_parent_get(o);
2481 if (!_is_focusable(o)) return;
2482 elm_widget_focus_steal(o);
2486 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
2490 if (!elm_widget_parent_get(obj))
2491 elm_widget_focused_object_clear(obj);
2493 _if_focused_revert(obj, EINA_TRUE);
2497 elm_widget_focus_disabled_handle(Evas_Object *obj)
2501 elm_widget_focus_tree_unfocusable_handle(obj);
2507 * Allocate a new Elm_Widget_Item-derived structure.
2509 * The goal of this structure is to provide common ground for actions
2510 * that a widget item have, such as the owner widget, callback to
2511 * notify deletion, data pointer and maybe more.
2513 * @param widget the owner widget that holds this item, must be an elm_widget!
2514 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2515 * be used to allocate memory.
2517 * @return allocated memory that is already zeroed out, or NULL on errors.
2519 * @see elm_widget_item_new() convenience macro.
2520 * @see elm_widget_item_del() to release memory.
2523 EAPI Elm_Widget_Item *
2524 _elm_widget_item_new(Evas_Object *widget,
2527 if (!_elm_widget_is(widget))
2530 Elm_Widget_Item *item;
2532 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2533 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2535 item = calloc(1, alloc_size);
2536 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2538 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2539 item->widget = widget;
2546 * Releases widget item memory, calling back del_cb() if it exists.
2548 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2549 * to memory release. Note that elm_widget_item_pre_notify_del() calls
2550 * this function and then unset it, thus being useful for 2 step
2551 * cleanup whenever the del_cb may use any of the data that must be
2552 * deleted from item.
2554 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2557 * @param item a valid #Elm_Widget_Item to be deleted.
2558 * @see elm_widget_item_del() convenience macro.
2562 _elm_widget_item_del(Elm_Widget_Item *item)
2564 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2567 item->del_cb((void *)item->data, item->widget, item);
2570 evas_object_del(item->view);
2572 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2579 * Notify object will be deleted without actually deleting it.
2581 * This function will callback Elm_Widget_Item::del_cb if it is set
2582 * and then unset it so it is not called twice (ie: from
2583 * elm_widget_item_del()).
2585 * @param item a valid #Elm_Widget_Item to be notified
2586 * @see elm_widget_item_pre_notify_del() convenience macro.
2590 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2592 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2593 if (!item->del_cb) return;
2594 item->del_cb((void *)item->data, item->widget, item);
2595 item->del_cb = NULL;
2601 * Set the function to notify when item is being deleted.
2603 * This function will complain if there was a callback set already,
2604 * however it will set the new one.
2606 * The callback will be called from elm_widget_item_pre_notify_del()
2607 * or elm_widget_item_del() will be called with:
2608 * - data: the Elm_Widget_Item::data value.
2609 * - obj: the Elm_Widget_Item::widget evas object.
2610 * - event_info: the item being deleted.
2612 * @param item a valid #Elm_Widget_Item to be notified
2613 * @see elm_widget_item_del_cb_set() convenience macro.
2617 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
2618 Evas_Smart_Cb del_cb)
2620 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2622 if ((item->del_cb) && (item->del_cb != del_cb))
2623 WRN("You're replacing a previously set del_cb %p of item %p with %p",
2624 item->del_cb, item, del_cb);
2626 item->del_cb = del_cb;
2632 * Set user-data in this item.
2634 * User data may be used to identify this item or just store any
2635 * application data. It is automatically given as the first parameter
2636 * of the deletion notify callback.
2638 * @param item a valid #Elm_Widget_Item to store data in.
2639 * @param data user data to store.
2640 * @see elm_widget_item_del_cb_set() convenience macro.
2644 _elm_widget_item_data_set(Elm_Widget_Item *item,
2647 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2648 if ((item->data) && (item->data != data))
2649 DBG("Replacing item %p data %p with %p", item, item->data, data);
2656 * Retrieves user-data of this item.
2658 * @param item a valid #Elm_Widget_Item to get data from.
2659 * @see elm_widget_item_data_set()
2663 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2665 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2666 return (void *)item->data;
2669 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2671 struct _Elm_Widget_Item_Tooltip
2673 Elm_Widget_Item *item;
2674 Elm_Tooltip_Item_Content_Cb func;
2675 Evas_Smart_Cb del_cb;
2679 static Evas_Object *
2680 _elm_widget_item_tooltip_label_create(void *data,
2682 void *item __UNUSED__)
2684 Evas_Object *label = elm_label_add(obj);
2687 elm_object_style_set(label, "tooltip");
2688 elm_object_text_set(label, data);
2693 _elm_widget_item_tooltip_label_del_cb(void *data,
2694 Evas_Object *obj __UNUSED__,
2695 void *event_info __UNUSED__)
2697 eina_stringshare_del(data);
2703 * Set the text to be shown in the widget item.
2705 * @param item Target item
2706 * @param text The text to set in the content
2708 * Setup the text as tooltip to object. The item can have only one tooltip,
2709 * so any previous tooltip data is removed.
2714 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
2717 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2718 EINA_SAFETY_ON_NULL_RETURN(text);
2720 text = eina_stringshare_add(text);
2721 _elm_widget_item_tooltip_content_cb_set
2722 (item, _elm_widget_item_tooltip_label_create, text,
2723 _elm_widget_item_tooltip_label_del_cb);
2726 static Evas_Object *
2727 _elm_widget_item_tooltip_create(void *data,
2730 Elm_Widget_Item_Tooltip *wit = data;
2731 return wit->func((void *)wit->data, obj, wit->item);
2735 _elm_widget_item_tooltip_del_cb(void *data,
2737 void *event_info __UNUSED__)
2739 Elm_Widget_Item_Tooltip *wit = data;
2740 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2747 * Set the content to be shown in the tooltip item
2749 * Setup the tooltip to item. The item can have only one tooltip,
2750 * so any previous tooltip data is removed. @p func(with @p data) will
2751 * be called every time that need show the tooltip and it should
2752 * return a valid Evas_Object. This object is then managed fully by
2753 * tooltip system and is deleted when the tooltip is gone.
2755 * @param item the widget item being attached a tooltip.
2756 * @param func the function used to create the tooltip contents.
2757 * @param data what to provide to @a func as callback data/context.
2758 * @param del_cb called when data is not needed anymore, either when
2759 * another callback replaces @func, the tooltip is unset with
2760 * elm_widget_item_tooltip_unset() or the owner @a item
2761 * dies. This callback receives as the first parameter the
2762 * given @a data, and @c event_info is the item.
2767 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
2768 Elm_Tooltip_Item_Content_Cb func,
2770 Evas_Smart_Cb del_cb)
2772 Elm_Widget_Item_Tooltip *wit;
2774 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2778 _elm_widget_item_tooltip_unset(item);
2782 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2783 if (!wit) goto error;
2787 wit->del_cb = del_cb;
2789 elm_object_sub_tooltip_content_cb_set
2790 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2791 _elm_widget_item_tooltip_del_cb);
2796 if (del_cb) del_cb((void *)data, NULL, item);
2799 if (del_cb) del_cb((void *)data, item->widget, item);
2805 * Unset tooltip from item
2807 * @param item widget item to remove previously set tooltip.
2809 * Remove tooltip from item. The callback provided as del_cb to
2810 * elm_widget_item_tooltip_content_cb_set() will be called to notify
2811 * it is not used anymore.
2813 * @see elm_widget_item_tooltip_content_cb_set()
2818 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2820 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2821 elm_object_tooltip_unset(item->view);
2827 * Sets a different style for this item tooltip.
2829 * @note before you set a style you should define a tooltip with
2830 * elm_widget_item_tooltip_content_cb_set() or
2831 * elm_widget_item_tooltip_text_set()
2833 * @param item widget item with tooltip already set.
2834 * @param style the theme style to use (default, transparent, ...)
2839 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
2842 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2843 elm_object_tooltip_style_set(item->view, style);
2849 * Get the style for this item tooltip.
2851 * @param item widget item with tooltip already set.
2852 * @return style the theme style in use, defaults to "default". If the
2853 * object does not have a tooltip set, then NULL is returned.
2858 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2860 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2861 return elm_object_tooltip_style_get(item->view);
2865 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
2868 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2869 elm_object_sub_cursor_set(item->view, item->widget, cursor);
2873 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2875 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2876 return elm_object_cursor_get(item->view);
2880 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2882 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2883 elm_object_cursor_unset(item->view);
2889 * Sets a different style for this item cursor.
2891 * @note before you set a style you should define a cursor with
2892 * elm_widget_item_cursor_set()
2894 * @param item widget item with cursor already set.
2895 * @param style the theme style to use (default, transparent, ...)
2900 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
2903 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2904 elm_object_cursor_style_set(item->view, style);
2910 * Get the style for this item cursor.
2912 * @param item widget item with cursor already set.
2913 * @return style the theme style in use, defaults to "default". If the
2914 * object does not have a cursor set, then NULL is returned.
2919 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2921 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2922 return elm_object_cursor_style_get(item->view);
2928 * Set if the cursor set should be searched on the theme or should use
2929 * the provided by the engine, only.
2931 * @note before you set if should look on theme you should define a cursor
2932 * with elm_object_cursor_set(). By default it will only look for cursors
2933 * provided by the engine.
2935 * @param item widget item with cursor already set.
2936 * @param engine_only boolean to define it cursors should be looked only
2937 * between the provided by the engine or searched on widget's theme as well.
2942 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
2943 Eina_Bool engine_only)
2945 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2946 elm_object_cursor_engine_only_set(item->view, engine_only);
2952 * Get the cursor engine only usage for this item cursor.
2954 * @param item widget item with cursor already set.
2955 * @return engine_only boolean to define it cursors should be looked only
2956 * between the provided by the engine or searched on widget's theme as well. If
2957 * the object does not have a cursor set, then EINA_FALSE is returned.
2962 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
2964 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2965 return elm_object_cursor_engine_only_get(item->view);
2968 // smart object funcs
2970 _smart_reconfigure(Smart_Data *sd)
2974 evas_object_move(sd->resize_obj, sd->x, sd->y);
2975 evas_object_resize(sd->resize_obj, sd->w, sd->h);
2979 evas_object_move(sd->hover_obj, sd->x, sd->y);
2980 evas_object_resize(sd->hover_obj, sd->w, sd->h);
2985 _elm_widget_item_content_part_set(Elm_Widget_Item *item,
2987 Evas_Object *content)
2989 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2990 if (!item->on_content_set_func) return;
2991 item->on_content_set_func((Elm_Object_Item *) item, part, content);
2995 _elm_widget_item_content_part_get(const Elm_Widget_Item *item,
2998 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2999 if (!item->on_content_get_func) return NULL;
3000 return item->on_content_get_func((Elm_Object_Item *) item, part);
3004 _elm_widget_item_content_part_unset(Elm_Widget_Item *item,
3007 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3008 if (!item->on_content_unset_func) return NULL;
3009 return item->on_content_unset_func((Elm_Object_Item *) item, part);
3013 _elm_widget_item_text_part_set(Elm_Widget_Item *item,
3017 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3018 if (!item->on_text_set_func) return;
3019 item->on_text_set_func((Elm_Object_Item *) item, part, label);
3023 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
3024 const char *emission,
3027 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3028 if (item->on_signal_emit_func)
3029 item->on_signal_emit_func((Elm_Object_Item *) item, emission, source);
3033 _elm_widget_item_text_part_get(const Elm_Widget_Item *item,
3036 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3037 if (!item->on_text_get_func) return NULL;
3038 return item->on_text_get_func((Elm_Object_Item *) item, part);
3042 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
3043 Elm_Widget_On_Content_Set_Cb func)
3045 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3046 item->on_content_set_func = func;
3050 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
3051 Elm_Widget_On_Content_Get_Cb func)
3053 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3054 item->on_content_get_func = func;
3058 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
3059 Elm_Widget_On_Content_Unset_Cb func)
3061 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3062 item->on_content_unset_func = func;
3066 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
3067 Elm_Widget_On_Text_Set_Cb func)
3069 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3070 item->on_text_set_func = func;
3074 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
3075 Elm_Widget_On_Text_Get_Cb func)
3077 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3078 item->on_text_get_func = func;
3082 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
3083 Elm_Widget_On_Signal_Emit_Cb func)
3085 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3086 item->on_signal_emit_func = func;
3090 _smart_add(Evas_Object *obj)
3094 sd = calloc(1, sizeof(Smart_Data));
3097 sd->x = sd->y = sd->w = sd->h = 0;
3099 sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
3100 evas_object_smart_data_set(obj, sd);
3103 static Evas_Object *
3104 _newest_focus_order_get(Evas_Object *obj,
3105 unsigned int *newest_focus_order,
3106 Eina_Bool can_focus_only)
3109 Evas_Object *child, *ret, *best;
3111 API_ENTRY return NULL;
3113 if (!evas_object_visible_get(obj)
3114 || (elm_widget_disabled_get(obj))
3115 || (elm_widget_tree_unfocusable_get(obj)))
3119 if (*newest_focus_order < sd->focus_order)
3121 *newest_focus_order = sd->focus_order;
3124 EINA_LIST_FOREACH(sd->subobjs, l, child)
3126 ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
3132 if ((!best) || (!elm_widget_can_focus_get(best)))
3139 _if_focused_revert(Evas_Object *obj,
3140 Eina_Bool can_focus_only)
3143 Evas_Object *newest = NULL;
3144 unsigned int newest_focus_order = 0;
3148 if (!sd->focused) return;
3149 if (!sd->parent_obj) return;
3151 top = elm_widget_top_get(sd->parent_obj);
3154 newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
3157 elm_object_unfocus(newest);
3158 elm_object_focus(newest);
3164 _smart_del(Evas_Object *obj)
3167 Edje_Signal_Data *esd;
3171 if (sd->del_pre_func) sd->del_pre_func(obj);
3174 sobj = sd->resize_obj;
3175 sd->resize_obj = NULL;
3176 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3177 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3178 evas_object_del(sobj);
3182 sobj = sd->hover_obj;
3183 sd->hover_obj = NULL;
3184 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3185 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3186 evas_object_del(sobj);
3188 EINA_LIST_FREE(sd->subobjs, sobj)
3190 evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
3191 evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
3192 evas_object_del(sobj);
3194 eina_list_free(sd->tooltips); /* should be empty anyway */
3195 eina_list_free(sd->cursors); /* should be empty anyway */
3196 EINA_LIST_FREE(sd->edje_signals, esd)
3198 eina_stringshare_del(esd->emission);
3199 eina_stringshare_del(esd->source);
3202 eina_list_free(sd->event_cb); /* should be empty anyway */
3203 if (sd->del_func) sd->del_func(obj);
3204 if (sd->style) eina_stringshare_del(sd->style);
3205 if (sd->type) eina_stringshare_del(sd->type);
3206 if (sd->theme) elm_theme_free(sd->theme);
3207 _if_focused_revert(obj, EINA_TRUE);
3212 _smart_move(Evas_Object *obj,
3219 _smart_reconfigure(sd);
3223 _smart_resize(Evas_Object *obj,
3230 _smart_reconfigure(sd);
3234 _smart_show(Evas_Object *obj)
3239 if ((list = evas_object_smart_members_get(obj)))
3241 EINA_LIST_FREE(list, o)
3243 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3244 evas_object_show(o);
3250 _smart_hide(Evas_Object *obj)
3256 list = evas_object_smart_members_get(obj);
3257 EINA_LIST_FREE(list, o)
3259 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3260 evas_object_hide(o);
3265 _smart_color_set(Evas_Object *obj,
3274 if ((list = evas_object_smart_members_get(obj)))
3276 EINA_LIST_FREE(list, o)
3278 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3279 evas_object_color_set(o, r, g, b, a);
3285 _smart_clip_set(Evas_Object *obj,
3291 if ((list = evas_object_smart_members_get(obj)))
3293 EINA_LIST_FREE(list, o)
3295 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3296 evas_object_clip_set(o, clip);
3302 _smart_clip_unset(Evas_Object *obj)
3307 if ((list = evas_object_smart_members_get(obj)))
3309 EINA_LIST_FREE(list, o)
3311 if (evas_object_data_get(o, "_elm_leaveme")) continue;
3312 evas_object_clip_unset(o);
3318 _smart_calculate(Evas_Object *obj)
3321 if (sd->changed_func) sd->changed_func(obj);
3324 /* never need to touch this */
3328 if (_e_smart) return;
3330 static const Evas_Smart_Class sc =
3333 EVAS_SMART_CLASS_VERSION,
3351 _e_smart = evas_smart_class_new(&sc);
3355 /* happy debug functions */
3358 _sub_obj_tree_dump(const Evas_Object *obj,
3363 for (i = 0; i < lvl * 3; i++)
3366 if (_elm_widget_is(obj))
3370 printf("+ %s(%p)\n",
3374 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
3375 EINA_LIST_FOREACH(sd->subobjs, l, obj)
3377 if (obj != sd->resize_obj)
3378 _sub_obj_tree_dump(obj, lvl + 1);
3382 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
3386 _sub_obj_tree_dot_dump(const Evas_Object *obj,
3389 if (!_elm_widget_is(obj))
3393 Eina_Bool visible = evas_object_visible_get(obj);
3394 Eina_Bool disabled = elm_widget_disabled_get(obj);
3395 Eina_Bool focused = elm_widget_focus_get(obj);
3396 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
3400 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
3403 fprintf(output, ", style=bold");
3406 fprintf(output, ", color=gray28");
3408 fprintf(output, " ];\n");
3411 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
3412 "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
3413 evas_object_name_get(obj), visible, disabled, focused, can_focus,
3417 fprintf(output, ", style=bold");
3420 fprintf(output, ", fontcolor=gray28");
3422 if ((disabled) || (!visible))
3423 fprintf(output, ", color=gray");
3425 fprintf(output, " ];\n");
3429 EINA_LIST_FOREACH(sd->subobjs, l, o)
3430 _sub_obj_tree_dot_dump(o, output);
3435 elm_widget_tree_dump(const Evas_Object *top)
3438 _sub_obj_tree_dump(top, 0);
3446 elm_widget_tree_dot_dump(const Evas_Object *top,
3450 if (!_elm_widget_is(top))
3452 fprintf(output, "graph " " { node [shape=record];\n");
3453 _sub_obj_tree_dot_dump(top, output);
3454 fprintf(output, "}\n");