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);
424 _if_focused_revert(Evas_Object *obj,
425 Eina_Bool can_focus_only)
428 Evas_Object *newest = NULL;
429 unsigned int newest_focus_order = 0;
433 if (!sd->focused) return;
434 if (!sd->parent_obj) return;
436 top = elm_widget_top_get(sd->parent_obj);
439 newest = elm_widget_newest_focus_order_get
440 (top, &newest_focus_order, can_focus_only);
443 elm_object_focus_set(newest, EINA_FALSE);
444 elm_object_focus_set(newest, EINA_TRUE);
450 _smart_del(Evas_Object *obj)
453 Elm_Translate_String_Data *ts;
454 Elm_Event_Cb_Data *ecb;
456 ELM_WIDGET_DATA_GET(obj, sd);
460 /* detach it from us */
461 evas_object_event_callback_del_full
462 (sd->hover_obj, EVAS_CALLBACK_DEL, _on_sub_obj_del, sd);
463 sd->hover_obj = NULL;
468 sobj = eina_list_data_get(sd->subobjs);
470 /* let the objects clean-up themselves and get rid of this list */
471 if (!elm_widget_sub_object_del(obj, sobj))
473 ERR("failed to remove sub object %p from %p\n", sobj, obj);
474 sd->subobjs = eina_list_remove_list
475 (sd->subobjs, sd->subobjs);
477 evas_object_del(sobj);
479 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
480 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
481 EINA_LIST_FREE (sd->translate_strings, ts)
483 eina_stringshare_del(ts->id);
484 eina_stringshare_del(ts->domain);
485 eina_stringshare_del(ts->string);
489 EINA_LIST_FREE (sd->event_cb, ecb)
492 if (sd->style) eina_stringshare_del(sd->style);
493 if (sd->theme) elm_theme_free(sd->theme);
494 _if_focused_revert(obj, EINA_TRUE);
495 if (sd->access_info) eina_stringshare_del(sd->access_info);
497 evas_object_smart_data_set(obj, NULL);
501 _smart_reconfigure(Elm_Widget_Smart_Data *sd)
505 evas_object_move(sd->resize_obj, sd->x, sd->y);
506 evas_object_resize(sd->resize_obj, sd->w, sd->h);
510 evas_object_move(sd->hover_obj, sd->x, sd->y);
511 evas_object_resize(sd->hover_obj, sd->w, sd->h);
516 _smart_move(Evas_Object *obj,
520 ELM_WIDGET_DATA_GET(obj, sd);
525 _smart_reconfigure(sd);
529 _smart_resize(Evas_Object *obj,
533 ELM_WIDGET_DATA_GET(obj, sd);
538 _smart_reconfigure(sd);
542 _smart_show(Evas_Object *obj)
547 if ((list = evas_object_smart_members_get(obj)))
549 EINA_LIST_FREE (list, o)
551 if (evas_object_data_get(o, "_elm_leaveme")) continue;
558 _smart_hide(Evas_Object *obj)
563 list = evas_object_smart_members_get(obj);
564 EINA_LIST_FREE (list, o)
566 if (evas_object_data_get(o, "_elm_leaveme")) continue;
572 _smart_color_set(Evas_Object *obj,
581 if ((list = evas_object_smart_members_get(obj)))
583 EINA_LIST_FREE (list, o)
585 if (evas_object_data_get(o, "_elm_leaveme")) continue;
586 evas_object_color_set(o, r, g, b, a);
592 _smart_clip_set(Evas_Object *obj,
598 if ((list = evas_object_smart_members_get(obj)))
600 EINA_LIST_FREE (list, o)
602 if (evas_object_data_get(o, "_elm_leaveme")) continue;
603 evas_object_clip_set(o, clip);
609 _smart_clip_unset(Evas_Object *obj)
614 if ((list = evas_object_smart_members_get(obj)))
616 EINA_LIST_FREE (list, o)
618 if (evas_object_data_get(o, "_elm_leaveme")) continue;
619 evas_object_clip_unset(o);
625 _smart_calculate(Evas_Object *obj __UNUSED__)
627 /* a NO-OP, on the base */
631 _smart_member_add(Evas_Object *obj,
636 if (evas_object_data_get(child, "_elm_leaveme")) return;
638 evas_object_color_get(obj, &r, &g, &b, &a);
639 evas_object_color_set(child, r, g, b, a);
641 evas_object_clip_set(child, evas_object_clip_get(obj));
643 if (evas_object_visible_get(obj))
644 evas_object_show(child);
646 evas_object_hide(child);
650 _smart_member_del(Evas_Object *obj __UNUSED__,
653 if (evas_object_data_get(child, "_elm_leaveme")) return;
654 evas_object_clip_unset(child);
658 _elm_widget_smart_set(Elm_Widget_Smart_Class *api)
660 Evas_Smart_Class *sc;
662 if (!(sc = (Evas_Smart_Class *)api))
665 sc->add = _smart_add;
666 sc->del = _smart_del;
667 sc->move = _smart_move;
668 sc->resize = _smart_resize;
669 sc->show = _smart_show;
670 sc->hide = _smart_hide;
671 sc->color_set = _smart_color_set;
672 sc->clip_set = _smart_clip_set;
673 sc->clip_unset = _smart_clip_unset;
674 sc->calculate = _smart_calculate;
675 sc->member_add = _smart_member_add;
676 sc->member_del = _smart_member_del;
678 #define API_DEFAULT_SET_UNIMPLEMENTED(_prefix) \
679 api->_prefix = _elm_widget_##_prefix##_func_unimplemented;
681 /* NB: always remember to call these parent versions on children,
682 * except for the unimplemented ones and calculate, which is moot */
684 #define API_DEFAULT_SET(_prefix) \
685 api->_prefix = _elm_widget_##_prefix##_func;
688 API_DEFAULT_SET_UNIMPLEMENTED(on_focus);
689 API_DEFAULT_SET_UNIMPLEMENTED(disable);
691 API_DEFAULT_SET(theme);
692 API_DEFAULT_SET_UNIMPLEMENTED(on_focus_region);
694 API_DEFAULT_SET_UNIMPLEMENTED(translate);
695 API_DEFAULT_SET_UNIMPLEMENTED(event);
696 API_DEFAULT_SET_UNIMPLEMENTED(focus_next);
697 API_DEFAULT_SET_UNIMPLEMENTED(focus_direction);
699 /* NB: because those two weren't hooks before, translate the
700 * individual calls to them on the widgets as we bring them to the
701 * new class hierarchy. also, sub_object_{add,del} must be
702 * different than member_{add,del} here, because widget parenting
703 * on elm does not always imply parent and child will live on the
705 API_DEFAULT_SET(sub_object_add);
706 API_DEFAULT_SET(sub_object_del);
708 #undef API_DEFAULT_SET
709 #undef API_DEFAULT_SET_UNIMPLEMENTED
711 sc->callbacks = _smart_callbacks;
715 static inline Eina_Bool
716 _elm_widget_focus_chain_manager_is(const Evas_Object *obj)
718 API_ENTRY return EINA_FALSE;
720 if (!sd->api) return EINA_FALSE;
721 return sd->api->focus_next &&
722 (sd->api->focus_next != _elm_widget_focus_next_func_unimplemented);
725 static inline Eina_Bool
726 _elm_widget_focus_direction_manager_is(const Evas_Object *obj)
728 API_ENTRY return EINA_FALSE;
730 if (!sd->api) return EINA_FALSE;
731 return sd->api->focus_direction &&
732 (sd->api->focus_direction !=
733 _elm_widget_focus_direction_func_unimplemented);
737 _obj_mouse_down(void *data,
739 Evas_Object *obj __UNUSED__,
742 Elm_Widget_Smart_Data *sd = data;
743 Evas_Event_Mouse_Down *ev = event_info;
744 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
745 sd->still_in = EINA_TRUE;
749 _obj_mouse_move(void *data,
754 Elm_Widget_Smart_Data *sd = data;
755 Evas_Event_Mouse_Move *ev = event_info;
758 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
759 sd->still_in = EINA_FALSE;
762 Evas_Coord x, y, w, h;
763 evas_object_geometry_get(obj, &x, &y, &w, &h);
764 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
765 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
766 sd->still_in = EINA_FALSE;
772 _obj_mouse_up(void *data,
775 void *event_info __UNUSED__)
777 Elm_Widget_Smart_Data *sd = data;
779 elm_widget_focus_mouse_up_handle(obj);
780 sd->still_in = EINA_FALSE;
784 _propagate_x_drag_lock(Evas_Object *obj,
790 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
793 sd2->child_drag_x_locked += dir;
794 _propagate_x_drag_lock(sd->parent_obj, dir);
800 _propagate_y_drag_lock(Evas_Object *obj,
806 Elm_Widget_Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
809 sd2->child_drag_y_locked += dir;
810 _propagate_y_drag_lock(sd->parent_obj, dir);
816 _propagate_event(void *data,
822 Evas_Callback_Type type = (Evas_Callback_Type)(long)data;
823 Evas_Event_Flags *event_flags = NULL;
827 case EVAS_CALLBACK_KEY_DOWN:
829 Evas_Event_Key_Down *ev = event_info;
830 event_flags = &(ev->event_flags);
834 case EVAS_CALLBACK_KEY_UP:
836 Evas_Event_Key_Up *ev = event_info;
837 event_flags = &(ev->event_flags);
841 case EVAS_CALLBACK_MOUSE_WHEEL:
843 Evas_Event_Mouse_Wheel *ev = event_info;
844 event_flags = &(ev->event_flags);
852 elm_widget_event_propagate(obj, type, event_info, event_flags);
856 * If elm_widget_focus_region_get() returns EINA_FALSE, this function will
857 * ignore region show action.
860 _elm_widget_focus_region_show(const Evas_Object *obj)
862 Evas_Coord x, y, ox, oy, w, h;
867 o = elm_widget_parent_get(obj);
870 if (!elm_widget_focus_region_get(obj, &x, &y, NULL, NULL))
873 evas_object_geometry_get(obj, &ox, &oy, &w, &h);
874 if (w == 0 && h == 0) return;
878 if (_elm_scrollable_is(o))
880 Evas_Coord px, py, pw, ph;
883 evas_object_geometry_get(o, &px, &py, &pw, &ph);
885 if ((px <= ox) && (px + pw) >= (ox + w) &&
886 (py <= oy) && (py + ph) >= (oy + h))
888 // if object is already shown
889 o = elm_widget_parent_get(o);
892 else if ((px < ox) && ((px + pw) < (ox + w)))
894 // if object is over the viewport to the x axis.
897 else if ((py < oy) && ((py + ph) < (oy + h)))
899 // if object is over the viewport to the y axis.
903 ELM_SCROLLABLE_IFACE_GET(o, s_iface);
904 s_iface->content_pos_get(o, &rx, &ry);
905 s_iface->content_viewport_size_get(o, &w, &h);
910 s_iface->content_region_show(o, x, y, w, h);
914 o = elm_widget_parent_get(o);
919 _parent_focus(Evas_Object *obj)
923 if (sd->focused) return;
925 Evas_Object *o = elm_widget_parent_get(obj);
926 sd->focus_order_on_calc = EINA_TRUE;
928 if (o) _parent_focus(o);
930 if (!sd->focus_order_on_calc)
931 return; /* we don't want to override it if by means of any of the
932 callbacks below one gets to calculate our order
936 sd->focus_order = focus_order;
937 if (!sd->api) return;
938 if (sd->top_win_focused)
940 sd->focused = EINA_TRUE;
941 sd->api->on_focus(obj);
943 sd->focus_order_on_calc = EINA_FALSE;
945 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
946 _elm_access_highlight_set(obj);
950 _elm_object_focus_chain_del_cb(void *data,
953 void *event_info __UNUSED__)
955 Elm_Widget_Smart_Data *sd = data;
957 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
960 EAPI const Elm_Widget_Smart_Class *
961 elm_widget_smart_class_get(void)
963 static Elm_Widget_Smart_Class _sc =
964 ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(ELM_WIDGET_SMART_NAME);
965 static const Elm_Widget_Smart_Class *class = NULL;
970 _elm_widget_smart_set(&_sc);
977 elm_widget_add(Evas_Smart *smart,
983 e = evas_object_evas_get(parent);
986 o = evas_object_smart_add(e, smart);
987 elm_widget_parent_set(o, parent);
993 elm_widget_parent_set(Evas_Object *obj,
996 ELM_WIDGET_DATA_GET(obj, sd);
998 if (!sd->api->parent_set) return;
1000 sd->api->parent_set(obj, parent);
1004 elm_widget_api_check(int ver)
1006 if (ver != ELM_INTERNAL_API_VERSION)
1008 CRITICAL("Elementary widget api versions do not match");
1015 elm_widget_access(Evas_Object *obj,
1016 Eina_Bool is_access)
1020 Eina_Bool ret = EINA_TRUE;
1022 API_ENTRY return EINA_FALSE;
1023 EINA_LIST_FOREACH(sd->subobjs, l, child)
1024 ret &= elm_widget_access(child, is_access);
1026 if (sd->api && sd->api->access)
1027 sd->api->access(obj, is_access);
1035 elm_widget_theme(Evas_Object *obj)
1041 Eina_Bool ret = EINA_TRUE;
1043 API_ENTRY return EINA_FALSE;
1045 EINA_LIST_FOREACH(sd->subobjs, l, child)
1046 if (_elm_widget_is(child)) ret &= elm_widget_theme(child);
1047 if (sd->resize_obj && _elm_widget_is(sd->resize_obj))
1048 ret &= elm_widget_theme(sd->resize_obj);
1049 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
1051 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1052 elm_tooltip_theme(tt);
1053 EINA_LIST_FOREACH(sd->cursors, l, cur)
1054 elm_cursor_theme(cur);
1056 if (!sd->api) return EINA_FALSE;
1058 ret &= sd->api->theme(obj);
1064 elm_widget_theme_specific(Evas_Object *obj,
1072 Elm_Theme *th2, *thdef;
1076 thdef = elm_theme_default_get();
1077 if (!th) th = thdef;
1081 if (!th2) th2 = thdef;
1089 if (th2 == thdef) break;
1090 th2 = th2->ref_theme;
1091 if (!th2) th2 = thdef;
1095 EINA_LIST_FOREACH(sd->subobjs, l, child)
1096 elm_widget_theme_specific(child, th, force);
1097 if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
1098 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
1099 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1100 elm_tooltip_theme(tt);
1101 EINA_LIST_FOREACH(sd->cursors, l, cur)
1102 elm_cursor_theme(cur);
1103 if (!sd->api) return;
1104 sd->api->theme(obj);
1108 * Returns the widget's mirrored mode.
1110 * @param obj The widget.
1111 * @return mirrored mode of the object.
1115 elm_widget_mirrored_get(const Evas_Object *obj)
1117 API_ENTRY return EINA_FALSE;
1118 return sd->is_mirrored;
1122 * Sets the widget's mirrored mode.
1124 * @param obj The widget.
1125 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
1128 elm_widget_mirrored_set(Evas_Object *obj,
1133 mirrored = !!mirrored;
1135 if (sd->is_mirrored == mirrored) return;
1137 sd->is_mirrored = mirrored;
1138 elm_widget_theme(obj);
1142 * Returns the widget's mirrored mode setting.
1144 * @param obj The widget.
1145 * @return mirrored mode setting of the object.
1149 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
1151 API_ENTRY return EINA_FALSE;
1152 return sd->mirrored_auto_mode;
1156 * Sets the widget's mirrored mode setting.
1157 * When widget in automatic mode, it follows the system mirrored mode set by
1158 * elm_mirrored_set().
1159 * @param obj The widget.
1160 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
1163 elm_widget_mirrored_automatic_set(Evas_Object *obj,
1164 Eina_Bool automatic)
1167 if (sd->mirrored_auto_mode != automatic)
1169 sd->mirrored_auto_mode = automatic;
1173 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
1179 elm_widget_on_show_region_hook_set(Evas_Object *obj,
1180 void (*func)(void *data,
1186 sd->on_show_region = func;
1187 sd->on_show_region_data = data;
1191 elm_widget_sub_object_add(Evas_Object *obj,
1194 API_ENTRY return EINA_FALSE;
1195 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1197 if (!sd->api) return EINA_FALSE;
1198 return sd->api->sub_object_add(obj, sobj);
1202 elm_widget_sub_object_del(Evas_Object *obj,
1205 API_ENTRY return EINA_FALSE;
1206 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1208 if (!sobj) return EINA_FALSE;
1210 if (!sd->api) return EINA_FALSE;
1211 return sd->api->sub_object_del(obj, sobj);
1214 //SHKWAK : Temp Function for Indicator Issue
1215 // THIS MUST BE REMOVED
1217 EAPI const Eina_List *
1218 elm_widget_sub_object_list_get(const Evas_Object *obj)
1220 API_ENTRY return NULL;
1221 return (const Eina_List *)sd->subobjs;
1227 /* a resize object is a sub object with some more callbacks on it and
1228 * a smart member of the parent
1231 elm_widget_resize_object_set(Evas_Object *obj,
1234 Evas_Object *parent;
1238 if (sd->resize_obj == sobj) return;
1240 // orphan previous resize obj
1243 evas_object_clip_unset(sd->resize_obj);
1244 evas_object_smart_member_del(sd->resize_obj);
1246 if (_elm_widget_is(sd->resize_obj))
1248 if (elm_widget_focus_get(sd->resize_obj)) _parents_unfocus(obj);
1251 elm_widget_sub_object_del(obj, sd->resize_obj);
1254 sd->resize_obj = sobj;
1257 evas_object_event_callback_del_full(obj,
1258 EVAS_CALLBACK_MOUSE_DOWN,
1259 _obj_mouse_down, sd);
1260 evas_object_event_callback_del_full(obj,
1261 EVAS_CALLBACK_MOUSE_MOVE,
1262 _obj_mouse_move, sd);
1263 evas_object_event_callback_del_full(obj,
1264 EVAS_CALLBACK_MOUSE_UP,
1269 // orphan new resize obj
1270 parent = evas_object_data_get(sobj, "elm-parent");
1271 if (parent && parent != obj)
1273 ELM_WIDGET_DATA_GET(parent, sdp);
1275 /* should be there, just being paranoid */
1278 if (sdp->resize_obj == sobj)
1279 elm_widget_resize_object_set(parent, NULL);
1281 elm_widget_sub_object_del(parent, sobj);
1285 elm_widget_sub_object_add(obj, sobj);
1287 evas_object_smart_member_add(sobj, obj);
1289 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1290 _obj_mouse_down, sd);
1291 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
1292 _obj_mouse_move, sd);
1293 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
1295 _smart_reconfigure(sd);
1298 /* WARNING: the programmer is responsible, in the scenario of
1299 * exchanging a hover object, of cleaning the old hover "target"
1303 elm_widget_hover_object_set(Evas_Object *obj,
1309 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1310 _on_sub_obj_del, sd);
1312 sd->hover_obj = sobj;
1315 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1316 _on_sub_obj_del, sd);
1317 _smart_reconfigure(sd);
1322 elm_widget_can_focus_set(Evas_Object *obj,
1323 Eina_Bool can_focus)
1327 can_focus = !!can_focus;
1329 if (sd->can_focus == can_focus) return;
1330 sd->can_focus = can_focus;
1333 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1335 (void *)(long)EVAS_CALLBACK_KEY_DOWN);
1336 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1338 (void *)(long)EVAS_CALLBACK_KEY_UP);
1339 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1341 (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
1345 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1347 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1349 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1355 elm_widget_can_focus_get(const Evas_Object *obj)
1357 API_ENTRY return EINA_FALSE;
1358 return sd->can_focus;
1362 elm_widget_child_can_focus_get(const Evas_Object *obj)
1364 API_ENTRY return EINA_FALSE;
1365 return sd->child_can_focus;
1371 * This API makes the widget object and its children to be unfocusable.
1373 * This API can be helpful for an object to be deleted.
1374 * When an object will be deleted soon, it and its children may not
1375 * want to get focus (by focus reverting or by other focus controls).
1376 * Then, just use this API before deleting.
1378 * @param obj The widget root of sub-tree
1379 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1384 elm_widget_tree_unfocusable_set(Evas_Object *obj,
1385 Eina_Bool tree_unfocusable)
1389 tree_unfocusable = !!tree_unfocusable;
1390 if (sd->tree_unfocusable == tree_unfocusable) return;
1391 sd->tree_unfocusable = tree_unfocusable;
1392 elm_widget_focus_tree_unfocusable_handle(obj);
1398 * This returns true, if the object sub-tree is unfocusable.
1400 * @param obj The widget root of sub-tree
1401 * @return EINA_TRUE if the object sub-tree is unfocusable
1406 elm_widget_tree_unfocusable_get(const Evas_Object *obj)
1408 API_ENTRY return EINA_FALSE;
1409 return sd->tree_unfocusable;
1415 * Get the list of focusable child objects.
1417 * This function retruns list of child objects which can get focus.
1419 * @param obj The parent widget
1420 * @retrun list of focusable child objects.
1425 elm_widget_can_focus_child_list_get(const Evas_Object *obj)
1427 API_ENTRY return NULL;
1430 Eina_List *child_list = NULL;
1435 EINA_LIST_FOREACH(sd->subobjs, l, child)
1437 if ((elm_widget_can_focus_get(child)) &&
1438 (evas_object_visible_get(child)) &&
1439 (!elm_widget_disabled_get(child)))
1440 child_list = eina_list_append(child_list, child);
1441 else if (elm_widget_is(child))
1443 Eina_List *can_focus_list;
1444 can_focus_list = elm_widget_can_focus_child_list_get(child);
1446 child_list = eina_list_merge(child_list, can_focus_list);
1454 elm_widget_highlight_ignore_set(Evas_Object *obj,
1458 sd->highlight_ignore = !!ignore;
1462 elm_widget_highlight_ignore_get(const Evas_Object *obj)
1464 API_ENTRY return EINA_FALSE;
1465 return sd->highlight_ignore;
1469 elm_widget_highlight_in_theme_set(Evas_Object *obj,
1470 Eina_Bool highlight)
1473 sd->highlight_in_theme = !!highlight;
1474 /* FIXME: if focused, it should switch from one mode to the other */
1478 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
1480 API_ENTRY return EINA_FALSE;
1481 return sd->highlight_in_theme;
1485 elm_widget_focus_get(const Evas_Object *obj)
1487 API_ENTRY return EINA_FALSE;
1492 elm_widget_focused_object_get(const Evas_Object *obj)
1494 const Evas_Object *subobj;
1496 API_ENTRY return NULL;
1498 if (!sd->focused) return NULL;
1499 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1501 Evas_Object *fobj = elm_widget_focused_object_get(subobj);
1502 if (fobj) return fobj;
1504 return (Evas_Object *)obj;
1508 elm_widget_top_get(const Evas_Object *obj)
1510 API_ENTRY return NULL;
1511 if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
1512 return (Evas_Object *)obj;
1516 elm_widget_is(const Evas_Object *obj)
1518 return _elm_widget_is(obj);
1522 elm_widget_parent_widget_get(const Evas_Object *obj)
1524 Evas_Object *parent;
1526 if (_elm_widget_is(obj))
1528 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1529 if (!sd) return NULL;
1530 parent = sd->parent_obj;
1534 parent = evas_object_data_get(obj, "elm-parent");
1535 if (!parent) parent = evas_object_smart_parent_get(obj);
1540 Evas_Object *elm_parent;
1541 if (_elm_widget_is(parent)) break;
1542 elm_parent = evas_object_data_get(parent, "elm-parent");
1543 if (elm_parent) parent = elm_parent;
1544 else parent = evas_object_smart_parent_get(parent);
1550 elm_widget_parent2_get(const Evas_Object *obj)
1552 if (_elm_widget_is(obj))
1554 Elm_Widget_Smart_Data *sd = evas_object_smart_data_get(obj);
1555 if (sd) return sd->parent2;
1561 elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent)
1564 sd->parent2 = parent;
1568 elm_widget_event_callback_add(Evas_Object *obj,
1573 EINA_SAFETY_ON_NULL_RETURN(func);
1574 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1577 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1581 elm_widget_event_callback_del(Evas_Object *obj,
1585 API_ENTRY return NULL;
1586 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1588 Elm_Event_Cb_Data *ecd;
1589 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1590 if ((ecd->func == func) && (ecd->data == data))
1593 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1594 return (void *)data;
1600 elm_widget_event_propagate(Evas_Object *obj,
1601 Evas_Callback_Type type,
1603 Evas_Event_Flags *event_flags)
1605 API_ENTRY return EINA_FALSE; //TODO reduce.
1607 if (!_elm_widget_is(obj)) return EINA_FALSE;
1608 Evas_Object *parent = obj;
1609 Elm_Event_Cb_Data *ecd;
1610 Eina_List *l, *l_prev;
1613 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1615 sd = evas_object_smart_data_get(parent);
1616 if ((!sd) || (!_elm_widget_is(obj)))
1617 return EINA_FALSE; //Not Elm Widget
1618 if (!sd->api) return EINA_FALSE;
1620 if (sd->api->event(parent, obj, type, event_info))
1623 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1625 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1626 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1629 parent = sd->parent_obj;
1638 * Set custom focus chain.
1640 * This function i set one new and overwrite any previous custom focus chain
1641 * with the list of objects. The previous list will be deleted and this list
1642 * will be managed. After setted, don't modity it.
1644 * @note On focus cycle, only will be evaluated children of this container.
1646 * @param obj The container widget
1647 * @param objs Chain of objects to pass focus
1651 elm_widget_focus_custom_chain_set(Evas_Object *obj,
1656 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1658 elm_widget_focus_custom_chain_unset(obj);
1663 EINA_LIST_FOREACH(objs, l, o)
1665 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1666 _elm_object_focus_chain_del_cb, sd);
1669 sd->focus_chain = objs;
1675 * Get custom focus chain
1677 * @param obj The container widget
1680 EAPI const Eina_List *
1681 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1683 API_ENTRY return NULL;
1684 return (const Eina_List *)sd->focus_chain;
1690 * Unset custom focus chain
1692 * @param obj The container widget
1696 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1699 Eina_List *l, *l_next;
1702 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1704 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1705 _elm_object_focus_chain_del_cb, sd);
1706 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1713 * Append object to custom focus chain.
1715 * @note If relative_child equal to NULL or not in custom chain, the object
1716 * will be added in end.
1718 * @note On focus cycle, only will be evaluated children of this container.
1720 * @param obj The container widget
1721 * @param child The child to be added in custom chain
1722 * @param relative_child The relative object to position the child
1726 elm_widget_focus_custom_chain_append(Evas_Object *obj,
1728 Evas_Object *relative_child)
1731 EINA_SAFETY_ON_NULL_RETURN(child);
1733 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1735 evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1736 _elm_object_focus_chain_del_cb, sd);
1738 if (!relative_child)
1739 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1741 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1742 child, relative_child);
1748 * Prepend 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 begin.
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_prepend(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_prepend(sd->focus_chain, child);
1776 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1777 child, relative_child);
1783 * Give focus to next object in object tree.
1785 * Give focus to next object in focus chain of one object sub-tree.
1786 * If the last object of chain already have focus, the focus will go to the
1787 * first object of chain.
1789 * @param obj The widget root of sub-tree
1790 * @param dir Direction to cycle the focus
1795 elm_widget_focus_cycle(Evas_Object *obj,
1796 Elm_Focus_Direction dir)
1798 Evas_Object *target = NULL;
1799 if (!_elm_widget_is(obj))
1801 elm_widget_focus_next_get(obj, dir, &target);
1805 if (_elm_config->access_mode && _elm_access_read_mode_get())
1807 _elm_access_highlight_set(target);
1808 _elm_widget_focus_region_show(target);
1810 else elm_widget_focus_steal(target);
1817 * Give focus to near object(in object tree) in one direction.
1819 * Give focus to near object(in object tree) in direction of current
1820 * focused object. If none focusable object in given direction or
1821 * none focused object in object tree, the focus will not change.
1823 * @param obj The reference widget
1824 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
1825 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
1826 * @return EINA_TRUE if focus is moved.
1831 elm_widget_focus_direction_go(Evas_Object *obj,
1834 Evas_Object *target = NULL;
1835 Evas_Object *current_focused = NULL;
1836 double weight = 0.0;
1838 if (!_elm_widget_is(obj)) return EINA_FALSE;
1839 if (!elm_widget_focus_get(obj)) return EINA_FALSE;
1841 current_focused = elm_widget_focused_object_get(obj);
1843 if (elm_widget_focus_direction_get
1844 (obj, current_focused, degree, &target, &weight))
1846 elm_widget_focus_steal(target);
1853 _direction_weight_get(const Evas_Object *obj1,
1854 const Evas_Object *obj2,
1857 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
1858 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
1859 double ax, ay, cx, cy;
1860 double weight = -1.0, g = 0.0;
1862 if (obj1 == obj2) return 0.0;
1865 while (degree >= 360.0)
1867 while (degree < 0.0)
1870 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
1871 cx = obj_x1 + (w1 / 2.0);
1872 cy = obj_y1 + (h1 / 2.0);
1873 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
1875 /* For overlapping cases. */
1876 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
1879 /* Change all points to relative one. */
1889 /* Get crossing points (ax, ay) between obj1 and a line extending
1890 * to the direction of current degree. */
1896 else if (degree == 90.0)
1901 else if (degree == 180.0)
1906 else if (degree == 270.0)
1913 g = tan(degree * (M_PI / 180.0));
1914 if ((degree > 0.0) && (degree < 90.0))
1917 if (ay <= yyy1) ax = xx1;
1924 else if ((degree > 90.0) && (degree < 180.0))
1927 if (ay <= yyy1) ax = x1;
1934 else if ((degree > 180.0) && (degree < 270.0))
1937 if (ay >= yy1) ax = x1;
1947 if (ay >= yy1) ax = xx1;
1956 /* Filter obj2, if it is not in the specific derection. */
1958 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
1959 double t1, t2, u1, v1, u2, v2;
1961 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
1971 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
1976 t1 = (u1 * ax) + (v1 * ay);
1977 t2 = (u2 * ax) + (v2 * ay);
1979 #define _R(x) (int)((x + 0.05) * 10.0)
1981 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
1987 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
1993 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
1999 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
2000 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
2009 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2011 else if (degree == 90.0)
2013 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2015 else if (degree == 180.0)
2017 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2019 else if (degree == 270.0)
2021 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2025 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
2027 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
2030 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
2032 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
2035 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
2038 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
2039 && (_R(ay * yy2) > 0)))
2042 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
2043 (_R((1.0 / g) * yyy2) <= _R(xx2)))
2045 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
2046 && (_R(ay * yyy2) > 0))) return 0.0;
2052 /* Calculate the weight for obj2. */
2055 if (_R(xx1) > _R(x2)) weight = -1.0;
2056 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2057 weight = (x2 - xx1) * (x2 - xx1);
2058 else if (_R(yy2) > 0)
2059 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
2060 else if (_R(yyy2) < 0)
2061 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
2062 else weight = (x2 - xx1) * (x2 - xx1);
2064 else if (degree == 90.0)
2066 if (_R(yyy1) > _R(yy2)) weight = -1.0;
2067 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2068 weight = (yy2 - yyy1) * (yy2 - yyy1);
2069 else if (_R(x2) > 0)
2070 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
2071 else if (_R(xx2) < 0)
2072 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
2073 else weight = (yy2 - yyy1) * (yy2 - yyy1);
2075 else if (degree == 180.0)
2077 if (_R(x1) < _R(xx2)) weight = -1.0;
2078 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2079 weight = (x1 - xx2) * (x1 - xx2);
2080 else if (_R(yy2) > 0)
2081 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
2082 else if (_R(yyy2) < 0)
2083 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
2084 else weight = (x1 - xx2) * (x1 - xx2);
2086 else if (degree == 270.0)
2088 if (_R(yy1) < _R(yyy2)) weight = -1.0;
2089 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2090 weight = (yy1 - yyy2) * (yy1 - yyy2);
2091 else if (_R(x2) > 0)
2092 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
2093 else if (_R(xx2) < 0)
2094 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
2095 else weight = (yy1 - yyy2) * (yy1 - yyy2);
2100 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
2101 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
2102 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
2106 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2107 ((ay - (g * x2)) * (ay - (g * x2)));
2109 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2113 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2114 ((ay - (g * xx2)) * (ay - (g * xx2)));
2116 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2118 sx[j] = (1.0 / g) * yy2;
2121 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2122 ((ay - yy2) * (ay - yy2));
2124 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2127 sx[j] = (1.0 / g) * yyy2;
2130 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2131 ((ay - yyy2) * (ay - yyy2));
2134 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2135 (_R(sy[0]) != _R(sy[1])))))
2139 if (_R(t_weight[k]) == 0) return -1.0;
2140 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2147 double ccx, ccy, t1_weight, x_diff, y_diff;
2148 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2150 x_diff = rx[k] - ccx;
2151 if (x_diff < 0) x_diff *= -1.0;
2152 y_diff = ry[k] - ccy;
2153 if (y_diff < 0) y_diff *= -1.0;
2155 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2156 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2157 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2162 /* Return the current object's weight. */
2163 if (weight == -1.0) return 0.0;
2164 if (_R(weight) == 0) return -1.0;
2168 return 1.0 / weight;
2174 * Get near object in one direction of base object.
2176 * Get near object(in the object sub-tree) in one direction of
2177 * base object. Return the near object by reference.
2178 * By initializing weight, you can filter objects locating far
2179 * from base object. If object is in the specific direction,
2180 * weight is (1/(distance^2)). If object is not exactly in one
2181 * direction, some penalty will be added.
2183 * @param obj The widget root of sub-tree
2184 * @param base The base object of the direction
2185 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2186 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2187 * @param direction The near object in one direction
2188 * @param weight The weight is bigger when the object is located near
2189 * @return EINA_TRUE if near object is updated.
2194 elm_widget_focus_direction_get(const Evas_Object *obj,
2195 const Evas_Object *base,
2197 Evas_Object **direction,
2202 API_ENTRY return EINA_FALSE;
2204 /* -1 means the best was already decided. Don't need any more searching. */
2205 if (!direction || !weight || !base || (obj == base))
2208 /* Ignore if disabled */
2209 if ((!evas_object_visible_get(obj))
2210 || (elm_widget_disabled_get(obj))
2211 || (elm_widget_tree_unfocusable_get(obj)))
2214 if (!sd->api) return EINA_FALSE;
2217 if (_elm_widget_focus_direction_manager_is(obj))
2218 return sd->api->focus_direction(obj, base, degree, direction, weight);
2220 if (!elm_widget_can_focus_get(obj) || elm_widget_focus_get(obj))
2223 c_weight = _direction_weight_get(base, obj, degree);
2224 if ((c_weight == -1.0) ||
2225 ((c_weight != 0.0) && (*weight != -1.0) &&
2226 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2228 if ((int)(*weight * 1000000) == (int)(c_weight * 1000000))
2230 Elm_Widget_Smart_Data *sd1 =
2231 evas_object_smart_data_get(*direction);
2234 if (sd->focus_order <= sd1->focus_order)
2238 *direction = (Evas_Object *)obj;
2248 * Get near object in one direction of base object in list.
2250 * Get near object in one direction of base object in the specific
2251 * object list. Return the near object by reference.
2252 * By initializing weight, you can filter objects locating far
2253 * from base object. If object is in the specific direction,
2254 * weight is (1/(distance^2)). If object is not exactly in one
2255 * direction, some penalty will be added.
2257 * @param obj The widget root of sub-tree
2258 * @param base The base object of the direction
2259 * @param items list with ordered objects
2260 * @param list_data_get function to get the object from one item of list
2261 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2262 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2263 * @param direction The near object in one direction
2264 * @param weight The weight is bigger when the object is located near
2265 * @return EINA_TRUE if near object is updated.
2270 elm_widget_focus_list_direction_get(const Evas_Object *obj,
2271 const Evas_Object *base,
2272 const Eina_List *items,
2273 void *(*list_data_get)(const Eina_List *l),
2275 Evas_Object **direction,
2278 API_ENTRY return EINA_FALSE;
2279 if (!direction || !weight || !base || !items)
2282 const Eina_List *l = items;
2283 Evas_Object *current_best = *direction;
2285 for (; l; l = eina_list_next(l))
2287 Evas_Object *cur = list_data_get(l);
2288 elm_widget_focus_direction_get(cur, base, degree, direction, weight);
2290 if (current_best != *direction)
2299 * Get next object in focus chain of object tree.
2301 * Get next object in focus chain of one object sub-tree.
2302 * Return the next object by reference. If don't have any candidate to receive
2303 * focus before chain end, the first candidate will be returned.
2305 * @param obj The widget root of sub-tree
2306 * @param dir Direction os focus chain
2307 * @param next The next object in focus chain
2308 * @return EINA_TRUE if don't need focus chain restart/loop back
2309 * to use 'next' obj.
2314 elm_widget_focus_next_get(const Evas_Object *obj,
2315 Elm_Focus_Direction dir,
2322 API_ENTRY return EINA_FALSE;
2324 /* Ignore if disabled */
2325 if ((!evas_object_visible_get(obj))
2326 || (elm_widget_disabled_get(obj))
2327 || (elm_widget_tree_unfocusable_get(obj)))
2330 if (!sd->api) return EINA_FALSE;
2333 if (_elm_widget_focus_chain_manager_is(obj))
2334 return sd->api->focus_next(obj, dir, next);
2336 if (!elm_widget_can_focus_get(obj))
2339 /* focusable object but does not have access info */
2340 if (_elm_config->access_mode)
2342 if (!_elm_access_object_get(obj)) return EINA_FALSE;
2346 *next = (Evas_Object *)obj;
2347 return !ELM_WIDGET_FOCUS_GET(obj);
2353 * Get next object in focus chain of object tree in list.
2355 * Get next object in focus chain of one object sub-tree ordered by one list.
2356 * Return the next object by reference. If don't have any candidate to receive
2357 * focus before list end, the first candidate will be returned.
2359 * @param obj The widget root of sub-tree
2360 * @param dir Direction os focus chain
2361 * @param items list with ordered objects
2362 * @param list_data_get function to get the object from one item of list
2363 * @param next The next object in focus chain
2364 * @return EINA_TRUE if don't need focus chain restart/loop back
2365 * to use 'next' obj.
2370 elm_widget_focus_list_next_get(const Evas_Object *obj,
2371 const Eina_List *items,
2372 void *(*list_data_get)(const Eina_List *list),
2373 Elm_Focus_Direction dir,
2376 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2382 if (!_elm_widget_is(obj))
2389 if (dir == ELM_FOCUS_PREVIOUS)
2391 items = eina_list_last(items);
2392 list_next = eina_list_prev;
2394 else if (dir == ELM_FOCUS_NEXT)
2395 list_next = eina_list_next;
2399 const Eina_List *l = items;
2401 /* Recovery last focused sub item */
2402 if (ELM_WIDGET_FOCUS_GET(obj))
2404 for (; l; l = list_next(l))
2406 Evas_Object *cur = list_data_get(l);
2407 if (ELM_WIDGET_FOCUS_GET(cur)) break;
2410 /* Focused object, but no focused sub item */
2414 const Eina_List *start = l;
2415 Evas_Object *to_focus = NULL;
2417 /* Interate sub items */
2418 /* Go to end of list */
2419 for (; l; l = list_next(l))
2421 Evas_Object *tmp = NULL;
2422 Evas_Object *cur = list_data_get(l);
2424 if (elm_widget_parent_get(cur) != obj)
2427 /* Try Focus cycle in subitem */
2428 if (elm_widget_focus_next_get(cur, dir, &tmp))
2433 else if ((tmp) && (!to_focus))
2439 /* Get First possible */
2440 for (; l != start; l = list_next(l))
2442 Evas_Object *tmp = NULL;
2443 Evas_Object *cur = list_data_get(l);
2445 if (elm_widget_parent_get(cur) != obj)
2448 /* Try Focus cycle in subitem */
2449 elm_widget_focus_next_get(cur, dir, &tmp);
2462 elm_widget_highlight_get(const Evas_Object *obj)
2464 API_ENTRY return EINA_FALSE;
2465 return sd->highlighted;
2469 elm_widget_parent_highlight_set(Evas_Object *obj,
2470 Eina_Bool highlighted)
2474 highlighted = !!highlighted;
2476 Evas_Object *o = elm_widget_parent_get(obj);
2478 if (o) elm_widget_parent_highlight_set(o, highlighted);
2480 sd->highlighted = highlighted;
2484 elm_widget_signal_emit(Evas_Object *obj,
2485 const char *emission,
2490 if (evas_object_smart_type_check(obj, "elm_layout"))
2491 elm_layout_signal_emit(obj, emission, source);
2492 else if (evas_object_smart_type_check(obj, "elm_icon"))
2494 WRN("Deprecated function. This functionality on icon objects"
2495 " will be dropped on a next release.");
2496 _elm_icon_signal_emit(obj, emission, source);
2501 elm_widget_signal_callback_add(Evas_Object *obj,
2502 const char *emission,
2504 Edje_Signal_Cb func,
2509 EINA_SAFETY_ON_NULL_RETURN(func);
2511 if (evas_object_smart_type_check(obj, "elm_layout"))
2512 elm_layout_signal_callback_add(obj, emission, source, func, data);
2513 else if (evas_object_smart_type_check(obj, "elm_icon"))
2515 WRN("Deprecated function. This functionality on icon objects"
2516 " will be dropped on a next release.");
2518 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2523 elm_widget_signal_callback_del(Evas_Object *obj,
2524 const char *emission,
2526 Edje_Signal_Cb func)
2530 API_ENTRY return NULL;
2532 if (evas_object_smart_type_check(obj, "elm_layout"))
2533 data = elm_layout_signal_callback_del(obj, emission, source, func);
2534 else if (evas_object_smart_type_check(obj, "elm_icon"))
2536 WRN("Deprecated function. This functionality on icon objects"
2537 " will be dropped on a next release.");
2539 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2546 elm_widget_focus_set(Evas_Object *obj,
2551 if (!sd->api) return;
2556 sd->focus_order = focus_order;
2557 sd->focused = EINA_TRUE;
2558 sd->api->on_focus(obj);
2563 if ((_is_focusable(sd->resize_obj)) &&
2564 (!elm_widget_disabled_get(sd->resize_obj)))
2566 elm_widget_focus_set(sd->resize_obj, first);
2573 EINA_LIST_FOREACH(sd->subobjs, l, child)
2575 if ((_is_focusable(child)) &&
2576 (!elm_widget_disabled_get(child)))
2578 elm_widget_focus_set(child, first);
2589 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2591 if ((_is_focusable(child)) &&
2592 (!elm_widget_disabled_get(child)))
2594 elm_widget_focus_set(child, first);
2600 if ((_is_focusable(sd->resize_obj)) &&
2601 (!elm_widget_disabled_get(sd->resize_obj)))
2603 elm_widget_focus_set(sd->resize_obj, first);
2610 elm_widget_parent_get(const Evas_Object *obj)
2612 API_ENTRY return NULL;
2613 return sd->parent_obj;
2617 elm_widget_focused_object_clear(Evas_Object *obj)
2621 if (!sd->api) return;
2623 if (!sd->focused) return;
2625 // FIXME: evas_object_ref/unref is temporary code to fix logical issue.
2626 // After Eo is applied to elementary, remove these.
2627 evas_object_ref(obj);
2628 if (sd->resize_obj && elm_widget_focus_get(sd->resize_obj))
2629 elm_widget_focused_object_clear(sd->resize_obj);
2634 EINA_LIST_FOREACH(sd->subobjs, l, child)
2636 if (elm_widget_focus_get(child))
2638 elm_widget_focused_object_clear(child);
2643 sd->focused = EINA_FALSE;
2644 sd->api->on_focus(obj);
2645 evas_object_unref(obj);
2649 elm_widget_focus_steal(Evas_Object *obj)
2651 Evas_Object *parent, *parent2, *o;
2654 if (sd->focused) return;
2655 if (sd->disabled) return;
2656 if (!sd->can_focus) return;
2657 if (sd->tree_unfocusable) return;
2661 o = elm_widget_parent_get(parent);
2663 sd = evas_object_smart_data_get(o);
2664 if (sd->disabled || sd->tree_unfocusable) return;
2665 if (sd->focused) break;
2668 if ((!elm_widget_parent_get(parent)) &&
2669 (!elm_widget_parent2_get(parent)))
2670 elm_widget_focused_object_clear(parent);
2673 parent2 = elm_widget_parent_get(parent);
2674 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2676 sd = evas_object_smart_data_get(parent);
2679 if ((sd->resize_obj) && (elm_widget_focus_get(sd->resize_obj)))
2680 elm_widget_focused_object_clear(sd->resize_obj);
2685 EINA_LIST_FOREACH(sd->subobjs, l, child)
2687 if (elm_widget_focus_get(child))
2689 elm_widget_focused_object_clear(child);
2697 _elm_widget_focus_region_show(obj);
2702 elm_widget_focus_restore(Evas_Object *obj)
2704 Evas_Object *newest = NULL;
2705 unsigned int newest_focus_order = 0;
2708 newest = elm_widget_newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2711 elm_object_focus_set(newest, EINA_FALSE);
2712 elm_object_focus_set(newest, EINA_TRUE);
2717 _elm_widget_top_win_focused_set(Evas_Object *obj,
2718 Eina_Bool top_win_focused)
2724 if (sd->top_win_focused == top_win_focused) return;
2726 _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
2727 EINA_LIST_FOREACH(sd->subobjs, l, child)
2729 _elm_widget_top_win_focused_set(child, top_win_focused);
2731 sd->top_win_focused = top_win_focused;
2735 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2737 API_ENTRY return EINA_FALSE;
2738 return sd->top_win_focused;
2742 elm_widget_disabled_set(Evas_Object *obj,
2747 if (sd->disabled == disabled) return;
2748 sd->disabled = !!disabled;
2749 elm_widget_focus_disabled_handle(obj);
2750 if (!sd->api) return;
2751 sd->api->disable(obj);
2755 elm_widget_disabled_get(const Evas_Object *obj)
2758 return sd->disabled;
2762 elm_widget_show_region_set(Evas_Object *obj,
2767 Eina_Bool forceshow)
2769 Evas_Object *parent_obj, *child_obj;
2770 Evas_Coord px, py, cx, cy;
2774 evas_smart_objects_calculate(evas_object_evas_get(obj));
2775 ELM_WIDGET_CHECK_OR_RETURN(obj);
2777 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2778 (w == sd->rw) && (h == sd->rh)) return;
2784 if (sd->on_show_region)
2786 (sd->on_show_region_data, obj);
2790 parent_obj = sd->parent_obj;
2791 child_obj = sd->obj;
2792 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2793 sd = evas_object_smart_data_get(parent_obj);
2796 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2797 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2806 if (sd->on_show_region)
2809 (sd->on_show_region_data, parent_obj);
2816 elm_widget_show_region_get(const Evas_Object *obj,
2832 * Get the focus region of the given widget.
2834 * @return show region or not
2835 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
2837 * The focus region is the area of a widget that should brought into the
2838 * visible area when the widget is focused. Mostly used to show the part of
2839 * an entry where the cursor is, for example. The area returned is relative
2840 * to the object @p obj.
2842 * @param obj The widget object
2843 * @param x Where to store the x coordinate of the area
2844 * @param y Where to store the y coordinate of the area
2845 * @param w Where to store the width of the area
2846 * @param h Where to store the height of the area
2851 elm_widget_focus_region_get(const Evas_Object *obj,
2857 API_ENTRY return EINA_FALSE;
2858 if (!sd->api->on_focus_region(obj, x, y, w, h))
2860 evas_object_geometry_get(obj, NULL, NULL, w, h);
2868 elm_widget_scrollable_children_get(Evas_Object *obj)
2870 Eina_List *l, *ret = NULL;
2873 API_ENTRY return NULL;
2875 EINA_LIST_FOREACH(sd->subobjs, l, child)
2877 if (_elm_scrollable_is(child))
2878 ret = eina_list_append(ret, child);
2885 elm_widget_scroll_hold_push(Evas_Object *obj)
2889 if (sd->scroll_hold == 1)
2891 if (_elm_scrollable_is(obj))
2893 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2894 s_iface->hold_set(obj, EINA_TRUE);
2898 Eina_List *scr_children, *l;
2901 scr_children = elm_widget_scrollable_children_get(obj);
2902 EINA_LIST_FOREACH(scr_children, l, child)
2904 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2905 s_iface->hold_set(child, EINA_TRUE);
2907 eina_list_free(scr_children);
2910 if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
2911 // FIXME: on delete/reparent hold pop
2915 elm_widget_scroll_hold_pop(Evas_Object *obj)
2919 if (!sd->scroll_hold)
2921 if (_elm_scrollable_is(obj))
2923 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2924 s_iface->hold_set(obj, EINA_FALSE);
2928 Eina_List *scr_children, *l;
2931 scr_children = elm_widget_scrollable_children_get(obj);
2932 EINA_LIST_FOREACH(scr_children, l, child)
2934 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2935 s_iface->hold_set(child, EINA_FALSE);
2937 eina_list_free(scr_children);
2940 if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
2941 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2945 elm_widget_scroll_hold_get(const Evas_Object *obj)
2948 return sd->scroll_hold;
2952 elm_widget_scroll_freeze_push(Evas_Object *obj)
2955 sd->scroll_freeze++;
2956 if (sd->scroll_freeze == 1)
2958 if (_elm_scrollable_is(obj))
2960 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2961 s_iface->freeze_set(obj, EINA_TRUE);
2965 Eina_List *scr_children, *l;
2968 scr_children = elm_widget_scrollable_children_get(obj);
2969 EINA_LIST_FOREACH(scr_children, l, child)
2971 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
2972 s_iface->freeze_set(child, EINA_TRUE);
2974 eina_list_free(scr_children);
2977 if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
2978 // FIXME: on delete/reparent freeze pop
2982 elm_widget_scroll_freeze_pop(Evas_Object *obj)
2985 sd->scroll_freeze--;
2986 if (!sd->scroll_freeze)
2988 if (_elm_scrollable_is(obj))
2990 ELM_SCROLLABLE_IFACE_GET(obj, s_iface);
2991 s_iface->freeze_set(obj, EINA_FALSE);
2995 Eina_List *scr_children, *l;
2998 scr_children = elm_widget_scrollable_children_get(obj);
2999 EINA_LIST_FOREACH(scr_children, l, child)
3001 ELM_SCROLLABLE_IFACE_GET(child, s_iface);
3002 s_iface->freeze_set(child, EINA_FALSE);
3004 eina_list_free(scr_children);
3007 if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
3008 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3012 elm_widget_scroll_freeze_get(const Evas_Object *obj)
3015 return sd->scroll_freeze;
3019 elm_widget_scale_set(Evas_Object *obj,
3023 if (scale <= 0.0) scale = 0.0;
3024 if (sd->scale != scale)
3027 elm_widget_theme(obj);
3032 elm_widget_scale_get(const Evas_Object *obj)
3034 API_ENTRY return 1.0;
3035 // FIXME: save walking up the tree by storing/caching parent scale
3036 if (sd->scale == 0.0)
3039 return elm_widget_scale_get(sd->parent_obj);
3047 elm_widget_theme_set(Evas_Object *obj,
3051 if (sd->theme != th)
3053 if (sd->theme) elm_theme_free(sd->theme);
3056 elm_widget_theme(obj);
3061 elm_widget_text_part_set(Evas_Object *obj,
3067 if (evas_object_smart_type_check(obj, "elm_layout"))
3068 elm_layout_text_set(obj, part, label);
3072 elm_widget_text_part_get(const Evas_Object *obj,
3075 API_ENTRY return NULL;
3077 if (evas_object_smart_type_check(obj, "elm_layout"))
3078 return elm_layout_text_get(obj, part);
3084 elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
3091 Elm_Translate_String_Data *ts = NULL;
3094 str = eina_stringshare_add(part);
3095 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3102 eina_stringshare_del(str);
3105 ts = malloc(sizeof(Elm_Translate_String_Data));
3109 ts->domain = eina_stringshare_add(domain);
3110 ts->string = eina_stringshare_add(label);
3111 sd->translate_strings = eina_list_append(sd->translate_strings, ts);
3117 eina_stringshare_replace(&ts->domain, domain);
3118 eina_stringshare_replace(&ts->string, label);
3122 sd->translate_strings = eina_list_remove_list(
3123 sd->translate_strings, l);
3124 eina_stringshare_del(ts->id);
3125 eina_stringshare_del(ts->domain);
3126 eina_stringshare_del(ts->string);
3129 eina_stringshare_del(str);
3133 if (label && label[0])
3134 label = dgettext(domain, label);
3136 elm_widget_text_part_set(obj, part, label);
3140 elm_widget_translatable_text_part_get(const Evas_Object *obj,
3143 const char *str, *ret = NULL;
3145 Elm_Translate_String_Data *ts;
3146 API_ENTRY return NULL;
3148 str = eina_stringshare_add(part);
3149 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3155 eina_stringshare_del(str);
3160 elm_widget_translate(Evas_Object *obj)
3165 Elm_Translate_String_Data *ts;
3170 EINA_LIST_FOREACH(sd->subobjs, l, child)
3171 elm_widget_translate(child);
3172 if (sd->resize_obj) elm_widget_translate(sd->resize_obj);
3173 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3174 if (!sd->api) return;
3175 sd->api->translate(obj);
3178 EINA_LIST_FOREACH(sd->translate_strings, l, ts)
3180 const char *s = dgettext(ts->domain, ts->string);
3181 elm_widget_text_part_set(obj, ts->id, s);
3187 elm_widget_content_part_set(Evas_Object *obj,
3189 Evas_Object *content)
3193 if (!sd->api) return;
3194 if (evas_object_smart_type_check(obj, "elm_container"))
3195 ELM_CONTAINER_CLASS(sd->api)->content_set(obj, part, content);
3199 elm_widget_content_part_get(const Evas_Object *obj,
3202 API_ENTRY return NULL;
3204 if (!sd->api) return NULL;
3206 if (evas_object_smart_type_check(obj, "elm_container"))
3207 return ELM_CONTAINER_CLASS(sd->api)->content_get(obj, part);
3213 elm_widget_content_part_unset(Evas_Object *obj,
3216 API_ENTRY return NULL;
3218 if (!sd->api) return NULL;
3219 if (evas_object_smart_type_check(obj, "elm_container"))
3220 return ELM_CONTAINER_CLASS(sd->api)->content_unset(obj, part);
3226 elm_widget_access_info_set(Evas_Object *obj,
3230 if (sd->access_info) eina_stringshare_del(sd->access_info);
3231 if (!txt) sd->access_info = NULL;
3232 else sd->access_info = eina_stringshare_add(txt);
3236 elm_widget_access_info_get(const Evas_Object *obj)
3238 API_ENTRY return NULL;
3239 return sd->access_info;
3243 elm_widget_theme_get(const Evas_Object *obj)
3245 API_ENTRY return NULL;
3249 return elm_widget_theme_get(sd->parent_obj);
3257 elm_widget_style_set(Evas_Object *obj,
3260 API_ENTRY return EINA_FALSE;
3262 if (eina_stringshare_replace(&sd->style, style))
3263 return elm_widget_theme(obj);
3269 elm_widget_style_get(const Evas_Object *obj)
3271 API_ENTRY return NULL;
3272 if (sd->style) return sd->style;
3277 elm_widget_tooltip_add(Evas_Object *obj,
3281 sd->tooltips = eina_list_append(sd->tooltips, tt);
3285 elm_widget_tooltip_del(Evas_Object *obj,
3289 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3293 elm_widget_cursor_add(Evas_Object *obj,
3297 sd->cursors = eina_list_append(sd->cursors, cur);
3301 elm_widget_cursor_del(Evas_Object *obj,
3305 sd->cursors = eina_list_remove(sd->cursors, cur);
3309 elm_widget_drag_lock_x_set(Evas_Object *obj,
3313 if (sd->drag_x_locked == lock) return;
3314 sd->drag_x_locked = lock;
3315 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
3316 else _propagate_x_drag_lock(obj, -1);
3320 elm_widget_drag_lock_y_set(Evas_Object *obj,
3324 if (sd->drag_y_locked == lock) return;
3325 sd->drag_y_locked = lock;
3326 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
3327 else _propagate_y_drag_lock(obj, -1);
3331 elm_widget_drag_lock_x_get(const Evas_Object *obj)
3333 API_ENTRY return EINA_FALSE;
3334 return sd->drag_x_locked;
3338 elm_widget_drag_lock_y_get(const Evas_Object *obj)
3340 API_ENTRY return EINA_FALSE;
3341 return sd->drag_y_locked;
3345 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
3348 return sd->child_drag_x_locked;
3352 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
3355 return sd->child_drag_y_locked;
3359 elm_widget_theme_object_set(Evas_Object *obj,
3362 const char *welement,
3365 API_ENTRY return EINA_FALSE;
3369 if (!_elm_theme_object_set(obj, edj, wname, welement, wstyle))
3372 if (sd->orient_mode != -1)
3375 snprintf(buf, sizeof(buf), "elm,state,orient,%d", ret);
3376 elm_widget_signal_emit(obj, buf, "elm");
3383 elm_widget_is_check(const Evas_Object *obj)
3385 static int abort_on_warn = -1;
3386 if (elm_widget_is(obj))
3389 ERR("Passing Object: %p.", obj);
3390 if (abort_on_warn == -1)
3392 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3393 else abort_on_warn = 0;
3395 if (abort_on_warn == 1) abort();
3400 elm_widget_type_get(const Evas_Object *obj)
3402 API_ENTRY return NULL;
3404 return evas_object_type_get(obj);
3408 elm_widget_type_check(const Evas_Object *obj,
3412 const char *provided, *expected = "(unknown)";
3413 static int abort_on_warn = -1;
3415 provided = elm_widget_type_get(obj);
3416 /* TODO: eventually migrate to check_ptr version */
3417 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
3418 if (type) expected = type;
3419 if ((!provided) || (!provided[0]))
3421 provided = evas_object_type_get(obj);
3422 if ((!provided) || (!provided[0]))
3423 provided = "(unknown)";
3425 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
3426 " type: '%s'", obj, func, provided, expected);
3427 if (abort_on_warn == -1)
3429 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3430 else abort_on_warn = 0;
3432 if (abort_on_warn == 1) abort();
3436 static Evas_Object *
3437 _widget_name_find(const Evas_Object *obj,
3444 INTERNAL_ENTRY NULL;
3446 if (!_elm_widget_is(obj)) return NULL;
3449 s = evas_object_name_get(sd->resize_obj);
3450 if ((s) && (!strcmp(s, name))) return sd->resize_obj;
3451 if ((recurse != 0) &&
3452 ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
3455 EINA_LIST_FOREACH(sd->subobjs, l, child)
3457 s = evas_object_name_get(child);
3458 if ((s) && (!strcmp(s, name))) return child;
3459 if ((recurse != 0) &&
3460 ((child = _widget_name_find(child, name, recurse - 1))))
3465 s = evas_object_name_get(sd->hover_obj);
3466 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
3467 if ((recurse != 0) &&
3468 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
3475 elm_widget_name_find(const Evas_Object *obj,
3479 API_ENTRY return NULL;
3480 if (!name) return NULL;
3481 return _widget_name_find(obj, name, recurse);
3485 elm_widget_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled)
3487 int orient_mode = -1;
3491 if (disabled && (sd->orient_mode == -1)) return;
3492 if (!disabled && (sd->orient_mode != -1)) return;
3496 //Get current orient mode from it's parent otherwise, 0.
3497 sd->orient_mode = 0;
3498 ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
3499 if (!sd_parent) orient_mode = 0;
3500 else orient_mode = sd_parent->orient_mode;
3502 elm_widget_orientation_set(obj, orient_mode);
3506 elm_widget_orientation_mode_disabled_get(const Evas_Object *obj)
3510 API_ENTRY return EINA_FALSE;
3512 if (sd->orient_mode == -1) ret = EINA_TRUE;
3513 else ret = EINA_FALSE;
3518 elm_widget_orientation_set(Evas_Object *obj, int rotation)
3525 if ((sd->orient_mode == rotation) || (sd->orient_mode == -1)) return;
3527 sd->orient_mode = rotation;
3529 EINA_LIST_FOREACH (sd->subobjs, l, child)
3530 elm_widget_orientation_set(child, rotation);
3535 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
3536 elm_widget_signal_emit(obj, buf, "elm");
3543 * Split string in words
3545 * @param str Source string
3546 * @return List of const words
3548 * @see elm_widget_stringlist_free()
3552 elm_widget_stringlist_get(const char *str)
3554 Eina_List *list = NULL;
3556 if (!str) return NULL;
3557 for (b = s = str; 1; s++)
3559 if ((*s == ' ') || (!*s))
3561 char *t = malloc(s - b + 1);
3564 strncpy(t, b, s - b);
3566 list = eina_list_append(list, eina_stringshare_add(t));
3577 elm_widget_stringlist_free(Eina_List *list)
3580 EINA_LIST_FREE (list, s)
3581 eina_stringshare_del(s);
3585 elm_widget_focus_hide_handle(Evas_Object *obj)
3587 if (!_elm_widget_is(obj))
3589 _if_focused_revert(obj, EINA_TRUE);
3593 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
3595 Evas_Object *o = obj;
3598 if (_elm_widget_is(o)) break;
3599 o = evas_object_smart_parent_get(o);
3603 if (!_is_focusable(o)) return;
3604 elm_widget_focus_steal(o);
3608 elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
3612 //FIXME: Need to check whether the object is unfocusable or not.
3614 if (!elm_widget_parent_get(obj))
3615 elm_widget_focused_object_clear(obj);
3617 _if_focused_revert(obj, EINA_TRUE);
3621 elm_widget_focus_disabled_handle(Evas_Object *obj)
3625 elm_widget_focus_tree_unfocusable_handle(obj);
3629 elm_widget_focus_order_get(const Evas_Object *obj)
3632 return sd->focus_order;
3636 elm_widget_newest_focus_order_get(const Evas_Object *obj,
3637 unsigned int *newest_focus_order,
3638 Eina_Bool can_focus_only)
3641 Evas_Object *child, *ret, *best;
3643 API_ENTRY return NULL;
3645 if (!evas_object_visible_get(obj)
3646 || (elm_widget_disabled_get(obj))
3647 || (elm_widget_tree_unfocusable_get(obj)))
3651 if (*newest_focus_order < sd->focus_order)
3653 *newest_focus_order = sd->focus_order;
3654 best = (Evas_Object *)obj;
3656 EINA_LIST_FOREACH(sd->subobjs, l, child)
3658 ret = elm_widget_newest_focus_order_get
3659 (child, newest_focus_order, can_focus_only);
3665 if ((!best) || (!elm_widget_can_focus_get(best)))
3672 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
3674 Evas_Object *parent;
3680 if (sd->api->activate)
3681 ret = sd->api->activate(obj, act);
3685 parent = elm_widget_parent_get(obj);
3687 elm_widget_activate(parent, act);
3695 * Returns the widget's Evas_Display_Mode
3697 * @param obj The widget.
3698 * @return Evas_Display_Mode of the object.
3700 * @see elm_widget_display_mode_set().
3703 EAPI Evas_Display_Mode
3704 elm_widget_display_mode_get(const Evas_Object *obj)
3706 Evas_Display_Mode new_mode;
3707 Evas_Object *parent;
3709 API_ENTRY return EVAS_DISPLAY_MODE_NONE;
3711 new_mode = evas_object_size_hint_display_mode_get(obj);
3712 parent = elm_widget_parent_get(obj);
3714 if ((new_mode == EVAS_DISPLAY_MODE_INHERIT) && parent)
3715 return elm_widget_display_mode_get(parent);
3723 * Sets the widget and child widget's Evas_Display_Mode.
3725 * @param obj The widget.
3726 * @param dispmode Evas_Display_Mode to set widget's mode.
3728 * Widgets are resized by several reasons.
3729 * Evas_Display_Mode can help for widgets to get one more reason of resize.
3730 * For example, elm conform widget resizes it's contents when keypad state changed.
3731 * After keypad showing, conform widget can change child's Evas_Display_Mode.
3735 elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
3737 Evas_Display_Mode child_mode;
3743 if (elm_widget_display_mode_get(obj) == dispmode) return;
3744 evas_object_size_hint_display_mode_set(obj, dispmode);
3746 //TODO: Need to deal with EVAS_DISPLAY_MODE_INHERIT efficiently.
3747 EINA_LIST_FOREACH (sd->subobjs, l, child)
3749 child_mode = evas_object_size_hint_display_mode_get(child);
3750 if (child_mode != EVAS_DISPLAY_MODE_DONT_CHANGE)
3752 elm_widget_display_mode_set(child, dispmode);
3758 // temporary code. should be removed after eo is applied.
3760 _elm_widget_orient_signal_emit(Evas_Object *obj)
3762 ELM_WIDGET_DATA_GET(obj, sd);
3764 if (sd->orient_mode > 0)
3766 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
3767 elm_widget_signal_emit(obj, buf, "elm");
3774 * Allocate a new Elm_Widget_Item-derived structure.
3776 * The goal of this structure is to provide common ground for actions
3777 * that a widget item have, such as the owner widget, callback to
3778 * notify deletion, data pointer and maybe more.
3780 * @param widget the owner widget that holds this item, must be an elm_widget!
3781 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
3782 * be used to allocate memory.
3784 * @return allocated memory that is already zeroed out, or NULL on errors.
3786 * @see elm_widget_item_new() convenience macro.
3787 * @see elm_widget_item_del() to release memory.
3790 EAPI Elm_Widget_Item *
3791 _elm_widget_item_new(Evas_Object *widget,
3794 if (!_elm_widget_is(widget))
3797 Elm_Widget_Item *item;
3799 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
3800 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
3802 item = calloc(1, alloc_size);
3803 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
3805 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
3806 item->widget = widget;
3811 _elm_widget_item_free(Elm_Widget_Item *item)
3813 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3816 item->del_func((void *)item->data, item->widget, item);
3819 evas_object_del(item->view);
3821 if (item->access_info)
3822 eina_stringshare_del(item->access_info);
3824 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
3831 * Releases widget item memory, calling back del_cb() if it exists.
3833 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
3834 * to memory release. Note that elm_widget_item_pre_notify_del() calls
3835 * this function and then unset it, thus being useful for 2 step
3836 * cleanup whenever the del_cb may use any of the data that must be
3837 * deleted from item.
3839 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
3842 * @param item a valid #Elm_Widget_Item to be deleted.
3843 * @see elm_widget_item_del() convenience macro.
3847 _elm_widget_item_del(Elm_Widget_Item *item)
3849 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3850 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3851 item->on_deletion = EINA_TRUE;
3853 //Widget item delete callback
3854 if (item->del_pre_func)
3855 if (item->del_pre_func((Elm_Object_Item *)item))
3856 _elm_widget_item_free(item);
3862 * Set the function to notify to widgets when item is being deleted by user.
3864 * @param item a valid #Elm_Widget_Item to be notified
3865 * @see elm_widget_item_del_pre_hook_set() convenience macro.
3869 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item,
3870 Elm_Widget_Del_Pre_Cb func)
3872 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3873 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3874 item->del_pre_func = func;
3880 * Notify object will be deleted without actually deleting it.
3882 * This function will callback Elm_Widget_Item::del_cb if it is set
3883 * and then unset it so it is not called twice (ie: from
3884 * elm_widget_item_del()).
3886 * @param item a valid #Elm_Widget_Item to be notified
3887 * @see elm_widget_item_pre_notify_del() convenience macro.
3891 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
3893 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3894 if (!item->del_func) return;
3895 item->del_func((void *)item->data, item->widget, item);
3896 item->del_func = NULL;
3902 * Set the function to notify when item is being deleted.
3904 * This function will complain if there was a callback set already,
3905 * however it will set the new one.
3907 * The callback will be called from elm_widget_item_pre_notify_del()
3908 * or elm_widget_item_del() will be called with:
3909 * - data: the Elm_Widget_Item::data value.
3910 * - obj: the Elm_Widget_Item::widget evas object.
3911 * - event_info: the item being deleted.
3913 * @param item a valid #Elm_Widget_Item to be notified
3914 * @see elm_widget_item_del_cb_set() convenience macro.
3918 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
3921 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3922 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3924 if ((item->del_func) && (item->del_func != func))
3925 WRN("You're replacing a previously set del_cb %p of item %p with %p",
3926 item->del_func, item, func);
3928 item->del_func = func;
3934 * Retrieves owner widget of this item.
3936 * @param item a valid #Elm_Widget_Item to get data from.
3937 * @return owner widget of this item.
3941 _elm_widget_item_widget_get(const Elm_Widget_Item *item)
3943 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3944 return item->widget;
3950 * Set user-data in this item.
3952 * User data may be used to identify this item or just store any
3953 * application data. It is automatically given as the first parameter
3954 * of the deletion notify callback.
3956 * @param item a valid #Elm_Widget_Item to store data in.
3957 * @param data user data to store.
3958 * @see elm_widget_item_del_cb_set() convenience macro.
3962 _elm_widget_item_data_set(Elm_Widget_Item *item,
3965 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3966 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3968 if ((item->data) && (item->data != data))
3969 DBG("Replacing item %p data %p with %p", item, item->data, data);
3976 * Retrieves user-data of this item.
3978 * @param item a valid #Elm_Widget_Item to get data from.
3979 * @see elm_widget_item_data_set()
3983 _elm_widget_item_data_get(const Elm_Widget_Item *item)
3985 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
3986 return (void *)item->data;
3990 _elm_widget_item_disabled_set(Elm_Widget_Item *item,
3993 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
3994 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
3996 if (item->disabled == disabled) return;
3997 item->disabled = !!disabled;
3998 if (item->disable_func) item->disable_func(item);
4002 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
4004 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4005 return item->disabled;
4009 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
4010 Elm_Widget_Disable_Cb func)
4012 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4013 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4015 item->disable_func = func;
4018 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
4020 struct _Elm_Widget_Item_Tooltip
4022 Elm_Widget_Item *item;
4023 Elm_Tooltip_Item_Content_Cb func;
4024 Evas_Smart_Cb del_cb;
4028 static Evas_Object *
4029 _elm_widget_item_tooltip_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_text_set(label, data);
4042 static Evas_Object *
4043 _elm_widget_item_tooltip_trans_label_create(void *data,
4044 Evas_Object *obj __UNUSED__,
4045 Evas_Object *tooltip,
4046 void *item __UNUSED__)
4048 Evas_Object *label = elm_label_add(tooltip);
4051 elm_object_style_set(label, "tooltip");
4052 elm_object_translatable_text_set(label, data);
4057 _elm_widget_item_tooltip_label_del_cb(void *data,
4058 Evas_Object *obj __UNUSED__,
4059 void *event_info __UNUSED__)
4061 eina_stringshare_del(data);
4067 * Set the text to be shown in the widget item.
4069 * @param item Target item
4070 * @param text The text to set in the content
4072 * Setup the text as tooltip to object. The item can have only one tooltip,
4073 * so any previous tooltip data is removed.
4078 _elm_widget_item_tooltip_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_label_create, text,
4088 _elm_widget_item_tooltip_label_del_cb);
4092 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
4095 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4096 EINA_SAFETY_ON_NULL_RETURN(text);
4097 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4099 text = eina_stringshare_add(text);
4100 _elm_widget_item_tooltip_content_cb_set
4101 (item, _elm_widget_item_tooltip_trans_label_create, text,
4102 _elm_widget_item_tooltip_label_del_cb);
4105 static Evas_Object *
4106 _elm_widget_item_tooltip_create(void *data,
4108 Evas_Object *tooltip)
4110 Elm_Widget_Item_Tooltip *wit = data;
4111 return wit->func((void *)wit->data, obj, tooltip, wit->item);
4115 _elm_widget_item_tooltip_del_cb(void *data,
4117 void *event_info __UNUSED__)
4119 Elm_Widget_Item_Tooltip *wit = data;
4120 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
4127 * Set the content to be shown in the tooltip item
4129 * Setup the tooltip to item. The item can have only one tooltip,
4130 * so any previous tooltip data is removed. @p func(with @p data) will
4131 * be called every time that need show the tooltip and it should
4132 * return a valid Evas_Object. This object is then managed fully by
4133 * tooltip system and is deleted when the tooltip is gone.
4135 * @param item the widget item being attached a tooltip.
4136 * @param func the function used to create the tooltip contents.
4137 * @param data what to provide to @a func as callback data/context.
4138 * @param del_cb called when data is not needed anymore, either when
4139 * another callback replaces @func, the tooltip is unset with
4140 * elm_widget_item_tooltip_unset() or the owner @a item
4141 * dies. This callback receives as the first parameter the
4142 * given @a data, and @c event_info is the item.
4147 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
4148 Elm_Tooltip_Item_Content_Cb func,
4150 Evas_Smart_Cb del_cb)
4152 Elm_Widget_Item_Tooltip *wit;
4154 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
4155 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4158 _elm_widget_item_tooltip_unset(item);
4162 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
4163 if (!wit) goto error;
4167 wit->del_cb = del_cb;
4169 elm_object_sub_tooltip_content_cb_set
4170 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
4171 _elm_widget_item_tooltip_del_cb);
4176 if (del_cb) del_cb((void *)data, NULL, item);
4179 if (del_cb) del_cb((void *)data, item->widget, item);
4185 * Unset tooltip from item
4187 * @param item widget item to remove previously set tooltip.
4189 * Remove tooltip from item. The callback provided as del_cb to
4190 * elm_widget_item_tooltip_content_cb_set() will be called to notify
4191 * it is not used anymore.
4193 * @see elm_widget_item_tooltip_content_cb_set()
4198 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
4200 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4201 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4203 elm_object_tooltip_unset(item->view);
4209 * Sets a different style for this item tooltip.
4211 * @note before you set a style you should define a tooltip with
4212 * elm_widget_item_tooltip_content_cb_set() or
4213 * elm_widget_item_tooltip_text_set()
4215 * @param item widget item with tooltip already set.
4216 * @param style the theme style to use (default, transparent, ...)
4221 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
4224 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4225 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4227 elm_object_tooltip_style_set(item->view, style);
4231 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item,
4234 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4235 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
4237 return elm_object_tooltip_window_mode_set(item->view, disable);
4241 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
4243 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4244 return elm_object_tooltip_window_mode_get(item->view);
4250 * Get the style for this item tooltip.
4252 * @param item widget item with tooltip already set.
4253 * @return style the theme style in use, defaults to "default". If the
4254 * object does not have a tooltip set, then NULL is returned.
4259 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
4261 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4262 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4264 return elm_object_tooltip_style_get(item->view);
4268 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
4271 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4272 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4274 elm_object_sub_cursor_set(item->view, item->widget, cursor);
4278 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
4280 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4281 return elm_object_cursor_get(item->view);
4285 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
4287 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4288 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4290 elm_object_cursor_unset(item->view);
4296 * Sets a different style for this item cursor.
4298 * @note before you set a style you should define a cursor with
4299 * elm_widget_item_cursor_set()
4301 * @param item widget item with cursor already set.
4302 * @param style the theme style to use (default, transparent, ...)
4307 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
4310 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4311 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4313 elm_object_cursor_style_set(item->view, style);
4319 * Get the style for this item cursor.
4321 * @param item widget item with cursor already set.
4322 * @return style the theme style in use, defaults to "default". If the
4323 * object does not have a cursor set, then NULL is returned.
4328 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
4330 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4331 return elm_object_cursor_style_get(item->view);
4337 * Set if the cursor set should be searched on the theme or should use
4338 * the provided by the engine, only.
4340 * @note before you set if should look on theme you should define a cursor
4341 * with elm_object_cursor_set(). By default it will only look for cursors
4342 * provided by the engine.
4344 * @param item widget item with cursor already set.
4345 * @param engine_only boolean to define it cursors should be looked only
4346 * between the provided by the engine or searched on widget's theme as well.
4351 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
4352 Eina_Bool engine_only)
4354 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4355 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4357 elm_object_cursor_theme_search_enabled_set(item->view, engine_only);
4363 * Get the cursor engine only usage for this item cursor.
4365 * @param item widget item with cursor already set.
4366 * @return engine_only boolean to define it cursors should be looked only
4367 * between the provided by the engine or searched on widget's theme as well. If
4368 * the object does not have a cursor set, then EINA_FALSE is returned.
4373 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
4375 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4376 return elm_object_cursor_theme_search_enabled_get(item->view);
4380 _elm_widget_item_part_content_set(Elm_Widget_Item *item,
4382 Evas_Object *content)
4384 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4385 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4386 if (!item->content_set_func)
4388 ERR("%s does not support elm_object_item_part_content_set() API.",
4389 elm_widget_type_get(item->widget));
4392 item->content_set_func((Elm_Object_Item *)item, part, content);
4396 _elm_widget_item_part_content_get(const Elm_Widget_Item *item,
4399 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4400 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4402 return item->content_get_func((Elm_Object_Item *)item, part);
4406 _elm_widget_item_part_content_unset(Elm_Widget_Item *item,
4409 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4410 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4411 if (!item->content_unset_func)
4413 ERR("%s does not support elm_object_item_part_content_unset() API.",
4414 elm_widget_type_get(item->widget));
4418 return item->content_unset_func((Elm_Object_Item *)item, part);
4422 _elm_widget_item_part_text_set(Elm_Widget_Item *item,
4426 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4427 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4428 if (!item->text_set_func)
4430 ERR("%s does not support elm_object_item_part_text_set() API.",
4431 elm_widget_type_get(item->widget));
4435 item->text_set_func((Elm_Object_Item *)item, part, label);
4439 _elm_widget_item_part_text_get(const Elm_Widget_Item *item,
4442 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4443 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4444 if (!item->text_get_func)
4446 ERR("%s does not support elm_object_item_part_text_get() API.",
4447 elm_widget_type_get(item->widget));
4451 return item->text_get_func((Elm_Object_Item *)item, part);
4455 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
4456 Elm_Widget_Content_Set_Cb func)
4458 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4459 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4461 item->content_set_func = func;
4465 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
4466 Elm_Widget_Content_Get_Cb func)
4468 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4469 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4471 item->content_get_func = func;
4475 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
4476 Elm_Widget_Content_Unset_Cb func)
4478 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4479 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4481 item->content_unset_func = func;
4485 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
4486 Elm_Widget_Text_Set_Cb func)
4488 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4489 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4491 item->text_set_func = func;
4495 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
4496 Elm_Widget_Text_Get_Cb func)
4498 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4499 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4501 item->text_get_func = func;
4505 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
4506 const char *emission,
4509 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4510 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4512 if (item->signal_emit_func)
4513 item->signal_emit_func((Elm_Object_Item *)item, emission, source);
4517 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
4518 Elm_Widget_Signal_Emit_Cb func)
4520 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4521 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4523 item->signal_emit_func = func;
4527 _elm_widget_item_access_info_set(Elm_Widget_Item *item,
4530 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4531 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4533 if (item->access_info) eina_stringshare_del(item->access_info);
4534 if (!txt) item->access_info = NULL;
4535 else item->access_info = eina_stringshare_add(txt);
4538 /* happy debug functions */
4541 _sub_obj_tree_dump(const Evas_Object *obj,
4546 for (i = 0; i < lvl * 3; i++)
4549 if (_elm_widget_is(obj))
4553 printf("+ %s(%p)\n",
4554 elm_widget_type_get(obj),
4557 _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
4558 EINA_LIST_FOREACH(sd->subobjs, l, obj)
4560 if (obj != sd->resize_obj)
4561 _sub_obj_tree_dump(obj, lvl + 1);
4565 printf("+ %s(%p)\n", evas_object_type_get(obj), obj);
4569 _sub_obj_tree_dot_dump(const Evas_Object *obj,
4572 if (!_elm_widget_is(obj))
4576 Eina_Bool visible = evas_object_visible_get(obj);
4577 Eina_Bool disabled = elm_widget_disabled_get(obj);
4578 Eina_Bool focused = elm_widget_focus_get(obj);
4579 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
4583 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
4586 fprintf(output, ", style=bold");
4589 fprintf(output, ", color=gray28");
4591 fprintf(output, " ];\n");
4594 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
4595 "disabled: %d|focused: %d/%d|focus order:%d}\"",
4596 obj, obj, elm_widget_type_get(obj),
4597 evas_object_name_get(obj), visible, disabled, focused, can_focus,
4601 fprintf(output, ", style=bold");
4604 fprintf(output, ", fontcolor=gray28");
4606 if ((disabled) || (!visible))
4607 fprintf(output, ", color=gray");
4609 fprintf(output, " ];\n");
4613 EINA_LIST_FOREACH(sd->subobjs, l, o)
4614 _sub_obj_tree_dot_dump(o, output);
4620 elm_widget_tree_dump(const Evas_Object *top)
4623 if (!_elm_widget_is(top))
4625 _sub_obj_tree_dump(top, 0);
4633 elm_widget_tree_dot_dump(const Evas_Object *top,
4637 if (!_elm_widget_is(top))
4639 fprintf(output, "graph " " { node [shape=record];\n");
4640 _sub_obj_tree_dot_dump(top, output);
4641 fprintf(output, "}\n");