1 #include <Elementary.h>
3 #include "elm_widget_container.h"
4 #include "elm_interface_scrollable.h"
6 static const char ELM_WIDGET_SMART_NAME[] = "elm_widget";
9 Elm_Widget_Smart_Data * sd = evas_object_smart_data_get(obj); \
10 if ((!sd) || (!_elm_widget_is(obj)))
11 #define INTERNAL_ENTRY \
12 Elm_Widget_Smart_Data * sd = evas_object_smart_data_get(obj); \
16 #define ELM_WIDGET_FOCUS_GET(obj) \
17 ((_elm_access_read_mode_get()) ? (elm_widget_highlight_get(obj)) : \
18 (elm_widget_focus_get(obj)))
19 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
20 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
22 struct _Elm_Event_Cb_Data
28 struct _Elm_Translate_String_Data
35 /* local subsystem globals */
36 static unsigned int focus_order = 0;
38 static inline Eina_Bool
39 _elm_widget_is(const Evas_Object *obj)
41 return evas_object_smart_type_check_ptr(obj, ELM_WIDGET_SMART_NAME);
44 static inline Eina_Bool
45 _is_focusable(Evas_Object *obj)
47 API_ENTRY return EINA_FALSE;
48 return sd->can_focus || (sd->child_can_focus);
51 static inline Eina_Bool
52 _elm_scrollable_is(const Evas_Object *obj)
54 INTERNAL_ENTRY EINA_FALSE;
55 return !!evas_object_smart_interface_get(obj, ELM_SCROLLABLE_IFACE_NAME);
58 /* what follows are basic (unimplemented) smart class functions */
59 #define UNIMPLEMENTED_MAKE(_prefix) \
61 _elm_widget_##_prefix##_func_unimplemented(Evas_Object * obj) \
63 WRN("The %s widget does not implement the \"" #_prefix "\" function.", \
64 elm_widget_type_get(obj)); \
68 UNIMPLEMENTED_MAKE(disable);
69 UNIMPLEMENTED_MAKE(translate);
71 #undef UNIMPLEMENTED_MAKE
75 * Resets the mirrored mode from the system mirror mode for widgets that are in
76 * automatic mirroring mode. This function does not call elm_widget_theme.
78 * @param obj The widget.
79 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
82 _elm_widget_mirrored_reload(Evas_Object *obj)
85 Eina_Bool mirrored = elm_config_mirrored_get();
87 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
89 sd->is_mirrored = mirrored;
94 _elm_widget_theme_func(Evas_Object *obj)
96 _elm_widget_mirrored_reload(obj);
98 elm_widget_disabled_set(obj, elm_widget_disabled_get(obj));
104 _elm_widget_on_focus_region_func_unimplemented(const Evas_Object *obj __UNUSED__,
105 Evas_Coord *x __UNUSED__,
106 Evas_Coord *y __UNUSED__,
107 Evas_Coord *w __UNUSED__,
108 Evas_Coord *h __UNUSED__)
110 WRN("The %s widget does not implement the \"on_focus_region\" function.",
111 elm_widget_type_get(obj));
116 _elm_widget_on_focus_func_unimplemented(Evas_Object *obj)
118 WRN("The %s widget does not implement the \"on_focus\" function.",
119 elm_widget_type_get(obj));
124 _elm_widget_event_func_unimplemented(Evas_Object *obj,
125 Evas_Object *source __UNUSED__,
126 Evas_Callback_Type type __UNUSED__,
127 void *event_info __UNUSED__)
129 WRN("The %s widget does not implement the \"event\" function.",
130 elm_widget_type_get(obj));
135 _elm_widget_focus_next_func_unimplemented(const Evas_Object *obj,
136 Elm_Focus_Direction dir __UNUSED__,
137 Evas_Object **next __UNUSED__)
139 WRN("The %s widget does not implement the \"focus_next\" function.",
140 elm_widget_type_get(obj));
145 _elm_widget_focus_direction_func_unimplemented(const Evas_Object *obj,
146 const Evas_Object *b __UNUSED__,
147 double degree __UNUSED__,
148 Evas_Object **target __UNUSED__,
149 double *weight __UNUSED__)
151 WRN("The %s widget does not implement the \"focus_direction\" function.",
152 elm_widget_type_get(obj));
157 _parents_focus(Evas_Object *obj)
159 for (; obj; obj = elm_widget_parent_get(obj))
162 if (sd->focused) return;
168 _parents_unfocus(Evas_Object *obj)
170 for (; obj; obj = elm_widget_parent_get(obj))
173 if (!sd->focused) return;
179 _on_sub_obj_hide(void *data __UNUSED__,
182 void *event_info __UNUSED__)
184 elm_widget_focus_hide_handle(obj);
188 _on_sub_obj_del(void *data,
191 void *event_info __UNUSED__)
193 Elm_Widget_Smart_Data *sd = data;
195 if (_elm_widget_is(obj))
197 if (elm_widget_focus_get(obj)) _parents_unfocus(sd->obj);
199 if (obj == sd->resize_obj)
201 /* already dels sub object */
202 elm_widget_resize_object_set(sd->obj, NULL);
205 else if (obj == sd->hover_obj)
207 sd->hover_obj = NULL;
212 if (!elm_widget_sub_object_del(sd->obj, obj))
213 ERR("failed to remove sub object %p from %p\n", obj, sd->obj);
218 _elm_widget_sub_object_add_func(Evas_Object *obj,
221 double scale, pscale = elm_widget_scale_get(sobj);
222 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
223 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
225 ELM_WIDGET_DATA_GET(obj, sd);
226 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
228 if (sobj == sd->parent_obj)
230 /* in this case, sobj must be an elm widget, or something
231 * very wrong is happening */
232 if (!_elm_widget_is(sobj)) return EINA_FALSE;
234 if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
235 WRN("You passed a parent object of obj = %p as the sub object = %p!",
239 if (_elm_widget_is(sobj))
241 ELM_WIDGET_DATA_GET(sobj, sdc);
243 if (sdc->parent_obj == obj) return EINA_TRUE;
246 if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
249 sdc->parent_obj = obj;
250 sdc->orient_mode = sd->orient_mode;
251 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
253 /* update child focusable-ness on self and parents, now that a
254 * focusable child got in */
255 if (!sd->child_can_focus && (_is_focusable(sobj)))
257 Elm_Widget_Smart_Data *sdp = sd;
259 sdp->child_can_focus = EINA_TRUE;
260 while (sdp->parent_obj)
262 sdp = evas_object_smart_data_get(sdp->parent_obj);
264 if (sdp->child_can_focus) break;
266 sdp->child_can_focus = EINA_TRUE;
272 void *data = evas_object_data_get(sobj, "elm-parent");
276 if (data == obj) return EINA_TRUE;
277 if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
281 sd->subobjs = eina_list_append(sd->subobjs, sobj);
282 evas_object_data_set(sobj, "elm-parent", obj);
283 evas_object_event_callback_add
284 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
285 if (_elm_widget_is(sobj))
287 evas_object_event_callback_add
288 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, sd);
290 scale = elm_widget_scale_get(sobj);
291 th = elm_widget_theme_get(sobj);
292 mirrored = elm_widget_mirrored_get(sobj);
294 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
295 elm_widget_theme(sobj);
297 if (elm_widget_focus_get(sobj)) _parents_focus(obj);
304 _elm_widget_sub_object_del_func(Evas_Object *obj,
307 Evas_Object *sobj_parent;
309 if (!sobj) return EINA_FALSE;
311 ELM_WIDGET_DATA_GET(obj, sd);
312 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
314 sobj_parent = evas_object_data_del(sobj, "elm-parent");
315 if (sobj_parent != obj)
317 static int abort_on_warn = -1;
319 ERR("removing sub object %p (%s) from parent %p (%s), "
320 "but elm-parent is different %p (%s)!",
321 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
322 sobj_parent, elm_widget_type_get(sobj_parent));
324 if (EINA_UNLIKELY(abort_on_warn == -1))
326 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
327 else abort_on_warn = 0;
329 if (abort_on_warn == 1) abort();
334 if (_elm_widget_is(sobj))
336 if (elm_widget_focus_get(sobj))
338 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
339 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
341 if ((sd->child_can_focus) && (_is_focusable(sobj)))
343 Evas_Object *parent = obj;
345 /* update child focusable-ness on self and parents, now that a
346 * focusable child is gone */
352 ELM_WIDGET_DATA_GET(parent, sdp);
354 sdp->child_can_focus = EINA_FALSE;
355 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
357 if ((subobj != sobj) && (_is_focusable(subobj)))
359 sdp->child_can_focus = EINA_TRUE;
364 /* break again, child_can_focus went back to
366 if (sdp->child_can_focus) break;
367 parent = sdp->parent_obj;
371 ELM_WIDGET_DATA_GET(sobj, sdc);
372 sdc->parent_obj = NULL;
375 if (sd->resize_obj == sobj) sd->resize_obj = NULL;
377 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
379 evas_object_event_callback_del_full
380 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
381 if (_elm_widget_is(sobj))
382 evas_object_event_callback_del_full
383 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, sd);
388 static const Evas_Smart_Cb_Description _smart_callbacks[] =
390 /* FIXME: complete later */
395 _smart_add(Evas_Object *obj)
397 const Evas_Smart_Class *sc;
398 const Evas_Smart *smart;
400 EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data);
402 smart = evas_object_smart_smart_get(obj);
403 sc = evas_smart_class_get(smart);
404 priv->api = (const Elm_Widget_Smart_Class *)sc;
406 priv->x = priv->y = priv->w = priv->h = 0;
407 priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale
409 elm_widget_can_focus_set(obj, EINA_TRUE);
410 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
412 /* just a helper for inheriting classes */
413 if (priv->resize_obj)
415 Evas_Object *r_obj = priv->resize_obj;
416 priv->resize_obj = NULL;
418 elm_widget_resize_object_set(obj, r_obj);
423 _newest_focus_order_get(Evas_Object *obj,
424 unsigned int *newest_focus_order,
425 Eina_Bool can_focus_only)
428 Evas_Object *child, *ret, *best;
430 API_ENTRY return NULL;
432 if (!evas_object_visible_get(obj)
433 || (elm_widget_disabled_get(obj))
434 || (elm_widget_tree_unfocusable_get(obj)))
438 if (*newest_focus_order < sd->focus_order)
440 *newest_focus_order = sd->focus_order;
443 EINA_LIST_FOREACH(sd->subobjs, l, child)
445 ret = _newest_focus_order_get
446 (child, newest_focus_order, can_focus_only);
452 if ((!best) || (!elm_widget_can_focus_get(best)))
459 _if_focused_revert(Evas_Object *obj,
460 Eina_Bool can_focus_only)
463 Evas_Object *newest = NULL;
464 unsigned int newest_focus_order = 0;
468 if (!sd->focused) return;
469 if (!sd->parent_obj) return;
471 top = elm_widget_top_get(sd->parent_obj);
474 newest = _newest_focus_order_get
475 (top, &newest_focus_order, can_focus_only);
478 elm_object_focus_set(newest, EINA_FALSE);
479 elm_object_focus_set(newest, EINA_TRUE);
485 _smart_del(Evas_Object *obj)
488 Elm_Translate_String_Data *ts;
489 Elm_Event_Cb_Data *ecb;
491 ELM_WIDGET_DATA_GET(obj, sd);
495 /* detach it from us */
496 evas_object_event_callback_del_full
497 (sd->hover_obj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
498 sd->hover_obj = NULL;
503 sobj = eina_list_data_get(sd->subobjs);
505 /* let the objects clean-up themselves and get rid of this list */
506 if (!elm_widget_sub_object_del(obj, sobj))
508 ERR("failed to remove sub object %p from %p\n", sobj, obj);
509 sd->subobjs = eina_list_remove_list
510 (sd->subobjs, sd->subobjs);
512 evas_object_del(sobj);
514 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
515 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
516 EINA_LIST_FREE (sd->translate_strings, ts)
518 eina_stringshare_del(ts->id);
519 eina_stringshare_del(ts->domain);
520 eina_stringshare_del(ts->string);
524 EINA_LIST_FREE (sd->event_cb, ecb)
527 if (sd->style) eina_stringshare_del(sd->style);
528 if (sd->theme) elm_theme_free(sd->theme);
529 _if_focused_revert(obj, EINA_TRUE);
530 if (sd->access_info) eina_stringshare_del(sd->access_info);
532 evas_object_smart_data_set(obj, NULL);
536 _smart_reconfigure(Elm_Widget_Smart_Data *sd)
540 evas_object_move(sd->resize_obj, sd->x, sd->y);
541 evas_object_resize(sd->resize_obj, sd->w, sd->h);
545 evas_object_move(sd->hover_obj, sd->x, sd->y);
546 evas_object_resize(sd->hover_obj, sd->w, sd->h);
551 _smart_move(Evas_Object *obj,
555 ELM_WIDGET_DATA_GET(obj, sd);
560 _smart_reconfigure(sd);
564 _smart_resize(Evas_Object *obj,
568 ELM_WIDGET_DATA_GET(obj, sd);
573 _smart_reconfigure(sd);
577 _smart_show(Evas_Object *obj)
582 if ((list = evas_object_smart_members_get(obj)))
584 EINA_LIST_FREE (list, o)
586 if (evas_object_data_get(o, "_elm_leaveme")) continue;
593 _smart_hide(Evas_Object *obj)
598 list = evas_object_smart_members_get(obj);
599 EINA_LIST_FREE (list, o)
601 if (evas_object_data_get(o, "_elm_leaveme")) continue;
607 _smart_color_set(Evas_Object *obj,
616 if ((list = evas_object_smart_members_get(obj)))
618 EINA_LIST_FREE (list, o)
620 if (evas_object_data_get(o, "_elm_leaveme")) continue;
621 evas_object_color_set(o, r, g, b, a);
627 _smart_clip_set(Evas_Object *obj,
633 if ((list = evas_object_smart_members_get(obj)))
635 EINA_LIST_FREE (list, o)
637 if (evas_object_data_get(o, "_elm_leaveme")) continue;
638 evas_object_clip_set(o, clip);
644 _smart_clip_unset(Evas_Object *obj)
649 if ((list = evas_object_smart_members_get(obj)))
651 EINA_LIST_FREE (list, o)
653 if (evas_object_data_get(o, "_elm_leaveme")) continue;
654 evas_object_clip_unset(o);
660 _smart_calculate(Evas_Object *obj __UNUSED__)
662 /* a NO-OP, on the base */
666 _smart_member_add(Evas_Object *obj,
671 if (evas_object_data_get(child, "_elm_leaveme")) return;
673 evas_object_color_get(obj, &r, &g, &b, &a);
674 evas_object_color_set(child, r, g, b, a);
676 evas_object_clip_set(child, evas_object_clip_get(obj));
678 if (evas_object_visible_get(obj))
679 evas_object_show(child);
681 evas_object_hide(child);
685 _smart_member_del(Evas_Object *obj __UNUSED__,
688 if (evas_object_data_get(child, "_elm_leaveme")) return;
689 evas_object_clip_unset(child);
693 _elm_widget_smart_set(Elm_Widget_Smart_Class *api)
695 Evas_Smart_Class *sc;
697 if (!(sc = (Evas_Smart_Class *)api))
700 sc->add = _smart_add;
701 sc->del = _smart_del;
702 sc->move = _smart_move;
703 sc->resize = _smart_resize;
704 sc->show = _smart_show;
705 sc->hide = _smart_hide;
706 sc->color_set = _smart_color_set;
707 sc->clip_set = _smart_clip_set;
708 sc->clip_unset = _smart_clip_unset;
709 sc->calculate = _smart_calculate;
710 sc->member_add = _smart_member_add;
711 sc->member_del = _smart_member_del;
713 #define API_DEFAULT_SET_UNIMPLEMENTED(_prefix) \
714 api->_prefix = _elm_widget_##_prefix##_func_unimplemented;
716 /* NB: always remember to call these parent versions on children,
717 * except for the unimplemented ones and calculate, which is moot */
719 #define API_DEFAULT_SET(_prefix) \
720 api->_prefix = _elm_widget_##_prefix##_func;
723 API_DEFAULT_SET_UNIMPLEMENTED(on_focus);
724 API_DEFAULT_SET_UNIMPLEMENTED(disable);
726 API_DEFAULT_SET(theme);
727 API_DEFAULT_SET_UNIMPLEMENTED(on_focus_region);
729 API_DEFAULT_SET_UNIMPLEMENTED(translate);
730 API_DEFAULT_SET_UNIMPLEMENTED(event);
731 API_DEFAULT_SET_UNIMPLEMENTED(focus_next);
732 API_DEFAULT_SET_UNIMPLEMENTED(focus_direction);
734 /* NB: because those two weren't hooks before, translate the
735 * individual calls to them on the widgets as we bring them to the
736 * new class hierarchy. also, sub_object_{add,del} must be
737 * different than member_{add,del} here, because widget parenting
738 * on elm does not always imply parent and child will live on the
740 API_DEFAULT_SET(sub_object_add);
741 API_DEFAULT_SET(sub_object_del);
743 #undef API_DEFAULT_SET
744 #undef API_DEFAULT_SET_UNIMPLEMENTED
746 sc->callbacks = _smart_callbacks;
750 static inline Eina_Bool
751 _elm_widget_focus_chain_manager_is(const Evas_Object *obj)
753 API_ENTRY return EINA_FALSE;
755 if (!sd->api) return EINA_FALSE;
756 return sd->api->focus_next &&
757 (sd->api->focus_next != _elm_widget_focus_next_func_unimplemented);
760 static inline Eina_Bool
761 _elm_widget_focus_direction_manager_is(const Evas_Object *obj)
763 API_ENTRY return EINA_FALSE;
765 if (!sd->api) return EINA_FALSE;
766 return sd->api->focus_direction &&
767 (sd->api->focus_direction !=
768 _elm_widget_focus_direction_func_unimplemented);
772 _obj_mouse_down(void *data,
774 Evas_Object *obj __UNUSED__,
777 Elm_Widget_Smart_Data *sd = data;
778 Evas_Event_Mouse_Down *ev = event_info;
779 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
780 sd->still_in = EINA_TRUE;
784 _obj_mouse_move(void *data,
789 Elm_Widget_Smart_Data *sd = data;
790 Evas_Event_Mouse_Move *ev = event_info;
793 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
794 sd->still_in = EINA_FALSE;
797 Evas_Coord x, y, w, h;
798 evas_object_geometry_get(obj, &x, &y, &w, &h);
799 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
800 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
801 sd->still_in = EINA_FALSE;
807 _obj_mouse_up(void *data,
810 void *event_info __UNUSED__)
812 Elm_Widget_Smart_Data *sd = data;
814 elm_widget_focus_mouse_up_handle(obj);
815 sd->still_in = EINA_FALSE;
819 _propagate_x_drag_lock(Evas_Object *obj,
825 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
828 sd2->child_drag_x_locked += dir;
829 _propagate_x_drag_lock(sd->parent_obj, dir);
835 _propagate_y_drag_lock(Evas_Object *obj,
841 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
844 sd2->child_drag_y_locked += dir;
845 _propagate_y_drag_lock(sd->parent_obj, dir);
851 _propagate_event(void *data,
857 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
858 Evas_Event_Flags *event_flags = NULL;
862 case EVAS_CALLBACK_KEY_DOWN:
864 Evas_Event_Key_Down *ev = event_info;
865 event_flags = &(ev->event_flags);
869 case EVAS_CALLBACK_KEY_UP:
871 Evas_Event_Key_Up *ev = event_info;
872 event_flags = &(ev->event_flags);
876 case EVAS_CALLBACK_MOUSE_WHEEL:
878 Evas_Event_Mouse_Wheel *ev = event_info;
879 event_flags = &(ev->event_flags);
887 elm_widget_event_propagate(obj, type, event_info, event_flags);
891 * If elm_widget_focus_region_get() returns EINA_FALSE, this function will
892 * ignore region show action.
895 _elm_widget_focus_region_show(const Evas_Object *obj)
897 Evas_Coord x, y, ox, oy, w, h;
902 o = elm_widget_parent_get(obj);
905 if (!elm_widget_focus_region_get(obj, &x, &y, NULL, NULL))
908 evas_object_geometry_get(obj, &ox, &oy, &w, &h);
909 if (w == 0 && h == 0) return;
913 if (_elm_scrollable_is(o))
915 Evas_Coord px, py, pw, ph;
918 evas_object_geometry_get(o, &px, &py, &pw, &ph);
920 if ((px <= ox) && (px + pw) >= (ox + w) &&
921 (py <= oy) && (py + ph) >= (oy + h))
923 // if object is already shown
924 o = elm_widget_parent_get(o);
927 else if ((px < ox) && ((px + pw) < (ox + w)))
929 // if object is over the viewport to the x axis.
932 else if ((py < oy) && ((py + ph) < (oy + h)))
934 // if object is over the viewport to the y axis.
938 ELM_SCROLLABLE_IFACE_GET(o, s_iface);
939 s_iface->content_pos_get(o, &rx, &ry);
940 s_iface->content_viewport_size_get(o, &w, &h);
945 s_iface->content_region_show(o, x, y, w, h);
949 o = elm_widget_parent_get(o);
954 _parent_focus(Evas_Object *obj)
958 if (sd->focused) return;
960 Evas_Object *o = elm_widget_parent_get(obj);
961 sd->focus_order_on_calc = EINA_TRUE;
963 if (o) _parent_focus(o);
965 if (!sd->focus_order_on_calc)
966 return; /* we don't want to override it if by means of any of the
967 callbacks below one gets to calculate our order
971 sd->focus_order = focus_order;
972 if (!sd->api) return;
973 if (sd->top_win_focused)
975 sd->focused = EINA_TRUE;
976 sd->api->on_focus(obj);
978 sd->focus_order_on_calc = EINA_FALSE;
980 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
981 _elm_access_highlight_set(obj);
985 _elm_object_focus_chain_del_cb(void *data,
988 void *event_info __UNUSED__)
990 Elm_Widget_Smart_Data *sd = data;
992 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
995 EAPI const Elm_Widget_Smart_Class *
996 elm_widget_smart_class_get(void)
998 static Elm_Widget_Smart_Class _sc =
999 ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(ELM_WIDGET_SMART_NAME);
1000 static const Elm_Widget_Smart_Class *class = NULL;
1005 _elm_widget_smart_set(&_sc);
1012 elm_widget_add(Evas_Smart *smart,
1013 Evas_Object *parent)
1018 e = evas_object_evas_get(parent);
1019 if (!e) return NULL;
1021 o = evas_object_smart_add(e, smart);
1022 elm_widget_parent_set(o, parent);
1028 elm_widget_parent_set(Evas_Object *obj,
1029 Evas_Object *parent)
1031 ELM_WIDGET_DATA_GET(obj, sd);
1033 if (!sd->api->parent_set) return;
1035 sd->api->parent_set(obj, parent);
1039 elm_widget_api_check(int ver)
1041 if (ver != ELM_INTERNAL_API_VERSION)
1043 CRITICAL("Elementary widget api versions do not match");
1050 elm_widget_access(Evas_Object *obj,
1051 Eina_Bool is_access)
1055 Eina_Bool ret = EINA_TRUE;
1057 API_ENTRY return EINA_FALSE;
1058 EINA_LIST_FOREACH(sd->subobjs, l, child)
1059 ret &= elm_widget_access(child, is_access);
1061 if (sd->api && sd->api->access)
1062 sd->api->access(obj, is_access);
1070 elm_widget_theme(Evas_Object *obj)
1076 Eina_Bool ret = EINA_TRUE;
1078 API_ENTRY return EINA_FALSE;
1080 EINA_LIST_FOREACH(sd->subobjs, l, child)
1081 if (_elm_widget_is(child)) ret &= elm_widget_theme(child);
1082 if (sd->resize_obj && _elm_widget_is(sd->resize_obj))
1083 ret &= elm_widget_theme(sd->resize_obj);
1084 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
1086 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1087 elm_tooltip_theme(tt);
1088 EINA_LIST_FOREACH(sd->cursors, l, cur)
1089 elm_cursor_theme(cur);
1091 if (!sd->api) return EINA_FALSE;
1093 ret &= sd->api->theme(obj);
1099 elm_widget_theme_specific(Evas_Object *obj,
1107 Elm_Theme *th2, *thdef;
1111 thdef = elm_theme_default_get();
1112 if (!th) th = thdef;
1116 if (!th2) th2 = thdef;
1124 if (th2 == thdef) break;
1125 th2 = th2->ref_theme;
1126 if (!th2) th2 = thdef;
1130 EINA_LIST_FOREACH(sd->subobjs, l, child)
1131 elm_widget_theme_specific(child, th, force);
1132 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
1133 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
1134 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1135 elm_tooltip_theme(tt);
1136 EINA_LIST_FOREACH(sd->cursors, l, cur)
1137 elm_cursor_theme(cur);
1138 if (!sd->api) return;
1139 sd->api->theme(obj);
1143 * Returns the widget's mirrored mode.
1145 * @param obj The widget.
1146 * @return mirrored mode of the object.
1150 elm_widget_mirrored_get(const Evas_Object *obj)
1152 API_ENTRY return EINA_FALSE;
1153 return sd->is_mirrored;
1157 * Sets the widget's mirrored mode.
1159 * @param obj The widget.
1160 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
1163 elm_widget_mirrored_set(Evas_Object *obj,
1168 mirrored = !!mirrored;
1170 if (sd->is_mirrored == mirrored) return;
1172 sd->is_mirrored = mirrored;
1173 elm_widget_theme(obj);
1177 * Returns the widget's mirrored mode setting.
1179 * @param obj The widget.
1180 * @return mirrored mode setting of the object.
1184 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
1186 API_ENTRY return EINA_FALSE;
1187 return sd->mirrored_auto_mode;
1191 * Sets the widget's mirrored mode setting.
1192 * When widget in automatic mode, it follows the system mirrored mode set by
1193 * elm_mirrored_set().
1194 * @param obj The widget.
1195 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
1198 elm_widget_mirrored_automatic_set(Evas_Object *obj,
1199 Eina_Bool automatic)
1202 if (sd->mirrored_auto_mode != automatic)
1204 sd->mirrored_auto_mode = automatic;
1208 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
1214 elm_widget_on_show_region_hook_set(Evas_Object *obj,
1215 void (*func)(void *data,
1221 sd->on_show_region = func;
1222 sd->on_show_region_data = data;
1226 elm_widget_sub_object_add(Evas_Object *obj,
1229 API_ENTRY return EINA_FALSE;
1230 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1232 if (!sd->api) return EINA_FALSE;
1233 return sd->api->sub_object_add(obj, sobj);
1237 elm_widget_sub_object_del(Evas_Object *obj,
1240 API_ENTRY return EINA_FALSE;
1241 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1243 if (!sobj) return EINA_FALSE;
1245 if (!sd->api) return EINA_FALSE;
1246 return sd->api->sub_object_del(obj, sobj);
1249 //SHKWAK : Temp Function for Indicator Issue
1250 // THIS MUST BE REMOVED
1252 EAPI const Eina_List *
1253 elm_widget_sub_object_list_get(const Evas_Object *obj)
1255 API_ENTRY return NULL;
1256 return (const Eina_List *)sd->subobjs;
1262 /* a resize object is a sub object with some more callbacks on it and
1263 * a smart member of the parent
1266 elm_widget_resize_object_set(Evas_Object *obj,
1269 Evas_Object *parent;
1273 if (sd->resize_obj == sobj) return;
1275 // orphan previous resize obj
1278 evas_object_clip_unset(sd->resize_obj);
1279 evas_object_smart_member_del(sd->resize_obj);
1281 if (_elm_widget_is(sd->resize_obj))
1283 if (elm_widget_focus_get(sd->resize_obj)) _parents_unfocus(obj);
1286 elm_widget_sub_object_del(obj, sd->resize_obj);
1289 sd->resize_obj = sobj;
1292 evas_object_event_callback_del_full(obj,
1293 EVAS_CALLBACK_MOUSE_DOWN,
1294 _obj_mouse_down, sd);
1295 evas_object_event_callback_del_full(obj,
1296 EVAS_CALLBACK_MOUSE_MOVE,
1297 _obj_mouse_move, sd);
1298 evas_object_event_callback_del_full(obj,
1299 EVAS_CALLBACK_MOUSE_UP,
1304 // orphan new resize obj
1305 parent = evas_object_data_get(sobj, "elm-parent");
1306 if (parent && parent != obj)
1308 ELM_WIDGET_DATA_GET(parent, sdp);
1310 /* should be there, just being paranoid */
1313 if (sdp->resize_obj == sobj)
1314 elm_widget_resize_object_set(parent, NULL);
1316 elm_widget_sub_object_del(parent, sobj);
1320 elm_widget_sub_object_add(obj, sobj);
1322 evas_object_smart_member_add(sobj, obj);
1324 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1325 _obj_mouse_down, sd);
1326 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
1327 _obj_mouse_move, sd);
1328 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
1330 _smart_reconfigure(sd);
1333 /* WARNING: the programmer is responsible, in the scenario of
1334 * exchanging a hover object, of cleaning the old hover "target"
1338 elm_widget_hover_object_set(Evas_Object *obj,
1344 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1345 _on_sub_obj_del, sd);
1347 sd->hover_obj = sobj;
1350 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1351 _on_sub_obj_del, sd);
1352 _smart_reconfigure(sd);
1357 elm_widget_can_focus_set(Evas_Object *obj,
1358 Eina_Bool can_focus)
1362 can_focus = !!can_focus;
1364 if (sd->can_focus == can_focus) return;
1365 sd->can_focus = can_focus;
1368 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1370 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1371 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1373 (void *)(long)EVAS_CALLBACK_KEY_UP);
1374 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1376 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1380 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1382 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1384 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1390 elm_widget_can_focus_get(const Evas_Object *obj)
1392 API_ENTRY return EINA_FALSE;
1393 return sd->can_focus;
1397 elm_widget_child_can_focus_get(const Evas_Object *obj)
1399 API_ENTRY return EINA_FALSE;
1400 return sd->child_can_focus;
1406 * This API makes the widget object and its children to be unfocusable.
1408 * This API can be helpful for an object to be deleted.
1409 * When an object will be deleted soon, it and its children may not
1410 * want to get focus (by focus reverting or by other focus controls).
1411 * Then, just use this API before deleting.
1413 * @param obj The widget root of sub-tree
1414 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1419 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1420 Eina_Bool tree_unfocusable)
1424 tree_unfocusable = !!tree_unfocusable;
1425 if (sd->tree_unfocusable == tree_unfocusable) return;
1426 sd->tree_unfocusable = tree_unfocusable;
1427 elm_widget_focus_tree_unfocusable_handle(obj);
1433 * This returns true, if the object sub-tree is unfocusable.
1435 * @param obj The widget root of sub-tree
1436 * @return EINA_TRUE if the object sub-tree is unfocusable
1441 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1443 API_ENTRY return EINA_FALSE;
1444 return sd->tree_unfocusable;
1450 * Get the list of focusable child objects.
1452 * This function retruns list of child objects which can get focus.
1454 * @param obj The parent widget
1455 * @retrun list of focusable child objects.
1460 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1462 API_ENTRY return NULL;
1465 Eina_List *child_list = NULL;
1470 EINA_LIST_FOREACH(sd->subobjs, l, child)
1472 if ((elm_widget_can_focus_get(child)) &&
1473 (evas_object_visible_get(child)) &&
1474 (!elm_widget_disabled_get(child)))
1475 child_list = eina_list_append(child_list, child);
1476 else if (elm_widget_is(child))
1478 Eina_List *can_focus_list;
1479 can_focus_list = elm_widget_can_focus_child_list_get(child);
1481 child_list = eina_list_merge(child_list, can_focus_list);
1489 elm_widget_highlight_ignore_set(Evas_Object *obj,
1493 sd->highlight_ignore = !!ignore;
1497 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1499 API_ENTRY return EINA_FALSE;
1500 return sd->highlight_ignore;
1504 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1505 Eina_Bool highlight)
1508 sd->highlight_in_theme = !!highlight;
1509 /* FIXME: if focused, it should switch from one mode to the other */
1513 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1515 API_ENTRY return EINA_FALSE;
1516 return sd->highlight_in_theme;
1520 elm_widget_focus_get(const Evas_Object *obj)
1522 API_ENTRY return EINA_FALSE;
1527 elm_widget_focused_object_get(const Evas_Object *obj)
1529 const Evas_Object *subobj;
1531 API_ENTRY return NULL;
1533 if (!sd->focused) return NULL;
1534 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1536 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1537 if (fobj) return fobj;
1539 return (Evas_Object *)obj;
1543 elm_widget_top_get(const Evas_Object *obj)
1545 API_ENTRY return NULL;
1546 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1547 return (Evas_Object *)obj;
1551 elm_widget_is(const Evas_Object *obj)
1553 return _elm_widget_is(obj);
1557 elm_widget_parent_widget_get(const Evas_Object *obj)
1559 Evas_Object *parent;
1561 if (_elm_widget_is(obj))
1563 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1564 if (!sd) return NULL;
1565 parent = sd->parent_obj;
1569 parent = evas_object_data_get(obj, "elm-parent");
1570 if (!parent) parent = evas_object_smart_parent_get(obj);
1575 Evas_Object *elm_parent;
1576 if (_elm_widget_is(parent)) break;
1577 elm_parent = evas_object_data_get(parent, "elm-parent");
1578 if (elm_parent) parent = elm_parent;
1579 else parent = evas_object_smart_parent_get(parent);
1585 elm_widget_parent2_get(const Evas_Object *obj)
1587 if (_elm_widget_is(obj))
1589 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1590 if (sd) return sd->parent2;
1596 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1599 sd->parent2 = parent;
1603 elm_widget_event_callback_add(Evas_Object *obj,
1608 EINA_SAFETY_ON_NULL_RETURN(func);
1609 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1612 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1616 elm_widget_event_callback_del(Evas_Object *obj,
1620 API_ENTRY return NULL;
1621 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1623 Elm_Event_Cb_Data *ecd;
1624 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1625 if ((ecd->func == func) && (ecd->data == data))
1628 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1629 return (void *)data;
1635 elm_widget_event_propagate(Evas_Object *obj,
1636 Evas_Callback_Type type,
1638 Evas_Event_Flags *event_flags)
1640 API_ENTRY return EINA_FALSE; //TODO reduce.
1642 if (!_elm_widget_is(obj)) return EINA_FALSE;
1643 Evas_Object *parent = obj;
1644 Elm_Event_Cb_Data *ecd;
1645 Eina_List *l, *l_prev;
1648 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1650 sd = evas_object_smart_data_get(parent);
1651 if ((!sd) || (!_elm_widget_is(obj)))
1652 return EINA_FALSE; //Not Elm Widget
1653 if (!sd->api) return EINA_FALSE;
1655 if (sd->api->event(parent, obj, type, event_info))
1658 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1660 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1661 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1664 parent = sd->parent_obj;
1673 * Set custom focus chain.
1675 * This function i set one new and overwrite any previous custom focus chain
1676 * with the list of objects. The previous list will be deleted and this list
1677 * will be managed. After setted, don't modity it.
1679 * @note On focus cycle, only will be evaluated children of this container.
1681 * @param obj The container widget
1682 * @param objs Chain of objects to pass focus
1686 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1691 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1693 elm_widget_focus_custom_chain_unset(obj);
1698 EINA_LIST_FOREACH(objs, l, o)
1700 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1701 _elm_object_focus_chain_del_cb, sd);
1704 sd->focus_chain = objs;
1710 * Get custom focus chain
1712 * @param obj The container widget
1715 EAPI const Eina_List *
1716 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1718 API_ENTRY return NULL;
1719 return (const Eina_List *)sd->focus_chain;
1725 * Unset custom focus chain
1727 * @param obj The container widget
1731 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1734 Eina_List *l, *l_next;
1737 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1739 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1740 _elm_object_focus_chain_del_cb, sd);
1741 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1748 * Append object to custom focus chain.
1750 * @note If relative_child equal to NULL or not in custom chain, the object
1751 * will be added in end.
1753 * @note On focus cycle, only will be evaluated children of this container.
1755 * @param obj The container widget
1756 * @param child The child to be added in custom chain
1757 * @param relative_child The relative object to position the child
1761 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1763 Evas_Object *relative_child)
1766 EINA_SAFETY_ON_NULL_RETURN(child);
1768 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1770 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1771 _elm_object_focus_chain_del_cb, sd);
1773 if (!relative_child)
1774 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1776 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1777 child, relative_child);
1783 * Prepend object to custom focus chain.
1785 * @note If relative_child equal to NULL or not in custom chain, the object
1786 * will be added in begin.
1788 * @note On focus cycle, only will be evaluated children of this container.
1790 * @param obj The container widget
1791 * @param child The child to be added in custom chain
1792 * @param relative_child The relative object to position the child
1796 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1798 Evas_Object *relative_child)
1801 EINA_SAFETY_ON_NULL_RETURN(child);
1803 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1805 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1806 _elm_object_focus_chain_del_cb, sd);
1808 if (!relative_child)
1809 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1811 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1812 child, relative_child);
1818 * Give focus to next object in object tree.
1820 * Give focus to next object in focus chain of one object sub-tree.
1821 * If the last object of chain already have focus, the focus will go to the
1822 * first object of chain.
1824 * @param obj The widget root of sub-tree
1825 * @param dir Direction to cycle the focus
1830 elm_widget_focus_cycle(Evas_Object *obj,
1831 Elm_Focus_Direction dir)
1833 Evas_Object *target = NULL;
1834 if (!_elm_widget_is(obj))
1836 elm_widget_focus_next_get(obj, dir, &target);
1840 if (_elm_config->access_mode && _elm_access_read_mode_get())
1842 _elm_access_highlight_set(target);
1843 _elm_widget_focus_region_show(target);
1845 else elm_widget_focus_steal(target);
1852 * Give focus to near object(in object tree) in one direction.
1854 * Give focus to near object(in object tree) in direction of current
1855 * focused object. If none focusable object in given direction or
1856 * none focused object in object tree, the focus will not change.
1858 * @param obj The reference widget
1859 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
1860 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
1861 * @return EINA_TRUE if focus is moved.
1866 elm_widget_focus_direction_go(Evas_Object *obj,
1869 Evas_Object *target = NULL;
1870 Evas_Object *current_focused = NULL;
1871 double weight = 0.0;
1873 if (!_elm_widget_is(obj)) return EINA_FALSE;
1874 if (!elm_widget_focus_get(obj)) return EINA_FALSE;
1876 current_focused = elm_widget_focused_object_get(obj);
1878 if (elm_widget_focus_direction_get
1879 (obj, current_focused, degree, &target, &weight))
1881 elm_widget_focus_steal(target);
1888 _direction_weight_get(const Evas_Object *obj1,
1889 const Evas_Object *obj2,
1892 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
1893 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
1894 double ax, ay, cx, cy;
1895 double weight = -1.0, g = 0.0;
1897 if (obj1 == obj2) return 0.0;
1900 while (degree >= 360.0)
1902 while (degree < 0.0)
1905 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
1906 cx = obj_x1 + (w1 / 2.0);
1907 cy = obj_y1 + (h1 / 2.0);
1908 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
1910 /* For overlapping cases. */
1911 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
1914 /* Change all points to relative one. */
1924 /* Get crossing points (ax, ay) between obj1 and a line extending
1925 * to the direction of current degree. */
1931 else if (degree == 90.0)
1936 else if (degree == 180.0)
1941 else if (degree == 270.0)
1948 g = tan(degree * (M_PI / 180.0));
1949 if ((degree > 0.0) && (degree < 90.0))
1952 if (ay <= yyy1) ax = xx1;
1959 else if ((degree > 90.0) && (degree < 180.0))
1962 if (ay <= yyy1) ax = x1;
1969 else if ((degree > 180.0) && (degree < 270.0))
1972 if (ay >= yy1) ax = x1;
1982 if (ay >= yy1) ax = xx1;
1991 /* Filter obj2, if it is not in the specific derection. */
1993 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
1994 double t1, t2, u1, v1, u2, v2;
1996 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
2006 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
2011 t1 = (u1 * ax) + (v1 * ay);
2012 t2 = (u2 * ax) + (v2 * ay);
2014 #define _R(x) (int)((x + 0.05) * 10.0)
2016 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
2022 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
2028 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
2034 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
2035 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
2044 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2046 else if (degree == 90.0)
2048 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2050 else if (degree == 180.0)
2052 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2054 else if (degree == 270.0)
2056 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2060 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
2062 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
2065 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
2067 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
2070 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
2073 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
2074 && (_R(ay * yy2) > 0)))
2077 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
2078 (_R((1.0 / g) * yyy2) <= _R(xx2)))
2080 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
2081 && (_R(ay * yyy2) > 0))) return 0.0;
2087 /* Calculate the weight for obj2. */
2090 if (_R(xx1) > _R(x2)) weight = -1.0;
2091 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2092 weight = (x2 - xx1) * (x2 - xx1);
2093 else if (_R(yy2) > 0)
2094 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
2095 else if (_R(yyy2) < 0)
2096 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
2097 else weight = (x2 - xx1) * (x2 - xx1);
2099 else if (degree == 90.0)
2101 if (_R(yyy1) > _R(yy2)) weight = -1.0;
2102 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2103 weight = (yy2 - yyy1) * (yy2 - yyy1);
2104 else if (_R(x2) > 0)
2105 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
2106 else if (_R(xx2) < 0)
2107 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
2108 else weight = (yy2 - yyy1) * (yy2 - yyy1);
2110 else if (degree == 180.0)
2112 if (_R(x1) < _R(xx2)) weight = -1.0;
2113 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2114 weight = (x1 - xx2) * (x1 - xx2);
2115 else if (_R(yy2) > 0)
2116 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
2117 else if (_R(yyy2) < 0)
2118 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
2119 else weight = (x1 - xx2) * (x1 - xx2);
2121 else if (degree == 270.0)
2123 if (_R(yy1) < _R(yyy2)) weight = -1.0;
2124 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2125 weight = (yy1 - yyy2) * (yy1 - yyy2);
2126 else if (_R(x2) > 0)
2127 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
2128 else if (_R(xx2) < 0)
2129 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
2130 else weight = (yy1 - yyy2) * (yy1 - yyy2);
2135 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
2136 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
2137 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
2141 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2142 ((ay - (g * x2)) * (ay - (g * x2)));
2144 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2148 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2149 ((ay - (g * xx2)) * (ay - (g * xx2)));
2151 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2153 sx[j] = (1.0 / g) * yy2;
2156 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2157 ((ay - yy2) * (ay - yy2));
2159 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2162 sx[j] = (1.0 / g) * yyy2;
2165 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2166 ((ay - yyy2) * (ay - yyy2));
2169 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2170 (_R(sy[0]) != _R(sy[1])))))
2174 if (_R(t_weight[k]) == 0) return -1.0;
2175 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2182 double ccx, ccy, t1_weight, x_diff, y_diff;
2183 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2185 x_diff = rx[k] - ccx;
2186 if (x_diff < 0) x_diff *= -1.0;
2187 y_diff = ry[k] - ccy;
2188 if (y_diff < 0) y_diff *= -1.0;
2190 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2191 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2192 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2197 /* Return the current object's weight. */
2198 if (weight == -1.0) return 0.0;
2199 if (_R(weight) == 0) return -1.0;
2203 return 1.0 / weight;
2209 * Get near object in one direction of base object.
2211 * Get near object(in the object sub-tree) in one direction of
2212 * base object. Return the near object by reference.
2213 * By initializing weight, you can filter objects locating far
2214 * from base object. If object is in the specific direction,
2215 * weight is (1/(distance^2)). If object is not exactly in one
2216 * direction, some penalty will be added.
2218 * @param obj The widget root of sub-tree
2219 * @param base The base object of the direction
2220 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2221 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2222 * @param direction The near object in one direction
2223 * @param weight The weight is bigger when the object is located near
2224 * @return EINA_TRUE if near object is updated.
2229 elm_widget_focus_direction_get(const Evas_Object *obj,
2230 const Evas_Object *base,
2232 Evas_Object **direction,
2237 API_ENTRY return EINA_FALSE;
2239 /* -1 means the best was already decided. Don't need any more searching. */
2240 if (!direction || !weight || !base || (obj == base))
2243 /* Ignore if disabled */
2244 if ((!evas_object_visible_get(obj))
2245 || (elm_widget_disabled_get(obj))
2246 || (elm_widget_tree_unfocusable_get(obj)))
2249 if (!sd->api) return EINA_FALSE;
2252 if (_elm_widget_focus_direction_manager_is(obj))
2253 return sd->api->focus_direction(obj, base, degree, direction, weight);
2255 if (!elm_widget_can_focus_get(obj) || elm_widget_focus_get(obj))
2258 c_weight = _direction_weight_get(base, obj, degree);
2259 if ((c_weight == -1.0) ||
2260 ((c_weight != 0.0) && (*weight != -1.0) &&
2261 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2263 if ((int)(*weight * 1000000) == (int)(c_weight * 1000000))
2265 Elm_Widget_Smart_Data *sd1 =
2266 evas_object_smart_data_get(*direction);
2269 if (sd->focus_order <= sd1->focus_order)
2273 *direction = (Evas_Object *)obj;
2283 * Get near object in one direction of base object in list.
2285 * Get near object in one direction of base object in the specific
2286 * object list. Return the near object by reference.
2287 * By initializing weight, you can filter objects locating far
2288 * from base object. If object is in the specific direction,
2289 * weight is (1/(distance^2)). If object is not exactly in one
2290 * direction, some penalty will be added.
2292 * @param obj The widget root of sub-tree
2293 * @param base The base object of the direction
2294 * @param items list with ordered objects
2295 * @param list_data_get function to get the object from one item of list
2296 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2297 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2298 * @param direction The near object in one direction
2299 * @param weight The weight is bigger when the object is located near
2300 * @return EINA_TRUE if near object is updated.
2305 elm_widget_focus_list_direction_get(const Evas_Object *obj,
2306 const Evas_Object *base,
2307 const Eina_List *items,
2308 void *(*list_data_get)(const Eina_List *l),
2310 Evas_Object **direction,
2313 API_ENTRY return EINA_FALSE;
2314 if (!direction || !weight || !base || !items)
2317 const Eina_List *l = items;
2318 Evas_Object *current_best = *direction;
2320 for (; l; l = eina_list_next(l))
2322 Evas_Object *cur = list_data_get(l);
2323 elm_widget_focus_direction_get(cur, base, degree, direction, weight);
2325 if (current_best != *direction)
2334 * Get next object in focus chain of object tree.
2336 * Get next object in focus chain of one object sub-tree.
2337 * Return the next object by reference. If don't have any candidate to receive
2338 * focus before chain end, the first candidate will be returned.
2340 * @param obj The widget root of sub-tree
2341 * @param dir Direction os focus chain
2342 * @param next The next object in focus chain
2343 * @return EINA_TRUE if don't need focus chain restart/loop back
2344 * to use 'next' obj.
2349 elm_widget_focus_next_get(const Evas_Object *obj,
2350 Elm_Focus_Direction dir,
2357 API_ENTRY return EINA_FALSE;
2359 /* Ignore if disabled */
2360 if ((!evas_object_visible_get(obj))
2361 || (elm_widget_disabled_get(obj))
2362 || (elm_widget_tree_unfocusable_get(obj)))
2365 if (!sd->api) return EINA_FALSE;
2368 if (_elm_widget_focus_chain_manager_is(obj))
2369 return sd->api->focus_next(obj, dir, next);
2371 if (!elm_widget_can_focus_get(obj))
2374 /* focusable object but does not have access info */
2375 if (_elm_config->access_mode)
2377 if (!_elm_access_object_get(obj)) return EINA_FALSE;
2381 *next = (Evas_Object *)obj;
2382 return !ELM_WIDGET_FOCUS_GET(obj);
2388 * Get next object in focus chain of object tree in list.
2390 * Get next object in focus chain of one object sub-tree ordered by one list.
2391 * Return the next object by reference. If don't have any candidate to receive
2392 * focus before list end, the first candidate will be returned.
2394 * @param obj The widget root of sub-tree
2395 * @param dir Direction os focus chain
2396 * @param items list with ordered objects
2397 * @param list_data_get function to get the object from one item of list
2398 * @param next The next object in focus chain
2399 * @return EINA_TRUE if don't need focus chain restart/loop back
2400 * to use 'next' obj.
2405 elm_widget_focus_list_next_get(const Evas_Object *obj,
2406 const Eina_List *items,
2407 void *(*list_data_get)(const Eina_List *list),
2408 Elm_Focus_Direction dir,
2411 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2417 if (!_elm_widget_is(obj))
2424 if (dir == ELM_FOCUS_PREVIOUS)
2426 items = eina_list_last(items);
2427 list_next = eina_list_prev;
2429 else if (dir == ELM_FOCUS_NEXT)
2430 list_next = eina_list_next;
2434 const Eina_List *l = items;
2436 /* Recovery last focused sub item */
2437 if (ELM_WIDGET_FOCUS_GET(obj))
2439 for (; l; l = list_next(l))
2441 Evas_Object *cur = list_data_get(l);
2442 if (ELM_WIDGET_FOCUS_GET(cur)) break;
2445 /* Focused object, but no focused sub item */
2449 const Eina_List *start = l;
2450 Evas_Object *to_focus = NULL;
2452 /* Interate sub items */
2453 /* Go to end of list */
2454 for (; l; l = list_next(l))
2456 Evas_Object *tmp = NULL;
2457 Evas_Object *cur = list_data_get(l);
2459 if (elm_widget_parent_get(cur) != obj)
2462 /* Try Focus cycle in subitem */
2463 if (elm_widget_focus_next_get(cur, dir, &tmp))
2468 else if ((tmp) && (!to_focus))
2474 /* Get First possible */
2475 for (; l != start; l = list_next(l))
2477 Evas_Object *tmp = NULL;
2478 Evas_Object *cur = list_data_get(l);
2480 if (elm_widget_parent_get(cur) != obj)
2483 /* Try Focus cycle in subitem */
2484 elm_widget_focus_next_get(cur, dir, &tmp);
2497 elm_widget_highlight_get(const Evas_Object *obj)
2499 API_ENTRY return EINA_FALSE;
2500 return sd->highlighted;
2504 elm_widget_parent_highlight_set(Evas_Object *obj,
2505 Eina_Bool highlighted)
2509 highlighted = !!highlighted;
2511 Evas_Object *o = elm_widget_parent_get(obj);
2513 if (o) elm_widget_parent_highlight_set(o, highlighted);
2515 sd->highlighted = highlighted;
2519 elm_widget_signal_emit(Evas_Object *obj,
2520 const char *emission,
2525 if (evas_object_smart_type_check(obj, "elm_layout"))
2526 elm_layout_signal_emit(obj, emission, source);
2527 else if (evas_object_smart_type_check(obj, "elm_icon"))
2529 WRN("Deprecated function. This functionality on icon objects"
2530 " will be dropped on a next release.");
2531 _elm_icon_signal_emit(obj, emission, source);
2536 elm_widget_signal_callback_add(Evas_Object *obj,
2537 const char *emission,
2539 Edje_Signal_Cb func,
2544 EINA_SAFETY_ON_NULL_RETURN(func);
2546 if (evas_object_smart_type_check(obj, "elm_layout"))
2547 elm_layout_signal_callback_add(obj, emission, source, func, data);
2548 else if (evas_object_smart_type_check(obj, "elm_icon"))
2550 WRN("Deprecated function. This functionality on icon objects"
2551 " will be dropped on a next release.");
2553 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2558 elm_widget_signal_callback_del(Evas_Object *obj,
2559 const char *emission,
2561 Edje_Signal_Cb func)
2565 API_ENTRY return NULL;
2567 if (evas_object_smart_type_check(obj, "elm_layout"))
2568 data = elm_layout_signal_callback_del(obj, emission, source, func);
2569 else if (evas_object_smart_type_check(obj, "elm_icon"))
2571 WRN("Deprecated function. This functionality on icon objects"
2572 " will be dropped on a next release.");
2574 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2581 elm_widget_focus_set(Evas_Object *obj,
2586 if (!sd->api) return;
2591 sd->focus_order = focus_order;
2592 sd->focused = EINA_TRUE;
2593 sd->api->on_focus(obj);
2598 if ((_is_focusable(sd->resize_obj)) &&
2599 (!elm_widget_disabled_get(sd->resize_obj)))
2601 elm_widget_focus_set(sd->resize_obj, first);
2608 EINA_LIST_FOREACH(sd->subobjs, l, child)
2610 if ((_is_focusable(child)) &&
2611 (!elm_widget_disabled_get(child)))
2613 elm_widget_focus_set(child, first);
2624 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2626 if ((_is_focusable(child)) &&
2627 (!elm_widget_disabled_get(child)))
2629 elm_widget_focus_set(child, first);
2635 if ((_is_focusable(sd->resize_obj)) &&
2636 (!elm_widget_disabled_get(sd->resize_obj)))
2638 elm_widget_focus_set(sd->resize_obj, first);
2645 elm_widget_parent_get(const Evas_Object *obj)
2647 API_ENTRY return NULL;
2648 return sd->parent_obj;
2652 elm_widget_focused_object_clear(Evas_Object *obj)
2656 if (!sd->api) return;
2658 if (!sd->focused) return;
2660 // FIXME: evas_object_ref/unref is temporary code to fix logical issue.
2661 // After Eo is applied to elementary, remove these.
2662 evas_object_ref(obj);
2663 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
2664 elm_widget_focused_object_clear(sd->resize_obj);
2669 EINA_LIST_FOREACH(sd->subobjs, l, child)
2671 if (elm_widget_focus_get(child))
2673 elm_widget_focused_object_clear(child);
2678 sd->focused = EINA_FALSE;
2679 sd->api->on_focus(obj);
2680 evas_object_unref(obj);
2684 elm_widget_focus_steal(Evas_Object *obj)
2686 Evas_Object *parent, *parent2, *o;
2689 if (sd->focused) return;
2690 if (sd->disabled) return;
2691 if (!sd->can_focus) return;
2692 if (sd->tree_unfocusable) return;
2696 o = elm_widget_parent_get(parent);
2698 sd = evas_object_smart_data_get(o);
2699 if (sd->disabled || sd->tree_unfocusable) return;
2700 if (sd->focused) break;
2703 if ((!elm_widget_parent_get(parent)) &&
2704 (!elm_widget_parent2_get(parent)))
2705 elm_widget_focused_object_clear(parent);
2708 parent2 = elm_widget_parent_get(parent);
2709 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2711 sd = evas_object_smart_data_get(parent);
2714 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2715 elm_widget_focused_object_clear(sd->resize_obj);
2720 EINA_LIST_FOREACH(sd->subobjs, l, child)
2722 if (elm_widget_focus_get(child))
2724 elm_widget_focused_object_clear(child);
2732 _elm_widget_focus_region_show(obj);
2737 elm_widget_focus_restore(Evas_Object *obj)
2739 Evas_Object *newest = NULL;
2740 unsigned int newest_focus_order = 0;
2743 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2746 elm_object_focus_set(newest, EINA_FALSE);
2747 elm_object_focus_set(newest, EINA_TRUE);
2752 _elm_widget_top_win_focused_set(Evas_Object *obj,
2753 Eina_Bool top_win_focused)
2759 if (sd->top_win_focused == top_win_focused) return;
2761 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2762 EINA_LIST_FOREACH(sd->subobjs, l, child)
2764 _elm_widget_top_win_focused_set(child, top_win_focused);
2766 sd->top_win_focused = top_win_focused;
2770 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2772 API_ENTRY return EINA_FALSE;
2773 return sd->top_win_focused;
2777 elm_widget_disabled_set(Evas_Object *obj,
2782 if (sd->disabled == disabled) return;
2783 sd->disabled = !!disabled;
2784 elm_widget_focus_disabled_handle(obj);
2785 if (!sd->api) return;
2786 sd->api->disable(obj);
2790 elm_widget_disabled_get(const Evas_Object *obj)
2793 return sd->disabled;
2797 elm_widget_show_region_set(Evas_Object *obj,
2802 Eina_Bool forceshow)
2804 Evas_Object *parent_obj, *child_obj;
2805 Evas_Coord px, py, cx, cy;
2809 evas_smart_objects_calculate(evas_object_evas_get(obj));
2810 ELM_WIDGET_CHECK_OR_RETURN(obj);
2812 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2813 (w == sd->rw) && (h == sd->rh)) return;
2819 if (sd->on_show_region)
2821 (sd->on_show_region_data, obj);
2825 parent_obj = sd->parent_obj;
2826 child_obj = sd->obj;
2827 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2828 sd = evas_object_smart_data_get(parent_obj);
2831 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2832 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2841 if (sd->on_show_region)
2844 (sd->on_show_region_data, parent_obj);
2851 elm_widget_show_region_get(const Evas_Object *obj,
2867 * Get the focus region of the given widget.
2869 * @return show region or not
2870 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
2872 * The focus region is the area of a widget that should brought into the
2873 * visible area when the widget is focused. Mostly used to show the part of
2874 * an entry where the cursor is, for example. The area returned is relative
2875 * to the object @p obj.
2877 * @param obj The widget object
2878 * @param x Where to store the x coordinate of the area
2879 * @param y Where to store the y coordinate of the area
2880 * @param w Where to store the width of the area
2881 * @param h Where to store the height of the area
2886 elm_widget_focus_region_get(const Evas_Object *obj,
2892 API_ENTRY return EINA_FALSE;
2893 if (!sd->api->on_focus_region(obj, x, y, w, h))
2895 evas_object_geometry_get(obj, NULL, NULL, w, h);
2903 elm_widget_scrollable_children_get(Evas_Object *obj)
2905 Eina_List *l, *ret = NULL;
2908 API_ENTRY return NULL;
2910 EINA_LIST_FOREACH(sd->subobjs, l, child)
2912 if (_elm_scrollable_is(child))
2913 ret = eina_list_append(ret, child);
2920 elm_widget_scroll_hold_push(Evas_Object *obj)
2924 if (sd->scroll_hold == 1)
2926 if (_elm_scrollable_is(obj))
2928 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2929 s_iface->hold_set(obj, EINA_TRUE);
2933 Eina_List *scr_children, *l;
2936 scr_children = elm_widget_scrollable_children_get(obj);
2937 EINA_LIST_FOREACH(scr_children, l, child)
2939 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2940 s_iface->hold_set(child, EINA_TRUE);
2942 eina_list_free(scr_children);
2945 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2946 // FIXME: on delete/reparent hold pop
2950 elm_widget_scroll_hold_pop(Evas_Object *obj)
2954 if (!sd->scroll_hold)
2956 if (_elm_scrollable_is(obj))
2958 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2959 s_iface->hold_set(obj, EINA_FALSE);
2963 Eina_List *scr_children, *l;
2966 scr_children = elm_widget_scrollable_children_get(obj);
2967 EINA_LIST_FOREACH(scr_children, l, child)
2969 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2970 s_iface->hold_set(child, EINA_FALSE);
2972 eina_list_free(scr_children);
2975 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2976 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2980 elm_widget_scroll_hold_get(const Evas_Object *obj)
2983 return sd->scroll_hold;
2987 elm_widget_scroll_freeze_push(Evas_Object *obj)
2990 sd->scroll_freeze++;
2991 if (sd->scroll_freeze == 1)
2993 if (_elm_scrollable_is(obj))
2995 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2996 s_iface->freeze_set(obj, EINA_TRUE);
3000 Eina_List *scr_children, *l;
3003 scr_children = elm_widget_scrollable_children_get(obj);
3004 EINA_LIST_FOREACH(scr_children, l, child)
3006 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
3007 s_iface->freeze_set(child, EINA_TRUE);
3009 eina_list_free(scr_children);
3012 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
3013 // FIXME: on delete/reparent freeze pop
3017 elm_widget_scroll_freeze_pop(Evas_Object *obj)
3020 sd->scroll_freeze--;
3021 if (!sd->scroll_freeze)
3023 if (_elm_scrollable_is(obj))
3025 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
3026 s_iface->freeze_set(obj, EINA_FALSE);
3030 Eina_List *scr_children, *l;
3033 scr_children = elm_widget_scrollable_children_get(obj);
3034 EINA_LIST_FOREACH(scr_children, l, child)
3036 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
3037 s_iface->freeze_set(child, EINA_FALSE);
3039 eina_list_free(scr_children);
3042 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
3043 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3047 elm_widget_scroll_freeze_get(const Evas_Object *obj)
3050 return sd->scroll_freeze;
3054 elm_widget_scale_set(Evas_Object *obj,
3058 if (scale <= 0.0) scale = 0.0;
3059 if (sd->scale != scale)
3062 elm_widget_theme(obj);
3067 elm_widget_scale_get(const Evas_Object *obj)
3069 API_ENTRY return 1.0;
3070 // FIXME: save walking up the tree by storing/caching parent scale
3071 if (sd->scale == 0.0)
3074 return elm_widget_scale_get(sd->parent_obj);
3082 elm_widget_theme_set(Evas_Object *obj,
3086 if (sd->theme != th)
3088 if (sd->theme) elm_theme_free(sd->theme);
3091 elm_widget_theme(obj);
3096 elm_widget_text_part_set(Evas_Object *obj,
3102 if (evas_object_smart_type_check(obj, "elm_layout"))
3103 elm_layout_text_set(obj, part, label);
3107 elm_widget_text_part_get(const Evas_Object *obj,
3110 API_ENTRY return NULL;
3112 if (evas_object_smart_type_check(obj, "elm_layout"))
3113 return elm_layout_text_get(obj, part);
3119 elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
3126 Elm_Translate_String_Data *ts = NULL;
3129 str = eina_stringshare_add(part);
3130 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3137 eina_stringshare_del(str);
3140 ts = malloc(sizeof(Elm_Translate_String_Data));
3144 ts->domain = eina_stringshare_add(domain);
3145 ts->string = eina_stringshare_add(label);
3146 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
3152 eina_stringshare_replace(&ts->domain, domain);
3153 eina_stringshare_replace(&ts->string, label);
3157 sd->translate_strings = eina_list_remove_list(
3158 sd->translate_strings, l);
3159 eina_stringshare_del(ts->id);
3160 eina_stringshare_del(ts->domain);
3161 eina_stringshare_del(ts->string);
3164 eina_stringshare_del(str);
3168 if (label && label[0])
3169 label = dgettext(domain, label);
3171 elm_widget_text_part_set(obj, part, label);
3175 elm_widget_translatable_text_part_get(const Evas_Object *obj,
3178 const char *str, *ret = NULL;
3180 Elm_Translate_String_Data *ts;
3181 API_ENTRY return NULL;
3183 str = eina_stringshare_add(part);
3184 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3190 eina_stringshare_del(str);
3195 elm_widget_translate(Evas_Object *obj)
3200 Elm_Translate_String_Data *ts;
3205 EINA_LIST_FOREACH(sd->subobjs, l, child)
3206 elm_widget_translate(child);
3207 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
3208 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3209 if (!sd->api) return;
3210 sd->api->translate(obj);
3213 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3215 const char *s = dgettext(ts->domain, ts->string);
3216 elm_widget_text_part_set(obj, ts->id, s);
3222 elm_widget_content_part_set(Evas_Object *obj,
3224 Evas_Object *content)
3228 if (!sd->api) return;
3229 if (evas_object_smart_type_check(obj, "elm_container"))
3230 ELM_CONTAINER_CLASS(sd->api)->content_set(obj, part, content);
3234 elm_widget_content_part_get(const Evas_Object *obj,
3237 API_ENTRY return NULL;
3239 if (!sd->api) return NULL;
3241 if (evas_object_smart_type_check(obj, "elm_container"))
3242 return ELM_CONTAINER_CLASS(sd->api)->content_get(obj, part);
3248 elm_widget_content_part_unset(Evas_Object *obj,
3251 API_ENTRY return NULL;
3253 if (!sd->api) return NULL;
3254 if (evas_object_smart_type_check(obj, "elm_container"))
3255 return ELM_CONTAINER_CLASS(sd->api)->content_unset(obj, part);
3261 elm_widget_access_info_set(Evas_Object *obj,
3265 if (sd->access_info) eina_stringshare_del(sd->access_info);
3266 if (!txt) sd->access_info = NULL;
3267 else sd->access_info = eina_stringshare_add(txt);
3271 elm_widget_access_info_get(const Evas_Object *obj)
3273 API_ENTRY return NULL;
3274 return sd->access_info;
3278 elm_widget_theme_get(const Evas_Object *obj)
3280 API_ENTRY return NULL;
3284 return elm_widget_theme_get(sd->parent_obj);
3292 elm_widget_style_set(Evas_Object *obj,
3295 API_ENTRY return EINA_FALSE;
3297 if (eina_stringshare_replace(&sd->style, style))
3298 return elm_widget_theme(obj);
3304 elm_widget_style_get(const Evas_Object *obj)
3306 API_ENTRY return NULL;
3307 if (sd->style) return sd->style;
3312 elm_widget_tooltip_add(Evas_Object *obj,
3316 sd->tooltips = eina_list_append(sd->tooltips, tt);
3320 elm_widget_tooltip_del(Evas_Object *obj,
3324 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3328 elm_widget_cursor_add(Evas_Object *obj,
3332 sd->cursors = eina_list_append(sd->cursors, cur);
3336 elm_widget_cursor_del(Evas_Object *obj,
3340 sd->cursors = eina_list_remove(sd->cursors, cur);
3344 elm_widget_drag_lock_x_set(Evas_Object *obj,
3348 if (sd->drag_x_locked == lock) return;
3349 sd->drag_x_locked = lock;
3350 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
3351 else _propagate_x_drag_lock(obj, -1);
3355 elm_widget_drag_lock_y_set(Evas_Object *obj,
3359 if (sd->drag_y_locked == lock) return;
3360 sd->drag_y_locked = lock;
3361 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
3362 else _propagate_y_drag_lock(obj, -1);
3366 elm_widget_drag_lock_x_get(const Evas_Object *obj)
3368 API_ENTRY return EINA_FALSE;
3369 return sd->drag_x_locked;
3373 elm_widget_drag_lock_y_get(const Evas_Object *obj)
3375 API_ENTRY return EINA_FALSE;
3376 return sd->drag_y_locked;
3380 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
3383 return sd->child_drag_x_locked;
3387 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
3390 return sd->child_drag_y_locked;
3394 elm_widget_theme_object_set(Evas_Object *obj,
3397 const char *welement,
3400 API_ENTRY return EINA_FALSE;
3404 if (!_elm_theme_object_set(obj, edj, wname, welement, wstyle))
3407 if (sd->orient_mode != -1)
3410 snprintf(buf, sizeof(buf), "elm,state,orient,%d", ret);
3411 elm_widget_signal_emit(obj, buf, "elm");
3418 elm_widget_is_check(const Evas_Object *obj)
3420 static int abort_on_warn = -1;
3421 if (elm_widget_is(obj))
3424 ERR("Passing Object: %p.", obj);
3425 if (abort_on_warn == -1)
3427 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3428 else abort_on_warn = 0;
3430 if (abort_on_warn == 1) abort();
3435 elm_widget_type_get(const Evas_Object *obj)
3437 API_ENTRY return NULL;
3439 return evas_object_type_get(obj);
3443 elm_widget_type_check(const Evas_Object *obj,
3447 const char *provided, *expected = "(unknown)";
3448 static int abort_on_warn = -1;
3450 provided = elm_widget_type_get(obj);
3451 /* TODO: eventually migrate to check_ptr version */
3452 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
3453 if (type) expected = type;
3454 if ((!provided) || (!provided[0]))
3456 provided = evas_object_type_get(obj);
3457 if ((!provided) || (!provided[0]))
3458 provided = "(unknown)";
3460 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
3461 " type: '%s'", obj, func, provided, expected);
3462 if (abort_on_warn == -1)
3464 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3465 else abort_on_warn = 0;
3467 if (abort_on_warn == 1) abort();
3471 static Evas_Object *
3472 _widget_name_find(const Evas_Object *obj,
3479 INTERNAL_ENTRY NULL;
3481 if (!_elm_widget_is(obj)) return NULL;
3484 s = evas_object_name_get(sd->resize_obj);
3485 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
3486 if ((recurse != 0) &&
3487 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
3490 EINA_LIST_FOREACH(sd->subobjs, l, child)
3492 s = evas_object_name_get(child);
3493 if ((s) && (!strcmp(s, name))) return child;
3494 if ((recurse != 0) &&
3495 ((child = _widget_name_find(child, name, recurse - 1))))
3500 s = evas_object_name_get(sd->hover_obj);
3501 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
3502 if ((recurse != 0) &&
3503 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
3510 elm_widget_name_find(const Evas_Object *obj,
3514 API_ENTRY return NULL;
3515 if (!name) return NULL;
3516 return _widget_name_find(obj, name, recurse);
3520 elm_widget_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3522 int orient_mode = -1;
3526 if (disabled && (sd->orient_mode == -1)) return;
3527 if (!disabled && (sd->orient_mode != -1)) return;
3531 //Get current orient mode from it's parent otherwise, 0.
3532 sd->orient_mode = 0;
3533 ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
3534 if (!sd_parent) orient_mode = 0;
3535 else orient_mode = sd_parent->orient_mode;
3537 elm_widget_orientation_set(obj, orient_mode);
3541 elm_widget_orientation_mode_disabled_get(const Evas_Object *obj)
3545 API_ENTRY return EINA_FALSE;
3547 if (sd->orient_mode == -1) ret = EINA_TRUE;
3548 else ret = EINA_FALSE;
3553 elm_widget_orientation_set(Evas_Object *obj, int rotation)
3560 if ((sd->orient_mode == rotation) || (sd->orient_mode == -1)) return;
3562 sd->orient_mode = rotation;
3564 EINA_LIST_FOREACH (sd->subobjs, l, child)
3565 elm_widget_orientation_set(child, rotation);
3570 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
3571 elm_widget_signal_emit(obj, buf, "elm");
3578 * Split string in words
3580 * @param str Source string
3581 * @return List of const words
3583 * @see elm_widget_stringlist_free()
3587 elm_widget_stringlist_get(const char *str)
3589 Eina_List *list = NULL;
3591 if (!str) return NULL;
3592 for (b = s = str; 1; s++)
3594 if ((*s == ' ') || (!*s))
3596 char *t = malloc(s - b + 1);
3599 strncpy(t, b, s - b);
3601 list = eina_list_append(list, eina_stringshare_add(t));
3612 elm_widget_stringlist_free(Eina_List *list)
3615 EINA_LIST_FREE (list, s)
3616 eina_stringshare_del(s);
3620 elm_widget_focus_hide_handle(Evas_Object *obj)
3622 if (!_elm_widget_is(obj))
3624 _if_focused_revert(obj, EINA_TRUE);
3628 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
3630 Evas_Object *o = obj;
3633 if (_elm_widget_is(o)) break;
3634 o = evas_object_smart_parent_get(o);
3638 if (!_is_focusable(o)) return;
3639 elm_widget_focus_steal(o);
3643 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
3647 //FIXME: Need to check whether the object is unfocusable or not.
3649 if (!elm_widget_parent_get(obj))
3650 elm_widget_focused_object_clear(obj);
3652 _if_focused_revert(obj, EINA_TRUE);
3656 elm_widget_focus_disabled_handle(Evas_Object *obj)
3660 elm_widget_focus_tree_unfocusable_handle(obj);
3664 elm_widget_focus_order_get(const Evas_Object *obj)
3667 return sd->focus_order;
3671 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
3673 Evas_Object *parent;
3679 if (sd->api->activate)
3680 ret = sd->api->activate(obj, act);
3684 parent = elm_widget_parent_get(obj);
3686 elm_widget_activate(parent, act);
3694 * Returns the widget's Evas_Display_Mode
3696 * @param obj The widget.
3697 * @return Evas_Display_Mode of the object.
3699 * @see elm_widget_display_mode_set().
3702 EAPI Evas_Display_Mode
3703 elm_widget_display_mode_get(const Evas_Object *obj)
3705 Evas_Display_Mode new_mode;
3706 Evas_Object *parent;
3708 API_ENTRY return EVAS_DISPLAY_MODE_NONE;
3710 new_mode = evas_object_size_hint_display_mode_get(obj);
3711 parent = elm_widget_parent_get(obj);
3713 if ((new_mode == EVAS_DISPLAY_MODE_INHERIT) && parent)
3714 return elm_widget_display_mode_get(parent);
3722 * Sets the widget and child widget's Evas_Display_Mode.
3724 * @param obj The widget.
3725 * @param dispmode Evas_Display_Mode to set widget's mode.
3727 * Widgets are resized by several reasons.
3728 * Evas_Display_Mode can help for widgets to get one more reason of resize.
3729 * For example, elm conform widget resizes it's contents when keypad state changed.
3730 * After keypad showing, conform widget can change child's Evas_Display_Mode.
3734 elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
3736 Evas_Display_Mode child_mode;
3742 if (elm_widget_display_mode_get(obj) == dispmode) return;
3743 evas_object_size_hint_display_mode_set(obj, dispmode);
3745 //TODO: Need to deal with EVAS_DISPLAY_MODE_INHERIT efficiently.
3746 EINA_LIST_FOREACH (sd->subobjs, l, child)
3748 child_mode = evas_object_size_hint_display_mode_get(child);
3749 if (child_mode != EVAS_DISPLAY_MODE_DONT_CHANGE)
3751 elm_widget_display_mode_set(child, dispmode);
3760 * Allocate a new Elm_Widget_Item-derived structure.
3762 * The goal of this structure is to provide common ground for actions
3763 * that a widget item have, such as the owner widget, callback to
3764 * notify deletion, data pointer and maybe more.
3766 * @param widget the owner widget that holds this item, must be an elm_widget!
3767 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
3768 * be used to allocate memory.
3770 * @return allocated memory that is already zeroed out, or NULL on errors.
3772 * @see elm_widget_item_new() convenience macro.
3773 * @see elm_widget_item_del() to release memory.
3776 EAPI Elm_Widget_Item *
3777 _elm_widget_item_new(Evas_Object *widget,
3780 if (!_elm_widget_is(widget))
3783 Elm_Widget_Item *item;
3785 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
3786 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
3788 item = calloc(1, alloc_size);
3789 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
3791 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
3792 item->widget = widget;
3797 _elm_widget_item_free(Elm_Widget_Item *item)
3799 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3802 item->del_func((void *)item->data, item->widget, item);
3805 evas_object_del(item->view);
3807 if (item->access_info)
3808 eina_stringshare_del(item->access_info);
3810 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
3817 * Releases widget item memory, calling back del_cb() if it exists.
3819 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
3820 * to memory release. Note that elm_widget_item_pre_notify_del() calls
3821 * this function and then unset it, thus being useful for 2 step
3822 * cleanup whenever the del_cb may use any of the data that must be
3823 * deleted from item.
3825 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
3828 * @param item a valid #Elm_Widget_Item to be deleted.
3829 * @see elm_widget_item_del() convenience macro.
3833 _elm_widget_item_del(Elm_Widget_Item *item)
3835 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3836 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3837 item->on_deletion = EINA_TRUE;
3839 //Widget item delete callback
3840 if (item->del_pre_func)
3841 if (item->del_pre_func((Elm_Object_Item *)item))
3842 _elm_widget_item_free(item);
3848 * Set the function to notify to widgets when item is being deleted by user.
3850 * @param item a valid #Elm_Widget_Item to be notified
3851 * @see elm_widget_item_del_pre_hook_set() convenience macro.
3855 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item,
3856 Elm_Widget_Del_Pre_Cb func)
3858 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3859 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3860 item->del_pre_func = func;
3866 * Notify object will be deleted without actually deleting it.
3868 * This function will callback Elm_Widget_Item::del_cb if it is set
3869 * and then unset it so it is not called twice (ie: from
3870 * elm_widget_item_del()).
3872 * @param item a valid #Elm_Widget_Item to be notified
3873 * @see elm_widget_item_pre_notify_del() convenience macro.
3877 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
3879 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3880 if (!item->del_func) return;
3881 item->del_func((void *)item->data, item->widget, item);
3882 item->del_func = NULL;
3888 * Set the function to notify when item is being deleted.
3890 * This function will complain if there was a callback set already,
3891 * however it will set the new one.
3893 * The callback will be called from elm_widget_item_pre_notify_del()
3894 * or elm_widget_item_del() will be called with:
3895 * - data: the Elm_Widget_Item::data value.
3896 * - obj: the Elm_Widget_Item::widget evas object.
3897 * - event_info: the item being deleted.
3899 * @param item a valid #Elm_Widget_Item to be notified
3900 * @see elm_widget_item_del_cb_set() convenience macro.
3904 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
3907 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3908 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3910 if ((item->del_func) && (item->del_func != func))
3911 WRN("You're replacing a previously set del_cb %p of item %p with %p",
3912 item->del_func, item, func);
3914 item->del_func = func;
3920 * Retrieves owner widget of this item.
3922 * @param item a valid #Elm_Widget_Item to get data from.
3923 * @return owner widget of this item.
3927 _elm_widget_item_widget_get(const Elm_Widget_Item *item)
3929 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3930 return item->widget;
3936 * Set user-data in this item.
3938 * User data may be used to identify this item or just store any
3939 * application data. It is automatically given as the first parameter
3940 * of the deletion notify callback.
3942 * @param item a valid #Elm_Widget_Item to store data in.
3943 * @param data user data to store.
3944 * @see elm_widget_item_del_cb_set() convenience macro.
3948 _elm_widget_item_data_set(Elm_Widget_Item *item,
3951 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3952 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3954 if ((item->data) && (item->data != data))
3955 DBG("Replacing item %p data %p with %p", item, item->data, data);
3962 * Retrieves user-data of this item.
3964 * @param item a valid #Elm_Widget_Item to get data from.
3965 * @see elm_widget_item_data_set()
3969 _elm_widget_item_data_get(const Elm_Widget_Item *item)
3971 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3972 return (void *)item->data;
3976 _elm_widget_item_disabled_set(Elm_Widget_Item *item,
3979 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3980 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3982 if (item->disabled == disabled) return;
3983 item->disabled = !!disabled;
3984 if (item->disable_func) item->disable_func(item);
3988 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3990 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3991 return item->disabled;
3995 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3996 Elm_Widget_Disable_Cb func)
3998 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3999 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4001 item->disable_func = func;
4004 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
4006 struct _Elm_Widget_Item_Tooltip
4008 Elm_Widget_Item *item;
4009 Elm_Tooltip_Item_Content_Cb func;
4010 Evas_Smart_Cb del_cb;
4014 static Evas_Object *
4015 _elm_widget_item_tooltip_label_create(void *data,
4016 Evas_Object *obj __UNUSED__,
4017 Evas_Object *tooltip,
4018 void *item __UNUSED__)
4020 Evas_Object *label = elm_label_add(tooltip);
4023 elm_object_style_set(label, "tooltip");
4024 elm_object_text_set(label, data);
4028 static Evas_Object *
4029 _elm_widget_item_tooltip_trans_label_create(void *data,
4030 Evas_Object *obj __UNUSED__,
4031 Evas_Object *tooltip,
4032 void *item __UNUSED__)
4034 Evas_Object *label = elm_label_add(tooltip);
4037 elm_object_style_set(label, "tooltip");
4038 elm_object_translatable_text_set(label, data);
4043 _elm_widget_item_tooltip_label_del_cb(void *data,
4044 Evas_Object *obj __UNUSED__,
4045 void *event_info __UNUSED__)
4047 eina_stringshare_del(data);
4053 * Set the text to be shown in the widget item.
4055 * @param item Target item
4056 * @param text The text to set in the content
4058 * Setup the text as tooltip to object. The item can have only one tooltip,
4059 * so any previous tooltip data is removed.
4064 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
4067 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4068 EINA_SAFETY_ON_NULL_RETURN(text);
4069 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4071 text = eina_stringshare_add(text);
4072 _elm_widget_item_tooltip_content_cb_set
4073 (item, _elm_widget_item_tooltip_label_create, text,
4074 _elm_widget_item_tooltip_label_del_cb);
4078 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
4081 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4082 EINA_SAFETY_ON_NULL_RETURN(text);
4083 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4085 text = eina_stringshare_add(text);
4086 _elm_widget_item_tooltip_content_cb_set
4087 (item, _elm_widget_item_tooltip_trans_label_create, text,
4088 _elm_widget_item_tooltip_label_del_cb);
4091 static Evas_Object *
4092 _elm_widget_item_tooltip_create(void *data,
4094 Evas_Object *tooltip)
4096 Elm_Widget_Item_Tooltip *wit = data;
4097 return wit->func((void *)wit->data, obj, tooltip, wit->item);
4101 _elm_widget_item_tooltip_del_cb(void *data,
4103 void *event_info __UNUSED__)
4105 Elm_Widget_Item_Tooltip *wit = data;
4106 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
4113 * Set the content to be shown in the tooltip item
4115 * Setup the tooltip to item. The item can have only one tooltip,
4116 * so any previous tooltip data is removed. @p func(with @p data) will
4117 * be called every time that need show the tooltip and it should
4118 * return a valid Evas_Object. This object is then managed fully by
4119 * tooltip system and is deleted when the tooltip is gone.
4121 * @param item the widget item being attached a tooltip.
4122 * @param func the function used to create the tooltip contents.
4123 * @param data what to provide to @a func as callback data/context.
4124 * @param del_cb called when data is not needed anymore, either when
4125 * another callback replaces @func, the tooltip is unset with
4126 * elm_widget_item_tooltip_unset() or the owner @a item
4127 * dies. This callback receives as the first parameter the
4128 * given @a data, and @c event_info is the item.
4133 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
4134 Elm_Tooltip_Item_Content_Cb func,
4136 Evas_Smart_Cb del_cb)
4138 Elm_Widget_Item_Tooltip *wit;
4140 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
4141 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4144 _elm_widget_item_tooltip_unset(item);
4148 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
4149 if (!wit) goto error;
4153 wit->del_cb = del_cb;
4155 elm_object_sub_tooltip_content_cb_set
4156 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
4157 _elm_widget_item_tooltip_del_cb);
4162 if (del_cb) del_cb((void *)data, NULL, item);
4165 if (del_cb) del_cb((void *)data, item->widget, item);
4171 * Unset tooltip from item
4173 * @param item widget item to remove previously set tooltip.
4175 * Remove tooltip from item. The callback provided as del_cb to
4176 * elm_widget_item_tooltip_content_cb_set() will be called to notify
4177 * it is not used anymore.
4179 * @see elm_widget_item_tooltip_content_cb_set()
4184 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
4186 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4187 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4189 elm_object_tooltip_unset(item->view);
4195 * Sets a different style for this item tooltip.
4197 * @note before you set a style you should define a tooltip with
4198 * elm_widget_item_tooltip_content_cb_set() or
4199 * elm_widget_item_tooltip_text_set()
4201 * @param item widget item with tooltip already set.
4202 * @param style the theme style to use (default, transparent, ...)
4207 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
4210 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4211 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4213 elm_object_tooltip_style_set(item->view, style);
4217 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item,
4220 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4221 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
4223 return elm_object_tooltip_window_mode_set(item->view, disable);
4227 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
4229 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4230 return elm_object_tooltip_window_mode_get(item->view);
4236 * Get the style for this item tooltip.
4238 * @param item widget item with tooltip already set.
4239 * @return style the theme style in use, defaults to "default". If the
4240 * object does not have a tooltip set, then NULL is returned.
4245 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
4247 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4248 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4250 return elm_object_tooltip_style_get(item->view);
4254 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
4257 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4258 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4260 elm_object_sub_cursor_set(item->view, item->widget, cursor);
4264 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
4266 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4267 return elm_object_cursor_get(item->view);
4271 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
4273 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4274 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4276 elm_object_cursor_unset(item->view);
4282 * Sets a different style for this item cursor.
4284 * @note before you set a style you should define a cursor with
4285 * elm_widget_item_cursor_set()
4287 * @param item widget item with cursor already set.
4288 * @param style the theme style to use (default, transparent, ...)
4293 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
4296 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4297 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4299 elm_object_cursor_style_set(item->view, style);
4305 * Get the style for this item cursor.
4307 * @param item widget item with cursor already set.
4308 * @return style the theme style in use, defaults to "default". If the
4309 * object does not have a cursor set, then NULL is returned.
4314 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
4316 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4317 return elm_object_cursor_style_get(item->view);
4323 * Set if the cursor set should be searched on the theme or should use
4324 * the provided by the engine, only.
4326 * @note before you set if should look on theme you should define a cursor
4327 * with elm_object_cursor_set(). By default it will only look for cursors
4328 * provided by the engine.
4330 * @param item widget item with cursor already set.
4331 * @param engine_only boolean to define it cursors should be looked only
4332 * between the provided by the engine or searched on widget's theme as well.
4337 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
4338 Eina_Bool engine_only)
4340 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4341 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4343 elm_object_cursor_theme_search_enabled_set(item->view, engine_only);
4349 * Get the cursor engine only usage for this item cursor.
4351 * @param item widget item with cursor already set.
4352 * @return engine_only boolean to define it cursors should be looked only
4353 * between the provided by the engine or searched on widget's theme as well. If
4354 * the object does not have a cursor set, then EINA_FALSE is returned.
4359 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
4361 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4362 return elm_object_cursor_theme_search_enabled_get(item->view);
4366 _elm_widget_item_part_content_set(Elm_Widget_Item *item,
4368 Evas_Object *content)
4370 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4371 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4372 if (!item->content_set_func)
4374 ERR("%s does not support elm_object_item_part_content_set() API.",
4375 elm_widget_type_get(item->widget));
4378 item->content_set_func((Elm_Object_Item *)item, part, content);
4382 _elm_widget_item_part_content_get(const Elm_Widget_Item *item,
4385 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4386 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4388 return item->content_get_func((Elm_Object_Item *)item, part);
4392 _elm_widget_item_part_content_unset(Elm_Widget_Item *item,
4395 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4396 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4397 if (!item->content_unset_func)
4399 ERR("%s does not support elm_object_item_part_content_unset() API.",
4400 elm_widget_type_get(item->widget));
4404 return item->content_unset_func((Elm_Object_Item *)item, part);
4408 _elm_widget_item_part_text_set(Elm_Widget_Item *item,
4412 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4413 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4414 if (!item->text_set_func)
4416 ERR("%s does not support elm_object_item_part_text_set() API.",
4417 elm_widget_type_get(item->widget));
4421 item->text_set_func((Elm_Object_Item *)item, part, label);
4425 _elm_widget_item_part_text_get(const Elm_Widget_Item *item,
4428 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4429 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4430 if (!item->text_get_func)
4432 ERR("%s does not support elm_object_item_part_text_get() API.",
4433 elm_widget_type_get(item->widget));
4437 return item->text_get_func((Elm_Object_Item *)item, part);
4441 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
4442 Elm_Widget_Content_Set_Cb func)
4444 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4445 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4447 item->content_set_func = func;
4451 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
4452 Elm_Widget_Content_Get_Cb func)
4454 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4455 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4457 item->content_get_func = func;
4461 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
4462 Elm_Widget_Content_Unset_Cb func)
4464 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4465 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4467 item->content_unset_func = func;
4471 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
4472 Elm_Widget_Text_Set_Cb func)
4474 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4475 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4477 item->text_set_func = func;
4481 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
4482 Elm_Widget_Text_Get_Cb func)
4484 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4485 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4487 item->text_get_func = func;
4491 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
4492 const char *emission,
4495 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4496 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4498 if (item->signal_emit_func)
4499 item->signal_emit_func((Elm_Object_Item *)item, emission, source);
4503 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
4504 Elm_Widget_Signal_Emit_Cb func)
4506 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4507 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4509 item->signal_emit_func = func;
4513 _elm_widget_item_access_info_set(Elm_Widget_Item *item,
4516 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4517 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4519 if (item->access_info) eina_stringshare_del(item->access_info);
4520 if (!txt) item->access_info = NULL;
4521 else item->access_info = eina_stringshare_add(txt);
4524 /* happy debug functions */
4527 _sub_obj_tree_dump(const Evas_Object *obj,
4532 for (i = 0; i < lvl * 3; i++)
4535 if (_elm_widget_is(obj))
4539 printf("+ %s(%p)\n",
4540 elm_widget_type_get(obj),
4543 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
4544 EINA_LIST_FOREACH(sd->subobjs, l, obj)
4546 if (obj != sd->resize_obj)
4547 _sub_obj_tree_dump(obj, lvl + 1);
4551 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
4555 _sub_obj_tree_dot_dump(const Evas_Object *obj,
4558 if (!_elm_widget_is(obj))
4562 Eina_Bool visible = evas_object_visible_get(obj);
4563 Eina_Bool disabled = elm_widget_disabled_get(obj);
4564 Eina_Bool focused = elm_widget_focus_get(obj);
4565 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
4569 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
4572 fprintf(output, ", style=bold");
4575 fprintf(output, ", color=gray28");
4577 fprintf(output, " ];\n");
4580 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
4581 "disabled: %d|focused: %d/%d|focus order:%d}\"",
4582 obj, obj, elm_widget_type_get(obj),
4583 evas_object_name_get(obj), visible, disabled, focused, can_focus,
4587 fprintf(output, ", style=bold");
4590 fprintf(output, ", fontcolor=gray28");
4592 if ((disabled) || (!visible))
4593 fprintf(output, ", color=gray");
4595 fprintf(output, " ];\n");
4599 EINA_LIST_FOREACH(sd->subobjs, l, o)
4600 _sub_obj_tree_dot_dump(o, output);
4606 elm_widget_tree_dump(const Evas_Object *top)
4609 if (!_elm_widget_is(top))
4611 _sub_obj_tree_dump(top, 0);
4619 elm_widget_tree_dot_dump(const Evas_Object *top,
4623 if (!_elm_widget_is(top))
4625 fprintf(output, "graph " " { node [shape=record];\n");
4626 _sub_obj_tree_dot_dump(top, output);
4627 fprintf(output, "}\n");