2 # include "elementary_config.h"
5 #include <Elementary.h>
8 #include "elm_widget_container.h"
9 #include "elm_interface_scrollable.h"
11 #define MY_CLASS ELM_OBJ_WIDGET_CLASS
13 #define MY_CLASS_NAME "Elm_Widget"
14 #define MY_CLASS_NAME_LEGACY "elm_widget"
16 #define ELM_WIDGET_DATA_GET(o, wd) \
17 Elm_Widget_Smart_Data *wd = eo_data_scope_get(o, MY_CLASS)
20 ELM_WIDGET_DATA_GET(obj, sd); \
21 if ((!sd) || (!_elm_widget_is(obj)))
22 #define INTERNAL_ENTRY \
23 ELM_WIDGET_DATA_GET(obj, sd); \
26 #define ELM_WIDGET_FOCUS_GET(obj) \
27 ((_elm_access_auto_highlight_get()) ? (elm_widget_highlight_get(obj)) : \
28 (elm_widget_focus_get(obj)))
30 const char SIG_WIDGET_FOCUSED[] = "focused";
31 const char SIG_WIDGET_UNFOCUSED[] = "unfocused";
32 const char SIG_WIDGET_LANG_CHANGED[] = "language,changed";
33 const char SIG_WIDGET_ACCESS_CHANGED[] = "access,changed";
35 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
36 typedef struct _Elm_Label_Data Elm_Label_Data;
37 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
39 struct _Elm_Event_Cb_Data
45 struct _Elm_Label_Data
51 struct _Elm_Translate_String_Data
55 Eina_Stringshare *domain;
56 Eina_Stringshare *string;
60 /* local subsystem globals */
61 static unsigned int focus_order = 0;
63 static inline Eina_Bool
64 _elm_widget_is(const Evas_Object *obj)
66 return eo_isa(obj, MY_CLASS);
69 static inline Eina_Bool
70 _is_focusable(Evas_Object *obj)
72 API_ENTRY return EINA_FALSE;
73 return sd->can_focus || (sd->child_can_focus);
76 static inline Eina_Bool
77 _elm_scrollable_is(const Evas_Object *obj)
79 INTERNAL_ENTRY EINA_FALSE;
81 eo_isa(obj, ELM_INTERFACE_SCROLLABLE_CLASS);
85 _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it)
90 str = edje_object_data_get(VIEW(it), "focus_highlight");
91 if ((str) && (!strcmp(str, "on")))
92 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
94 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
98 _elm_widget_focus_highlight_start(const Evas_Object *obj)
100 Evas_Object *top = elm_widget_top_get(obj);
102 if (top && eo_isa(top, ELM_OBJ_WIN_CLASS))
103 _elm_win_focus_highlight_start(top);
107 elm_widget_focus_highlight_enabled_get(const Evas_Object *obj)
109 const Evas_Object *win = elm_widget_top_get(obj);
111 if (win && eo_isa(win, ELM_OBJ_WIN_CLASS))
112 return elm_win_focus_highlight_enabled_get(win);
119 * Resets the mirrored mode from the system mirror mode for widgets that are in
120 * automatic mirroring mode. This function does not call elm_widget_theme.
122 * @param obj The widget.
123 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
126 _elm_widget_mirrored_reload(Evas_Object *obj)
129 Eina_Bool mirrored = elm_config_mirrored_get();
131 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
133 sd->is_mirrored = mirrored;
137 EOLIAN static Eina_Bool
138 _elm_widget_on_focus_region(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x EINA_UNUSED, Evas_Coord *y EINA_UNUSED, Evas_Coord *w EINA_UNUSED, Evas_Coord *h EINA_UNUSED)
140 WRN("The %s widget does not implement the \"on_focus_region\" function.",
141 eo_class_name_get(eo_class_get(obj)));
147 _parents_focus(Evas_Object *obj)
149 for (; obj; obj = elm_widget_parent_get(obj))
152 if (sd->focused) return;
158 _parents_unfocus(Evas_Object *obj)
160 for (; obj; obj = elm_widget_parent_get(obj))
163 if (!sd->focused) return;
169 _on_sub_obj_hide(void *data EINA_UNUSED,
172 void *event_info EINA_UNUSED)
174 elm_widget_focus_hide_handle(obj);
178 _on_sub_obj_del(void *data,
181 void *event_info EINA_UNUSED)
183 ELM_WIDGET_DATA_GET(data, sd);
185 if (_elm_widget_is(obj))
187 if (elm_widget_focus_get(obj)) _parents_unfocus(sd->obj);
189 if (obj == sd->resize_obj)
191 /* already dels sub object */
192 elm_widget_resize_object_set(sd->obj, NULL, EINA_TRUE);
195 else if (obj == sd->hover_obj)
197 sd->hover_obj = NULL;
202 if (!elm_widget_sub_object_del(sd->obj, obj))
203 ERR("failed to remove sub object %p from %p\n", obj, sd->obj);
207 static const Evas_Smart_Cb_Description _smart_callbacks[] =
209 /* FIXME: complete later */
214 _obj_mouse_down(void *data,
216 Evas_Object *obj EINA_UNUSED,
219 ELM_WIDGET_DATA_GET(data, sd);
220 Evas_Event_Mouse_Down *ev = event_info;
221 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
222 sd->still_in = EINA_TRUE;
226 _obj_mouse_move(void *data,
231 ELM_WIDGET_DATA_GET(data, sd);
232 Evas_Event_Mouse_Move *ev = event_info;
233 if (!sd->still_in) return;
235 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
236 sd->still_in = EINA_FALSE;
239 Evas_Coord x, y, w, h;
240 evas_object_geometry_get(obj, &x, &y, &w, &h);
241 if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y))
242 sd->still_in = EINA_FALSE;
247 _obj_mouse_up(void *data,
250 void *event_info EINA_UNUSED)
252 ELM_WIDGET_DATA_GET(data, sd);
254 (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
255 elm_widget_focus_mouse_up_handle(obj);
257 sd->still_in = EINA_FALSE;
261 _obj_mouse_in(void *data EINA_UNUSED,
264 void *event_info EINA_UNUSED)
266 if (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
267 elm_widget_focus_mouse_up_handle(obj);
271 _elm_widget_evas_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
275 priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale
277 elm_widget_can_focus_set(obj, EINA_TRUE);
278 priv->is_mirrored = elm_config_mirrored_get();
280 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
281 _obj_mouse_down, obj);
282 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
283 _obj_mouse_move, obj);
284 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
286 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_IN,
288 /* just a helper for inheriting classes */
289 if (priv->resize_obj)
291 Evas_Object *r_obj = priv->resize_obj;
292 priv->resize_obj = NULL;
294 elm_widget_resize_object_set(obj, r_obj, EINA_TRUE);
299 _if_focused_revert(Evas_Object *obj,
300 Eina_Bool can_focus_only)
303 Evas_Object *newest = NULL;
304 unsigned int newest_focus_order = 0;
308 if (!sd->focused) return;
309 if (!sd->parent_obj) return;
311 top = elm_widget_top_get(sd->parent_obj);
314 newest = elm_widget_newest_focus_order_get
315 (top, &newest_focus_order, can_focus_only);
318 elm_object_focus_set(newest, EINA_FALSE);
319 elm_object_focus_set(newest, EINA_TRUE);
325 _elm_widget_evas_smart_del(Eo *obj, Elm_Widget_Smart_Data *sd)
328 Elm_Translate_String_Data *ts;
329 Elm_Event_Cb_Data *ecb;
333 /* detach it from us */
334 evas_object_event_callback_del_full
335 (sd->hover_obj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj);
336 sd->hover_obj = NULL;
341 sobj = eina_list_data_get(sd->subobjs);
343 /* let the objects clean-up themselves and get rid of this list */
344 if (!elm_widget_sub_object_del(obj, sobj))
346 ERR("failed to remove sub object %p from %p\n", sobj, obj);
347 sd->subobjs = eina_list_remove_list
348 (sd->subobjs, sd->subobjs);
350 evas_object_del(sobj);
352 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
353 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
354 while (sd->translate_strings)
356 ts = EINA_INLIST_CONTAINER_GET(sd->translate_strings,
357 Elm_Translate_String_Data);
358 eina_stringshare_del(ts->id);
359 eina_stringshare_del(ts->domain);
360 eina_stringshare_del(ts->string);
361 sd->translate_strings = eina_inlist_remove(sd->translate_strings,
362 sd->translate_strings);
366 EINA_LIST_FREE(sd->event_cb, ecb)
369 eina_stringshare_del(sd->style);
370 if (sd->theme) elm_theme_free(sd->theme);
371 _if_focused_revert(obj, EINA_TRUE);
372 elm_widget_focus_custom_chain_unset(obj);
373 eina_stringshare_del(sd->access_info);
374 evas_object_smart_data_set(obj, NULL);
378 _smart_reconfigure(Elm_Widget_Smart_Data *sd)
382 evas_object_move(sd->resize_obj, sd->x, sd->y);
383 evas_object_resize(sd->resize_obj, sd->w, sd->h);
387 evas_object_move(sd->hover_obj, sd->x, sd->y);
388 evas_object_resize(sd->hover_obj, sd->w, sd->h);
393 _elm_widget_evas_smart_move(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord x, Evas_Coord y)
398 _smart_reconfigure(sd);
402 _elm_widget_evas_smart_resize(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord w, Evas_Coord h)
407 _smart_reconfigure(sd);
411 _elm_widget_evas_smart_show(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
416 it = evas_object_smart_iterator_new(obj);
417 EINA_ITERATOR_FOREACH(it, o)
419 if (evas_object_data_get(o, "_elm_leaveme")) continue;
422 eina_iterator_free(it);
426 _elm_widget_evas_smart_hide(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
431 it = evas_object_smart_iterator_new(obj);
432 EINA_ITERATOR_FOREACH(it, o)
434 if (evas_object_data_get(o, "_elm_leaveme")) continue;
437 eina_iterator_free(it);
441 _elm_widget_evas_smart_color_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, int r, int g, int b, int a)
446 it = evas_object_smart_iterator_new(obj);
447 EINA_ITERATOR_FOREACH(it, o)
449 if (evas_object_data_get(o, "_elm_leaveme")) continue;
450 evas_object_color_set(o, r, g, b, a);
452 eina_iterator_free(it);
456 _elm_widget_evas_smart_clip_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *clip)
461 it = evas_object_smart_iterator_new(obj);
462 EINA_ITERATOR_FOREACH(it, o)
464 if (evas_object_data_get(o, "_elm_leaveme")) continue;
465 evas_object_clip_set(o, clip);
467 eina_iterator_free(it);
471 _elm_widget_evas_smart_clip_unset(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
476 it = evas_object_smart_iterator_new(obj);
477 EINA_ITERATOR_FOREACH(it, o)
479 if (evas_object_data_get(o, "_elm_leaveme")) continue;
480 evas_object_clip_unset(o);
482 eina_iterator_free(it);
486 _elm_widget_evas_smart_calculate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
488 /* a NO-OP, on the base */
492 _elm_widget_evas_smart_member_add(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *child)
495 eo_do_super(obj, MY_CLASS, evas_obj_smart_member_add(child));
497 if (evas_object_data_get(child, "_elm_leaveme")) return;
499 evas_object_color_get(obj, &r, &g, &b, &a);
500 evas_object_color_set(child, r, g, b, a);
502 evas_object_clip_set(child, evas_object_clip_get(obj));
504 if (evas_object_visible_get(obj))
505 evas_object_show(child);
507 evas_object_hide(child);
511 _elm_widget_evas_smart_member_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *child)
513 if (!evas_object_data_get(child, "_elm_leaveme"))
514 evas_object_clip_unset(child);
515 eo_do_super(obj, MY_CLASS, evas_obj_smart_member_del(child));
522 * Check if the widget has its own focus next function.
524 * @param obj The widget.
525 * @return focus next function is implemented/unimplemented.
526 * (@c EINA_TRUE = implemented/@c EINA_FALSE = unimplemented.)
528 static inline Eina_Bool
529 _elm_widget_focus_chain_manager_is(const Evas_Object *obj)
531 ELM_WIDGET_CHECK(obj) EINA_FALSE;
533 Eina_Bool manager_is = EINA_FALSE;
534 eo_do((Eo *)obj, elm_obj_widget_focus_next_manager_is(&manager_is));
538 static inline Eina_Bool
539 _internal_elm_widget_focus_direction_manager_is(const Evas_Object *obj)
541 ELM_WIDGET_CHECK(obj) EINA_FALSE;
543 Eina_Bool manager_is = EINA_FALSE;
544 eo_do((Eo *)obj, elm_obj_widget_focus_direction_manager_is(&manager_is));
549 _propagate_x_drag_lock(Evas_Object *obj,
555 ELM_WIDGET_DATA_GET(sd->parent_obj, sd2);
558 sd2->child_drag_x_locked += dir;
559 _propagate_x_drag_lock(sd->parent_obj, dir);
565 _propagate_y_drag_lock(Evas_Object *obj,
571 ELM_WIDGET_DATA_GET(sd->parent_obj, sd2);
574 sd2->child_drag_y_locked += dir;
575 _propagate_y_drag_lock(sd->parent_obj, dir);
581 _propagate_event(void *data,
587 Evas_Callback_Type type = (Evas_Callback_Type)(uintptr_t)data;
588 Evas_Event_Flags *event_flags = NULL;
592 case EVAS_CALLBACK_KEY_DOWN:
594 Evas_Event_Key_Down *ev = event_info;
595 event_flags = &(ev->event_flags);
599 case EVAS_CALLBACK_KEY_UP:
601 Evas_Event_Key_Up *ev = event_info;
602 event_flags = &(ev->event_flags);
606 case EVAS_CALLBACK_MOUSE_WHEEL:
608 Evas_Event_Mouse_Wheel *ev = event_info;
609 event_flags = &(ev->event_flags);
617 elm_widget_event_propagate(obj, type, event_info, event_flags);
623 * If elm_widget_focus_region_get() returns EINA_FALSE, this function will
624 * ignore region show action.
627 _elm_widget_focus_region_show(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
629 Evas_Coord x, y, w, h, ox, oy;
632 o = elm_widget_parent_get(obj);
635 if (!elm_widget_focus_region_get(obj, &x, &y, &w, &h))
638 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
644 if (_elm_scrollable_is(o) && !elm_widget_disabled_get(o))
646 eo_do(o, elm_interface_scrollable_content_region_show(x, y, w, h));
648 if (!elm_widget_focus_region_get(o, &x, &y, &w, &h))
650 o = elm_widget_parent_get(o);
656 evas_object_geometry_get(o, &px, &py, NULL, NULL);
662 o = elm_widget_parent_get(o);
666 EOLIAN static Eina_Bool
667 _elm_widget_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *style)
669 if (eina_stringshare_replace(&sd->focus_highlight_style, style)) return EINA_TRUE;
673 EOLIAN static const char*
674 _elm_widget_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
676 return sd->focus_highlight_style;
680 _parent_focus(Evas_Object *obj)
684 if (sd->focused) return;
686 Evas_Object *o = elm_widget_parent_get(obj);
687 sd->focus_order_on_calc = EINA_TRUE;
689 if (o) _parent_focus(o);
691 if (!sd->focus_order_on_calc)
692 return; /* we don't want to override it if by means of any of the
693 callbacks below one gets to calculate our order
697 sd->focus_order = focus_order;
699 if (sd->top_win_focused)
701 sd->focused = EINA_TRUE;
702 eo_do(obj, elm_obj_widget_on_focus(NULL));
703 elm_widget_focus_region_show(obj);
705 sd->focus_order_on_calc = EINA_FALSE;
707 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
708 _elm_access_highlight_set(obj);
712 _elm_object_focus_chain_del_cb(void *data,
715 void *event_info EINA_UNUSED)
717 ELM_WIDGET_DATA_GET(data, sd);
719 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
723 _elm_widget_parent_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED)
728 elm_widget_api_check(int ver)
730 if (ver != ELM_INTERNAL_API_VERSION)
732 CRI("Elementary widget api versions do not match");
739 elm_widget_access(Evas_Object *obj,
744 Eina_Bool ret = EINA_TRUE;
746 API_ENTRY return EINA_FALSE;
747 EINA_LIST_FOREACH(sd->subobjs, l, child)
749 if (elm_widget_is(child))
750 ret &= elm_widget_access(child, is_access);
753 eo_do(obj, elm_obj_widget_access(is_access));
754 evas_object_smart_callback_call(obj, SIG_WIDGET_ACCESS_CHANGED, NULL);
760 _elm_widget_access(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool is_access EINA_UNUSED)
765 elm_widget_theme(Evas_Object *obj)
771 Eina_Bool ret = EINA_TRUE;
773 API_ENTRY return EINA_FALSE;
775 EINA_LIST_FOREACH(sd->subobjs, l, child)
776 if (_elm_widget_is(child))
777 ret &= elm_widget_theme(child);
779 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
781 EINA_LIST_FOREACH(sd->tooltips, l, tt)
782 elm_tooltip_theme(tt);
783 EINA_LIST_FOREACH(sd->cursors, l, cur)
784 elm_cursor_theme(cur);
787 eo_do(obj, elm_obj_widget_theme_apply(&ret2));
794 elm_widget_theme_specific(Evas_Object *obj,
802 Elm_Theme *th2, *thdef;
806 thdef = elm_theme_default_get();
811 if (!th2) th2 = thdef;
819 if (th2 == thdef) break;
820 th2 = th2->ref_theme;
821 if (!th2) th2 = thdef;
825 EINA_LIST_FOREACH(sd->subobjs, l, child)
827 if (elm_widget_is(child))
828 elm_widget_theme_specific(child, th, force);
830 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
831 EINA_LIST_FOREACH(sd->tooltips, l, tt)
832 elm_tooltip_theme(tt);
833 EINA_LIST_FOREACH(sd->cursors, l, cur)
834 elm_cursor_theme(cur);
835 eo_do(obj, elm_obj_widget_theme_apply(NULL));
838 EOLIAN static Eina_Bool
839 _elm_widget_theme_apply(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
841 _elm_widget_mirrored_reload(obj);
843 elm_widget_disabled_set(obj, elm_widget_disabled_get(obj));
851 * Returns the widget's mirrored mode.
853 * @param obj The widget.
854 * @return mirrored mode of the object.
857 EOLIAN static Eina_Bool
858 _elm_widget_mirrored_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
860 return sd->is_mirrored;
866 * Sets the widget's mirrored mode.
868 * @param obj The widget.
869 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
872 _elm_widget_mirrored_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool mirrored)
874 mirrored = !!mirrored;
876 if (sd->is_mirrored == mirrored) return;
878 sd->is_mirrored = mirrored;
879 elm_widget_theme(obj);
883 * Returns the widget's mirrored mode setting.
885 * @param obj The widget.
886 * @return mirrored mode setting of the object.
889 EOLIAN static Eina_Bool
890 _elm_widget_mirrored_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
892 return sd->mirrored_auto_mode;
898 * Sets the widget's mirrored mode setting.
899 * When widget in automatic mode, it follows the system mirrored mode set by
900 * elm_mirrored_set().
901 * @param obj The widget.
902 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
905 _elm_widget_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic)
907 if (sd->mirrored_auto_mode != automatic)
909 sd->mirrored_auto_mode = automatic;
913 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
919 _elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, region_hook_func_type func, void *data)
921 sd->on_show_region = func;
922 sd->on_show_region_data = data;
928 * Add myself as a sub object of parent object
930 * @see elm_widget_sub_object_add()
933 elm_widget_sub_object_parent_add(Evas_Object *sobj)
935 Eina_Bool ret = EINA_FALSE;
938 eo_do(sobj, eo_parent_get(&parent));
939 eo_do(parent, elm_obj_widget_sub_object_add(sobj, &ret));
947 * Add sobj to obj's sub object.
949 * What does elementary sub object mean? This is unique in elementary, it
950 * handles overall elementary policies between parent and sub objects.
951 * focus, access, deletion, theme, scale, mirror, scrollable child get,
952 * translate, name find, display mode set, orientation set, tree dump
955 * @see elm_widget_sub_object_parent_add()
957 EOLIAN static Eina_Bool
958 _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
960 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
962 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
964 if (sobj == sd->parent_obj)
966 /* in this case, sobj must be an elm widget, or something
967 * very wrong is happening */
968 if (!_elm_widget_is(sobj)) return EINA_FALSE;
970 if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
971 WRN("You passed a parent object of obj = %p as the sub object = %p!",
975 if (_elm_widget_is(sobj))
977 ELM_WIDGET_DATA_GET(sobj, sdc);
979 if (sdc->parent_obj == obj) goto end;
982 if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
985 sdc->parent_obj = obj;
986 sdc->orient_mode = sd->orient_mode;
987 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
989 /* update child focusable-ness on self and parents, now that a
990 * focusable child got in */
991 if (!sd->child_can_focus && (_is_focusable(sobj)))
993 Elm_Widget_Smart_Data *sdp = sd;
995 sdp->child_can_focus = EINA_TRUE;
996 while (sdp->parent_obj)
998 sdp = eo_data_scope_get(sdp->parent_obj, MY_CLASS);
1000 if (sdp->child_can_focus) break;
1002 sdp->child_can_focus = EINA_TRUE;
1008 void *data = evas_object_data_get(sobj, "elm-parent");
1012 if (data == obj) goto end;
1013 if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
1016 sd->subobjs = eina_list_append(sd->subobjs, sobj);
1017 evas_object_data_set(sobj, "elm-parent", obj);
1018 evas_object_event_callback_add
1019 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj);
1020 if (_elm_widget_is(sobj))
1022 ELM_WIDGET_DATA_GET(sobj, sdc);
1024 /* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
1025 * Due to elementary's scale policy, scale and pscale can be different in
1026 * some cases. This happens when sobj's previous parent and new parent have
1027 * different scale value.
1028 * For example, if sobj's previous parent's scale is 5 and new parent's scale
1029 * is 2 while sobj's scale is 0. Then 'pscale' is 5 and 'scale' is 2. So we
1030 * need to reset sobj's scale to 5.
1031 * Note that each widget's scale is 0 by default.
1033 double scale, pscale = elm_widget_scale_get(sobj);
1034 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
1036 evas_object_event_callback_add
1037 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, NULL);
1039 scale = elm_widget_scale_get(sobj);
1040 th = elm_widget_theme_get(sobj);
1041 mirrored = elm_widget_mirrored_get(sobj);
1043 if (!sdc->on_create)
1045 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
1046 elm_widget_theme(sobj);
1049 if (elm_widget_focus_get(sobj)) _parents_focus(obj);
1051 elm_widget_display_mode_set(sobj,
1052 evas_object_size_hint_display_mode_get(obj));
1059 EOLIAN static Eina_Bool
1060 _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1062 Evas_Object *sobj_parent;
1064 if (!sobj) return EINA_FALSE;
1066 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1068 sobj_parent = evas_object_data_del(sobj, "elm-parent");
1069 if (sobj_parent != obj)
1071 static int abort_on_warn = -1;
1073 ERR("removing sub object %p (%s) from parent %p (%s), "
1074 "but elm-parent is different %p (%s)!",
1075 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
1076 sobj_parent, elm_widget_type_get(sobj_parent));
1078 if (EINA_UNLIKELY(abort_on_warn == -1))
1080 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
1081 else abort_on_warn = 0;
1083 if (abort_on_warn == 1) abort();
1088 if (_elm_widget_is(sobj))
1090 if (elm_widget_focus_get(sobj))
1092 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1093 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1095 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1097 Evas_Object *parent = obj;
1099 /* update child focusable-ness on self and parents, now that a
1100 * focusable child is gone */
1104 Evas_Object *subobj;
1106 ELM_WIDGET_DATA_GET(parent, sdp);
1108 sdp->child_can_focus = EINA_FALSE;
1109 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1111 if ((subobj != sobj) && (_is_focusable(subobj)))
1113 sdp->child_can_focus = EINA_TRUE;
1118 /* break again, child_can_focus went back to
1120 if (sdp->child_can_focus) break;
1121 parent = sdp->parent_obj;
1125 ELM_WIDGET_DATA_GET(sobj, sdc);
1126 sdc->parent_obj = NULL;
1129 if (sd->resize_obj == sobj) sd->resize_obj = NULL;
1131 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1133 evas_object_event_callback_del_full
1134 (sobj, EVAS_CALLBACK_DEL, _on_sub_obj_del, obj);
1135 if (_elm_widget_is(sobj))
1136 evas_object_event_callback_del_full
1137 (sobj, EVAS_CALLBACK_HIDE, _on_sub_obj_hide, NULL);
1145 * a resize object is added to and deleted from the smart member and the sub object
1146 * of the parent if the third argument, Eina_Bool sub_obj, is set as EINA_TRUE.
1149 _elm_widget_resize_object_set(Eo *obj, Elm_Widget_Smart_Data *sd,
1153 Evas_Object *parent;
1155 if (sd->resize_obj == sobj) return;
1157 // orphan previous resize obj
1158 if (sd->resize_obj && sub_obj)
1160 evas_object_clip_unset(sd->resize_obj);
1161 evas_object_smart_member_del(sd->resize_obj);
1163 if (_elm_widget_is(sd->resize_obj))
1165 if (elm_widget_focus_get(sd->resize_obj)) _parents_unfocus(obj);
1167 elm_widget_sub_object_del(obj, sd->resize_obj);
1170 sd->resize_obj = sobj;
1173 // orphan new resize obj
1174 parent = evas_object_data_get(sobj, "elm-parent");
1175 if (parent && parent != obj)
1177 ELM_WIDGET_DATA_GET(parent, sdp);
1179 /* should be there, just being paranoid */
1182 if (sdp->resize_obj == sobj)
1183 elm_widget_resize_object_set(parent, NULL, sub_obj);
1185 elm_widget_sub_object_del(parent, sobj);
1190 elm_widget_sub_object_add(obj, sobj);
1191 evas_object_smart_member_add(sobj, obj);
1194 _smart_reconfigure(sd);
1200 * WARNING: the programmer is responsible, in the scenario of
1201 * exchanging a hover object, of cleaning the old hover "target"
1205 _elm_widget_hover_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1209 evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
1210 _on_sub_obj_del, obj);
1212 sd->hover_obj = sobj;
1215 evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
1216 _on_sub_obj_del, obj);
1217 _smart_reconfigure(sd);
1222 _elm_widget_can_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can_focus)
1224 can_focus = !!can_focus;
1226 if (sd->can_focus == can_focus) return;
1227 sd->can_focus = can_focus;
1230 /* update child_can_focus of parents */
1231 Evas_Object *o = obj;
1235 o = elm_widget_parent_get(o);
1237 sd = eo_data_scope_get(o, MY_CLASS);
1238 if (!sd || sd->child_can_focus) break;
1239 sd->child_can_focus = EINA_TRUE;
1242 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
1244 (void *)(uintptr_t)EVAS_CALLBACK_KEY_DOWN);
1245 evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
1247 (void *)(uintptr_t)EVAS_CALLBACK_KEY_UP);
1248 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1250 (void *)(uintptr_t)EVAS_CALLBACK_MOUSE_WHEEL);
1254 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
1256 evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
1258 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
1263 EOLIAN static Eina_Bool
1264 _elm_widget_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1266 return sd->can_focus;
1269 EOLIAN static Eina_Bool
1270 _elm_widget_child_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1272 return sd->child_can_focus;
1278 * This API makes the widget object and its children to be unfocusable.
1280 * This API can be helpful for an object to be deleted.
1281 * When an object will be deleted soon, it and its children may not
1282 * want to get focus (by focus reverting or by other focus controls).
1283 * Then, just use this API before deleting.
1285 * @param obj The widget root of sub-tree
1286 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1291 _elm_widget_tree_unfocusable_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool tree_unfocusable)
1293 tree_unfocusable = !!tree_unfocusable;
1294 if (sd->tree_unfocusable == tree_unfocusable) return;
1295 sd->tree_unfocusable = tree_unfocusable;
1296 elm_widget_focus_tree_unfocusable_handle(obj);
1302 * This returns true, if the object sub-tree is unfocusable.
1304 * @param obj The widget root of sub-tree
1305 * @return EINA_TRUE if the object sub-tree is unfocusable
1309 EOLIAN static Eina_Bool
1310 _elm_widget_tree_unfocusable_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1312 return sd->tree_unfocusable;
1318 * Get the list of focusable child objects.
1320 * This function retruns list of child objects which can get focus.
1322 * @param obj The parent widget
1323 * @retrun list of focusable child objects.
1327 EOLIAN static Eina_List*
1328 _elm_widget_can_focus_child_list_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1331 Eina_List *child_list = NULL;
1334 EINA_LIST_FOREACH(sd->subobjs, l, child)
1336 if (!_elm_widget_is(child)) continue;
1337 if ((elm_widget_can_focus_get(child)) &&
1338 (evas_object_visible_get(child)) &&
1339 (!elm_widget_disabled_get(child)))
1340 child_list = eina_list_append(child_list, child);
1343 Eina_List *can_focus_list;
1344 can_focus_list = elm_widget_can_focus_child_list_get(child);
1346 child_list = eina_list_merge(child_list, can_focus_list);
1354 _elm_widget_highlight_ignore_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool ignore)
1356 sd->highlight_ignore = !!ignore;
1359 EOLIAN static Eina_Bool
1360 _elm_widget_highlight_ignore_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1362 return sd->highlight_ignore;
1366 _elm_widget_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1368 sd->highlight_in_theme = !!highlight;
1369 /* FIXME: if focused, it should switch from one mode to the other */
1372 EOLIAN static Eina_Bool
1373 _elm_widget_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1375 return sd->highlight_in_theme;
1379 _elm_widget_access_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1381 sd->access_highlight_in_theme = !!highlight;
1384 EOLIAN static Eina_Bool
1385 _elm_widget_access_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1387 return sd->access_highlight_in_theme;
1390 EOLIAN static Eina_Bool
1391 _elm_widget_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1396 EOLIAN static Eina_Bool
1397 _elm_widget_highlight_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1399 return sd->highlighted;
1402 EOLIAN static Evas_Object*
1403 _elm_widget_focused_object_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1405 const Evas_Object *subobj;
1408 if (!sd->focused) return NULL;
1409 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1412 if (!_elm_widget_is(subobj)) continue;
1413 fobj = elm_widget_focused_object_get(subobj);
1414 if (fobj) return fobj;
1416 return (Evas_Object *)obj;
1419 EOLIAN static Evas_Object*
1420 _elm_widget_top_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1424 Evas_Object *int_ret = NULL;
1425 eo_do((Eo *) sd->parent_obj, elm_obj_widget_top_get(&int_ret));
1428 return (Evas_Object *)obj;
1432 elm_widget_is(const Evas_Object *obj)
1434 return _elm_widget_is(obj);
1438 elm_widget_parent_widget_get(const Evas_Object *obj)
1440 Evas_Object *parent;
1442 if (_elm_widget_is(obj))
1444 ELM_WIDGET_DATA_GET(obj, sd);
1445 if (!sd) return NULL;
1446 parent = sd->parent_obj;
1450 parent = evas_object_data_get(obj, "elm-parent");
1451 if (!parent) parent = evas_object_smart_parent_get(obj);
1456 Evas_Object *elm_parent;
1457 if (_elm_widget_is(parent)) break;
1458 elm_parent = evas_object_data_get(parent, "elm-parent");
1459 if (elm_parent) parent = elm_parent;
1460 else parent = evas_object_smart_parent_get(parent);
1465 EOLIAN static Evas_Object *
1466 _elm_widget_parent2_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1472 _elm_widget_parent2_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *parent)
1474 sd->parent2 = parent;
1478 _elm_widget_event_callback_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1480 EINA_SAFETY_ON_NULL_RETURN(func);
1482 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1485 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1489 _elm_widget_event_callback_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1491 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1493 Elm_Event_Cb_Data *ecd;
1494 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1495 if ((ecd->func == func) && (ecd->data == data))
1498 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1499 return (void *)data;
1505 EOLIAN static Eina_Bool
1506 _elm_widget_event_propagate(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags)
1508 Evas_Object *parent = obj;
1509 Elm_Event_Cb_Data *ecd;
1510 Eina_List *l, *l_prev;
1513 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1515 ELM_WIDGET_CHECK(parent) EINA_FALSE;
1516 Elm_Widget_Smart_Data *sd = eo_data_scope_get(parent, MY_CLASS);
1518 Eina_Bool int_ret = EINA_FALSE;
1519 eo_do(parent, elm_obj_widget_event(obj, type, event_info, &int_ret));
1520 if (int_ret) return EINA_TRUE;
1522 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1524 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1525 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1528 parent = sd->parent_obj;
1537 * Set custom focus chain.
1539 * This function i set one new and overwrite any previous custom focus chain
1540 * with the list of objects. The previous list will be deleted and this list
1541 * will be managed. After setted, don't modity it.
1543 * @note On focus cycle, only will be evaluated children of this container.
1545 * @param obj The container widget
1546 * @param objs Chain of objects to pass focus
1550 _elm_widget_focus_custom_chain_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_List *objs)
1552 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1554 elm_widget_focus_custom_chain_unset(obj);
1559 EINA_LIST_FOREACH(objs, l, o)
1561 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1562 _elm_object_focus_chain_del_cb, obj);
1565 sd->focus_chain = objs;
1571 * Get custom focus chain
1573 * @param obj The container widget
1576 EOLIAN static const Eina_List*
1577 _elm_widget_focus_custom_chain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1579 return (const Eina_List *)sd->focus_chain;
1585 * Unset custom focus chain
1587 * @param obj The container widget
1591 _elm_widget_focus_custom_chain_unset(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1593 Eina_List *l, *l_next;
1596 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1598 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1599 _elm_object_focus_chain_del_cb, obj);
1600 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1607 * Append object to custom focus chain.
1609 * @note If relative_child equal to NULL or not in custom chain, the object
1610 * will be added in end.
1612 * @note On focus cycle, only will be evaluated children of this container.
1614 * @param obj The container widget
1615 * @param child The child to be added in custom chain
1616 * @param relative_child The relative object to position the child
1620 _elm_widget_focus_custom_chain_append(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1622 EINA_SAFETY_ON_NULL_RETURN(child);
1624 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1626 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1627 _elm_object_focus_chain_del_cb, obj);
1629 if (!relative_child)
1630 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1632 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1633 child, relative_child);
1639 * Prepend object to custom focus chain.
1641 * @note If relative_child equal to NULL or not in custom chain, the object
1642 * will be added in begin.
1644 * @note On focus cycle, only will be evaluated children of this container.
1646 * @param obj The container widget
1647 * @param child The child to be added in custom chain
1648 * @param relative_child The relative object to position the child
1652 _elm_widget_focus_custom_chain_prepend(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1654 EINA_SAFETY_ON_NULL_RETURN(child);
1656 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1658 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1659 _elm_object_focus_chain_del_cb, obj);
1661 if (!relative_child)
1662 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1664 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1665 child, relative_child);
1671 * Give focus to next object in object tree.
1673 * Give focus to next object in focus chain of one object sub-tree.
1674 * If the last object of chain already have focus, the focus will go to the
1675 * first object of chain.
1677 * @param obj The widget root of sub-tree
1678 * @param dir Direction to cycle the focus
1683 _elm_widget_focus_cycle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir)
1685 Evas_Object *target = NULL;
1686 if (!_elm_widget_is(obj))
1688 elm_widget_focus_next_get(obj, dir, &target);
1692 if (_elm_config->access_mode)
1694 /* highlight cycle does not steal a focus, only after window gets
1695 the ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE message,
1696 target will steal focus, or focus its own job. */
1697 if (!_elm_access_auto_highlight_get())
1698 elm_widget_focus_steal(target);
1700 _elm_access_highlight_set(target);
1701 elm_widget_focus_region_show(target);
1703 else elm_widget_focus_steal(target);
1710 * Give focus to near object(in object tree) in one direction.
1712 * Give focus to near object(in object tree) in direction of current
1713 * focused object. If none focusable object in given direction or
1714 * none focused object in object tree, the focus will not change.
1716 * @param obj The reference widget
1717 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
1718 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
1719 * @return EINA_TRUE if focus is moved.
1723 EOLIAN static Eina_Bool
1724 _elm_widget_focus_direction_go(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, double degree)
1726 Evas_Object *target = NULL;
1727 Evas_Object *current_focused = NULL;
1728 double weight = 0.0;
1730 if (!_elm_widget_is(obj)) return EINA_FALSE;
1731 if (!elm_widget_focus_get(obj)) return EINA_FALSE;
1733 current_focused = elm_widget_focused_object_get(obj);
1735 if (elm_widget_focus_direction_get
1736 (obj, current_focused, degree, &target, &weight))
1738 elm_widget_focus_steal(target);
1746 _direction_weight_get(const Evas_Object *obj1,
1747 const Evas_Object *obj2,
1750 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
1751 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
1752 double ax, ay, cx, cy;
1753 double weight = -1.0, g = 0.0;
1755 if (obj1 == obj2) return 0.0;
1758 while (degree >= 360.0)
1760 while (degree < 0.0)
1763 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
1764 cx = obj_x1 + (w1 / 2.0);
1765 cy = obj_y1 + (h1 / 2.0);
1766 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
1768 /* For overlapping cases. */
1769 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
1772 /* Change all points to relative one. */
1782 /* Get crossing points (ax, ay) between obj1 and a line extending
1783 * to the direction of current degree. */
1789 else if (degree == 90.0)
1794 else if (degree == 180.0)
1799 else if (degree == 270.0)
1806 g = tan(degree * (M_PI / 180.0));
1807 if ((degree > 0.0) && (degree < 90.0))
1810 if (ay <= yyy1) ax = xx1;
1817 else if ((degree > 90.0) && (degree < 180.0))
1820 if (ay <= yyy1) ax = x1;
1827 else if ((degree > 180.0) && (degree < 270.0))
1830 if (ay >= yy1) ax = x1;
1840 if (ay >= yy1) ax = xx1;
1849 /* Filter obj2, if it is not in the specific derection. */
1851 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
1852 double t1, t2, u1, v1, u2, v2;
1854 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
1864 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
1869 t1 = (u1 * ax) + (v1 * ay);
1870 t2 = (u2 * ax) + (v2 * ay);
1872 #define _R(x) (int)((x + 0.05) * 10.0)
1874 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
1880 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
1886 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
1892 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
1893 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
1902 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
1904 else if (degree == 90.0)
1906 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
1908 else if (degree == 180.0)
1910 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
1912 else if (degree == 270.0)
1914 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
1918 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
1920 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
1923 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
1925 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
1928 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
1931 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
1932 && (_R(ay * yy2) > 0)))
1935 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
1936 (_R((1.0 / g) * yyy2) <= _R(xx2)))
1938 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
1939 && (_R(ay * yyy2) > 0))) return 0.0;
1945 /* Calculate the weight for obj2. */
1948 if (_R(xx1) > _R(x2)) weight = -1.0;
1949 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
1950 weight = (x2 - xx1) * (x2 - xx1);
1951 else if (_R(yy2) > 0)
1952 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
1953 else if (_R(yyy2) < 0)
1954 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
1955 else weight = (x2 - xx1) * (x2 - xx1);
1957 else if (degree == 90.0)
1959 if (_R(yyy1) > _R(yy2)) weight = -1.0;
1960 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
1961 weight = (yy2 - yyy1) * (yy2 - yyy1);
1962 else if (_R(x2) > 0)
1963 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
1964 else if (_R(xx2) < 0)
1965 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
1966 else weight = (yy2 - yyy1) * (yy2 - yyy1);
1968 else if (degree == 180.0)
1970 if (_R(x1) < _R(xx2)) weight = -1.0;
1971 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
1972 weight = (x1 - xx2) * (x1 - xx2);
1973 else if (_R(yy2) > 0)
1974 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
1975 else if (_R(yyy2) < 0)
1976 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
1977 else weight = (x1 - xx2) * (x1 - xx2);
1979 else if (degree == 270.0)
1981 if (_R(yy1) < _R(yyy2)) weight = -1.0;
1982 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
1983 weight = (yy1 - yyy2) * (yy1 - yyy2);
1984 else if (_R(x2) > 0)
1985 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
1986 else if (_R(xx2) < 0)
1987 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
1988 else weight = (yy1 - yyy2) * (yy1 - yyy2);
1993 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
1994 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
1995 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
1999 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2000 ((ay - (g * x2)) * (ay - (g * x2)));
2002 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2006 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2007 ((ay - (g * xx2)) * (ay - (g * xx2)));
2009 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2011 sx[j] = (1.0 / g) * yy2;
2014 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2015 ((ay - yy2) * (ay - yy2));
2017 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2020 sx[j] = (1.0 / g) * yyy2;
2023 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2024 ((ay - yyy2) * (ay - yyy2));
2027 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2028 (_R(sy[0]) != _R(sy[1])))))
2032 if (_R(t_weight[k]) == 0) return -1.0;
2033 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2040 double ccx, ccy, t1_weight, x_diff, y_diff;
2041 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2043 x_diff = rx[k] - ccx;
2044 if (x_diff < 0) x_diff *= -1.0;
2045 y_diff = ry[k] - ccy;
2046 if (y_diff < 0) y_diff *= -1.0;
2048 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2049 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2050 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2055 /* Return the current object's weight. */
2056 if (weight == -1.0) return 0.0;
2057 if (_R(weight) == 0) return -1.0;
2061 return 1.0 / weight;
2067 * Get near object in one direction of base object.
2069 * Get near object(in the object sub-tree) in one direction of
2070 * base object. Return the near object by reference.
2071 * By initializing weight, you can filter objects locating far
2072 * from base object. If object is in the specific direction,
2073 * weight is (1/(distance^2)). If object is not exactly in one
2074 * direction, some penalty will be added.
2076 * @param obj The widget root of sub-tree
2077 * @param base The base object of the direction
2078 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2079 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2080 * @param direction The near object in one direction
2081 * @param weight The weight is bigger when the object is located near
2082 * @return EINA_TRUE if near object is updated.
2087 EOLIAN static Eina_Bool
2088 _elm_widget_focus_direction_get(Eo *obj, Elm_Widget_Smart_Data *sd, const Evas_Object *base, double degree, Evas_Object **direction, double *weight)
2092 /* -1 means the best was already decided. Don't need any more searching. */
2093 if (!direction || !weight || !base || (obj == base))
2096 /* Ignore if disabled */
2097 if ((!evas_object_visible_get(obj))
2098 || (elm_widget_disabled_get(obj))
2099 || (elm_widget_tree_unfocusable_get(obj)))
2103 if (_internal_elm_widget_focus_direction_manager_is(obj))
2105 Eina_Bool int_ret = EINA_FALSE;
2106 eo_do((Eo *)obj, elm_obj_widget_focus_direction(base, degree, direction, weight, &int_ret));
2110 if (!elm_widget_can_focus_get(obj) || elm_widget_focus_get(obj))
2113 c_weight = _direction_weight_get(base, obj, degree);
2114 if ((c_weight == -1.0) ||
2115 ((c_weight != 0.0) && (*weight != -1.0) &&
2116 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2119 ((int)(*weight * 1000000) == (int)(c_weight * 1000000)))
2121 ELM_WIDGET_DATA_GET(*direction, sd1);
2124 if (sd->focus_order <= sd1->focus_order)
2128 *direction = (Evas_Object *)obj;
2139 * Get near object in one direction of base object in list.
2141 * Get near object in one direction of base object in the specific
2142 * object list. Return the near object by reference.
2143 * By initializing weight, you can filter objects locating far
2144 * from base object. If object is in the specific direction,
2145 * weight is (1/(distance^2)). If object is not exactly in one
2146 * direction, some penalty will be added.
2148 * @param obj The widget root of sub-tree
2149 * @param base The base object of the direction
2150 * @param items list with ordered objects
2151 * @param list_data_get function to get the object from one item of list
2152 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2153 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2154 * @param direction The near object in one direction
2155 * @param weight The weight is bigger when the object is located near
2156 * @return EINA_TRUE if near object is updated.
2160 EOLIAN static Eina_Bool
2161 _elm_widget_focus_list_direction_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const Evas_Object *base, const Eina_List *items, list_data_get_func_type list_data_get, double degree, Evas_Object **direction, double *weight)
2163 if (!direction || !weight || !base || !items)
2166 const Eina_List *l = items;
2167 Evas_Object *current_best = *direction;
2169 for (; l; l = eina_list_next(l))
2171 Evas_Object *cur = list_data_get(l);
2172 if (cur && _elm_widget_is(cur))
2173 elm_widget_focus_direction_get(cur, base, degree, direction, weight);
2175 if (current_best != *direction) return EINA_TRUE;
2183 * Get next object in focus chain of object tree.
2185 * Get next object in focus chain of one object sub-tree.
2186 * Return the next object by reference. If don't have any candidate to receive
2187 * focus before chain end, the first candidate will be returned.
2189 * @param obj The widget root of sub-tree
2190 * @param dir Direction of focus chain
2191 * @param next The next object in focus chain
2192 * @return EINA_TRUE if don't need focus chain restart/loop back
2193 * to use 'next' obj.
2197 EOLIAN static Eina_Bool
2198 _elm_widget_focus_next_get(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir, Evas_Object **next)
2200 Elm_Access_Info *ac;
2206 /* Ignore if disabled */
2207 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2209 if (!evas_object_visible_get(obj)
2210 || (elm_widget_tree_unfocusable_get(obj)))
2215 if ((!evas_object_visible_get(obj))
2216 || (elm_widget_disabled_get(obj))
2217 || (elm_widget_tree_unfocusable_get(obj)))
2222 if (_elm_widget_focus_chain_manager_is(obj))
2224 Eina_Bool int_ret = EINA_FALSE;
2225 eo_do((Eo *)obj, elm_obj_widget_focus_next(dir, next, &int_ret));
2226 if (!int_ret && elm_widget_focus_get(obj))
2228 Evas_Object *o = NULL;
2229 if (dir == ELM_FOCUS_PREVIOUS)
2230 o = sd->focus_previous;
2231 else if (dir == ELM_FOCUS_NEXT)
2233 else if (dir == ELM_FOCUS_UP)
2235 else if (dir == ELM_FOCUS_DOWN)
2237 else if (dir == ELM_FOCUS_RIGHT)
2238 o = sd->focus_right;
2239 else if (dir == ELM_FOCUS_LEFT)
2251 /* access object does not check sd->can_focus, because an object could
2252 have highlight even though the object is not focusable. */
2253 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2255 ac = _elm_access_info_get(obj);
2256 if (!ac) return EINA_FALSE;
2258 /* check whether the hover object is visible or not */
2259 if (!evas_object_visible_get(ac->hoverobj))
2262 else if (!elm_widget_can_focus_get(obj))
2265 if (elm_widget_focus_get(obj))
2267 if (dir == ELM_FOCUS_PREVIOUS)
2268 *next = sd->focus_previous;
2269 else if (dir == ELM_FOCUS_NEXT)
2270 *next = sd->focus_next;
2271 else if (dir == ELM_FOCUS_UP)
2272 *next = sd->focus_up;
2273 else if (dir == ELM_FOCUS_DOWN)
2274 *next = sd->focus_down;
2275 else if (dir == ELM_FOCUS_RIGHT)
2276 *next = sd->focus_right;
2277 else if (dir == ELM_FOCUS_LEFT)
2278 *next = sd->focus_left;
2280 if (*next) return EINA_TRUE;
2284 *next = (Evas_Object *)obj;
2285 return !ELM_WIDGET_FOCUS_GET(obj);
2291 * Get next object in focus chain of object tree in list.
2293 * Get next object in focus chain of one object sub-tree ordered by one list.
2294 * Return the next object by reference. If don't have any candidate to receive
2295 * focus before list end, the first candidate will be returned.
2297 * @param obj The widget root of sub-tree
2298 * @param items list with ordered objects
2299 * @param list_data_get function to get the object from one item of list
2300 * @param dir Direction of focus chain
2301 * @param next The next object in focus chain
2302 * @return EINA_TRUE if don't need focus chain restart/loop back
2303 * to use 'next' obj.
2307 EOLIAN static Eina_Bool
2308 _elm_widget_focus_list_next_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const Eina_List *items, list_data_get_func_type list_data_get, Elm_Focus_Direction dir, Evas_Object **next)
2310 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2311 Evas_Object *focused_object = NULL;
2317 if (!_elm_widget_is(obj))
2323 /* When Up, Down, Right, or Left, try direction_get first. */
2324 focused_object = elm_widget_focused_object_get(obj);
2327 if((dir == ELM_FOCUS_UP)
2328 || (dir == ELM_FOCUS_DOWN)
2329 || (dir == ELM_FOCUS_RIGHT)
2330 || (dir == ELM_FOCUS_LEFT))
2332 *next = elm_widget_focus_next_object_get(focused_object, dir);
2333 if (*next) return EINA_TRUE;
2336 Evas_Object *n = NULL;
2338 double weight = 0.0;
2340 if (dir == ELM_FOCUS_UP) degree = 0.0;
2341 else if (dir == ELM_FOCUS_DOWN) degree = 180.0;
2342 else if (dir == ELM_FOCUS_RIGHT) degree = 90.0;
2343 else if (dir == ELM_FOCUS_LEFT) degree = 270.0;
2345 if (elm_widget_focus_list_direction_get(obj, focused_object,
2346 items, list_data_get,
2347 degree, &n, &weight))
2357 if (dir == ELM_FOCUS_PREVIOUS)
2359 items = eina_list_last(items);
2360 list_next = eina_list_prev;
2362 else if ((dir == ELM_FOCUS_NEXT)
2363 || (dir == ELM_FOCUS_UP)
2364 || (dir == ELM_FOCUS_DOWN)
2365 || (dir == ELM_FOCUS_RIGHT)
2366 || (dir == ELM_FOCUS_LEFT))
2367 list_next = eina_list_next;
2371 const Eina_List *l = items;
2373 /* Recovery last focused sub item */
2374 if (ELM_WIDGET_FOCUS_GET(obj))
2376 for (; l; l = list_next(l))
2378 Evas_Object *cur = list_data_get(l);
2379 if (ELM_WIDGET_FOCUS_GET(cur)) break;
2382 /* Focused object, but no focused sub item */
2386 const Eina_List *start = l;
2387 Evas_Object *to_focus = NULL;
2389 /* Iterate sub items */
2390 /* Go to the end of list */
2391 for (; l; l = list_next(l))
2393 Evas_Object *tmp = NULL;
2394 Evas_Object *cur = list_data_get(l);
2397 if (!_elm_widget_is(cur)) continue;
2398 if (elm_widget_parent_get(cur) != obj)
2401 /* Try Focus cycle in subitem */
2402 if (elm_widget_focus_next_get(cur, dir, &tmp))
2407 else if ((dir == ELM_FOCUS_UP)
2408 || (dir == ELM_FOCUS_DOWN)
2409 || (dir == ELM_FOCUS_RIGHT)
2410 || (dir == ELM_FOCUS_LEFT))
2412 if (tmp && elm_widget_focus_get(cur))
2418 else if ((tmp) && (!to_focus))
2424 /* Get First possible */
2425 for (; l != start; l = list_next(l))
2427 Evas_Object *tmp = NULL;
2428 Evas_Object *cur = list_data_get(l);
2430 if (elm_widget_parent_get(cur) != obj)
2433 /* Try Focus cycle in subitem */
2434 elm_widget_focus_next_get(cur, dir, &tmp);
2449 * Get next object which was set with specific focus direction.
2451 * Get next object which was set by elm_widget_focus_next_object_set
2452 * with specific focus directioin.
2454 * @param obj The widget
2455 * @param dir Direction of focus
2456 * @return Widget which was registered with sepecific focus direction.
2460 EOLIAN static Evas_Object*
2461 _elm_widget_focus_next_object_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir)
2465 if (dir == ELM_FOCUS_PREVIOUS)
2466 ret = sd->focus_previous;
2467 else if (dir == ELM_FOCUS_NEXT)
2468 ret = sd->focus_next;
2469 else if (dir == ELM_FOCUS_UP)
2471 else if (dir == ELM_FOCUS_DOWN)
2472 ret = sd->focus_down;
2473 else if (dir == ELM_FOCUS_RIGHT)
2474 ret = sd->focus_right;
2475 else if (dir == ELM_FOCUS_LEFT)
2476 ret = sd->focus_left;
2484 * Set next object with specific focus direction.
2486 * When a widget is set with specific focus direction, this widget will be
2487 * the first candidate when finding the next focus object.
2488 * Focus next object can be registered with six directions that are previous,
2489 * next, up, down, right, and left.
2491 * @param obj The widget
2492 * @param next Next focus object
2493 * @param dir Direction of focus
2498 _elm_widget_focus_next_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *next, Elm_Focus_Direction dir)
2501 if (dir == ELM_FOCUS_PREVIOUS)
2502 sd->focus_previous = next;
2503 else if (dir == ELM_FOCUS_NEXT)
2504 sd->focus_next = next;
2505 else if (dir == ELM_FOCUS_UP)
2506 sd->focus_up = next;
2507 else if (dir == ELM_FOCUS_DOWN)
2508 sd->focus_down = next;
2509 else if (dir == ELM_FOCUS_RIGHT)
2510 sd->focus_right = next;
2511 else if (dir == ELM_FOCUS_LEFT)
2512 sd->focus_left = next;
2516 _elm_widget_parent_highlight_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool highlighted)
2518 highlighted = !!highlighted;
2520 Evas_Object *o = elm_widget_parent_get(obj);
2522 if (o) elm_widget_parent_highlight_set(o, highlighted);
2524 sd->highlighted = highlighted;
2528 _elm_widget_signal_emit(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source)
2530 if (evas_object_smart_type_check(obj, "elm_layout"))
2531 elm_layout_signal_emit(obj, emission, source);
2532 else if (evas_object_smart_type_check(obj, "elm_icon"))
2534 WRN("Deprecated function. This functionality on icon objects"
2535 " will be dropped on a next release.");
2536 _elm_icon_signal_emit(obj, emission, source);
2541 _elm_widget_signal_callback_add(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
2543 EINA_SAFETY_ON_NULL_RETURN(func);
2545 if (evas_object_smart_type_check(obj, "elm_layout"))
2546 elm_layout_signal_callback_add(obj, emission, source, func, data);
2547 else if (evas_object_smart_type_check(obj, "elm_icon"))
2549 WRN("Deprecated function. This functionality on icon objects"
2550 " will be dropped on a next release.");
2552 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2557 _elm_widget_signal_callback_del(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source, Edje_Signal_Cb func)
2561 if (evas_object_smart_type_check(obj, "elm_layout"))
2562 data = elm_layout_signal_callback_del(obj, emission, source, func);
2563 else if (evas_object_smart_type_check(obj, "elm_icon"))
2565 WRN("Deprecated function. This functionality on icon objects"
2566 " will be dropped on a next release.");
2568 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2575 _elm_widget_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool focus)
2580 sd->focus_order = focus_order;
2581 sd->focused = EINA_TRUE;
2582 eo_do(obj, elm_obj_widget_on_focus(NULL));
2587 if ((_is_focusable(sd->resize_obj)) &&
2588 (!elm_widget_disabled_get(sd->resize_obj)))
2590 elm_widget_focus_set(sd->resize_obj, focus);
2597 EINA_LIST_FOREACH(sd->subobjs, l, child)
2599 if (!_elm_widget_is(child)) continue;
2600 if ((_is_focusable(child)) &&
2601 (!elm_widget_disabled_get(child)))
2603 elm_widget_focus_set(child, focus);
2614 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2616 if (!_elm_widget_is(child)) continue;
2617 if ((_is_focusable(child)) &&
2618 (!elm_widget_disabled_get(child)))
2620 elm_widget_focus_set(child, focus);
2627 EOLIAN static Evas_Object*
2628 _elm_widget_parent_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2630 return sd->parent_obj;
2634 _elm_widget_focused_object_clear(Eo *obj, Elm_Widget_Smart_Data *sd)
2636 if (!sd->focused) return;
2637 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
2638 elm_widget_focus_get(sd->resize_obj))
2640 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
2646 EINA_LIST_FOREACH(sd->subobjs, l, child)
2648 if (_elm_widget_is(child) && elm_widget_focus_get(child))
2650 eo_do(child, elm_obj_widget_focused_object_clear());
2655 sd->focused = EINA_FALSE;
2656 eo_do(obj, elm_obj_widget_on_focus(NULL));
2660 _elm_widget_focus_steal(Eo *obj, Elm_Widget_Smart_Data *sd)
2662 Evas_Object *parent, *parent2, *o;
2664 if (sd->focused) return;
2665 if (sd->disabled) return;
2666 if (!sd->can_focus) return;
2667 if (sd->tree_unfocusable) return;
2671 o = elm_widget_parent_get(parent);
2673 sd = eo_data_scope_get(o, MY_CLASS);
2674 if (sd->disabled || sd->tree_unfocusable) return;
2675 if (sd->focused) break;
2678 if ((!elm_widget_parent_get(parent)) &&
2679 (!elm_widget_parent2_get(parent)))
2680 eo_do(parent, elm_obj_widget_focused_object_clear());
2683 parent2 = elm_widget_parent_get(parent);
2684 if (!parent2) parent2 = elm_widget_parent2_get(parent);
2686 sd = eo_data_scope_get(parent, MY_CLASS);
2689 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
2690 elm_widget_focus_get(sd->resize_obj))
2692 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
2698 EINA_LIST_FOREACH(sd->subobjs, l, child)
2700 if (_elm_widget_is(child) && elm_widget_focus_get(child))
2702 eo_do(child, elm_obj_widget_focused_object_clear());
2714 _elm_widget_focus_restore(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
2716 Evas_Object *newest = NULL;
2717 unsigned int newest_focus_order = 0;
2719 newest = elm_widget_newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
2722 elm_object_focus_set(newest, EINA_FALSE);
2723 elm_object_focus_set(newest, EINA_TRUE);
2728 _elm_widget_top_win_focused_set(Evas_Object *obj,
2729 Eina_Bool top_win_focused)
2735 if (sd->top_win_focused == top_win_focused) return;
2736 EINA_LIST_FOREACH(sd->subobjs, l, child)
2738 if (elm_widget_is(child))
2739 _elm_widget_top_win_focused_set(child, top_win_focused);
2741 sd->top_win_focused = top_win_focused;
2745 _elm_widget_top_win_focused_get(const Evas_Object *obj)
2747 API_ENTRY return EINA_FALSE;
2748 return sd->top_win_focused;
2752 _elm_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
2754 if (sd->disabled == disabled) return;
2755 sd->disabled = !!disabled;
2756 elm_widget_focus_disabled_handle(obj);
2757 eo_do(obj, elm_obj_widget_disable(NULL));
2760 EOLIAN static Eina_Bool
2761 _elm_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2763 return sd->disabled;
2767 _elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow)
2770 Evas_Object *parent_obj, *child_obj;
2771 Evas_Coord px, py, cx, cy, nx, ny;
2774 evas_smart_objects_calculate(evas_object_evas_get(obj));
2776 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
2777 (w == sd->rw) && (h == sd->rh)) return;
2783 if (sd->on_show_region)
2786 (sd->on_show_region_data, obj);
2788 if (_elm_scrollable_is(obj))
2790 eo_do(obj, elm_interface_scrollable_content_pos_get(&nx, &ny));
2798 parent_obj = sd->parent_obj;
2799 child_obj = sd->obj;
2800 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2801 sd = eo_data_scope_get(parent_obj, MY_CLASS);
2804 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2805 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2814 if (sd->on_show_region)
2817 (sd->on_show_region_data, parent_obj);
2824 _elm_widget_show_region_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2835 * Get the focus region of the given widget.
2837 * @return show region or not
2838 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
2840 * The focus region is the area of a widget that should brought into the
2841 * visible area when the widget is focused. Mostly used to show the part of
2842 * an entry where the cursor is, for example. The area returned is relative
2843 * to the object @p obj.
2845 * @param obj The widget object
2846 * @param x Where to store the x coordinate of the area
2847 * @param y Where to store the y coordinate of the area
2848 * @param w Where to store the width of the area
2849 * @param h Where to store the height of the area
2853 EOLIAN static Eina_Bool
2854 _elm_widget_focus_region_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2856 Eina_Bool int_ret = EINA_FALSE;
2857 eo_do((Eo *)obj, elm_obj_widget_on_focus_region(x, y, w, h, &int_ret));
2860 evas_object_geometry_get(obj, NULL, NULL, w, h);
2868 _elm_widget_parents_bounce_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool *horiz, Eina_Bool *vert)
2870 Evas_Object *parent_obj = obj;
2873 *horiz = EINA_FALSE;
2878 parent_obj = elm_widget_parent_get(parent_obj);
2879 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2881 if (_elm_scrollable_is(parent_obj))
2883 eo_do(parent_obj, elm_interface_scrollable_bounce_allow_get(&h, &v));
2884 if (h) *horiz = EINA_TRUE;
2885 if (v) *vert = EINA_TRUE;
2891 EOLIAN static Eina_List*
2892 _elm_widget_scrollable_children_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2901 EINA_LIST_FOREACH(sd->subobjs, l, child)
2903 if (elm_widget_is(child) && _elm_scrollable_is(child))
2904 ret = eina_list_append(ret, child);
2911 _elm_widget_scroll_hold_push(Eo *obj, Elm_Widget_Smart_Data *sd)
2914 if (sd->scroll_hold == 1)
2916 if (_elm_scrollable_is(obj))
2917 eo_do(obj, elm_interface_scrollable_hold_set(EINA_TRUE));
2920 Eina_List *scr_children, *l;
2923 scr_children = elm_widget_scrollable_children_get(obj);
2924 EINA_LIST_FOREACH(scr_children, l, child)
2926 eo_do(child, elm_interface_scrollable_hold_set(EINA_TRUE));
2928 eina_list_free(scr_children);
2931 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_push());
2932 // FIXME: on delete/reparent hold pop
2936 _elm_widget_scroll_hold_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
2939 if (!sd->scroll_hold)
2941 if (_elm_scrollable_is(obj))
2942 eo_do(obj, elm_interface_scrollable_hold_set(EINA_FALSE));
2945 Eina_List *scr_children, *l;
2948 scr_children = elm_widget_scrollable_children_get(obj);
2949 EINA_LIST_FOREACH(scr_children, l, child)
2951 eo_do(child, elm_interface_scrollable_hold_set(EINA_FALSE));
2953 eina_list_free(scr_children);
2956 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_pop());
2957 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
2961 _elm_widget_scroll_hold_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2963 return sd->scroll_hold;
2967 _elm_widget_scroll_freeze_push(Eo *obj, Elm_Widget_Smart_Data *sd)
2969 sd->scroll_freeze++;
2970 if (sd->scroll_freeze == 1)
2972 if (_elm_scrollable_is(obj))
2973 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_TRUE));
2976 Eina_List *scr_children, *l;
2979 scr_children = elm_widget_scrollable_children_get(obj);
2980 EINA_LIST_FOREACH(scr_children, l, child)
2982 eo_do(child, elm_interface_scrollable_freeze_set(EINA_TRUE));
2984 eina_list_free(scr_children);
2987 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_push());
2988 // FIXME: on delete/reparent freeze pop
2992 _elm_widget_scroll_freeze_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
2994 sd->scroll_freeze--;
2995 if (!sd->scroll_freeze)
2997 if (_elm_scrollable_is(obj))
2998 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_FALSE));
3001 Eina_List *scr_children, *l;
3004 scr_children = elm_widget_scrollable_children_get(obj);
3005 EINA_LIST_FOREACH(scr_children, l, child)
3007 eo_do(child, elm_interface_scrollable_freeze_set(EINA_FALSE));
3009 eina_list_free(scr_children);
3012 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_pop());
3013 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3017 _elm_widget_scroll_freeze_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3019 return sd->scroll_freeze;
3023 _elm_widget_scale_set(Eo *obj, Elm_Widget_Smart_Data *sd, double scale)
3025 if (scale <= 0.0) scale = 0.0;
3026 if (sd->scale != scale)
3029 elm_widget_theme(obj);
3033 EOLIAN static double
3034 _elm_widget_scale_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3036 // FIXME: save walking up the tree by storing/caching parent scale
3037 if (sd->scale == 0.0)
3039 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3041 return elm_widget_scale_get(sd->parent_obj);
3052 _elm_widget_theme_set(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Theme *th)
3054 Eina_Bool apply = EINA_FALSE;
3055 if (sd->theme != th)
3057 if (elm_widget_theme_get(obj) != th) apply = EINA_TRUE;
3058 if (sd->theme) elm_theme_free(sd->theme);
3061 if (apply) elm_widget_theme(obj);
3066 _elm_widget_part_text_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part, const char *label)
3068 if (evas_object_smart_type_check(obj, "elm_layout"))
3069 elm_layout_text_set(obj, part, label);
3072 EOLIAN static const char*
3073 _elm_widget_part_text_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part)
3075 if (evas_object_smart_type_check(obj, "elm_layout"))
3076 return elm_layout_text_get(obj, part);
3081 static Elm_Translate_String_Data *
3082 _translate_string_data_get(Eina_Inlist *translate_strings, const char *part)
3084 Elm_Translate_String_Data *ts;
3085 Eina_Stringshare *str;
3087 if (!translate_strings) return NULL;
3089 str = eina_stringshare_add(part);
3090 EINA_INLIST_FOREACH(translate_strings, ts)
3092 if (ts->id == str) break;
3095 eina_stringshare_del(str);
3100 static Elm_Translate_String_Data *
3101 _part_text_translatable_set(Eina_Inlist **translate_strings, const char *part, Eina_Bool translatable, Eina_Bool preset)
3104 Elm_Translate_String_Data *ts;
3105 t = *translate_strings;
3106 ts = _translate_string_data_get(t, part);
3112 ts = ELM_NEW(Elm_Translate_String_Data);
3113 if (!ts) return NULL;
3115 ts->id = eina_stringshare_add(part);
3116 t = eina_inlist_append(t, (Eina_Inlist*) ts);
3118 if (preset) ts->preset = EINA_TRUE;
3120 //Delete this exist one if this part has been not preset.
3121 //see elm_widget_part_text_translatable_set()
3122 else if ((preset) || (!ts->preset))
3126 t = eina_inlist_remove(t, EINA_INLIST_GET(ts));
3127 eina_stringshare_del(ts->id);
3128 eina_stringshare_del(ts->domain);
3129 eina_stringshare_del(ts->string);
3130 ELM_SAFE_FREE(ts, free);
3134 *translate_strings = t;
3140 _elm_widget_domain_translatable_part_text_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, const char *label)
3143 Elm_Translate_String_Data *ts;
3147 _part_text_translatable_set(&sd->translate_strings, part, EINA_FALSE,
3152 ts = _part_text_translatable_set(&sd->translate_strings, part,
3153 EINA_TRUE, EINA_FALSE);
3155 if (!ts->string) ts->string = eina_stringshare_add(label);
3156 else eina_stringshare_replace(&ts->string, label);
3157 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3158 else eina_stringshare_replace(&ts->domain, domain);
3160 if (label[0]) label = dgettext(domain, label);
3164 sd->on_translate = EINA_TRUE;
3165 eo_do(obj, elm_obj_widget_part_text_set(part, label));
3166 sd->on_translate = EINA_FALSE;
3169 EOLIAN static const char*
3170 _elm_widget_translatable_part_text_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part)
3172 Elm_Translate_String_Data *ts;
3174 ts = _translate_string_data_get(sd->translate_strings, part);
3175 if (ts) return ts->string;
3180 _elm_widget_domain_part_text_translatable_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, Eina_Bool translatable)
3182 Elm_Translate_String_Data *ts;
3185 ts = _part_text_translatable_set(&sd->translate_strings, part,
3186 translatable, EINA_TRUE);
3188 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3189 else eina_stringshare_replace(&ts->domain, domain);
3191 eo_do(obj, elm_obj_widget_part_text_get(part, &text));
3192 if (!text || !text[0]) return;
3194 if (!ts->string) ts->string = eina_stringshare_add(text);
3196 //Try to translate text since we don't know the text is already translated.
3198 text = dgettext(domain, text);
3200 sd->on_translate = EINA_TRUE;
3201 eo_do(obj, elm_obj_widget_part_text_set(part, text));
3202 sd->on_translate = EINA_FALSE;
3206 elm_widget_translate(Evas_Object *obj)
3208 ELM_WIDGET_CHECK(obj);
3209 eo_do(obj, elm_obj_widget_translate(NULL));
3213 _part_text_translate(Eina_Inlist *translate_strings,
3217 Elm_Translate_String_Data *ts;
3218 ts = _translate_string_data_get(translate_strings, part);
3219 if (!ts) return text;
3221 if (!ts->string) ts->string = eina_stringshare_add(text);
3222 else eina_stringshare_replace(&ts->string, text);
3224 if (text && text[0])
3225 text = dgettext(ts->domain, text);
3230 EOLIAN static const char*
3231 _elm_widget_part_text_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part, const char *text)
3235 if (!sd->translate_strings || sd->on_translate) return text;
3236 return _part_text_translate(sd->translate_strings, part, text);
3239 EOLIAN static Eina_Bool
3240 _elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3244 API_ENTRY return EINA_FALSE;
3246 EINA_LIST_FOREACH(sd->subobjs, l, child)
3248 if (elm_widget_is(child))
3249 elm_widget_translate(child);
3252 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3255 Elm_Translate_String_Data *ts;
3256 EINA_INLIST_FOREACH(sd->translate_strings, ts)
3258 if (!ts->string) continue;
3259 const char *s = dgettext(ts->domain, ts->string);
3260 sd->on_translate = EINA_TRUE;
3261 eo_do(obj, elm_obj_widget_part_text_set(ts->id, s));
3262 sd->on_translate = EINA_FALSE;
3265 evas_object_smart_callback_call(obj, SIG_WIDGET_LANG_CHANGED, NULL);
3270 elm_widget_content_part_set(Evas_Object *obj,
3272 Evas_Object *content)
3274 ELM_WIDGET_CHECK(obj);
3275 eo_do(obj, elm_obj_container_content_set(part, content, NULL));
3279 elm_widget_content_part_get(const Evas_Object *obj,
3282 ELM_WIDGET_CHECK(obj) NULL;
3283 Evas_Object *ret = NULL;
3284 eo_do((Eo *) obj, elm_obj_container_content_get(part, &ret));
3289 elm_widget_content_part_unset(Evas_Object *obj,
3292 ELM_WIDGET_CHECK(obj) NULL;
3293 Evas_Object *ret = NULL;
3294 eo_do(obj, elm_obj_container_content_unset(part, &ret));
3299 _elm_widget_access_info_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *txt)
3301 eina_stringshare_del(sd->access_info);
3302 if (!txt) sd->access_info = NULL;
3303 else sd->access_info = eina_stringshare_add(txt);
3306 EOLIAN static const char*
3307 _elm_widget_access_info_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3309 return sd->access_info;
3312 EOLIAN static Elm_Theme*
3313 _elm_widget_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3317 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3318 return elm_widget_theme_get(sd->parent_obj);
3324 EOLIAN static Eina_Bool
3325 _elm_widget_style_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *style)
3327 if (eina_stringshare_replace(&sd->style, style))
3328 return elm_widget_theme(obj);
3333 EOLIAN static const char*
3334 _elm_widget_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3338 if (sd->style) ret = sd->style;
3344 _elm_widget_tooltip_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3346 sd->tooltips = eina_list_append(sd->tooltips, tt);
3350 _elm_widget_tooltip_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3352 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3356 _elm_widget_cursor_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3358 sd->cursors = eina_list_append(sd->cursors, cur);
3362 _elm_widget_cursor_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3364 sd->cursors = eina_list_remove(sd->cursors, cur);
3368 _elm_widget_drag_lock_x_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
3370 if (sd->drag_x_locked == lock) return;
3371 sd->drag_x_locked = lock;
3372 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
3373 else _propagate_x_drag_lock(obj, -1);
3377 _elm_widget_drag_lock_y_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
3379 if (sd->drag_y_locked == lock) return;
3380 sd->drag_y_locked = lock;
3381 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
3382 else _propagate_y_drag_lock(obj, -1);
3385 EOLIAN static Eina_Bool
3386 _elm_widget_drag_lock_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3388 return sd->drag_x_locked;
3391 EOLIAN static Eina_Bool
3392 _elm_widget_drag_lock_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3394 return sd->drag_y_locked;
3398 _elm_widget_drag_child_locked_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3400 return sd->child_drag_x_locked;
3404 _elm_widget_drag_child_locked_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3406 return sd->child_drag_y_locked;
3410 _elm_widget_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED, Eina_Bool enable EINA_UNUSED)
3415 EOLIAN static Eina_Bool
3416 _elm_widget_item_loop_enabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED)
3421 EOLIAN static Eina_Bool
3422 _elm_widget_theme_object_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle)
3424 if (!_elm_theme_object_set(obj, edj, wname, welement, wstyle))
3429 if (sd->orient_mode != -1)
3432 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
3433 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
3440 _elm_widget_eo_base_dbg_info_get(Eo *eo_obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eo_Dbg_Info *root)
3442 eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
3443 Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
3445 EO_DBG_INFO_APPEND(group, "Wid-Type", EINA_VALUE_TYPE_STRING, elm_widget_type_get(eo_obj));
3446 EO_DBG_INFO_APPEND(group, "Style", EINA_VALUE_TYPE_STRING, elm_widget_style_get(eo_obj));
3447 EO_DBG_INFO_APPEND(group, "Layer", EINA_VALUE_TYPE_INT,
3448 (int) evas_object_layer_get(eo_obj));
3449 EO_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE,
3450 evas_object_scale_get(eo_obj));
3451 EO_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR,
3452 elm_object_focus_get(eo_obj));
3453 EO_DBG_INFO_APPEND(group, "Disabled", EINA_VALUE_TYPE_CHAR,
3454 elm_widget_disabled_get(eo_obj));
3455 EO_DBG_INFO_APPEND(group, "Mirrored", EINA_VALUE_TYPE_CHAR,
3456 elm_widget_mirrored_get(eo_obj));
3457 EO_DBG_INFO_APPEND(group, "Automatic mirroring", EINA_VALUE_TYPE_CHAR,
3458 elm_widget_mirrored_automatic_get(eo_obj));
3462 elm_widget_is_check(const Evas_Object *obj)
3464 static int abort_on_warn = -1;
3465 if (elm_widget_is(obj))
3468 ERR("Passing Object: %p.", obj);
3469 if (abort_on_warn == -1)
3471 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3472 else abort_on_warn = 0;
3474 if (abort_on_warn == 1) abort();
3479 elm_widget_type_get(const Evas_Object *obj)
3481 API_ENTRY return NULL;
3483 return eo_class_name_get(eo_class_get(obj));
3487 elm_widget_type_check(const Evas_Object *obj,
3491 const char *provided, *expected = "(unknown)";
3492 static int abort_on_warn = -1;
3494 provided = elm_widget_type_get(obj);
3495 /* TODO: eventually migrate to check_ptr version */
3496 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
3497 if (type) expected = type;
3498 if ((!provided) || (!provided[0]))
3500 provided = evas_object_type_get(obj);
3501 if ((!provided) || (!provided[0]))
3502 provided = "(unknown)";
3504 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
3505 " type: '%s'", obj, func, provided, expected);
3506 if (abort_on_warn == -1)
3508 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
3509 else abort_on_warn = 0;
3511 if (abort_on_warn == 1) abort();
3515 static Evas_Object *
3516 _widget_name_find(const Evas_Object *obj,
3523 INTERNAL_ENTRY NULL;
3525 if (!_elm_widget_is(obj)) return NULL;
3526 EINA_LIST_FOREACH(sd->subobjs, l, child)
3528 s = evas_object_name_get(child);
3529 if ((s) && (!strcmp(s, name))) return child;
3530 if ((recurse != 0) &&
3531 ((child = _widget_name_find(child, name, recurse - 1))))
3536 s = evas_object_name_get(sd->hover_obj);
3537 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
3538 if ((recurse != 0) &&
3539 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
3545 EOLIAN static Evas_Object*
3546 _elm_widget_name_find(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *name, int recurse)
3548 if (!name) return NULL;
3549 return _widget_name_find(obj, name, recurse);
3555 * Split string in words
3557 * @param str Source string
3558 * @return List of const words
3560 * @see elm_widget_stringlist_free()
3564 elm_widget_stringlist_get(const char *str)
3566 Eina_List *list = NULL;
3568 if (!str) return NULL;
3569 for (b = s = str; 1; s++)
3571 if ((*s == ' ') || (!*s))
3573 char *t = malloc(s - b + 1);
3576 strncpy(t, b, s - b);
3578 list = eina_list_append(list, eina_stringshare_add(t));
3589 elm_widget_stringlist_free(Eina_List *list)
3592 EINA_LIST_FREE(list, s)
3593 eina_stringshare_del(s);
3597 _elm_widget_focus_hide_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3599 if (!_elm_widget_is(obj))
3601 _if_focused_revert(obj, EINA_TRUE);
3605 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
3607 Evas_Object *o = obj;
3610 if (_elm_widget_is(o)) break;
3611 o = evas_object_smart_parent_get(o);
3615 eo_do(o, elm_obj_widget_focus_mouse_up_handle());
3619 _elm_widget_focus_mouse_up_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3622 if (!_is_focusable(obj)) return;
3623 elm_widget_focus_steal(obj);
3627 _elm_widget_focus_tree_unfocusable_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3629 if (!elm_widget_parent_get(obj))
3630 elm_widget_focused_object_clear(obj);
3632 _if_focused_revert(obj, EINA_TRUE);
3636 _elm_widget_focus_disabled_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3638 elm_widget_focus_tree_unfocusable_handle(obj);
3641 EOLIAN static unsigned int
3642 _elm_widget_focus_order_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3644 return sd->focus_order;
3647 EOLIAN static Evas_Object*
3648 _elm_widget_newest_focus_order_get(Eo *obj, Elm_Widget_Smart_Data *sd, unsigned int *newest_focus_order, Eina_Bool can_focus_only)
3651 Evas_Object *child, *cur, *best;
3653 if (!evas_object_visible_get(obj)
3654 || (elm_widget_disabled_get(obj))
3655 || (elm_widget_tree_unfocusable_get(obj)))
3659 if (*newest_focus_order < sd->focus_order)
3661 if (!can_focus_only || elm_widget_can_focus_get(obj))
3663 *newest_focus_order = sd->focus_order;
3667 EINA_LIST_FOREACH(sd->subobjs, l, child)
3669 if (!_elm_widget_is(child)) continue;
3671 cur = elm_widget_newest_focus_order_get
3672 (child, newest_focus_order, can_focus_only);
3682 * Get the focus highlight geometry of an widget.
3684 * @param obj Widget object for the focus highlight
3685 * @param x Focus highlight x coordinate
3686 * @param y Focus highlight y coordinate
3687 * @param w Focus highlight object width
3688 * @param h Focus highlight object height
3689 * @param is_next @c EINA_TRUE if this request is for the new focused object,
3690 * @c EINA_FALSE if this request is for the previously focused object. This
3691 * information becomes important when the focus highlight is changed inside one
3699 * Get the 'focus_part' geometry if there is any
3701 * This queries if there is a 'focus_part' request from the edc style. If edc
3702 * style offers 'focus_part' edje data item, this function requests for the
3703 * geometry of a specific part which is described in 'focus_part' edje data.
3705 * @param obj Widget object for the focus highlight
3706 * @param x Focus highlight x coordinate
3707 * @param y Focus highlight y coordinate
3708 * @param w Focus highlight object width
3709 * @param h Focus highlight object height
3711 * x, y, w, h already contain the object's geometry. If there is a 'focus_part'
3712 * support, these values will be updated accordingly or the values will be
3713 * remained as they were.
3718 elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj,
3724 Evas_Coord tx = 0, ty = 0, tw = 0, th = 0;
3725 const char *target_hl_part = NULL;
3726 const Evas_Object *edje_obj = NULL;
3728 if (obj && eo_isa(obj, EDJE_OBJ_CLASS))
3731 if (!(target_hl_part = edje_object_data_get(edje_obj, "focus_part")))
3734 else if (obj && eo_isa(obj, ELM_OBJ_LAYOUT_CLASS))
3736 edje_obj = elm_layout_edje_get(obj);
3737 if (!(target_hl_part = elm_layout_data_get(obj, "focus_part")))
3743 edje_object_part_geometry_get(edje_obj, target_hl_part,
3744 &tx, &ty, &tw, &th);
3747 if (tw != *w) *w = tw;
3748 if (th != *h) *h = th;
3752 _elm_widget_focus_highlight_geometry_get(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h, Eina_Bool is_next)
3757 evas_object_geometry_get(obj, x, y, w, h);
3758 elm_widget_focus_highlight_focus_part_geometry_get(sd->resize_obj, x, y, w, h);
3761 EOLIAN static Elm_Object_Item*
3762 _elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3768 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
3770 Evas_Object *parent;
3773 ELM_WIDGET_CHECK(obj);
3777 eo_do(obj, elm_obj_widget_activate(act, &ret));
3781 parent = elm_widget_parent_get(obj);
3783 elm_widget_activate(parent, act);
3791 * Sets the widget and child widget's Evas_Display_Mode.
3793 * @param obj The widget.
3794 * @param dispmode Evas_Display_Mode to set widget's mode.
3796 * Widgets are resized by several reasons.
3797 * Evas_Display_Mode can help for widgets to get one more reason of resize.
3798 * For example, elm conform widget resizes it's contents when keypad state changed.
3799 * After keypad showing, conform widget can change child's Evas_Display_Mode.
3803 _elm_widget_display_mode_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Display_Mode dispmode)
3805 Evas_Display_Mode prev_dispmode;
3809 prev_dispmode = evas_object_size_hint_display_mode_get(obj);
3811 if ((prev_dispmode == dispmode) ||
3812 (prev_dispmode == EVAS_DISPLAY_MODE_DONT_CHANGE)) return;
3814 evas_object_size_hint_display_mode_set(obj, dispmode);
3816 EINA_LIST_FOREACH (sd->subobjs, l, child)
3818 if (elm_widget_is(child))
3819 elm_widget_display_mode_set(child, dispmode);
3824 _elm_widget_orientation_mode_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
3826 int orient_mode = -1;
3830 //Get current orient mode from it's parent otherwise, 0.
3831 sd->orient_mode = 0;
3832 ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
3833 if (!sd_parent) orient_mode = 0;
3834 else orient_mode = sd_parent->orient_mode;
3836 eo_do(obj, elm_obj_widget_orientation_set(orient_mode));
3839 EOLIAN static Eina_Bool
3840 _elm_widget_orientation_mode_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3842 if (sd->orient_mode == -1) return EINA_TRUE;
3843 else return EINA_FALSE;
3847 _elm_widget_orientation_set(Eo *obj, Elm_Widget_Smart_Data *sd, int orient_mode)
3852 sd->orient_mode = orient_mode;
3854 EINA_LIST_FOREACH (sd->subobjs, l, child)
3856 if (elm_widget_is(child))
3857 elm_widget_orientation_set(child, orient_mode);
3860 if (orient_mode != -1)
3863 snprintf(buf, sizeof(buf), "elm,state,orient,%d", orient_mode);
3864 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
3869 _track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
3872 _track_obj_update(Evas_Object *track, Evas_Object *obj)
3875 Evas_Coord x, y, w, h;
3876 evas_object_geometry_get(obj, &x, &y, &w, &h);
3877 evas_object_move(track, x, y);
3878 evas_object_resize(track, w, h);
3881 if (evas_object_visible_get(obj)) evas_object_show(track);
3882 else evas_object_hide(track);
3886 _track_obj_view_update(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
3887 void *event_info EINA_UNUSED)
3889 Evas_Object *track = data;
3890 _track_obj_update(track, obj);
3894 _track_obj_view_del(void *data, Evas *e EINA_UNUSED,
3895 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
3897 Elm_Widget_Item *item = data;
3899 while (evas_object_ref_get(item->track_obj) > 0)
3900 evas_object_unref(item->track_obj);
3902 evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
3904 evas_object_del(item->track_obj);
3905 item->track_obj = NULL;
3909 _track_obj_del(void *data, Evas *e EINA_UNUSED,
3910 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
3912 Elm_Widget_Item *item = data;
3913 item->track_obj = NULL;
3915 if (!item->view) return;
3917 evas_object_event_callback_del(item->view, EVAS_CALLBACK_RESIZE,
3918 _track_obj_view_update);
3919 evas_object_event_callback_del(item->view, EVAS_CALLBACK_MOVE,
3920 _track_obj_view_update);
3921 evas_object_event_callback_del(item->view, EVAS_CALLBACK_SHOW,
3922 _track_obj_view_update);
3923 evas_object_event_callback_del(item->view, EVAS_CALLBACK_HIDE,
3924 _track_obj_view_update);
3925 evas_object_event_callback_del(item->view, EVAS_CALLBACK_DEL,
3926 _track_obj_view_del);
3930 _elm_widget_item_signal_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission,
3933 Elm_Widget_Item_Signal_Data *wisd = data;
3934 wisd->func(wisd->data, wisd->item, emission, source);
3938 _elm_widget_item_signal_callback_list_get(Elm_Widget_Item *item, Eina_List *position)
3940 Elm_Widget_Item_Signal_Data *wisd = eina_list_data_get(position);
3943 item->signals = eina_list_remove_list(item->signals, position);
3946 if (_elm_widget_is(item->view))
3947 elm_object_signal_callback_del(item->view,
3948 wisd->emission, wisd->source,
3949 _elm_widget_item_signal_cb);
3950 else if (!strcmp(eo_class_name_get(eo_class_get(item->view)),
3952 edje_object_signal_callback_del_full(item->view,
3953 wisd->emission, wisd->source,
3954 _elm_widget_item_signal_cb, wisd);
3956 eina_stringshare_del(wisd->emission);
3957 eina_stringshare_del(wisd->source);
3966 * Allocate a new Elm_Widget_Item-derived structure.
3968 * The goal of this structure is to provide common ground for actions
3969 * that a widget item have, such as the owner widget, callback to
3970 * notify deletion, data pointer and maybe more.
3972 * @param widget the owner widget that holds this item, must be an elm_widget!
3973 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
3974 * be used to allocate memory.
3976 * @return allocated memory that is already zeroed out, or NULL on errors.
3978 * @see elm_widget_item_new() convenience macro.
3979 * @see elm_widget_item_del() to release memory.
3982 EAPI Elm_Widget_Item *
3983 _elm_widget_item_new(Evas_Object *widget,
3986 if (!_elm_widget_is(widget))
3989 Elm_Widget_Item *item;
3991 EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
3992 EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
3994 item = calloc(1, alloc_size);
3995 EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
3997 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
3998 item->widget = widget;
4003 _elm_widget_item_free(Elm_Widget_Item *item)
4005 Elm_Translate_String_Data *ts;
4007 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4010 item->del_func((void *)item->data, item->widget, item);
4012 evas_object_del(item->view);
4014 eina_stringshare_del(item->access_info);
4016 while (item->signals)
4017 _elm_widget_item_signal_callback_list_get(item, item->signals);
4019 while (item->translate_strings)
4021 ts = EINA_INLIST_CONTAINER_GET(item->translate_strings,
4022 Elm_Translate_String_Data);
4023 eina_stringshare_del(ts->id);
4024 eina_stringshare_del(ts->domain);
4025 eina_stringshare_del(ts->string);
4026 item->translate_strings = eina_inlist_remove(item->translate_strings,
4027 item->translate_strings);
4030 eina_hash_free(item->labels);
4032 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
4039 * Releases widget item memory, calling back del_cb() if it exists.
4041 * If there is a Elm_Widget_Item::del_cb, then it will be called prior
4042 * to memory release. Note that elm_widget_item_pre_notify_del() calls
4043 * this function and then unset it, thus being useful for 2 step
4044 * cleanup whenever the del_cb may use any of the data that must be
4045 * deleted from item.
4047 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
4050 * @param item a valid #Elm_Widget_Item to be deleted.
4051 * @see elm_widget_item_del() convenience macro.
4055 _elm_widget_item_del(Elm_Widget_Item *item)
4057 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4058 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4059 item->on_deletion = EINA_TRUE;
4061 //Widget item delete callback
4062 if (item->del_pre_func)
4064 if (item->del_pre_func((Elm_Object_Item *)item))
4065 _elm_widget_item_free(item);
4068 _elm_widget_item_free(item);
4074 * Set the function to notify to widgets when item is being deleted by user.
4076 * @param item a valid #Elm_Widget_Item to be notified
4077 * @see elm_widget_item_del_pre_hook_set() convenience macro.
4081 _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item,
4082 Elm_Widget_Del_Pre_Cb func)
4084 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4085 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4086 item->del_pre_func = func;
4091 * Set the function to set the style of item
4093 * @param item a valid #Elm_Widget_Item to be notified
4094 * @see elm_widget_item_style_set_hook_set() convenience macro.
4098 _elm_widget_item_style_set_hook_set(Elm_Widget_Item *item,
4099 Elm_Widget_Style_Set_Cb func)
4101 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4102 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4103 item->style_set_func = func;
4109 * Set the function to get the style of item
4111 * @param item a valid #Elm_Widget_Item to be notified
4112 * @see elm_widget_item_style_get_hook_set() convenience macro.
4116 _elm_widget_item_style_get_hook_set(Elm_Widget_Item *item,
4117 Elm_Widget_Style_Get_Cb func)
4119 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4120 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4121 item->style_get_func = func;
4127 * Set the function to set the focus on widget item.
4129 * @param item a valid #Elm_Widget_Item to be notified
4130 * @see elm_widget_item_focus_set_hook_set() convenience macro.
4134 _elm_widget_item_focus_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Focus_Set_Cb func)
4136 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4137 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4138 item->focus_set_func = func;
4144 * Set the function to set the focus on widget item.
4146 * @param item a valid #Elm_Widget_Item to be notified
4147 * @see elm_widget_item_focus_get_hook_set() convenience macro.
4151 _elm_widget_item_focus_get_hook_set(Elm_Widget_Item *item,
4152 Elm_Widget_Focus_Get_Cb func)
4154 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4155 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4156 item->focus_get_func = func;
4162 * Notify object will be deleted without actually deleting it.
4164 * This function will callback Elm_Widget_Item::del_cb if it is set
4165 * and then unset it so it is not called twice (ie: from
4166 * elm_widget_item_del()).
4168 * @param item a valid #Elm_Widget_Item to be notified
4169 * @see elm_widget_item_pre_notify_del() convenience macro.
4173 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
4175 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4176 if (!item->del_func) return;
4177 item->del_func((void *)item->data, item->widget, item);
4178 item->del_func = NULL;
4184 * Set the function to notify when item is being deleted.
4186 * This function will complain if there was a callback set already,
4187 * however it will set the new one.
4189 * The callback will be called from elm_widget_item_pre_notify_del()
4190 * or elm_widget_item_del() will be called with:
4191 * - data: the Elm_Widget_Item::data value.
4192 * - obj: the Elm_Widget_Item::widget evas object.
4193 * - event_info: the item being deleted.
4195 * @param item a valid #Elm_Widget_Item to be notified
4196 * @see elm_widget_item_del_cb_set() convenience macro.
4200 _elm_widget_item_del_cb_set(Elm_Widget_Item *item,
4203 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4204 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4206 if ((item->del_func) && (item->del_func != func))
4207 WRN("You're replacing a previously set del_cb %p of item %p with %p",
4208 item->del_func, item, func);
4210 item->del_func = func;
4216 * Retrieves owner widget of this item.
4218 * @param item a valid #Elm_Widget_Item to get data from.
4219 * @return owner widget of this item.
4223 _elm_widget_item_widget_get(const Elm_Widget_Item *item)
4225 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4226 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4228 return item->widget;
4234 * Set user-data in this item.
4236 * User data may be used to identify this item or just store any
4237 * application data. It is automatically given as the first parameter
4238 * of the deletion notify callback.
4240 * @param item a valid #Elm_Widget_Item to store data in.
4241 * @param data user data to store.
4242 * @see elm_widget_item_del_cb_set() convenience macro.
4246 _elm_widget_item_data_set(Elm_Widget_Item *item,
4249 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4250 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4252 if ((item->data) && (item->data != data))
4253 DBG("Replacing item %p data %p with %p", item, item->data, data);
4260 * Retrieves user-data of this item.
4262 * @param item a valid #Elm_Widget_Item to get data from.
4263 * @see elm_widget_item_data_set()
4267 _elm_widget_item_data_get(const Elm_Widget_Item *item)
4269 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4270 return (void *)item->data;
4274 _elm_widget_item_disabled_set(Elm_Widget_Item *item,
4277 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4278 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4280 if (item->disabled == disabled) return;
4281 item->disabled = !!disabled;
4282 if (item->disable_func) item->disable_func(item);
4286 _elm_widget_item_disabled_get(const Elm_Widget_Item *item)
4288 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4289 return item->disabled;
4293 _elm_widget_item_style_set(Elm_Widget_Item *item, const char *style)
4295 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4296 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4297 item->style_set_func(item, style);
4301 _elm_widget_item_style_get(Elm_Widget_Item *item)
4303 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4304 return item->style_get_func(item);
4308 _elm_widget_item_disable_hook_set(Elm_Widget_Item *item,
4309 Elm_Widget_Disable_Cb func)
4311 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4312 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4313 item->disable_func = func;
4317 _elm_widget_item_focus_set(Elm_Widget_Item *item, Eina_Bool focused)
4319 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4320 item->focus_set_func(item, focused);
4324 _elm_widget_item_focus_get(const Elm_Widget_Item *item)
4326 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4327 return item->focus_get_func(item);
4331 _elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item,
4336 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4337 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4338 Elm_Translate_String_Data *ts;
4342 _part_text_translatable_set(&item->translate_strings, part, EINA_FALSE,
4347 ts = _part_text_translatable_set(&item->translate_strings, part,
4348 EINA_TRUE, EINA_FALSE);
4350 if (!ts->string) ts->string = eina_stringshare_add(label);
4351 else eina_stringshare_replace(&ts->string, label);
4352 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
4353 else eina_stringshare_replace(&ts->domain, domain);
4355 if (label[0]) label = dgettext(domain, label);
4358 item->on_translate = EINA_TRUE;
4359 _elm_widget_item_part_text_set(item, part, label);
4360 item->on_translate = EINA_FALSE;
4364 _elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item,
4367 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4368 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4370 Elm_Translate_String_Data *ts;
4371 ts = _translate_string_data_get(item->translate_strings, part);
4372 if (ts) return ts->string;
4377 _elm_widget_item_domain_part_text_translatable_set(Elm_Widget_Item *item,
4380 Eina_Bool translatable)
4382 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4383 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4384 Elm_Translate_String_Data *ts;
4387 ts = _part_text_translatable_set(&item->translate_strings, part,
4388 translatable, EINA_TRUE);
4390 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
4391 else eina_stringshare_replace(&ts->domain, domain);
4393 text = _elm_widget_item_part_text_get(item, part);
4394 if (!text || !text[0]) return;
4396 if (!ts->string) ts->string = eina_stringshare_add(text);
4398 //Try to translate text since we don't know the text is already translated.
4400 text = dgettext(domain, text);
4402 item->on_translate = EINA_TRUE;
4403 _elm_widget_item_part_text_set(item, part, text);
4404 item->on_translate = EINA_FALSE;
4408 _elm_widget_item_track_cancel(Elm_Widget_Item *item)
4410 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4411 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4413 if (!item->track_obj) return;
4415 while (evas_object_ref_get(item->track_obj) > 0)
4416 evas_object_unref(item->track_obj);
4418 evas_object_del(item->track_obj);
4422 elm_widget_item_track(Elm_Widget_Item *item)
4424 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4425 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4427 if (item->track_obj)
4429 evas_object_ref(item->track_obj);
4430 return item->track_obj;
4435 WRN("view obj of the item(%p) is invalid. Please make sure the view obj is created!", item);
4439 Evas_Object *track =
4440 evas_object_rectangle_add(evas_object_evas_get(item->widget));
4441 evas_object_color_set(track, 0, 0, 0, 0);
4442 evas_object_pass_events_set(track, EINA_TRUE);
4443 _track_obj_update(track, item->view);
4444 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
4447 evas_object_event_callback_add(item->view, EVAS_CALLBACK_RESIZE,
4448 _track_obj_view_update, track);
4449 evas_object_event_callback_add(item->view, EVAS_CALLBACK_MOVE,
4450 _track_obj_view_update, track);
4451 evas_object_event_callback_add(item->view, EVAS_CALLBACK_SHOW,
4452 _track_obj_view_update, track);
4453 evas_object_event_callback_add(item->view, EVAS_CALLBACK_HIDE,
4454 _track_obj_view_update, track);
4455 evas_object_event_callback_add(item->view, EVAS_CALLBACK_DEL,
4456 _track_obj_view_del, item);
4458 evas_object_ref(track);
4460 item->track_obj = track;
4466 elm_widget_item_untrack(Elm_Widget_Item *item)
4468 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4469 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4471 if (!item->track_obj) return;
4472 evas_object_unref(item->track_obj);
4474 if (evas_object_ref_get(item->track_obj) == 0)
4475 evas_object_del(item->track_obj);
4479 elm_widget_item_track_get(const Elm_Widget_Item *item)
4481 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
4482 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, 0);
4484 if (!item->track_obj) return 0;
4485 return evas_object_ref_get(item->track_obj);
4488 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
4490 struct _Elm_Widget_Item_Tooltip
4492 Elm_Widget_Item *item;
4493 Elm_Tooltip_Item_Content_Cb func;
4494 Evas_Smart_Cb del_cb;
4498 static Evas_Object *
4499 _elm_widget_item_tooltip_label_create(void *data,
4500 Evas_Object *obj EINA_UNUSED,
4501 Evas_Object *tooltip,
4502 void *item EINA_UNUSED)
4504 Evas_Object *label = elm_label_add(tooltip);
4507 elm_object_style_set(label, "tooltip");
4508 elm_object_text_set(label, data);
4512 static Evas_Object *
4513 _elm_widget_item_tooltip_trans_label_create(void *data,
4514 Evas_Object *obj EINA_UNUSED,
4515 Evas_Object *tooltip,
4516 void *item EINA_UNUSED)
4518 Evas_Object *label = elm_label_add(tooltip);
4521 elm_object_style_set(label, "tooltip");
4522 elm_object_translatable_text_set(label, data);
4527 _elm_widget_item_tooltip_label_del_cb(void *data,
4528 Evas_Object *obj EINA_UNUSED,
4529 void *event_info EINA_UNUSED)
4531 eina_stringshare_del(data);
4537 * Set the text to be shown in the widget item.
4539 * @param item Target item
4540 * @param text The text to set in the content
4542 * Setup the text as tooltip to object. The item can have only one tooltip,
4543 * so any previous tooltip data is removed.
4548 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item,
4551 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4552 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4553 EINA_SAFETY_ON_NULL_RETURN(text);
4555 text = eina_stringshare_add(text);
4556 _elm_widget_item_tooltip_content_cb_set
4557 (item, _elm_widget_item_tooltip_label_create, text,
4558 _elm_widget_item_tooltip_label_del_cb);
4562 _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item,
4565 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4566 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4567 EINA_SAFETY_ON_NULL_RETURN(text);
4569 text = eina_stringshare_add(text);
4570 _elm_widget_item_tooltip_content_cb_set
4571 (item, _elm_widget_item_tooltip_trans_label_create, text,
4572 _elm_widget_item_tooltip_label_del_cb);
4575 static Evas_Object *
4576 _elm_widget_item_tooltip_create(void *data,
4578 Evas_Object *tooltip)
4580 Elm_Widget_Item_Tooltip *wit = data;
4581 return wit->func((void *)wit->data, obj, tooltip, wit->item);
4585 _elm_widget_item_tooltip_del_cb(void *data,
4587 void *event_info EINA_UNUSED)
4589 Elm_Widget_Item_Tooltip *wit = data;
4590 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
4597 * Set the content to be shown in the tooltip item
4599 * Setup the tooltip to item. The item can have only one tooltip,
4600 * so any previous tooltip data is removed. @p func(with @p data) will
4601 * be called every time that need show the tooltip and it should
4602 * return a valid Evas_Object. This object is then managed fully by
4603 * tooltip system and is deleted when the tooltip is gone.
4605 * @param item the widget item being attached a tooltip.
4606 * @param func the function used to create the tooltip contents.
4607 * @param data what to provide to @a func as callback data/context.
4608 * @param del_cb called when data is not needed anymore, either when
4609 * another callback replaces @func, the tooltip is unset with
4610 * elm_widget_item_tooltip_unset() or the owner @a item
4611 * dies. This callback receives as the first parameter the
4612 * given @a data, and @c event_info is the item.
4617 _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item,
4618 Elm_Tooltip_Item_Content_Cb func,
4620 Evas_Smart_Cb del_cb)
4622 Elm_Widget_Item_Tooltip *wit;
4624 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
4625 //ELM_WIDGET_ITEM_RETURN_IF_GOTO(item, error_noitem);
4629 _elm_widget_item_tooltip_unset(item);
4633 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
4634 if (!wit) goto error;
4638 wit->del_cb = del_cb;
4640 elm_object_sub_tooltip_content_cb_set
4641 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
4642 _elm_widget_item_tooltip_del_cb);
4647 if (del_cb) del_cb((void *)data, NULL, item);
4650 if (del_cb) del_cb((void *)data, item->widget, item);
4656 * Unset tooltip from item
4658 * @param item widget item to remove previously set tooltip.
4660 * Remove tooltip from item. The callback provided as del_cb to
4661 * elm_widget_item_tooltip_content_cb_set() will be called to notify
4662 * it is not used anymore.
4664 * @see elm_widget_item_tooltip_content_cb_set()
4669 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
4671 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4672 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4674 elm_object_tooltip_unset(item->view);
4680 * Sets a different style for this item tooltip.
4682 * @note before you set a style you should define a tooltip with
4683 * elm_widget_item_tooltip_content_cb_set() or
4684 * elm_widget_item_tooltip_text_set()
4686 * @param item widget item with tooltip already set.
4687 * @param style the theme style to use (default, transparent, ...)
4692 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item,
4695 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4696 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4698 elm_object_tooltip_style_set(item->view, style);
4702 _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item,
4705 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4706 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
4708 return elm_object_tooltip_window_mode_set(item->view, disable);
4712 _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item)
4714 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4715 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
4717 return elm_object_tooltip_window_mode_get(item->view);
4723 * Get the style for this item tooltip.
4725 * @param item widget item with tooltip already set.
4726 * @return style the theme style in use, defaults to "default". If the
4727 * object does not have a tooltip set, then NULL is returned.
4732 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
4734 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4736 return elm_object_tooltip_style_get(item->view);
4740 _elm_widget_item_cursor_set(Elm_Widget_Item *item,
4743 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4744 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4746 elm_object_sub_cursor_set(item->view, item->widget, cursor);
4750 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
4752 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4753 return elm_object_cursor_get(item->view);
4757 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
4759 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4760 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4762 elm_object_cursor_unset(item->view);
4768 * Sets a different style for this item cursor.
4770 * @note before you set a style you should define a cursor with
4771 * elm_widget_item_cursor_set()
4773 * @param item widget item with cursor already set.
4774 * @param style the theme style to use (default, transparent, ...)
4779 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item,
4782 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4783 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4785 elm_object_cursor_style_set(item->view, style);
4791 * Get the style for this item cursor.
4793 * @param item widget item with cursor already set.
4794 * @return style the theme style in use, defaults to "default". If the
4795 * object does not have a cursor set, then NULL is returned.
4800 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
4802 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4803 return elm_object_cursor_style_get(item->view);
4809 * Set if the cursor set should be searched on the theme or should use
4810 * the provided by the engine, only.
4812 * @note before you set if should look on theme you should define a cursor
4813 * with elm_object_cursor_set(). By default it will only look for cursors
4814 * provided by the engine.
4816 * @param item widget item with cursor already set.
4817 * @param engine_only boolean to define it cursors should be looked only
4818 * between the provided by the engine or searched on widget's theme as well.
4823 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item,
4824 Eina_Bool engine_only)
4826 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4827 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4829 elm_object_cursor_theme_search_enabled_set(item->view, !engine_only);
4835 * Get the cursor engine only usage for this item cursor.
4837 * @param item widget item with cursor already set.
4838 * @return engine_only boolean to define it cursors should be looked only
4839 * between the provided by the engine or searched on widget's theme as well. If
4840 * the object does not have a cursor set, then EINA_FALSE is returned.
4845 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
4847 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4848 return !elm_object_cursor_theme_search_enabled_get(item->view);
4852 _elm_widget_item_part_content_set(Elm_Widget_Item *item,
4854 Evas_Object *content)
4856 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4857 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4858 if (!item->content_set_func)
4860 ERR("%s does not support elm_object_item_part_content_set() API.",
4861 elm_widget_type_get(item->widget));
4864 item->content_set_func((Elm_Object_Item *)item, part, content);
4868 _elm_widget_item_part_content_get(const Elm_Widget_Item *item,
4871 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4872 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4873 if (!item->content_get_func)
4875 ERR("%s does not support elm_object_item_part_content_get() API.",
4876 elm_widget_type_get(item->widget));
4879 return item->content_get_func((Elm_Object_Item *)item, part);
4883 _elm_widget_item_part_content_unset(Elm_Widget_Item *item,
4886 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4887 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4888 if (!item->content_unset_func)
4890 ERR("%s does not support elm_object_item_part_content_unset() API.",
4891 elm_widget_type_get(item->widget));
4894 return item->content_unset_func((Elm_Object_Item *)item, part);
4898 _elm_widget_item_part_text_set(Elm_Widget_Item *item,
4902 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4903 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4904 if (!item->text_set_func)
4906 ERR("%s does not support elm_object_item_part_text_set() API.",
4907 elm_widget_type_get(item->widget));
4910 item->text_set_func((Elm_Object_Item *)item, part, label);
4914 _elm_widget_item_part_text_get(const Elm_Widget_Item *item,
4917 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4918 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4919 if (!item->text_get_func)
4921 ERR("%s does not support elm_object_item_part_text_get() API.",
4922 elm_widget_type_get(item->widget));
4925 return item->text_get_func((Elm_Object_Item *)item, part);
4929 _elm_widget_item_part_text_custom_free(void *data)
4931 Elm_Label_Data *label;
4933 eina_stringshare_del(label->part);
4934 eina_stringshare_del(label->text);
4939 _elm_widget_item_part_text_custom_set(Elm_Widget_Item *item,
4943 Elm_Label_Data *label;
4944 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4945 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4947 if (!item->text_get_func)
4949 ERR("%s does not support elm_object_item_part_text_get() API.",
4950 elm_widget_type_get(item->widget));
4955 eina_hash_stringshared_new(_elm_widget_item_part_text_custom_free);
4956 label = eina_hash_find(item->labels, part);
4959 label = malloc(sizeof(Elm_Label_Data));
4960 label->part = eina_stringshare_add(part);
4961 label->text = eina_stringshare_add(text);
4962 eina_hash_add(item->labels, part, label);
4965 eina_stringshare_replace(&label->text, text);
4969 _elm_widget_item_part_text_custom_get(Elm_Widget_Item *item,
4972 Elm_Label_Data *label;
4973 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4974 label = eina_hash_find(item->labels, part);
4975 return label ? label->text : NULL;
4979 _elm_widget_item_part_text_custom_foreach(const Eina_Hash *labels EINA_UNUSED,
4980 const void *key EINA_UNUSED,
4984 Elm_Label_Data *label;
4985 Elm_Widget_Item *item;
4988 item->text_set_func((Elm_Object_Item *)item, label->part, label->text);
4993 _elm_widget_item_part_text_custom_update(Elm_Widget_Item *item)
4995 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4996 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4998 eina_hash_foreach(item->labels,
4999 _elm_widget_item_part_text_custom_foreach, item);
5003 _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item,
5004 Elm_Widget_Content_Set_Cb func)
5006 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5007 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5009 item->content_set_func = func;
5013 _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item,
5014 Elm_Widget_Content_Get_Cb func)
5016 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5017 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5019 item->content_get_func = func;
5023 _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item,
5024 Elm_Widget_Content_Unset_Cb func)
5026 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5027 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5029 item->content_unset_func = func;
5033 _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item,
5034 Elm_Widget_Text_Set_Cb func)
5036 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5037 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5039 item->text_set_func = func;
5043 _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item,
5044 Elm_Widget_Text_Get_Cb func)
5046 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5047 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5049 item->text_get_func = func;
5053 _elm_widget_item_signal_emit(Elm_Widget_Item *item,
5054 const char *emission,
5057 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5058 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5060 if (item->signal_emit_func)
5061 item->signal_emit_func((Elm_Object_Item *)item, emission, source);
5065 _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *item,
5066 Elm_Widget_Signal_Emit_Cb func)
5068 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5069 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5071 item->signal_emit_func = func;
5075 _elm_widget_item_signal_callback_add(Elm_Widget_Item *item,
5076 const char *emission,
5078 Elm_Widget_Item_Signal_Cb func,
5081 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5082 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5083 EINA_SAFETY_ON_NULL_RETURN(func);
5085 Elm_Widget_Item_Signal_Data *wisd;
5087 wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
5093 wisd->emission = eina_stringshare_add(emission);
5094 wisd->source = eina_stringshare_add(source);
5096 if (_elm_widget_is(item->view))
5097 elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5098 else if (!strcmp(eo_class_name_get(eo_class_get(item->view)), "edje"))
5099 edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5102 WRN("The %s widget item doesn't support signal callback add!",
5103 eo_class_name_get(eo_class_get(item->widget)));
5108 item->signals = eina_list_append(item->signals, wisd);
5112 _elm_widget_item_signal_callback_del(Elm_Widget_Item *item,
5113 const char *emission,
5115 Elm_Widget_Item_Signal_Cb func)
5117 Elm_Widget_Item_Signal_Data *wisd;
5120 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5121 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5122 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
5124 EINA_LIST_FOREACH(item->signals, l, wisd)
5126 if ((wisd->func == func) &&
5127 !strcmp(wisd->emission, emission) &&
5128 !strcmp(wisd->source, source))
5129 return _elm_widget_item_signal_callback_list_get(item, l);
5136 _elm_widget_item_access_info_set(Elm_Widget_Item *item,
5139 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5140 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5142 eina_stringshare_del(item->access_info);
5143 if (!txt) item->access_info = NULL;
5144 else item->access_info = eina_stringshare_add(txt);
5148 _elm_widget_item_translate(Elm_Widget_Item *item)
5150 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5151 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5154 Elm_Translate_String_Data *ts;
5155 EINA_INLIST_FOREACH(item->translate_strings, ts)
5157 if (!ts->string) continue;
5158 const char *s = dgettext(ts->domain, ts->string);
5159 item->on_translate = EINA_TRUE;
5160 _elm_widget_item_part_text_set(item, ts->id, s);
5161 item->on_translate = EINA_FALSE;
5166 /* happy debug functions */
5169 _sub_obj_tree_dump(const Evas_Object *obj,
5174 for (i = 0; i < lvl * 3; i++)
5177 if (_elm_widget_is(obj))
5182 elm_widget_type_get(obj),
5184 EINA_LIST_FOREACH(sd->subobjs, l, obj)
5185 _sub_obj_tree_dump(obj, lvl + 1);
5188 DBG("+ %s(%p)\n", evas_object_type_get(obj), obj);
5192 _sub_obj_tree_dot_dump(const Evas_Object *obj,
5195 if (!_elm_widget_is(obj))
5199 Eina_Bool visible = evas_object_visible_get(obj);
5200 Eina_Bool disabled = elm_widget_disabled_get(obj);
5201 Eina_Bool focused = elm_widget_focus_get(obj);
5202 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
5206 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
5209 fprintf(output, ", style=bold");
5212 fprintf(output, ", color=gray28");
5214 fprintf(output, " ];\n");
5217 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
5218 "disabled: %d|focused: %d/%d|focus order:%d}\"",
5219 obj, obj, elm_widget_type_get(obj),
5220 evas_object_name_get(obj), visible, disabled, focused, can_focus,
5224 fprintf(output, ", style=bold");
5227 fprintf(output, ", fontcolor=gray28");
5229 if ((disabled) || (!visible))
5230 fprintf(output, ", color=gray");
5232 fprintf(output, " ];\n");
5236 EINA_LIST_FOREACH(sd->subobjs, l, o)
5237 _sub_obj_tree_dot_dump(o, output);
5243 elm_widget_tree_dump(const Evas_Object *top)
5246 if (!_elm_widget_is(top))
5248 _sub_obj_tree_dump(top, 0);
5256 elm_widget_tree_dot_dump(const Evas_Object *top,
5260 if (!_elm_widget_is(top))
5262 fprintf(output, "graph " " { node [shape=record];\n");
5263 _sub_obj_tree_dot_dump(top, output);
5264 fprintf(output, "}\n");
5273 _atspi_obj_create(void *data)
5275 Elm_Atspi_Object *parent = NULL;
5276 Elm_Atspi_Object *obj = _elm_atspi_factory_construct(data);
5279 eo_do(obj, elm_atspi_obj_parent_get(&parent));
5280 eo_do(parent, eo_event_callback_call(ELM_ATSPI_OBJECT_EVENT_CHILD_ADDED, obj, NULL));
5286 _elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd)
5290 sd->on_create = EINA_TRUE;
5291 eo_do_super(obj, MY_CLASS, eo_constructor());
5293 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
5294 eo_parent_get(&parent));
5295 eo_do(obj, elm_obj_widget_parent_set(parent));
5296 sd->on_create = EINA_FALSE;
5298 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
5299 ecore_idle_enterer_add(_atspi_obj_create, obj);
5302 EOLIAN static Eina_Bool
5303 _elm_widget_on_focus(Eo *obj, Elm_Widget_Smart_Data *sd)
5305 if (elm_widget_can_focus_get(obj))
5307 if (elm_widget_focus_get(obj))
5309 if (!sd->resize_obj)
5310 evas_object_focus_set(obj, EINA_TRUE);
5311 evas_object_smart_callback_call(obj, SIG_WIDGET_FOCUSED, NULL);
5315 if (!sd->resize_obj)
5316 evas_object_focus_set(obj, EINA_FALSE);
5317 evas_object_smart_callback_call(obj, SIG_WIDGET_UNFOCUSED, NULL);
5326 EOLIAN static Eina_Bool
5327 _elm_widget_disable(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
5332 EOLIAN static Eina_Bool
5333 _elm_widget_event(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *source EINA_UNUSED, Evas_Callback_Type type EINA_UNUSED, void *event_info EINA_UNUSED)
5338 EOLIAN static Eina_Bool
5339 _elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
5341 WRN("The %s widget does not implement the \"focus_next/focus_next_manager_is\" functions.",
5342 eo_class_name_get(eo_class_get(obj)));
5347 _elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
5349 WRN("The %s widget does not implement the \"focus_direction/focus_direction_manager_is\" functions.",
5350 eo_class_name_get(eo_class_get(obj)));
5354 EOLIAN static Eina_Bool
5355 _elm_widget_activate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Activate act EINA_UNUSED)
5357 WRN("The %s widget does not implement the \"activate\" functions.",
5358 eo_class_name_get(eo_class_get(obj)));
5363 _elm_widget_class_constructor(Eo_Class *klass)
5365 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
5368 #include "elm_widget.eo.c"