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 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
17 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
19 struct _Elm_Event_Cb_Data
25 struct _Elm_Translate_String_Data
32 /* local subsystem globals */
33 static unsigned int focus_order = 0;
35 static inline Eina_Bool
36 _elm_widget_is(const Evas_Object *obj)
38 return evas_object_smart_type_check_ptr(obj, ELM_WIDGET_SMART_NAME);
41 static inline Eina_Bool
42 _is_focusable(Evas_Object *obj)
44 API_ENTRY return EINA_FALSE;
45 return sd->can_focus || (sd->child_can_focus);
48 static inline Eina_Bool
49 _elm_scrollable_is(const Evas_Object *obj)
51 INTERNAL_ENTRY EINA_FALSE;
52 return !!evas_object_smart_interface_get(obj, ELM_SCROLLABLE_IFACE_NAME);
55 /* what follows are basic (unimplemented) smart class functions */
56 #define UNIMPLEMENTED_MAKE(_prefix) \
58 _elm_widget_##_prefix##_func_unimplemented(Evas_Object * obj) \
60 WRN("The %s widget does not implement the \"" #_prefix "\" function.", \
61 elm_widget_type_get(obj)); \
65 UNIMPLEMENTED_MAKE(disable);
66 UNIMPLEMENTED_MAKE(translate);
68 #undef UNIMPLEMENTED_MAKE
72 * Resets the mirrored mode from the system mirror mode for widgets that are in
73 * automatic mirroring mode. This function does not call elm_widget_theme.
75 * @param obj The widget.
76 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
79 _elm_widget_mirrored_reload(Evas_Object *obj)
82 Eina_Bool mirrored = elm_config_mirrored_get();
84 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
86 sd->is_mirrored = mirrored;
91 _elm_widget_theme_func(Evas_Object *obj)
93 _elm_widget_mirrored_reload(obj);
95 elm_widget_disabled_set(obj, elm_widget_disabled_get(obj));
101 _elm_widget_on_focus_region_func_unimplemented(const Evas_Object *obj __UNUSED__,
102 Evas_Coord *x __UNUSED__,
103 Evas_Coord *y __UNUSED__,
104 Evas_Coord *w __UNUSED__,
105 Evas_Coord *h __UNUSED__)
107 WRN("The %s widget does not implement the \"on_focus_region\" function.",
108 elm_widget_type_get(obj));
113 _elm_widget_on_focus_func_unimplemented(Evas_Object *obj)
115 WRN("The %s widget does not implement the \"on_focus\" function.",
116 elm_widget_type_get(obj));
121 _elm_widget_event_func_unimplemented(Evas_Object *obj,
122 Evas_Object *source __UNUSED__,
123 Evas_Callback_Type type __UNUSED__,
124 void *event_info __UNUSED__)
126 WRN("The %s widget does not implement the \"event\" function.",
127 elm_widget_type_get(obj));
132 _elm_widget_focus_next_func_unimplemented(const Evas_Object *obj,
133 Elm_Focus_Direction dir __UNUSED__,
134 Evas_Object **next __UNUSED__)
136 WRN("The %s widget does not implement the \"focus_next\" function.",
137 elm_widget_type_get(obj));
142 _elm_widget_focus_direction_func_unimplemented(const Evas_Object *obj,
143 const Evas_Object *b __UNUSED__,
144 double degree __UNUSED__,
145 Evas_Object **target __UNUSED__,
146 double *weight __UNUSED__)
148 WRN("The %s widget does not implement the \"focus_direction\" function.",
149 elm_widget_type_get(obj));
154 _parents_focus(Evas_Object *obj)
156 for (; obj; obj = elm_widget_parent_get(obj))
159 if (sd->focused) return;
165 _parents_unfocus(Evas_Object *obj)
167 for (; obj; obj = elm_widget_parent_get(obj))
170 if (!sd->focused) return;
176 _on_sub_obj_hide(void *data __UNUSED__,
179 void *event_info __UNUSED__)
181 elm_widget_focus_hide_handle(obj);
185 _on_sub_obj_del(void *data,
188 void *event_info __UNUSED__)
190 Elm_Widget_Smart_Data *sd = data;
192 if (_elm_widget_is(obj))
194 if (elm_widget_focus_get(obj)) _parents_unfocus(sd->obj);
196 if (obj == sd->resize_obj)
198 /* already dels sub object */
199 elm_widget_resize_object_set(sd->obj, NULL);
202 else if (obj == sd->hover_obj)
204 sd->hover_obj = NULL;
209 if (!elm_widget_sub_object_del(sd->obj, obj))
210 ERR("failed to remove sub object %p from %p\n", obj, sd->obj);
215 _elm_widget_sub_object_add_func(Evas_Object *obj,
218 double scale, pscale = elm_widget_scale_get(sobj);
219 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
220 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
222 ELM_WIDGET_DATA_GET(obj, sd);
223 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
225 if (sobj == sd->parent_obj)
227 /* in this case, sobj must be an elm widget, or something
228 * very wrong is happening */
229 if (!_elm_widget_is(sobj)) return EINA_FALSE;
231 if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
232 WRN("You passed a parent object of obj = %p as the sub object = %p!",
236 if (_elm_widget_is(sobj))
238 ELM_WIDGET_DATA_GET(sobj, sdc);
240 if (sdc->parent_obj == obj) return EINA_TRUE;
243 if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
246 sdc->parent_obj = obj;
247 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
249 /* update child focusable-ness on self and parents, now that a
250 * focusable child got in */
251 if (!sd->child_can_focus && (_is_focusable(sobj)))
253 Elm_Widget_Smart_Data *sdp = sd;
255 sdp->child_can_focus = EINA_TRUE;
256 while (sdp->parent_obj)
258 sdp = evas_object_smart_data_get(sdp->parent_obj);
260 if (sdp->child_can_focus) break;
262 sdp->child_can_focus = EINA_TRUE;
268 void *data = evas_object_data_get(sobj, "elm-parent");
272 if (data == obj) return EINA_TRUE;
273 if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
277 sd->subobjs = eina_list_append(sd->subobjs, sobj);
278 evas_object_data_set(sobj, "elm-parent", obj);
279 evas_object_event_callback_add
280 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
281 if (_elm_widget_is(sobj))
283 evas_object_event_callback_add
284 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, sd);
286 scale = elm_widget_scale_get(sobj);
287 th = elm_widget_theme_get(sobj);
288 mirrored = elm_widget_mirrored_get(sobj);
290 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
291 elm_widget_theme(sobj);
293 if (elm_widget_focus_get(sobj)) _parents_focus(obj);
300 _elm_widget_sub_object_del_func(Evas_Object *obj,
303 Evas_Object *sobj_parent;
305 if (!sobj) return EINA_FALSE;
307 ELM_WIDGET_DATA_GET(obj, sd);
308 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
310 sobj_parent = evas_object_data_del(sobj, "elm-parent");
311 if (sobj_parent != obj)
313 static int abort_on_warn = -1;
315 ERR("removing sub object %p (%s) from parent %p (%s), "
316 "but elm-parent is different %p (%s)!",
317 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
318 sobj_parent, elm_widget_type_get(sobj_parent));
320 if (EINA_UNLIKELY(abort_on_warn == -1))
322 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
323 else abort_on_warn = 0;
325 if (abort_on_warn == 1) abort();
330 if (_elm_widget_is(sobj))
332 if (elm_widget_focus_get(sobj))
334 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
335 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
337 if ((sd->child_can_focus) && (_is_focusable(sobj)))
339 Evas_Object *parent = obj;
341 /* update child focusable-ness on self and parents, now that a
342 * focusable child is gone */
348 ELM_WIDGET_DATA_GET(parent, sdp);
350 sdp->child_can_focus = EINA_FALSE;
351 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
353 if ((subobj != sobj) && (_is_focusable(subobj)))
355 sdp->child_can_focus = EINA_TRUE;
360 /* break again, child_can_focus went back to
362 if (sdp->child_can_focus) break;
363 parent = sdp->parent_obj;
367 ELM_WIDGET_DATA_GET(sobj, sdc);
368 sdc->parent_obj = NULL;
371 if (sd->resize_obj == sobj) sd->resize_obj = NULL;
373 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
375 evas_object_event_callback_del_full
376 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
377 if (_elm_widget_is(sobj))
378 evas_object_event_callback_del_full
379 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, sd);
384 static const Evas_Smart_Cb_Description _smart_callbacks[] =
386 /* FIXME: complete later */
391 _smart_add(Evas_Object *obj)
393 const Evas_Smart_Class *sc;
394 const Evas_Smart *smart;
396 EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data);
398 smart = evas_object_smart_smart_get(obj);
399 sc = evas_smart_class_get(smart);
400 priv->api = (const Elm_Widget_Smart_Class *)sc;
402 priv->x = priv->y = priv->w = priv->h = 0;
403 priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale
405 elm_widget_can_focus_set(obj, EINA_TRUE);
406 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
408 /* just a helper for inheriting classes */
409 if (priv->resize_obj)
411 Evas_Object *r_obj = priv->resize_obj;
412 priv->resize_obj = NULL;
414 elm_widget_resize_object_set(obj, r_obj);
419 _newest_focus_order_get(Evas_Object *obj,
420 unsigned int *newest_focus_order,
421 Eina_Bool can_focus_only)
424 Evas_Object *child, *ret, *best;
426 API_ENTRY return NULL;
428 if (!evas_object_visible_get(obj)
429 || (elm_widget_disabled_get(obj))
430 || (elm_widget_tree_unfocusable_get(obj)))
434 if (*newest_focus_order < sd->focus_order)
436 *newest_focus_order = sd->focus_order;
439 EINA_LIST_FOREACH(sd->subobjs, l, child)
441 ret = _newest_focus_order_get
442 (child, newest_focus_order, can_focus_only);
448 if ((!best) || (!elm_widget_can_focus_get(best)))
455 _if_focused_revert(Evas_Object *obj,
456 Eina_Bool can_focus_only)
459 Evas_Object *newest = NULL;
460 unsigned int newest_focus_order = 0;
464 if (!sd->focused) return;
465 if (!sd->parent_obj) return;
467 top = elm_widget_top_get(sd->parent_obj);
470 newest = _newest_focus_order_get
471 (top, &newest_focus_order, can_focus_only);
474 elm_object_focus_set(newest, EINA_FALSE);
475 elm_object_focus_set(newest, EINA_TRUE);
481 _smart_del(Evas_Object *obj)
484 Elm_Translate_String_Data *ts;
485 Elm_Event_Cb_Data *ecb;
487 ELM_WIDGET_DATA_GET(obj, sd);
491 /* detach it from us */
492 evas_object_event_callback_del_full
493 (sd->hover_obj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
494 sd->hover_obj = NULL;
499 sobj = eina_list_data_get(sd->subobjs);
501 /* let the objects clean-up themselves and get rid of this list */
502 if (!elm_widget_sub_object_del(obj, sobj))
504 ERR("failed to remove sub object %p from %p\n", sobj, obj);
505 sd->subobjs = eina_list_remove_list
506 (sd->subobjs, sd->subobjs);
508 evas_object_del(sobj);
510 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
511 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
512 EINA_LIST_FREE (sd->translate_strings, ts)
514 eina_stringshare_del(ts->id);
515 eina_stringshare_del(ts->domain);
516 eina_stringshare_del(ts->string);
520 EINA_LIST_FREE (sd->event_cb, ecb)
523 if (sd->style) eina_stringshare_del(sd->style);
524 if (sd->theme) elm_theme_free(sd->theme);
525 _if_focused_revert(obj, EINA_TRUE);
526 if (sd->access_info) eina_stringshare_del(sd->access_info);
528 evas_object_smart_data_set(obj, NULL);
532 _smart_reconfigure(Elm_Widget_Smart_Data *sd)
536 evas_object_move(sd->resize_obj, sd->x, sd->y);
537 evas_object_resize(sd->resize_obj, sd->w, sd->h);
541 evas_object_move(sd->hover_obj, sd->x, sd->y);
542 evas_object_resize(sd->hover_obj, sd->w, sd->h);
547 _smart_move(Evas_Object *obj,
551 ELM_WIDGET_DATA_GET(obj, sd);
556 _smart_reconfigure(sd);
560 _smart_resize(Evas_Object *obj,
564 ELM_WIDGET_DATA_GET(obj, sd);
569 _smart_reconfigure(sd);
573 _smart_show(Evas_Object *obj)
578 if ((list = evas_object_smart_members_get(obj)))
580 EINA_LIST_FREE (list, o)
582 if (evas_object_data_get(o, "_elm_leaveme")) continue;
589 _smart_hide(Evas_Object *obj)
594 list = evas_object_smart_members_get(obj);
595 EINA_LIST_FREE (list, o)
597 if (evas_object_data_get(o, "_elm_leaveme")) continue;
603 _smart_color_set(Evas_Object *obj,
612 if ((list = evas_object_smart_members_get(obj)))
614 EINA_LIST_FREE (list, o)
616 if (evas_object_data_get(o, "_elm_leaveme")) continue;
617 evas_object_color_set(o, r, g, b, a);
623 _smart_clip_set(Evas_Object *obj,
629 if ((list = evas_object_smart_members_get(obj)))
631 EINA_LIST_FREE (list, o)
633 if (evas_object_data_get(o, "_elm_leaveme")) continue;
634 evas_object_clip_set(o, clip);
640 _smart_clip_unset(Evas_Object *obj)
645 if ((list = evas_object_smart_members_get(obj)))
647 EINA_LIST_FREE (list, o)
649 if (evas_object_data_get(o, "_elm_leaveme")) continue;
650 evas_object_clip_unset(o);
656 _smart_calculate(Evas_Object *obj __UNUSED__)
658 /* a NO-OP, on the base */
662 _smart_member_add(Evas_Object *obj,
667 if (evas_object_data_get(child, "_elm_leaveme")) return;
669 evas_object_color_get(obj, &r, &g, &b, &a);
670 evas_object_color_set(child, r, g, b, a);
672 evas_object_clip_set(child, evas_object_clip_get(obj));
674 if (evas_object_visible_get(obj))
675 evas_object_show(child);
677 evas_object_hide(child);
681 _smart_member_del(Evas_Object *obj __UNUSED__,
684 if (evas_object_data_get(child, "_elm_leaveme")) return;
685 evas_object_clip_unset(child);
689 _elm_widget_smart_set(Elm_Widget_Smart_Class *api)
691 Evas_Smart_Class *sc;
693 if (!(sc = (Evas_Smart_Class *)api))
696 sc->add = _smart_add;
697 sc->del = _smart_del;
698 sc->move = _smart_move;
699 sc->resize = _smart_resize;
700 sc->show = _smart_show;
701 sc->hide = _smart_hide;
702 sc->color_set = _smart_color_set;
703 sc->clip_set = _smart_clip_set;
704 sc->clip_unset = _smart_clip_unset;
705 sc->calculate = _smart_calculate;
706 sc->member_add = _smart_member_add;
707 sc->member_del = _smart_member_del;
709 #define API_DEFAULT_SET_UNIMPLEMENTED(_prefix) \
710 api->_prefix = _elm_widget_##_prefix##_func_unimplemented;
712 /* NB: always remember to call these parent versions on children,
713 * except for the unimplemented ones and calculate, which is moot */
715 #define API_DEFAULT_SET(_prefix) \
716 api->_prefix = _elm_widget_##_prefix##_func;
719 API_DEFAULT_SET_UNIMPLEMENTED(on_focus);
720 API_DEFAULT_SET_UNIMPLEMENTED(disable);
722 API_DEFAULT_SET(theme);
723 API_DEFAULT_SET_UNIMPLEMENTED(on_focus_region);
725 API_DEFAULT_SET_UNIMPLEMENTED(translate);
726 API_DEFAULT_SET_UNIMPLEMENTED(event);
727 API_DEFAULT_SET_UNIMPLEMENTED(focus_next);
728 API_DEFAULT_SET_UNIMPLEMENTED(focus_direction);
730 /* NB: because those two weren't hooks before, translate the
731 * individual calls to them on the widgets as we bring them to the
732 * new class hierarchy. also, sub_object_{add,del} must be
733 * different than member_{add,del} here, because widget parenting
734 * on elm does not always imply parent and child will live on the
736 API_DEFAULT_SET(sub_object_add);
737 API_DEFAULT_SET(sub_object_del);
739 #undef API_DEFAULT_SET
740 #undef API_DEFAULT_SET_UNIMPLEMENTED
742 sc->callbacks = _smart_callbacks;
746 static inline Eina_Bool
747 _elm_widget_focus_chain_manager_is(const Evas_Object *obj)
749 API_ENTRY return EINA_FALSE;
751 if (!sd->api) return EINA_FALSE;
752 return sd->api->focus_next &&
753 (sd->api->focus_next != _elm_widget_focus_next_func_unimplemented);
756 static inline Eina_Bool
757 _elm_widget_focus_direction_manager_is(const Evas_Object *obj)
759 API_ENTRY return EINA_FALSE;
761 if (!sd->api) return EINA_FALSE;
762 return sd->api->focus_direction &&
763 (sd->api->focus_direction !=
764 _elm_widget_focus_direction_func_unimplemented);
768 _obj_mouse_down(void *data,
770 Evas_Object *obj __UNUSED__,
773 Elm_Widget_Smart_Data *sd = data;
774 Evas_Event_Mouse_Down *ev = event_info;
775 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
776 sd->still_in = EINA_TRUE;
780 _obj_mouse_move(void *data,
785 Elm_Widget_Smart_Data *sd = data;
786 Evas_Event_Mouse_Move *ev = event_info;
789 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
790 sd->still_in = EINA_FALSE;
793 Evas_Coord x, y, w, h;
794 evas_object_geometry_get(obj, &x, &y, &w, &h);
795 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
796 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
797 sd->still_in = EINA_FALSE;
803 _obj_mouse_up(void *data,
806 void *event_info __UNUSED__)
808 Elm_Widget_Smart_Data *sd = data;
810 elm_widget_focus_mouse_up_handle(obj);
811 sd->still_in = EINA_FALSE;
815 _propagate_x_drag_lock(Evas_Object *obj,
821 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
824 sd2->child_drag_x_locked += dir;
825 _propagate_x_drag_lock(sd->parent_obj, dir);
831 _propagate_y_drag_lock(Evas_Object *obj,
837 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
840 sd2->child_drag_y_locked += dir;
841 _propagate_y_drag_lock(sd->parent_obj, dir);
847 _propagate_event(void *data,
853 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
854 Evas_Event_Flags *event_flags = NULL;
858 case EVAS_CALLBACK_KEY_DOWN:
860 Evas_Event_Key_Down *ev = event_info;
861 event_flags = &(ev->event_flags);
865 case EVAS_CALLBACK_KEY_UP:
867 Evas_Event_Key_Up *ev = event_info;
868 event_flags = &(ev->event_flags);
872 case EVAS_CALLBACK_MOUSE_WHEEL:
874 Evas_Event_Mouse_Wheel *ev = event_info;
875 event_flags = &(ev->event_flags);
883 elm_widget_event_propagate(obj, type, event_info, event_flags);
887 * If elm_widget_focus_region_get() returns EINA_FALSE, this function will
888 * ignore region show action.
891 _elm_widget_focus_region_show(const Evas_Object *obj)
893 Evas_Coord x, y, ox, oy, w, h;
898 o = elm_widget_parent_get(obj);
901 if (!elm_widget_focus_region_get(obj, &x, &y, NULL, NULL))
904 evas_object_geometry_get(obj, &ox, &oy, &w, &h);
905 if (w == 0 && h == 0) return;
909 if (_elm_scrollable_is(o))
911 Evas_Coord px, py, pw, ph;
914 evas_object_geometry_get(o, &px, &py, &pw, &ph);
916 if ((px <= ox) && (px + pw) >= (ox + w) &&
917 (py <= oy) && (py + ph) >= (oy + h))
919 // if object is already shown
920 o = elm_widget_parent_get(o);
923 else if ((px < ox) && ((px + pw) < (ox + w)))
925 // if object is over the viewport to the x axis.
928 else if ((py < oy) && ((py + ph) < (oy + h)))
930 // if object is over the viewport to the y axis.
934 ELM_SCROLLABLE_IFACE_GET(o, s_iface);
935 s_iface->content_pos_get(o, &rx, &ry);
936 s_iface->content_viewport_size_get(o, &w, &h);
941 s_iface->content_region_show(o, x, y, w, h);
945 o = elm_widget_parent_get(o);
950 _parent_focus(Evas_Object *obj)
954 if (sd->focused) return;
956 Evas_Object *o = elm_widget_parent_get(obj);
957 sd->focus_order_on_calc = EINA_TRUE;
959 if (o) _parent_focus(o);
961 if (!sd->focus_order_on_calc)
962 return; /* we don't want to override it if by means of any of the
963 callbacks below one gets to calculate our order
967 sd->focus_order = focus_order;
968 if (!sd->api) return;
969 if (sd->top_win_focused)
971 sd->focused = EINA_TRUE;
972 sd->api->on_focus(obj);
974 sd->focus_order_on_calc = EINA_FALSE;
976 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
977 _elm_access_highlight_set(obj);
981 _elm_object_focus_chain_del_cb(void *data,
984 void *event_info __UNUSED__)
986 Elm_Widget_Smart_Data *sd = data;
988 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
991 EAPI const Elm_Widget_Smart_Class *
992 elm_widget_smart_class_get(void)
994 static Elm_Widget_Smart_Class _sc =
995 ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(ELM_WIDGET_SMART_NAME);
996 static const Elm_Widget_Smart_Class *class = NULL;
1001 _elm_widget_smart_set(&_sc);
1008 elm_widget_add(Evas_Smart *smart,
1009 Evas_Object *parent)
1014 e = evas_object_evas_get(parent);
1015 if (!e) return NULL;
1017 o = evas_object_smart_add(e, smart);
1018 elm_widget_parent_set(o, parent);
1024 elm_widget_parent_set(Evas_Object *obj,
1025 Evas_Object *parent)
1027 ELM_WIDGET_DATA_GET(obj, sd);
1029 if (!sd->api->parent_set) return;
1031 sd->api->parent_set(obj, parent);
1035 elm_widget_api_check(int ver)
1037 if (ver != ELM_INTERNAL_API_VERSION)
1039 CRITICAL("Elementary widget api versions do not match");
1046 elm_widget_access(Evas_Object *obj,
1047 Eina_Bool is_access)
1051 Eina_Bool ret = EINA_TRUE;
1053 API_ENTRY return EINA_FALSE;
1054 EINA_LIST_FOREACH(sd->subobjs, l, child)
1055 ret &= elm_widget_access(child, is_access);
1057 if (sd->api && sd->api->access)
1058 sd->api->access(obj, is_access);
1066 elm_widget_theme(Evas_Object *obj)
1072 Eina_Bool ret = EINA_TRUE;
1074 API_ENTRY return EINA_FALSE;
1076 EINA_LIST_FOREACH(sd->subobjs, l, child)
1077 if (_elm_widget_is(child)) ret &= elm_widget_theme(child);
1078 if (sd->resize_obj && _elm_widget_is(sd->resize_obj))
1079 ret &= elm_widget_theme(sd->resize_obj);
1080 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
1082 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1083 elm_tooltip_theme(tt);
1084 EINA_LIST_FOREACH(sd->cursors, l, cur)
1085 elm_cursor_theme(cur);
1087 if (!sd->api) return EINA_FALSE;
1089 ret &= sd->api->theme(obj);
1095 elm_widget_theme_specific(Evas_Object *obj,
1103 Elm_Theme *th2, *thdef;
1107 thdef = elm_theme_default_get();
1108 if (!th) th = thdef;
1112 if (!th2) th2 = thdef;
1120 if (th2 == thdef) break;
1121 th2 = th2->ref_theme;
1122 if (!th2) th2 = thdef;
1126 EINA_LIST_FOREACH(sd->subobjs, l, child)
1127 elm_widget_theme_specific(child, th, force);
1128 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
1129 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
1130 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1131 elm_tooltip_theme(tt);
1132 EINA_LIST_FOREACH(sd->cursors, l, cur)
1133 elm_cursor_theme(cur);
1134 if (!sd->api) return;
1135 sd->api->theme(obj);
1139 * Returns the widget's mirrored mode.
1141 * @param obj The widget.
1142 * @return mirrored mode of the object.
1146 elm_widget_mirrored_get(const Evas_Object *obj)
1148 API_ENTRY return EINA_FALSE;
1149 return sd->is_mirrored;
1153 * Sets the widget's mirrored mode.
1155 * @param obj The widget.
1156 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
1159 elm_widget_mirrored_set(Evas_Object *obj,
1164 mirrored = !!mirrored;
1166 if (sd->is_mirrored == mirrored) return;
1168 sd->is_mirrored = mirrored;
1169 elm_widget_theme(obj);
1173 * Returns the widget's mirrored mode setting.
1175 * @param obj The widget.
1176 * @return mirrored mode setting of the object.
1180 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
1182 API_ENTRY return EINA_FALSE;
1183 return sd->mirrored_auto_mode;
1187 * Sets the widget's mirrored mode setting.
1188 * When widget in automatic mode, it follows the system mirrored mode set by
1189 * elm_mirrored_set().
1190 * @param obj The widget.
1191 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
1194 elm_widget_mirrored_automatic_set(Evas_Object *obj,
1195 Eina_Bool automatic)
1198 if (sd->mirrored_auto_mode != automatic)
1200 sd->mirrored_auto_mode = automatic;
1204 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
1210 elm_widget_on_show_region_hook_set(Evas_Object *obj,
1211 void (*func)(void *data,
1217 sd->on_show_region = func;
1218 sd->on_show_region_data = data;
1222 elm_widget_sub_object_add(Evas_Object *obj,
1225 API_ENTRY return EINA_FALSE;
1226 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1228 if (!sd->api) return EINA_FALSE;
1229 return sd->api->sub_object_add(obj, sobj);
1233 elm_widget_sub_object_del(Evas_Object *obj,
1236 API_ENTRY return EINA_FALSE;
1237 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1239 if (!sobj) return EINA_FALSE;
1241 if (!sd->api) return EINA_FALSE;
1242 return sd->api->sub_object_del(obj, sobj);
1245 //SHKWAK : Temp Function for Indicator Issue
1246 // THIS MUST BE REMOVED
1248 EAPI const Eina_List *
1249 elm_widget_sub_object_list_get(const Evas_Object *obj)
1251 API_ENTRY return NULL;
1252 return (const Eina_List *)sd->subobjs;
1258 /* a resize object is a sub object with some more callbacks on it and
1259 * a smart member of the parent
1262 elm_widget_resize_object_set(Evas_Object *obj,
1265 Evas_Object *parent;
1269 if (sd->resize_obj == sobj) return;
1271 // orphan previous resize obj
1274 evas_object_clip_unset(sd->resize_obj);
1275 evas_object_smart_member_del(sd->resize_obj);
1277 if (_elm_widget_is(sd->resize_obj))
1279 if (elm_widget_focus_get(sd->resize_obj)) _parents_unfocus(obj);
1282 elm_widget_sub_object_del(obj, sd->resize_obj);
1285 sd->resize_obj = sobj;
1288 evas_object_event_callback_del_full(obj,
1289 EVAS_CALLBACK_MOUSE_DOWN,
1290 _obj_mouse_down, sd);
1291 evas_object_event_callback_del_full(obj,
1292 EVAS_CALLBACK_MOUSE_MOVE,
1293 _obj_mouse_move, sd);
1294 evas_object_event_callback_del_full(obj,
1295 EVAS_CALLBACK_MOUSE_UP,
1300 // orphan new resize obj
1301 parent = evas_object_data_get(sobj, "elm-parent");
1302 if (parent && parent != obj)
1304 ELM_WIDGET_DATA_GET(parent, sdp);
1306 /* should be there, just being paranoid */
1309 if (sdp->resize_obj == sobj)
1310 elm_widget_resize_object_set(parent, NULL);
1312 elm_widget_sub_object_del(parent, sobj);
1316 elm_widget_sub_object_add(obj, sobj);
1318 evas_object_smart_member_add(sobj, obj);
1320 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1321 _obj_mouse_down, sd);
1322 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
1323 _obj_mouse_move, sd);
1324 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
1326 _smart_reconfigure(sd);
1329 /* WARNING: the programmer is responsible, in the scenario of
1330 * exchanging a hover object, of cleaning the old hover "target"
1334 elm_widget_hover_object_set(Evas_Object *obj,
1340 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1341 _on_sub_obj_del, sd);
1343 sd->hover_obj = sobj;
1346 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1347 _on_sub_obj_del, sd);
1348 _smart_reconfigure(sd);
1353 elm_widget_can_focus_set(Evas_Object *obj,
1354 Eina_Bool can_focus)
1358 can_focus = !!can_focus;
1360 if (sd->can_focus == can_focus) return;
1361 sd->can_focus = can_focus;
1364 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1366 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1367 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1369 (void *)(long)EVAS_CALLBACK_KEY_UP);
1370 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1372 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1376 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1378 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1380 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1386 elm_widget_can_focus_get(const Evas_Object *obj)
1388 API_ENTRY return EINA_FALSE;
1389 return sd->can_focus;
1393 elm_widget_child_can_focus_get(const Evas_Object *obj)
1395 API_ENTRY return EINA_FALSE;
1396 return sd->child_can_focus;
1402 * This API makes the widget object and its children to be unfocusable.
1404 * This API can be helpful for an object to be deleted.
1405 * When an object will be deleted soon, it and its children may not
1406 * want to get focus (by focus reverting or by other focus controls).
1407 * Then, just use this API before deleting.
1409 * @param obj The widget root of sub-tree
1410 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1415 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1416 Eina_Bool tree_unfocusable)
1420 tree_unfocusable = !!tree_unfocusable;
1421 if (sd->tree_unfocusable == tree_unfocusable) return;
1422 sd->tree_unfocusable = tree_unfocusable;
1423 elm_widget_focus_tree_unfocusable_handle(obj);
1429 * This returns true, if the object sub-tree is unfocusable.
1431 * @param obj The widget root of sub-tree
1432 * @return EINA_TRUE if the object sub-tree is unfocusable
1437 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1439 API_ENTRY return EINA_FALSE;
1440 return sd->tree_unfocusable;
1446 * Get the list of focusable child objects.
1448 * This function retruns list of child objects which can get focus.
1450 * @param obj The parent widget
1451 * @retrun list of focusable child objects.
1456 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1458 API_ENTRY return NULL;
1461 Eina_List *child_list = NULL;
1466 EINA_LIST_FOREACH(sd->subobjs, l, child)
1468 if ((elm_widget_can_focus_get(child)) &&
1469 (evas_object_visible_get(child)) &&
1470 (!elm_widget_disabled_get(child)))
1471 child_list = eina_list_append(child_list, child);
1472 else if (elm_widget_is(child))
1474 Eina_List *can_focus_list;
1475 can_focus_list = elm_widget_can_focus_child_list_get(child);
1477 child_list = eina_list_merge(child_list, can_focus_list);
1485 elm_widget_highlight_ignore_set(Evas_Object *obj,
1489 sd->highlight_ignore = !!ignore;
1493 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1495 API_ENTRY return EINA_FALSE;
1496 return sd->highlight_ignore;
1500 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1501 Eina_Bool highlight)
1504 sd->highlight_in_theme = !!highlight;
1505 /* FIXME: if focused, it should switch from one mode to the other */
1509 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1511 API_ENTRY return EINA_FALSE;
1512 return sd->highlight_in_theme;
1516 elm_widget_focus_get(const Evas_Object *obj)
1518 API_ENTRY return EINA_FALSE;
1523 elm_widget_focused_object_get(const Evas_Object *obj)
1525 const Evas_Object *subobj;
1527 API_ENTRY return NULL;
1529 if (!sd->focused) return NULL;
1530 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1532 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1533 if (fobj) return fobj;
1535 return (Evas_Object *)obj;
1539 elm_widget_top_get(const Evas_Object *obj)
1541 API_ENTRY return NULL;
1542 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1543 return (Evas_Object *)obj;
1547 elm_widget_is(const Evas_Object *obj)
1549 return _elm_widget_is(obj);
1553 elm_widget_parent_widget_get(const Evas_Object *obj)
1555 Evas_Object *parent;
1557 if (_elm_widget_is(obj))
1559 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1560 if (!sd) return NULL;
1561 parent = sd->parent_obj;
1565 parent = evas_object_data_get(obj, "elm-parent");
1566 if (!parent) parent = evas_object_smart_parent_get(obj);
1571 Evas_Object *elm_parent;
1572 if (_elm_widget_is(parent)) break;
1573 elm_parent = evas_object_data_get(parent, "elm-parent");
1574 if (elm_parent) parent = elm_parent;
1575 else parent = evas_object_smart_parent_get(parent);
1581 elm_widget_parent2_get(const Evas_Object *obj)
1583 if (_elm_widget_is(obj))
1585 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1586 if (sd) return sd->parent2;
1592 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1595 sd->parent2 = parent;
1599 elm_widget_event_callback_add(Evas_Object *obj,
1604 EINA_SAFETY_ON_NULL_RETURN(func);
1605 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1608 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1612 elm_widget_event_callback_del(Evas_Object *obj,
1616 API_ENTRY return NULL;
1617 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1619 Elm_Event_Cb_Data *ecd;
1620 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1621 if ((ecd->func == func) && (ecd->data == data))
1624 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1625 return (void *)data;
1631 elm_widget_event_propagate(Evas_Object *obj,
1632 Evas_Callback_Type type,
1634 Evas_Event_Flags *event_flags)
1636 API_ENTRY return EINA_FALSE; //TODO reduce.
1638 if (!_elm_widget_is(obj)) return EINA_FALSE;
1639 Evas_Object *parent = obj;
1640 Elm_Event_Cb_Data *ecd;
1641 Eina_List *l, *l_prev;
1644 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1646 sd = evas_object_smart_data_get(parent);
1647 if ((!sd) || (!_elm_widget_is(obj)))
1648 return EINA_FALSE; //Not Elm Widget
1649 if (!sd->api) return EINA_FALSE;
1651 if (sd->api->event(parent, obj, type, event_info))
1654 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1656 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1657 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1660 parent = sd->parent_obj;
1669 * Set custom focus chain.
1671 * This function i set one new and overwrite any previous custom focus chain
1672 * with the list of objects. The previous list will be deleted and this list
1673 * will be managed. After setted, don't modity it.
1675 * @note On focus cycle, only will be evaluated children of this container.
1677 * @param obj The container widget
1678 * @param objs Chain of objects to pass focus
1682 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1687 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1689 elm_widget_focus_custom_chain_unset(obj);
1694 EINA_LIST_FOREACH(objs, l, o)
1696 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1697 _elm_object_focus_chain_del_cb, sd);
1700 sd->focus_chain = objs;
1706 * Get custom focus chain
1708 * @param obj The container widget
1711 EAPI const Eina_List *
1712 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1714 API_ENTRY return NULL;
1715 return (const Eina_List *)sd->focus_chain;
1721 * Unset custom focus chain
1723 * @param obj The container widget
1727 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1730 Eina_List *l, *l_next;
1733 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1735 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1736 _elm_object_focus_chain_del_cb, sd);
1737 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1744 * Append object to custom focus chain.
1746 * @note If relative_child equal to NULL or not in custom chain, the object
1747 * will be added in end.
1749 * @note On focus cycle, only will be evaluated children of this container.
1751 * @param obj The container widget
1752 * @param child The child to be added in custom chain
1753 * @param relative_child The relative object to position the child
1757 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1759 Evas_Object *relative_child)
1762 EINA_SAFETY_ON_NULL_RETURN(child);
1764 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1766 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1767 _elm_object_focus_chain_del_cb, sd);
1769 if (!relative_child)
1770 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1772 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1773 child, relative_child);
1779 * Prepend object to custom focus chain.
1781 * @note If relative_child equal to NULL or not in custom chain, the object
1782 * will be added in begin.
1784 * @note On focus cycle, only will be evaluated children of this container.
1786 * @param obj The container widget
1787 * @param child The child to be added in custom chain
1788 * @param relative_child The relative object to position the child
1792 elm_widget_focus_custom_chain_prepend(Evas_Object *obj,
1794 Evas_Object *relative_child)
1797 EINA_SAFETY_ON_NULL_RETURN(child);
1799 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1801 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1802 _elm_object_focus_chain_del_cb, sd);
1804 if (!relative_child)
1805 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1807 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1808 child, relative_child);
1814 * Give focus to next object in object tree.
1816 * Give focus to next object in focus chain of one object sub-tree.
1817 * If the last object of chain already have focus, the focus will go to the
1818 * first object of chain.
1820 * @param obj The widget root of sub-tree
1821 * @param dir Direction to cycle the focus
1826 elm_widget_focus_cycle(Evas_Object *obj,
1827 Elm_Focus_Direction dir)
1829 Evas_Object *target = NULL;
1830 if (!_elm_widget_is(obj))
1832 elm_widget_focus_next_get(obj, dir, &target);
1834 elm_widget_focus_steal(target);
1840 * Give focus to near object(in object tree) in one direction.
1842 * Give focus to near object(in object tree) in direction of current
1843 * focused object. If none focusable object in given direction or
1844 * none focused object in object tree, the focus will not change.
1846 * @param obj The reference widget
1847 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
1848 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
1849 * @return EINA_TRUE if focus is moved.
1854 elm_widget_focus_direction_go(Evas_Object *obj,
1857 Evas_Object *target = NULL;
1858 Evas_Object *current_focused = NULL;
1859 double weight = 0.0;
1861 if (!_elm_widget_is(obj)) return EINA_FALSE;
1862 if (!elm_widget_focus_get(obj)) return EINA_FALSE;
1864 current_focused = elm_widget_focused_object_get(obj);
1866 if (elm_widget_focus_direction_get
1867 (obj, current_focused, degree, &target, &weight))
1869 elm_widget_focus_steal(target);
1876 _direction_weight_get(const Evas_Object *obj1,
1877 const Evas_Object *obj2,
1880 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
1881 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
1882 double ax, ay, cx, cy;
1883 double weight = -1.0, g = 0.0;
1885 if (obj1 == obj2) return 0.0;
1888 while (degree >= 360.0)
1890 while (degree < 0.0)
1893 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
1894 cx = obj_x1 + (w1 / 2.0);
1895 cy = obj_y1 + (h1 / 2.0);
1896 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
1898 /* For overlapping cases. */
1899 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
1902 /* Change all points to relative one. */
1912 /* Get crossing points (ax, ay) between obj1 and a line extending
1913 * to the direction of current degree. */
1919 else if (degree == 90.0)
1924 else if (degree == 180.0)
1929 else if (degree == 270.0)
1936 g = tan(degree * (M_PI / 180.0));
1937 if ((degree > 0.0) && (degree < 90.0))
1940 if (ay <= yyy1) ax = xx1;
1947 else if ((degree > 90.0) && (degree < 180.0))
1950 if (ay <= yyy1) ax = x1;
1957 else if ((degree > 180.0) && (degree < 270.0))
1960 if (ay >= yy1) ax = x1;
1970 if (ay >= yy1) ax = xx1;
1979 /* Filter obj2, if it is not in the specific derection. */
1981 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
1982 double t1, t2, u1, v1, u2, v2;
1984 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
1994 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
1999 t1 = (u1 * ax) + (v1 * ay);
2000 t2 = (u2 * ax) + (v2 * ay);
2002 #define _R(x) (int)((x + 0.05) * 10.0)
2004 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
2010 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
2016 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
2022 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
2023 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
2032 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2034 else if (degree == 90.0)
2036 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2038 else if (degree == 180.0)
2040 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2042 else if (degree == 270.0)
2044 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2048 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
2050 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
2053 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
2055 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
2058 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
2061 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
2062 && (_R(ay * yy2) > 0)))
2065 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
2066 (_R((1.0 / g) * yyy2) <= _R(xx2)))
2068 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
2069 && (_R(ay * yyy2) > 0))) return 0.0;
2075 /* Calculate the weight for obj2. */
2078 if (_R(xx1) > _R(x2)) weight = -1.0;
2079 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2080 weight = (x2 - xx1) * (x2 - xx1);
2081 else if (_R(yy2) > 0)
2082 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
2083 else if (_R(yyy2) < 0)
2084 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
2085 else weight = (x2 - xx1) * (x2 - xx1);
2087 else if (degree == 90.0)
2089 if (_R(yyy1) > _R(yy2)) weight = -1.0;
2090 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2091 weight = (yy2 - yyy1) * (yy2 - yyy1);
2092 else if (_R(x2) > 0)
2093 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
2094 else if (_R(xx2) < 0)
2095 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
2096 else weight = (yy2 - yyy1) * (yy2 - yyy1);
2098 else if (degree == 180.0)
2100 if (_R(x1) < _R(xx2)) weight = -1.0;
2101 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2102 weight = (x1 - xx2) * (x1 - xx2);
2103 else if (_R(yy2) > 0)
2104 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
2105 else if (_R(yyy2) < 0)
2106 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
2107 else weight = (x1 - xx2) * (x1 - xx2);
2109 else if (degree == 270.0)
2111 if (_R(yy1) < _R(yyy2)) weight = -1.0;
2112 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2113 weight = (yy1 - yyy2) * (yy1 - yyy2);
2114 else if (_R(x2) > 0)
2115 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
2116 else if (_R(xx2) < 0)
2117 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
2118 else weight = (yy1 - yyy2) * (yy1 - yyy2);
2123 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
2124 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
2125 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
2129 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2130 ((ay - (g * x2)) * (ay - (g * x2)));
2132 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2136 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2137 ((ay - (g * xx2)) * (ay - (g * xx2)));
2139 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2141 sx[j] = (1.0 / g) * yy2;
2144 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2145 ((ay - yy2) * (ay - yy2));
2147 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2150 sx[j] = (1.0 / g) * yyy2;
2153 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2154 ((ay - yyy2) * (ay - yyy2));
2157 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2158 (_R(sy[0]) != _R(sy[1])))))
2162 if (_R(t_weight[k]) == 0) return -1.0;
2163 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2170 double ccx, ccy, t1_weight, x_diff, y_diff;
2171 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2173 x_diff = rx[k] - ccx;
2174 if (x_diff < 0) x_diff *= -1.0;
2175 y_diff = ry[k] - ccy;
2176 if (y_diff < 0) y_diff *= -1.0;
2178 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2179 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2180 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2185 /* Return the current object's weight. */
2186 if (weight == -1.0) return 0.0;
2187 if (_R(weight) == 0) return -1.0;
2191 return 1.0 / weight;
2197 * Get near object in one direction of base object.
2199 * Get near object(in the object sub-tree) in one direction of
2200 * base object. Return the near object by reference.
2201 * By initializing weight, you can filter objects locating far
2202 * from base object. If object is in the specific direction,
2203 * weight is (1/(distance^2)). If object is not exactly in one
2204 * direction, some penalty will be added.
2206 * @param obj The widget root of sub-tree
2207 * @param base The base object of the direction
2208 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2209 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2210 * @param direction The near object in one direction
2211 * @param weight The weight is bigger when the object is located near
2212 * @return EINA_TRUE if near object is updated.
2217 elm_widget_focus_direction_get(const Evas_Object *obj,
2218 const Evas_Object *base,
2220 Evas_Object **direction,
2225 API_ENTRY return EINA_FALSE;
2227 /* -1 means the best was already decided. Don't need any more searching. */
2228 if (!direction || !weight || !base || (obj == base))
2231 /* Ignore if disabled */
2232 if ((!evas_object_visible_get(obj))
2233 || (elm_widget_disabled_get(obj))
2234 || (elm_widget_tree_unfocusable_get(obj)))
2237 if (!sd->api) return EINA_FALSE;
2240 if (_elm_widget_focus_direction_manager_is(obj))
2241 return sd->api->focus_direction(obj, base, degree, direction, weight);
2243 if (!elm_widget_can_focus_get(obj) || elm_widget_focus_get(obj))
2246 c_weight = _direction_weight_get(base, obj, degree);
2247 if ((c_weight == -1.0) ||
2248 ((c_weight != 0.0) && (*weight != -1.0) &&
2249 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2251 if ((int)(*weight * 1000000) == (int)(c_weight * 1000000))
2253 Elm_Widget_Smart_Data *sd1 =
2254 evas_object_smart_data_get(*direction);
2257 if (sd->focus_order <= sd1->focus_order)
2261 *direction = (Evas_Object *)obj;
2271 * Get near object in one direction of base object in list.
2273 * Get near object in one direction of base object in the specific
2274 * object list. Return the near object by reference.
2275 * By initializing weight, you can filter objects locating far
2276 * from base object. If object is in the specific direction,
2277 * weight is (1/(distance^2)). If object is not exactly in one
2278 * direction, some penalty will be added.
2280 * @param obj The widget root of sub-tree
2281 * @param base The base object of the direction
2282 * @param items list with ordered objects
2283 * @param list_data_get function to get the object from one item of list
2284 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2285 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2286 * @param direction The near object in one direction
2287 * @param weight The weight is bigger when the object is located near
2288 * @return EINA_TRUE if near object is updated.
2293 elm_widget_focus_list_direction_get(const Evas_Object *obj,
2294 const Evas_Object *base,
2295 const Eina_List *items,
2296 void *(*list_data_get)(const Eina_List *l),
2298 Evas_Object **direction,
2301 API_ENTRY return EINA_FALSE;
2302 if (!direction || !weight || !base || !items)
2305 const Eina_List *l = items;
2306 Evas_Object *current_best = *direction;
2308 for (; l; l = eina_list_next(l))
2310 Evas_Object *cur = list_data_get(l);
2311 elm_widget_focus_direction_get(cur, base, degree, direction, weight);
2313 if (current_best != *direction)
2322 * Get next object in focus chain of object tree.
2324 * Get next object in focus chain of one object sub-tree.
2325 * Return the next object by reference. If don't have any candidate to receive
2326 * focus before chain end, the first candidate will be returned.
2328 * @param obj The widget root of sub-tree
2329 * @param dir Direction os focus chain
2330 * @param next The next object in focus chain
2331 * @return EINA_TRUE if don't need focus chain restart/loop back
2332 * to use 'next' obj.
2337 elm_widget_focus_next_get(const Evas_Object *obj,
2338 Elm_Focus_Direction dir,
2345 API_ENTRY return EINA_FALSE;
2347 /* Ignore if disabled */
2348 if ((!evas_object_visible_get(obj))
2349 || (elm_widget_disabled_get(obj))
2350 || (elm_widget_tree_unfocusable_get(obj)))
2353 if (!sd->api) return EINA_FALSE;
2356 if (_elm_widget_focus_chain_manager_is(obj))
2357 return sd->api->focus_next(obj, dir, next);
2359 if (!elm_widget_can_focus_get(obj))
2363 *next = (Evas_Object *)obj;
2364 return !elm_widget_focus_get(obj);
2370 * Get next object in focus chain of object tree in list.
2372 * Get next object in focus chain of one object sub-tree ordered by one list.
2373 * Return the next object by reference. If don't have any candidate to receive
2374 * focus before list end, the first candidate will be returned.
2376 * @param obj The widget root of sub-tree
2377 * @param dir Direction os focus chain
2378 * @param items list with ordered objects
2379 * @param list_data_get function to get the object from one item of list
2380 * @param next The next object in focus chain
2381 * @return EINA_TRUE if don't need focus chain restart/loop back
2382 * to use 'next' obj.
2387 elm_widget_focus_list_next_get(const Evas_Object *obj,
2388 const Eina_List *items,
2389 void *(*list_data_get)(const Eina_List *list),
2390 Elm_Focus_Direction dir,
2393 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2399 if (!_elm_widget_is(obj))
2406 if (dir == ELM_FOCUS_PREVIOUS)
2408 items = eina_list_last(items);
2409 list_next = eina_list_prev;
2411 else if (dir == ELM_FOCUS_NEXT)
2412 list_next = eina_list_next;
2416 const Eina_List *l = items;
2418 /* Recovery last focused sub item */
2419 if (elm_widget_focus_get(obj))
2421 for (; l; l = list_next(l))
2423 Evas_Object *cur = list_data_get(l);
2424 if (elm_widget_focus_get(cur)) break;
2427 /* Focused object, but no focused sub item */
2431 const Eina_List *start = l;
2432 Evas_Object *to_focus = NULL;
2434 /* Interate sub items */
2435 /* Go to end of list */
2436 for (; l; l = list_next(l))
2438 Evas_Object *tmp = NULL;
2439 Evas_Object *cur = list_data_get(l);
2441 if (elm_widget_parent_get(cur) != obj)
2444 /* Try Focus cycle in subitem */
2445 if (elm_widget_focus_next_get(cur, dir, &tmp))
2450 else if ((tmp) && (!to_focus))
2456 /* Get First possible */
2457 for (; l != start; l = list_next(l))
2459 Evas_Object *tmp = NULL;
2460 Evas_Object *cur = list_data_get(l);
2462 if (elm_widget_parent_get(cur) != obj)
2465 /* Try Focus cycle in subitem */
2466 elm_widget_focus_next_get(cur, dir, &tmp);
2479 elm_widget_signal_emit(Evas_Object *obj,
2480 const char *emission,
2485 if (evas_object_smart_type_check(obj, "elm_layout"))
2486 elm_layout_signal_emit(obj, emission, source);
2487 else if (evas_object_smart_type_check(obj, "elm_icon"))
2489 WRN("Deprecated function. This functionality on icon objects"
2490 " will be dropped on a next release.");
2491 _elm_icon_signal_emit(obj, emission, source);
2496 elm_widget_signal_callback_add(Evas_Object *obj,
2497 const char *emission,
2499 Edje_Signal_Cb func,
2504 EINA_SAFETY_ON_NULL_RETURN(func);
2506 if (evas_object_smart_type_check(obj, "elm_layout"))
2507 elm_layout_signal_callback_add(obj, emission, source, func, data);
2508 else if (evas_object_smart_type_check(obj, "elm_icon"))
2510 WRN("Deprecated function. This functionality on icon objects"
2511 " will be dropped on a next release.");
2513 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2518 elm_widget_signal_callback_del(Evas_Object *obj,
2519 const char *emission,
2521 Edje_Signal_Cb func)
2525 API_ENTRY return NULL;
2527 if (evas_object_smart_type_check(obj, "elm_layout"))
2528 data = elm_layout_signal_callback_del(obj, emission, source, func);
2529 else if (evas_object_smart_type_check(obj, "elm_icon"))
2531 WRN("Deprecated function. This functionality on icon objects"
2532 " will be dropped on a next release.");
2534 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2541 elm_widget_focus_set(Evas_Object *obj,
2546 if (!sd->api) return;
2551 sd->focus_order = focus_order;
2552 sd->focused = EINA_TRUE;
2553 sd->api->on_focus(obj);
2558 if ((_is_focusable(sd->resize_obj)) &&
2559 (!elm_widget_disabled_get(sd->resize_obj)))
2561 elm_widget_focus_set(sd->resize_obj, first);
2568 EINA_LIST_FOREACH(sd->subobjs, l, child)
2570 if ((_is_focusable(child)) &&
2571 (!elm_widget_disabled_get(child)))
2573 elm_widget_focus_set(child, first);
2584 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2586 if ((_is_focusable(child)) &&
2587 (!elm_widget_disabled_get(child)))
2589 elm_widget_focus_set(child, first);
2595 if ((_is_focusable(sd->resize_obj)) &&
2596 (!elm_widget_disabled_get(sd->resize_obj)))
2598 elm_widget_focus_set(sd->resize_obj, first);
2605 elm_widget_parent_get(const Evas_Object *obj)
2607 API_ENTRY return NULL;
2608 return sd->parent_obj;
2612 elm_widget_focused_object_clear(Evas_Object *obj)
2616 if (!sd->api) return;
2618 if (!sd->focused) return;
2619 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
2620 elm_widget_focused_object_clear(sd->resize_obj);
2625 EINA_LIST_FOREACH(sd->subobjs, l, child)
2627 if (elm_widget_focus_get(child))
2629 elm_widget_focused_object_clear(child);
2634 sd->focused = EINA_FALSE;
2635 sd->api->on_focus(obj);
2639 elm_widget_focus_steal(Evas_Object *obj)
2641 Evas_Object *parent, *parent2, *o;
2644 if (sd->focused) return;
2645 if (sd->disabled) return;
2646 if (!sd->can_focus) return;
2647 if (sd->tree_unfocusable) return;
2651 o = elm_widget_parent_get(parent);
2653 sd = evas_object_smart_data_get(o);
2654 if (sd->disabled || sd->tree_unfocusable) return;
2655 if (sd->focused) break;
2658 if ((!elm_widget_parent_get(parent)) &&
2659 (!elm_widget_parent2_get(parent)))
2660 elm_widget_focused_object_clear(parent);
2663 parent2 = elm_widget_parent_get(parent);
2664 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2666 sd = evas_object_smart_data_get(parent);
2669 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2670 elm_widget_focused_object_clear(sd->resize_obj);
2675 EINA_LIST_FOREACH(sd->subobjs, l, child)
2677 if (elm_widget_focus_get(child))
2679 elm_widget_focused_object_clear(child);
2687 _elm_widget_focus_region_show(obj);
2692 elm_widget_focus_restore(Evas_Object *obj)
2694 Evas_Object *newest = NULL;
2695 unsigned int newest_focus_order = 0;
2698 newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2701 elm_object_focus_set(newest, EINA_FALSE);
2702 elm_object_focus_set(newest, EINA_TRUE);
2707 _elm_widget_top_win_focused_set(Evas_Object *obj,
2708 Eina_Bool top_win_focused)
2714 if (sd->top_win_focused == top_win_focused) return;
2716 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2717 EINA_LIST_FOREACH(sd->subobjs, l, child)
2719 _elm_widget_top_win_focused_set(child, top_win_focused);
2721 sd->top_win_focused = top_win_focused;
2725 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2727 API_ENTRY return EINA_FALSE;
2728 return sd->top_win_focused;
2732 elm_widget_disabled_set(Evas_Object *obj,
2737 if (sd->disabled == disabled) return;
2738 sd->disabled = !!disabled;
2739 elm_widget_focus_disabled_handle(obj);
2740 if (!sd->api) return;
2741 sd->api->disable(obj);
2745 elm_widget_disabled_get(const Evas_Object *obj)
2748 return sd->disabled;
2752 elm_widget_show_region_set(Evas_Object *obj,
2757 Eina_Bool forceshow)
2759 Evas_Object *parent_obj, *child_obj;
2760 Evas_Coord px, py, cx, cy;
2764 evas_smart_objects_calculate(evas_object_evas_get(obj));
2765 ELM_WIDGET_CHECK_OR_RETURN(obj);
2767 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2768 (w == sd->rw) && (h == sd->rh)) return;
2774 if (sd->on_show_region)
2776 (sd->on_show_region_data, obj);
2780 parent_obj = sd->parent_obj;
2781 child_obj = sd->obj;
2782 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2783 sd = evas_object_smart_data_get(parent_obj);
2786 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2787 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2796 if (sd->on_show_region)
2799 (sd->on_show_region_data, parent_obj);
2806 elm_widget_show_region_get(const Evas_Object *obj,
2822 * Get the focus region of the given widget.
2824 * @return show region or not
2825 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
2827 * The focus region is the area of a widget that should brought into the
2828 * visible area when the widget is focused. Mostly used to show the part of
2829 * an entry where the cursor is, for example. The area returned is relative
2830 * to the object @p obj.
2832 * @param obj The widget object
2833 * @param x Where to store the x coordinate of the area
2834 * @param y Where to store the y coordinate of the area
2835 * @param w Where to store the width of the area
2836 * @param h Where to store the height of the area
2841 elm_widget_focus_region_get(const Evas_Object *obj,
2847 API_ENTRY return EINA_FALSE;
2848 if (!sd->api->on_focus_region(obj, x, y, w, h))
2850 evas_object_geometry_get(obj, NULL, NULL, w, h);
2858 elm_widget_scrollable_children_get(Evas_Object *obj)
2860 Eina_List *l, *ret = NULL;
2863 API_ENTRY return NULL;
2865 EINA_LIST_FOREACH(sd->subobjs, l, child)
2867 if (_elm_scrollable_is(child))
2868 ret = eina_list_append(ret, child);
2875 elm_widget_scroll_hold_push(Evas_Object *obj)
2879 if (sd->scroll_hold == 1)
2881 if (_elm_scrollable_is(obj))
2883 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2884 s_iface->hold_set(obj, EINA_TRUE);
2888 Eina_List *scr_children, *l;
2891 scr_children = elm_widget_scrollable_children_get(obj);
2892 EINA_LIST_FOREACH(scr_children, l, child)
2894 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2895 s_iface->hold_set(child, EINA_TRUE);
2897 eina_list_free(scr_children);
2900 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2901 // FIXME: on delete/reparent hold pop
2905 elm_widget_scroll_hold_pop(Evas_Object *obj)
2909 if (!sd->scroll_hold)
2911 if (_elm_scrollable_is(obj))
2913 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2914 s_iface->hold_set(obj, EINA_FALSE);
2918 Eina_List *scr_children, *l;
2921 scr_children = elm_widget_scrollable_children_get(obj);
2922 EINA_LIST_FOREACH(scr_children, l, child)
2924 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2925 s_iface->hold_set(child, EINA_FALSE);
2927 eina_list_free(scr_children);
2930 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2931 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2935 elm_widget_scroll_hold_get(const Evas_Object *obj)
2938 return sd->scroll_hold;
2942 elm_widget_scroll_freeze_push(Evas_Object *obj)
2945 sd->scroll_freeze++;
2946 if (sd->scroll_freeze == 1)
2948 if (_elm_scrollable_is(obj))
2950 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2951 s_iface->freeze_set(obj, EINA_TRUE);
2955 Eina_List *scr_children, *l;
2958 scr_children = elm_widget_scrollable_children_get(obj);
2959 EINA_LIST_FOREACH(scr_children, l, child)
2961 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2962 s_iface->freeze_set(child, EINA_TRUE);
2964 eina_list_free(scr_children);
2967 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2968 // FIXME: on delete/reparent freeze pop
2972 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2975 sd->scroll_freeze--;
2976 if (!sd->scroll_freeze)
2978 if (_elm_scrollable_is(obj))
2980 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2981 s_iface->freeze_set(obj, EINA_FALSE);
2985 Eina_List *scr_children, *l;
2988 scr_children = elm_widget_scrollable_children_get(obj);
2989 EINA_LIST_FOREACH(scr_children, l, child)
2991 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2992 s_iface->freeze_set(child, EINA_FALSE);
2994 eina_list_free(scr_children);
2997 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
2998 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3002 elm_widget_scroll_freeze_get(const Evas_Object *obj)
3005 return sd->scroll_freeze;
3009 elm_widget_scale_set(Evas_Object *obj,
3013 if (scale <= 0.0) scale = 0.0;
3014 if (sd->scale != scale)
3017 elm_widget_theme(obj);
3022 elm_widget_scale_get(const Evas_Object *obj)
3024 API_ENTRY return 1.0;
3025 // FIXME: save walking up the tree by storing/caching parent scale
3026 if (sd->scale == 0.0)
3029 return elm_widget_scale_get(sd->parent_obj);
3037 elm_widget_theme_set(Evas_Object *obj,
3041 if (sd->theme != th)
3043 if (sd->theme) elm_theme_free(sd->theme);
3046 elm_widget_theme(obj);
3051 elm_widget_text_part_set(Evas_Object *obj,
3057 if (evas_object_smart_type_check(obj, "elm_layout"))
3058 elm_layout_text_set(obj, part, label);
3062 elm_widget_text_part_get(const Evas_Object *obj,
3065 API_ENTRY return NULL;
3067 if (evas_object_smart_type_check(obj, "elm_layout"))
3068 return elm_layout_text_get(obj, part);
3074 elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
3081 Elm_Translate_String_Data *ts = NULL;
3084 str = eina_stringshare_add(part);
3085 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3092 eina_stringshare_del(str);
3095 ts = malloc(sizeof(Elm_Translate_String_Data));
3099 ts->domain = eina_stringshare_add(domain);
3100 ts->string = eina_stringshare_add(label);
3101 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
3107 eina_stringshare_replace(&ts->domain, domain);
3108 eina_stringshare_replace(&ts->string, label);
3112 sd->translate_strings = eina_list_remove_list(
3113 sd->translate_strings, l);
3114 eina_stringshare_del(ts->id);
3115 eina_stringshare_del(ts->domain);
3116 eina_stringshare_del(ts->string);
3119 eina_stringshare_del(str);
3123 if (label && label[0])
3124 label = dgettext(domain, label);
3126 elm_widget_text_part_set(obj, part, label);
3130 elm_widget_translatable_text_part_get(const Evas_Object *obj,
3133 const char *str, *ret = NULL;
3135 Elm_Translate_String_Data *ts;
3136 API_ENTRY return NULL;
3138 str = eina_stringshare_add(part);
3139 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3145 eina_stringshare_del(str);
3150 elm_widget_translate(Evas_Object *obj)
3155 Elm_Translate_String_Data *ts;
3160 EINA_LIST_FOREACH(sd->subobjs, l, child)
3161 elm_widget_translate(child);
3162 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
3163 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3164 if (!sd->api) return;
3165 sd->api->translate(obj);
3168 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3170 const char *s = dgettext(ts->domain, ts->string);
3171 elm_widget_text_part_set(obj, ts->id, s);
3177 elm_widget_content_part_set(Evas_Object *obj,
3179 Evas_Object *content)
3183 if (!sd->api) return;
3184 if (evas_object_smart_type_check(obj, "elm_container"))
3185 ELM_CONTAINER_CLASS(sd->api)->content_set(obj, part, content);
3189 elm_widget_content_part_get(const Evas_Object *obj,
3192 API_ENTRY return NULL;
3194 if (!sd->api) return NULL;
3196 if (evas_object_smart_type_check(obj, "elm_container"))
3197 return ELM_CONTAINER_CLASS(sd->api)->content_get(obj, part);
3203 elm_widget_content_part_unset(Evas_Object *obj,
3206 API_ENTRY return NULL;
3208 if (!sd->api) return NULL;
3209 if (evas_object_smart_type_check(obj, "elm_container"))
3210 return ELM_CONTAINER_CLASS(sd->api)->content_unset(obj, part);
3216 elm_widget_access_info_set(Evas_Object *obj,
3220 if (sd->access_info) eina_stringshare_del(sd->access_info);
3221 if (!txt) sd->access_info = NULL;
3222 else sd->access_info = eina_stringshare_add(txt);
3226 elm_widget_access_info_get(const Evas_Object *obj)
3228 API_ENTRY return NULL;
3229 return sd->access_info;
3233 elm_widget_theme_get(const Evas_Object *obj)
3235 API_ENTRY return NULL;
3239 return elm_widget_theme_get(sd->parent_obj);
3247 elm_widget_style_set(Evas_Object *obj,
3250 API_ENTRY return EINA_FALSE;
3252 if (eina_stringshare_replace(&sd->style, style))
3253 return elm_widget_theme(obj);
3259 elm_widget_style_get(const Evas_Object *obj)
3261 API_ENTRY return NULL;
3262 if (sd->style) return sd->style;
3267 elm_widget_tooltip_add(Evas_Object *obj,
3271 sd->tooltips = eina_list_append(sd->tooltips, tt);
3275 elm_widget_tooltip_del(Evas_Object *obj,
3279 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3283 elm_widget_cursor_add(Evas_Object *obj,
3287 sd->cursors = eina_list_append(sd->cursors, cur);
3291 elm_widget_cursor_del(Evas_Object *obj,
3295 sd->cursors = eina_list_remove(sd->cursors, cur);
3299 elm_widget_drag_lock_x_set(Evas_Object *obj,
3303 if (sd->drag_x_locked == lock) return;
3304 sd->drag_x_locked = lock;
3305 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
3306 else _propagate_x_drag_lock(obj, -1);
3310 elm_widget_drag_lock_y_set(Evas_Object *obj,
3314 if (sd->drag_y_locked == lock) return;
3315 sd->drag_y_locked = lock;
3316 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
3317 else _propagate_y_drag_lock(obj, -1);
3321 elm_widget_drag_lock_x_get(const Evas_Object *obj)
3323 API_ENTRY return EINA_FALSE;
3324 return sd->drag_x_locked;
3328 elm_widget_drag_lock_y_get(const Evas_Object *obj)
3330 API_ENTRY return EINA_FALSE;
3331 return sd->drag_y_locked;
3335 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
3338 return sd->child_drag_x_locked;
3342 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
3345 return sd->child_drag_y_locked;
3349 elm_widget_theme_object_set(Evas_Object *obj,
3352 const char *welement,
3355 API_ENTRY return EINA_FALSE;
3356 return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
3360 elm_widget_is_check(const Evas_Object *obj)
3362 static int abort_on_warn = -1;
3363 if (elm_widget_is(obj))
3366 ERR("Passing Object: %p.", obj);
3367 if (abort_on_warn == -1)
3369 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3370 else abort_on_warn = 0;
3372 if (abort_on_warn == 1) abort();
3377 elm_widget_type_get(const Evas_Object *obj)
3379 API_ENTRY return NULL;
3381 return evas_object_type_get(obj);
3385 elm_widget_type_check(const Evas_Object *obj,
3389 const char *provided, *expected = "(unknown)";
3390 static int abort_on_warn = -1;
3392 provided = elm_widget_type_get(obj);
3393 /* TODO: eventually migrate to check_ptr version */
3394 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
3395 if (type) expected = type;
3396 if ((!provided) || (!provided[0]))
3398 provided = evas_object_type_get(obj);
3399 if ((!provided) || (!provided[0]))
3400 provided = "(unknown)";
3402 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
3403 " type: '%s'", obj, func, provided, expected);
3404 if (abort_on_warn == -1)
3406 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3407 else abort_on_warn = 0;
3409 if (abort_on_warn == 1) abort();
3413 static Evas_Object *
3414 _widget_name_find(const Evas_Object *obj,
3421 INTERNAL_ENTRY NULL;
3423 if (!_elm_widget_is(obj)) return NULL;
3426 s = evas_object_name_get(sd->resize_obj);
3427 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
3428 if ((recurse != 0) &&
3429 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
3432 EINA_LIST_FOREACH(sd->subobjs, l, child)
3434 s = evas_object_name_get(child);
3435 if ((s) && (!strcmp(s, name))) return child;
3436 if ((recurse != 0) &&
3437 ((child = _widget_name_find(child, name, recurse - 1))))
3442 s = evas_object_name_get(sd->hover_obj);
3443 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
3444 if ((recurse != 0) &&
3445 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
3452 elm_widget_name_find(const Evas_Object *obj,
3456 API_ENTRY return NULL;
3457 if (!name) return NULL;
3458 return _widget_name_find(obj, name, recurse);
3464 * Split string in words
3466 * @param str Source string
3467 * @return List of const words
3469 * @see elm_widget_stringlist_free()
3473 elm_widget_stringlist_get(const char *str)
3475 Eina_List *list = NULL;
3477 if (!str) return NULL;
3478 for (b = s = str; 1; s++)
3480 if ((*s == ' ') || (!*s))
3482 char *t = malloc(s - b + 1);
3485 strncpy(t, b, s - b);
3487 list = eina_list_append(list, eina_stringshare_add(t));
3498 elm_widget_stringlist_free(Eina_List *list)
3501 EINA_LIST_FREE (list, s)
3502 eina_stringshare_del(s);
3506 elm_widget_focus_hide_handle(Evas_Object *obj)
3508 if (!_elm_widget_is(obj))
3510 _if_focused_revert(obj, EINA_TRUE);
3514 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
3516 Evas_Object *o = obj;
3519 if (_elm_widget_is(o)) break;
3520 o = evas_object_smart_parent_get(o);
3524 if (!_is_focusable(o)) return;
3525 elm_widget_focus_steal(o);
3529 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
3533 //FIXME: Need to check whether the object is unfocusable or not.
3535 if (!elm_widget_parent_get(obj))
3536 elm_widget_focused_object_clear(obj);
3538 _if_focused_revert(obj, EINA_TRUE);
3542 elm_widget_focus_disabled_handle(Evas_Object *obj)
3546 elm_widget_focus_tree_unfocusable_handle(obj);
3550 elm_widget_focus_order_get(const Evas_Object *obj)
3553 return sd->focus_order;
3557 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
3559 Evas_Object *parent;
3565 if (sd->api->activate)
3566 ret = sd->api->activate(obj, act);
3570 parent = elm_widget_parent_get(obj);
3572 elm_widget_activate(parent, act);
3580 * Returns the widget's Evas_Display_Mode
3582 * @param obj The widget.
3583 * @return Evas_Display_Mode of the object.
3585 * @see elm_widget_display_mode_set().
3588 EAPI Evas_Display_Mode
3589 elm_widget_display_mode_get(const Evas_Object *obj)
3591 Evas_Display_Mode new_mode;
3592 Evas_Object *parent;
3594 API_ENTRY return EVAS_DISPLAY_MODE_NONE;
3596 new_mode = evas_object_size_hint_display_mode_get(obj);
3597 parent = elm_widget_parent_get(obj);
3599 if ((new_mode == EVAS_DISPLAY_MODE_INHERIT) && parent)
3600 return elm_widget_display_mode_get(parent);
3608 * Sets the widget and child widget's Evas_Display_Mode.
3610 * @param obj The widget.
3611 * @param dispmode Evas_Display_Mode to set widget's mode.
3613 * Widgets are resized by several reasons.
3614 * Evas_Display_Mode can help for widgets to get one more reason of resize.
3615 * For example, elm conform widget resizes it's contents when keypad state changed.
3616 * After keypad showing, conform widget can change child's Evas_Display_Mode.
3620 elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
3622 Evas_Display_Mode child_mode;
3628 if (elm_widget_display_mode_get(obj) == dispmode) return;
3629 evas_object_size_hint_display_mode_set(obj, dispmode);
3631 //TODO: Need to deal with EVAS_DISPLAY_MODE_INHERIT efficiently.
3632 EINA_LIST_FOREACH (sd->subobjs, l, child)
3634 child_mode = evas_object_size_hint_display_mode_get(child);
3635 if (child_mode != EVAS_DISPLAY_MODE_DONT_CHANGE)
3637 elm_widget_display_mode_set(child, dispmode);
3646 * Allocate a new Elm_Widget_Item-derived structure.
3648 * The goal of this structure is to provide common ground for actions
3649 * that a widget item have, such as the owner widget, callback to
3650 * notify deletion, data pointer and maybe more.
3652 * @param widget the owner widget that holds this item, must be an elm_widget!
3653 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
3654 * be used to allocate memory.
3656 * @return allocated memory that is already zeroed out, or NULL on errors.
3658 * @see elm_widget_item_new() convenience macro.
3659 * @see elm_widget_item_del() to release memory.
3662 EAPI Elm_Widget_Item *
3663 _elm_widget_item_new(Evas_Object *widget,
3666 if (!_elm_widget_is(widget))
3669 Elm_Widget_Item *item;
3671 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
3672 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
3674 item = calloc(1, alloc_size);
3675 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
3677 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
3678 item->widget = widget;
3683 _elm_widget_item_free(Elm_Widget_Item *item)
3685 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3688 item->del_func((void *)item->data, item->widget, item);
3691 evas_object_del(item->view);
3693 if (item->access_info)
3694 eina_stringshare_del(item->access_info);
3696 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
3703 * Releases widget item memory, calling back del_cb() if it exists.
3705 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
3706 * to memory release. Note that elm_widget_item_pre_notify_del() calls
3707 * this function and then unset it, thus being useful for 2 step
3708 * cleanup whenever the del_cb may use any of the data that must be
3709 * deleted from item.
3711 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
3714 * @param item a valid #Elm_Widget_Item to be deleted.
3715 * @see elm_widget_item_del() convenience macro.
3719 _elm_widget_item_del(Elm_Widget_Item *item)
3721 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3722 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3723 item->on_deletion = EINA_TRUE;
3725 //Widget item delete callback
3726 if (item->del_pre_func)
3727 if (item->del_pre_func((Elm_Object_Item *)item))
3728 _elm_widget_item_free(item);
3734 * Set the function to notify to widgets when item is being deleted by user.
3736 * @param item a valid #Elm_Widget_Item to be notified
3737 * @see elm_widget_item_del_pre_hook_set() convenience macro.
3741 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item,
3742 Elm_Widget_Del_Pre_Cb func)
3744 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3745 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3746 item->del_pre_func = func;
3752 * Notify object will be deleted without actually deleting it.
3754 * This function will callback Elm_Widget_Item::del_cb if it is set
3755 * and then unset it so it is not called twice (ie: from
3756 * elm_widget_item_del()).
3758 * @param item a valid #Elm_Widget_Item to be notified
3759 * @see elm_widget_item_pre_notify_del() convenience macro.
3763 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
3765 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3766 if (!item->del_func) return;
3767 item->del_func((void *)item->data, item->widget, item);
3768 item->del_func = NULL;
3774 * Set the function to notify when item is being deleted.
3776 * This function will complain if there was a callback set already,
3777 * however it will set the new one.
3779 * The callback will be called from elm_widget_item_pre_notify_del()
3780 * or elm_widget_item_del() will be called with:
3781 * - data: the Elm_Widget_Item::data value.
3782 * - obj: the Elm_Widget_Item::widget evas object.
3783 * - event_info: the item being deleted.
3785 * @param item a valid #Elm_Widget_Item to be notified
3786 * @see elm_widget_item_del_cb_set() convenience macro.
3790 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
3793 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3794 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3796 if ((item->del_func) && (item->del_func != func))
3797 WRN("You're replacing a previously set del_cb %p of item %p with %p",
3798 item->del_func, item, func);
3800 item->del_func = func;
3806 * Retrieves owner widget of this item.
3808 * @param item a valid #Elm_Widget_Item to get data from.
3809 * @return owner widget of this item.
3813 _elm_widget_item_widget_get(const Elm_Widget_Item *item)
3815 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3816 return item->widget;
3822 * Set user-data in this item.
3824 * User data may be used to identify this item or just store any
3825 * application data. It is automatically given as the first parameter
3826 * of the deletion notify callback.
3828 * @param item a valid #Elm_Widget_Item to store data in.
3829 * @param data user data to store.
3830 * @see elm_widget_item_del_cb_set() convenience macro.
3834 _elm_widget_item_data_set(Elm_Widget_Item *item,
3837 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3838 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3840 if ((item->data) && (item->data != data))
3841 DBG("Replacing item %p data %p with %p", item, item->data, data);
3848 * Retrieves user-data of this item.
3850 * @param item a valid #Elm_Widget_Item to get data from.
3851 * @see elm_widget_item_data_set()
3855 _elm_widget_item_data_get(const Elm_Widget_Item *item)
3857 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3858 return (void *)item->data;
3862 _elm_widget_item_disabled_set(Elm_Widget_Item *item,
3865 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3866 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3868 if (item->disabled == disabled) return;
3869 item->disabled = !!disabled;
3870 if (item->disable_func) item->disable_func(item);
3874 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
3876 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
3877 return item->disabled;
3881 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
3882 Elm_Widget_Disable_Cb func)
3884 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3885 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3887 item->disable_func = func;
3890 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
3892 struct _Elm_Widget_Item_Tooltip
3894 Elm_Widget_Item *item;
3895 Elm_Tooltip_Item_Content_Cb func;
3896 Evas_Smart_Cb del_cb;
3900 static Evas_Object *
3901 _elm_widget_item_tooltip_label_create(void *data,
3902 Evas_Object *obj __UNUSED__,
3903 Evas_Object *tooltip,
3904 void *item __UNUSED__)
3906 Evas_Object *label = elm_label_add(tooltip);
3909 elm_object_style_set(label, "tooltip");
3910 elm_object_text_set(label, data);
3914 static Evas_Object *
3915 _elm_widget_item_tooltip_trans_label_create(void *data,
3916 Evas_Object *obj __UNUSED__,
3917 Evas_Object *tooltip,
3918 void *item __UNUSED__)
3920 Evas_Object *label = elm_label_add(tooltip);
3923 elm_object_style_set(label, "tooltip");
3924 elm_object_translatable_text_set(label, data);
3929 _elm_widget_item_tooltip_label_del_cb(void *data,
3930 Evas_Object *obj __UNUSED__,
3931 void *event_info __UNUSED__)
3933 eina_stringshare_del(data);
3939 * Set the text to be shown in the widget item.
3941 * @param item Target item
3942 * @param text The text to set in the content
3944 * Setup the text as tooltip to object. The item can have only one tooltip,
3945 * so any previous tooltip data is removed.
3950 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
3953 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3954 EINA_SAFETY_ON_NULL_RETURN(text);
3955 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3957 text = eina_stringshare_add(text);
3958 _elm_widget_item_tooltip_content_cb_set
3959 (item, _elm_widget_item_tooltip_label_create, text,
3960 _elm_widget_item_tooltip_label_del_cb);
3964 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
3967 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3968 EINA_SAFETY_ON_NULL_RETURN(text);
3969 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3971 text = eina_stringshare_add(text);
3972 _elm_widget_item_tooltip_content_cb_set
3973 (item, _elm_widget_item_tooltip_trans_label_create, text,
3974 _elm_widget_item_tooltip_label_del_cb);
3977 static Evas_Object *
3978 _elm_widget_item_tooltip_create(void *data,
3980 Evas_Object *tooltip)
3982 Elm_Widget_Item_Tooltip *wit = data;
3983 return wit->func((void *)wit->data, obj, tooltip, wit->item);
3987 _elm_widget_item_tooltip_del_cb(void *data,
3989 void *event_info __UNUSED__)
3991 Elm_Widget_Item_Tooltip *wit = data;
3992 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
3999 * Set the content to be shown in the tooltip item
4001 * Setup the tooltip to item. The item can have only one tooltip,
4002 * so any previous tooltip data is removed. @p func(with @p data) will
4003 * be called every time that need show the tooltip and it should
4004 * return a valid Evas_Object. This object is then managed fully by
4005 * tooltip system and is deleted when the tooltip is gone.
4007 * @param item the widget item being attached a tooltip.
4008 * @param func the function used to create the tooltip contents.
4009 * @param data what to provide to @a func as callback data/context.
4010 * @param del_cb called when data is not needed anymore, either when
4011 * another callback replaces @func, the tooltip is unset with
4012 * elm_widget_item_tooltip_unset() or the owner @a item
4013 * dies. This callback receives as the first parameter the
4014 * given @a data, and @c event_info is the item.
4019 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
4020 Elm_Tooltip_Item_Content_Cb func,
4022 Evas_Smart_Cb del_cb)
4024 Elm_Widget_Item_Tooltip *wit;
4026 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
4027 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4030 _elm_widget_item_tooltip_unset(item);
4034 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
4035 if (!wit) goto error;
4039 wit->del_cb = del_cb;
4041 elm_object_sub_tooltip_content_cb_set
4042 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
4043 _elm_widget_item_tooltip_del_cb);
4048 if (del_cb) del_cb((void *)data, NULL, item);
4051 if (del_cb) del_cb((void *)data, item->widget, item);
4057 * Unset tooltip from item
4059 * @param item widget item to remove previously set tooltip.
4061 * Remove tooltip from item. The callback provided as del_cb to
4062 * elm_widget_item_tooltip_content_cb_set() will be called to notify
4063 * it is not used anymore.
4065 * @see elm_widget_item_tooltip_content_cb_set()
4070 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
4072 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4073 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4075 elm_object_tooltip_unset(item->view);
4081 * Sets a different style for this item tooltip.
4083 * @note before you set a style you should define a tooltip with
4084 * elm_widget_item_tooltip_content_cb_set() or
4085 * elm_widget_item_tooltip_text_set()
4087 * @param item widget item with tooltip already set.
4088 * @param style the theme style to use (default, transparent, ...)
4093 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
4096 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4097 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4099 elm_object_tooltip_style_set(item->view, style);
4103 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item,
4106 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4107 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
4109 return elm_object_tooltip_window_mode_set(item->view, disable);
4113 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
4115 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4116 return elm_object_tooltip_window_mode_get(item->view);
4122 * Get the style for this item tooltip.
4124 * @param item widget item with tooltip already set.
4125 * @return style the theme style in use, defaults to "default". If the
4126 * object does not have a tooltip set, then NULL is returned.
4131 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
4133 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4134 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4136 return elm_object_tooltip_style_get(item->view);
4140 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
4143 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4144 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4146 elm_object_sub_cursor_set(item->view, item->widget, cursor);
4150 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
4152 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4153 return elm_object_cursor_get(item->view);
4157 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
4159 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4160 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4162 elm_object_cursor_unset(item->view);
4168 * Sets a different style for this item cursor.
4170 * @note before you set a style you should define a cursor with
4171 * elm_widget_item_cursor_set()
4173 * @param item widget item with cursor already set.
4174 * @param style the theme style to use (default, transparent, ...)
4179 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
4182 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4183 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4185 elm_object_cursor_style_set(item->view, style);
4191 * Get the style for this item cursor.
4193 * @param item widget item with cursor already set.
4194 * @return style the theme style in use, defaults to "default". If the
4195 * object does not have a cursor set, then NULL is returned.
4200 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
4202 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4203 return elm_object_cursor_style_get(item->view);
4209 * Set if the cursor set should be searched on the theme or should use
4210 * the provided by the engine, only.
4212 * @note before you set if should look on theme you should define a cursor
4213 * with elm_object_cursor_set(). By default it will only look for cursors
4214 * provided by the engine.
4216 * @param item widget item with cursor already set.
4217 * @param engine_only boolean to define it cursors should be looked only
4218 * between the provided by the engine or searched on widget's theme as well.
4223 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
4224 Eina_Bool engine_only)
4226 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4227 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4229 elm_object_cursor_theme_search_enabled_set(item->view, engine_only);
4235 * Get the cursor engine only usage for this item cursor.
4237 * @param item widget item with cursor already set.
4238 * @return engine_only boolean to define it cursors should be looked only
4239 * between the provided by the engine or searched on widget's theme as well. If
4240 * the object does not have a cursor set, then EINA_FALSE is returned.
4245 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
4247 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4248 return elm_object_cursor_theme_search_enabled_get(item->view);
4252 _elm_widget_item_part_content_set(Elm_Widget_Item *item,
4254 Evas_Object *content)
4256 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4257 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4258 if (!item->content_set_func)
4260 ERR("%s does not support elm_object_item_part_content_set() API.",
4261 elm_widget_type_get(item->widget));
4264 item->content_set_func((Elm_Object_Item *)item, part, content);
4268 _elm_widget_item_part_content_get(const Elm_Widget_Item *item,
4271 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4272 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4274 return item->content_get_func((Elm_Object_Item *)item, part);
4278 _elm_widget_item_part_content_unset(Elm_Widget_Item *item,
4281 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4282 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4283 if (!item->content_unset_func)
4285 ERR("%s does not support elm_object_item_part_content_unset() API.",
4286 elm_widget_type_get(item->widget));
4290 return item->content_unset_func((Elm_Object_Item *)item, part);
4294 _elm_widget_item_part_text_set(Elm_Widget_Item *item,
4298 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4299 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4300 if (!item->text_set_func)
4302 ERR("%s does not support elm_object_item_part_text_set() API.",
4303 elm_widget_type_get(item->widget));
4307 item->text_set_func((Elm_Object_Item *)item, part, label);
4311 _elm_widget_item_part_text_get(const Elm_Widget_Item *item,
4314 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4315 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4316 if (!item->text_get_func)
4318 ERR("%s does not support elm_object_item_part_text_get() API.",
4319 elm_widget_type_get(item->widget));
4323 return item->text_get_func((Elm_Object_Item *)item, part);
4327 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
4328 Elm_Widget_Content_Set_Cb func)
4330 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4331 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4333 item->content_set_func = func;
4337 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
4338 Elm_Widget_Content_Get_Cb func)
4340 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4341 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4343 item->content_get_func = func;
4347 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
4348 Elm_Widget_Content_Unset_Cb func)
4350 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4351 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4353 item->content_unset_func = func;
4357 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
4358 Elm_Widget_Text_Set_Cb func)
4360 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4361 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4363 item->text_set_func = func;
4367 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
4368 Elm_Widget_Text_Get_Cb func)
4370 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4371 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4373 item->text_get_func = func;
4377 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
4378 const char *emission,
4381 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4382 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4384 if (item->signal_emit_func)
4385 item->signal_emit_func((Elm_Object_Item *)item, emission, source);
4389 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
4390 Elm_Widget_Signal_Emit_Cb func)
4392 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4393 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4395 item->signal_emit_func = func;
4399 _elm_widget_item_access_info_set(Elm_Widget_Item *item,
4402 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4403 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4405 if (item->access_info) eina_stringshare_del(item->access_info);
4406 if (!txt) item->access_info = NULL;
4407 else item->access_info = eina_stringshare_add(txt);
4410 /* happy debug functions */
4413 _sub_obj_tree_dump(const Evas_Object *obj,
4418 for (i = 0; i < lvl * 3; i++)
4421 if (_elm_widget_is(obj))
4425 printf("+ %s(%p)\n",
4426 elm_widget_type_get(obj),
4429 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
4430 EINA_LIST_FOREACH(sd->subobjs, l, obj)
4432 if (obj != sd->resize_obj)
4433 _sub_obj_tree_dump(obj, lvl + 1);
4437 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
4441 _sub_obj_tree_dot_dump(const Evas_Object *obj,
4444 if (!_elm_widget_is(obj))
4448 Eina_Bool visible = evas_object_visible_get(obj);
4449 Eina_Bool disabled = elm_widget_disabled_get(obj);
4450 Eina_Bool focused = elm_widget_focus_get(obj);
4451 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
4455 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
4458 fprintf(output, ", style=bold");
4461 fprintf(output, ", color=gray28");
4463 fprintf(output, " ];\n");
4466 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
4467 "disabled: %d|focused: %d/%d|focus order:%d}\"",
4468 obj, obj, elm_widget_type_get(obj),
4469 evas_object_name_get(obj), visible, disabled, focused, can_focus,
4473 fprintf(output, ", style=bold");
4476 fprintf(output, ", fontcolor=gray28");
4478 if ((disabled) || (!visible))
4479 fprintf(output, ", color=gray");
4481 fprintf(output, " ];\n");
4485 EINA_LIST_FOREACH(sd->subobjs, l, o)
4486 _sub_obj_tree_dot_dump(o, output);
4492 elm_widget_tree_dump(const Evas_Object *top)
4495 if (!_elm_widget_is(top))
4497 _sub_obj_tree_dump(top, 0);
4505 elm_widget_tree_dot_dump(const Evas_Object *top,
4509 if (!_elm_widget_is(top))
4511 fprintf(output, "graph " " { node [shape=record];\n");
4512 _sub_obj_tree_dot_dump(top, output);
4513 fprintf(output, "}\n");