2 # include "elementary_config.h"
5 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6 #define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
7 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
8 #define ELM_WIDGET_ITEM_PROTECTED
9 #include <Elementary.h>
12 #include "elm_widget_container.h"
13 #include "elm_interface_scrollable.h"
15 #define MY_CLASS ELM_WIDGET_CLASS
17 #define MY_CLASS_NAME "Elm_Widget"
18 #define MY_CLASS_NAME_LEGACY "elm_widget"
20 #define ELM_WIDGET_DATA_GET(o, wd) \
21 Elm_Widget_Smart_Data *wd = eo_data_scope_get(o, MY_CLASS)
24 ELM_WIDGET_DATA_GET(obj, sd); \
25 if ((!sd) || (!_elm_widget_is(obj)))
26 #define INTERNAL_ENTRY \
27 ELM_WIDGET_DATA_GET(obj, sd); \
30 #define ELM_WIDGET_FOCUS_GET(obj) \
31 (eo_isa(obj, ELM_WIDGET_CLASS) && \
32 ((_elm_access_auto_highlight_get()) ? (elm_widget_highlight_get(obj)) : \
33 (elm_widget_focus_get(obj))))
35 const char SIG_WIDGET_FOCUSED[] = "focused";
36 const char SIG_WIDGET_UNFOCUSED[] = "unfocused";
37 const char SIG_WIDGET_LANG_CHANGED[] = "language,changed";
38 const char SIG_WIDGET_ACCESS_CHANGED[] = "access,changed";
40 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
41 const char SIG_WIDGET_ATSPI_HIGHLIGHTED[] = "atspi,highlighted";
42 const char SIG_WIDGET_ATSPI_UNHIGHLIGHTED[] = "atspi,unhighlighted";
45 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
46 typedef struct _Elm_Label_Data Elm_Label_Data;
47 typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
49 struct _Elm_Event_Cb_Data
55 struct _Elm_Label_Data
61 struct _Elm_Translate_String_Data
65 Eina_Stringshare *domain;
66 Eina_Stringshare *string;
70 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
72 _elm_widget_evas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir);
75 /* local subsystem globals */
76 static unsigned int focus_order = 0;
78 static inline Eina_Bool
79 _elm_widget_is(const Evas_Object *obj)
81 return eo_isa(obj, MY_CLASS);
84 static inline Eina_Bool
85 _is_focusable(Evas_Object *obj)
87 API_ENTRY return EINA_FALSE;
88 return sd->can_focus || (sd->child_can_focus);
91 static inline Eina_Bool
92 _is_focused(Evas_Object *obj)
94 API_ENTRY return EINA_FALSE;
98 static inline Eina_Bool
99 _elm_scrollable_is(const Evas_Object *obj)
101 INTERNAL_ENTRY EINA_FALSE;
103 eo_isa(obj, ELM_INTERFACE_SCROLLABLE_MIXIN);
107 elm_widget_disabled_internal(Eo *obj, Eina_Bool disabled);
109 _on_sub_obj_del(void *data,
111 const Eo_Event_Description *desc,
114 _on_sub_obj_hide(void *data,
116 const Eo_Event_Description *desc,
119 _propagate_event(void *data,
121 const Eo_Event_Description *desc,
124 EO_CALLBACKS_ARRAY_DEFINE(elm_widget_subitems_callbacks,
125 { EVAS_OBJECT_EVENT_DEL, _on_sub_obj_del },
126 { EVAS_OBJECT_EVENT_HIDE, _on_sub_obj_hide });
127 EO_CALLBACKS_ARRAY_DEFINE(efl_subitems_callbacks,
128 { EVAS_OBJECT_EVENT_DEL, _on_sub_obj_del });
129 EO_CALLBACKS_ARRAY_DEFINE(focus_callbacks,
130 { EVAS_OBJECT_EVENT_KEY_DOWN, _propagate_event },
131 { EVAS_OBJECT_EVENT_KEY_UP, _propagate_event },
132 { EVAS_OBJECT_EVENT_MOUSE_WHEEL, _propagate_event });
135 _callbacks_add(Eo *widget, void *data)
137 if (_elm_widget_is(widget))
140 eo_event_callback_array_add(elm_widget_subitems_callbacks(), data));
145 eo_event_callback_array_add(efl_subitems_callbacks(), data));
150 _callbacks_del(Eo *widget, void *data)
152 if (_elm_widget_is(widget))
155 eo_event_callback_array_del(elm_widget_subitems_callbacks(), data));
160 eo_event_callback_array_del(efl_subitems_callbacks(), data));
165 _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *eo_it)
170 if (eo_isa(eo_it, ELM_WIDGET_ITEM_CLASS))
172 Elm_Widget_Item_Data *it = eo_data_scope_get(eo_it, ELM_WIDGET_ITEM_CLASS);
174 if (eo_isa(it->view, ELM_LAYOUT_CLASS))
175 str = edje_object_data_get(elm_layout_edje_get(it->view), "focus_highlight");
177 str = edje_object_data_get(it->view, "focus_highlight");
180 str = edje_object_data_get(((Elm_Widget_Item_Data *)eo_it)->view, "focus_highlight");
181 if ((str) && (!strcmp(str, "on")))
182 elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
184 elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
188 _elm_widget_focus_highlight_start(const Evas_Object *obj)
190 Evas_Object *top = elm_widget_top_get(obj);
192 if (top && eo_isa(top, ELM_WIN_CLASS))
193 _elm_win_focus_highlight_start(top);
197 _elm_widget_focus_highlight_object_get(const Evas_Object *obj)
199 Evas_Object *top = elm_widget_top_get(obj);
201 if (top && eo_isa(top, ELM_WIN_CLASS))
202 return _elm_win_focus_highlight_object_get(top);
207 elm_widget_focus_highlight_enabled_get(const Evas_Object *obj)
209 const Evas_Object *win = elm_widget_top_get(obj);
211 if (win && eo_isa(win, ELM_WIN_CLASS))
212 return elm_win_focus_highlight_enabled_get(win);
219 * Resets the mirrored mode from the system mirror mode for widgets that are in
220 * automatic mirroring mode. This function does not call elm_widget_theme.
222 * @param obj The widget.
223 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
226 _elm_widget_mirrored_reload(Evas_Object *obj)
229 Eina_Bool mirrored = elm_config_mirrored_get();
231 if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
233 sd->is_mirrored = mirrored;
237 EOLIAN static Eina_Bool
238 _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)
240 WRN("The %s widget does not implement the \"on_focus_region\" function.",
241 eo_class_name_get(eo_class_get(obj)));
247 _parents_focus(Evas_Object *obj)
249 for (; obj; obj = elm_widget_parent_get(obj))
252 if (sd->focused) return;
258 _parents_unfocus(Evas_Object *obj)
260 for (; obj; obj = elm_widget_parent_get(obj))
263 if (!sd->focused) return;
269 _on_sub_obj_hide(void *data EINA_UNUSED,
271 const Eo_Event_Description *desc EINA_UNUSED,
272 void *event_info EINA_UNUSED)
274 elm_widget_focus_hide_handle(obj);
275 return EO_CALLBACK_CONTINUE;
279 _on_sub_obj_del(void *data,
281 const Eo_Event_Description *desc EINA_UNUSED,
282 void *event_info EINA_UNUSED)
284 ELM_WIDGET_DATA_GET(data, sd);
286 if (_elm_widget_is(obj))
288 if (_is_focused((Eo *)obj)) _parents_unfocus(sd->obj);
290 if (obj == sd->resize_obj)
292 /* already dels sub object */
293 elm_widget_resize_object_set(sd->obj, NULL, EINA_TRUE);
295 else if (obj == sd->hover_obj)
297 sd->hover_obj = NULL;
301 if (!elm_widget_sub_object_del(sd->obj, obj))
302 ERR("failed to remove sub object %p from %p\n", obj, sd->obj);
305 return EO_CALLBACK_CONTINUE;
308 static const Evas_Smart_Cb_Description _smart_callbacks[] =
310 {SIG_WIDGET_FOCUSED, ""},
311 {SIG_WIDGET_UNFOCUSED, ""},
312 {SIG_WIDGET_LANG_CHANGED, ""},
313 {SIG_WIDGET_ACCESS_CHANGED, ""},
314 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
315 {SIG_WIDGET_ATSPI_HIGHLIGHTED, ""},
316 {SIG_WIDGET_ATSPI_UNHIGHLIGHTED, ""},
322 _obj_mouse_down(void *data,
324 Evas_Object *obj EINA_UNUSED,
329 ELM_WIDGET_DATA_GET(data, sd);
330 Evas_Event_Mouse_Down *ev = event_info;
331 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
333 top = elm_widget_top_get(data);
334 if (top && eo_isa(top, ELM_WIN_CLASS)) _elm_win_focus_auto_hide(top);
335 sd->still_in = EINA_TRUE;
339 _obj_mouse_move(void *data,
344 ELM_WIDGET_DATA_GET(data, sd);
345 Evas_Event_Mouse_Move *ev = event_info;
346 if (!sd->still_in) return;
348 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
349 sd->still_in = EINA_FALSE;
352 Evas_Coord x, y, w, h;
353 evas_object_geometry_get(obj, &x, &y, &w, &h);
354 if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y))
355 sd->still_in = EINA_FALSE;
360 _obj_mouse_up(void *data,
363 void *event_info EINA_UNUSED)
365 ELM_WIDGET_DATA_GET(data, sd);
367 (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
368 elm_widget_focus_mouse_up_handle(obj);
370 sd->still_in = EINA_FALSE;
374 _obj_mouse_in(void *data,
377 void *event_info EINA_UNUSED)
379 ELM_WIDGET_DATA_GET(data, sd);
380 if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
381 elm_widget_focus_mouse_up_handle(obj);
385 _elm_widget_evas_object_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
389 priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale
391 priv->focus_move_policy_auto_mode = EINA_TRUE;
392 priv->focus_region_show_mode = ELM_FOCUS_REGION_SHOW_WIDGET;
393 elm_widget_can_focus_set(obj, EINA_TRUE);
394 priv->is_mirrored = elm_config_mirrored_get();
395 priv->focus_move_policy = _elm_config->focus_move_policy;
397 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
398 _obj_mouse_down, obj);
399 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
400 _obj_mouse_move, obj);
401 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
403 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_IN,
405 /* just a helper for inheriting classes */
406 if (priv->resize_obj)
408 Evas_Object *r_obj = priv->resize_obj;
409 priv->resize_obj = NULL;
411 elm_widget_resize_object_set(obj, r_obj, EINA_TRUE);
416 _if_focused_revert(Evas_Object *obj,
417 Eina_Bool can_focus_only)
420 Evas_Object *newest = NULL;
421 unsigned int newest_focus_order = 0;
425 if (!sd->focused) return;
426 if (!sd->parent_obj) return;
428 top = elm_widget_top_get(sd->parent_obj);
431 newest = elm_widget_newest_focus_order_get
432 (top, &newest_focus_order, can_focus_only);
437 ELM_WIDGET_DATA_GET(newest, sd2);
440 if (!_is_focused(newest))
441 elm_widget_focus_steal(newest, NULL);
444 if (sd2->resize_obj && _is_focused(sd2->resize_obj))
445 elm_widget_focused_object_clear(sd2->resize_obj);
450 EINA_LIST_FOREACH(sd2->subobjs, l, child)
452 if (_is_focused(child))
454 elm_widget_focused_object_clear(child);
460 evas_object_focus_set(newest, EINA_TRUE);
464 elm_object_focus_set(newest, EINA_FALSE);
465 elm_object_focus_set(newest, EINA_TRUE);
472 _elm_widget_evas_object_smart_del(Eo *obj, Elm_Widget_Smart_Data *sd)
475 Elm_Translate_String_Data *ts;
476 Elm_Event_Cb_Data *ecb;
480 /* detach it from us */
481 _callbacks_del(sd->hover_obj, obj);
482 sd->hover_obj = NULL;
487 sobj = eina_list_data_get(sd->subobjs);
489 /* let the objects clean-up themselves and get rid of this list */
490 if (!elm_widget_sub_object_del(obj, sobj))
492 ERR("failed to remove sub object %p from %p\n", sobj, obj);
493 sd->subobjs = eina_list_remove_list
494 (sd->subobjs, sd->subobjs);
496 evas_object_del(sobj);
498 sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
499 sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
500 while (sd->translate_strings)
502 ts = EINA_INLIST_CONTAINER_GET(sd->translate_strings,
503 Elm_Translate_String_Data);
504 eina_stringshare_del(ts->id);
505 eina_stringshare_del(ts->domain);
506 eina_stringshare_del(ts->string);
507 sd->translate_strings = eina_inlist_remove(sd->translate_strings,
508 sd->translate_strings);
512 EINA_LIST_FREE(sd->event_cb, ecb)
515 eina_stringshare_del(sd->style);
516 if (sd->theme) elm_theme_free(sd->theme);
517 _if_focused_revert(obj, EINA_TRUE);
518 elm_widget_focus_custom_chain_unset(obj);
519 eina_stringshare_del(sd->access_info);
520 eina_stringshare_del(sd->accessible_name);
521 evas_object_smart_data_set(obj, NULL);
525 _smart_reconfigure(Elm_Widget_Smart_Data *sd)
529 evas_object_move(sd->resize_obj, sd->x, sd->y);
530 evas_object_resize(sd->resize_obj, sd->w, sd->h);
534 evas_object_move(sd->hover_obj, sd->x, sd->y);
535 evas_object_resize(sd->hover_obj, sd->w, sd->h);
540 _elm_widget_evas_object_smart_move(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord x, Evas_Coord y)
545 _smart_reconfigure(sd);
549 _elm_widget_evas_object_smart_resize(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord w, Evas_Coord h)
554 _smart_reconfigure(sd);
558 _elm_widget_evas_object_smart_show(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
563 if (_elm_atspi_enabled())
566 eo_do(obj, parent = elm_interface_atspi_accessible_parent_get());
567 if (parent) elm_interface_atspi_accessible_children_changed_added_signal_emit(parent, obj);
570 it = evas_object_smart_iterator_new(obj);
571 EINA_ITERATOR_FOREACH(it, o)
573 if (evas_object_data_get(o, "_elm_leaveme")) continue;
576 eina_iterator_free(it);
578 if (_elm_atspi_enabled())
580 elm_interface_atspi_accessible_added(obj);
581 if (_elm_widget_onscreen_is(obj))
582 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_SHOWING, EINA_TRUE);
587 _elm_widget_evas_object_smart_hide(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
592 it = evas_object_smart_iterator_new(obj);
593 EINA_ITERATOR_FOREACH(it, o)
595 if (evas_object_data_get(o, "_elm_leaveme")) continue;
598 eina_iterator_free(it);
600 if (_elm_atspi_enabled())
601 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_SHOWING, EINA_FALSE);
605 _elm_widget_evas_object_smart_color_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, int r, int g, int b, int a)
610 it = evas_object_smart_iterator_new(obj);
611 EINA_ITERATOR_FOREACH(it, o)
613 if (evas_object_data_get(o, "_elm_leaveme")) continue;
614 evas_object_color_set(o, r, g, b, a);
616 eina_iterator_free(it);
620 _elm_widget_evas_object_smart_clip_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *clip)
625 it = evas_object_smart_iterator_new(obj);
626 EINA_ITERATOR_FOREACH(it, o)
628 if (evas_object_data_get(o, "_elm_leaveme")) continue;
629 evas_object_clip_set(o, clip);
631 eina_iterator_free(it);
635 _elm_widget_evas_object_smart_clip_unset(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
640 it = evas_object_smart_iterator_new(obj);
641 EINA_ITERATOR_FOREACH(it, o)
643 if (evas_object_data_get(o, "_elm_leaveme")) continue;
644 evas_object_clip_unset(o);
646 eina_iterator_free(it);
650 _elm_widget_evas_object_smart_calculate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
652 /* a NO-OP, on the base */
656 _elm_widget_evas_object_smart_member_add(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *child)
659 eo_do_super(obj, MY_CLASS, evas_obj_smart_member_add(child));
661 if (evas_object_data_get(child, "_elm_leaveme")) return;
663 evas_object_color_get(obj, &r, &g, &b, &a);
664 evas_object_color_set(child, r, g, b, a);
666 evas_object_clip_set(child, evas_object_clip_get(obj));
668 if (evas_object_visible_get(obj))
669 evas_object_show(child);
671 evas_object_hide(child);
675 _elm_widget_evas_object_smart_member_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *child)
677 if (!evas_object_data_get(child, "_elm_leaveme"))
678 evas_object_clip_unset(child);
679 eo_do_super(obj, MY_CLASS, evas_obj_smart_member_del(child));
686 * Check if the widget has its own focus next function.
688 * @param obj The widget.
689 * @return focus next function is implemented/unimplemented.
690 * (@c EINA_TRUE = implemented/@c EINA_FALSE = unimplemented.)
692 static inline Eina_Bool
693 _elm_widget_focus_chain_manager_is(const Evas_Object *obj)
695 ELM_WIDGET_CHECK(obj) EINA_FALSE;
697 Eina_Bool manager_is = EINA_FALSE;
698 eo_do((Eo *)obj, manager_is = elm_obj_widget_focus_next_manager_is());
702 static inline Eina_Bool
703 _internal_elm_widget_focus_direction_manager_is(const Evas_Object *obj)
705 ELM_WIDGET_CHECK(obj) EINA_FALSE;
707 Eina_Bool manager_is = EINA_FALSE;
708 eo_do((Eo *)obj, manager_is = elm_obj_widget_focus_direction_manager_is());
713 _propagate_x_drag_lock(Evas_Object *obj,
719 ELM_WIDGET_DATA_GET(sd->parent_obj, sd2);
722 sd2->child_drag_x_locked += dir;
723 _propagate_x_drag_lock(sd->parent_obj, dir);
729 _propagate_y_drag_lock(Evas_Object *obj,
735 ELM_WIDGET_DATA_GET(sd->parent_obj, sd2);
738 sd2->child_drag_y_locked += dir;
739 _propagate_y_drag_lock(sd->parent_obj, dir);
745 _propagate_event(void *data EINA_UNUSED,
747 const Eo_Event_Description *desc,
750 INTERNAL_ENTRY EO_CALLBACK_CONTINUE;
751 Evas_Callback_Type type;
752 Evas_Event_Flags *event_flags = NULL;
754 if (desc == EVAS_OBJECT_EVENT_KEY_DOWN)
756 Evas_Event_Key_Down *ev = event_info;
757 event_flags = &(ev->event_flags);
758 type = EVAS_CALLBACK_KEY_DOWN;
760 else if (desc == EVAS_OBJECT_EVENT_KEY_UP)
762 Evas_Event_Key_Up *ev = event_info;
763 event_flags = &(ev->event_flags);
764 type = EVAS_CALLBACK_KEY_UP;
766 else if (desc == EVAS_OBJECT_EVENT_MOUSE_WHEEL)
768 Evas_Event_Mouse_Wheel *ev = event_info;
769 event_flags = &(ev->event_flags);
770 type = EVAS_CALLBACK_MOUSE_WHEEL;
773 return EO_CALLBACK_CONTINUE;
775 elm_widget_event_propagate(obj, type, event_info, event_flags);
777 return EO_CALLBACK_CONTINUE;
783 * If elm_widget_focus_region_get() returns EINA_FALSE, this function will
784 * ignore region show action.
787 _elm_widget_focus_region_show(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
789 Evas_Coord x, y, w, h, ox, oy;
792 o = elm_widget_parent_get(obj);
795 if (!elm_widget_focus_region_get(obj, &x, &y, &w, &h))
798 evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
803 evas_object_geometry_get(o, &px, &py, NULL, NULL);
805 if (_elm_scrollable_is(o) && !elm_widget_disabled_get(o))
808 eo_do(o, elm_interface_scrollable_content_region_get(&sx, &sy, NULL, NULL));
810 // Get the object's on_focus_region position relative to the scroller.
812 rx = ox + x - px + sx;
813 ry = oy + y - py + sy;
815 switch (_elm_config->focus_autoscroll_mode)
817 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
818 eo_do(o, elm_interface_scrollable_content_region_show(rx, ry, w, h));
820 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
821 eo_do(o, elm_interface_scrollable_region_bring_in(rx, ry, w, h));
827 elm_widget_focus_region_get(o, &x, &y, &w, &h);
828 evas_object_geometry_get(o, &ox, &oy, NULL, NULL);
837 o = elm_widget_parent_get(o);
841 EOLIAN static Eina_Bool
842 _elm_widget_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *style)
844 if (eina_stringshare_replace(&sd->focus_highlight_style, style)) return EINA_TRUE;
848 EOLIAN static const char*
849 _elm_widget_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
851 return sd->focus_highlight_style;
855 _parent_focus(Evas_Object *obj, Elm_Object_Item *item)
859 if (sd->focused) return;
861 Evas_Object *o = elm_widget_parent_get(obj);
862 sd->focus_order_on_calc = EINA_TRUE;
864 if (o) _parent_focus(o, item);
866 if (!sd->focus_order_on_calc)
867 return; /* we don't want to override it if by means of any of the
868 callbacks below one gets to calculate our order
872 sd->focus_order = focus_order;
873 sd->focused = EINA_TRUE;
875 if (sd->top_win_focused)
876 eo_do(obj, elm_obj_widget_on_focus(item));
877 sd->focus_order_on_calc = EINA_FALSE;
879 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
880 _elm_access_highlight_set(obj);
884 _elm_object_focus_chain_del_cb(void *data,
887 void *event_info EINA_UNUSED)
889 ELM_WIDGET_DATA_GET(data, sd);
891 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
895 _elm_widget_parent_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED)
900 elm_widget_api_check(int ver)
902 if (ver != ELM_INTERNAL_API_VERSION)
904 CRI("Elementary widget api versions do not match");
911 elm_widget_access(Evas_Object *obj,
916 Eina_Bool ret = EINA_TRUE;
918 API_ENTRY return EINA_FALSE;
919 EINA_LIST_FOREACH(sd->subobjs, l, child)
921 if (elm_widget_is(child))
922 ret &= elm_widget_access(child, is_access);
925 eo_do(obj, elm_obj_widget_access(is_access));
926 eo_do(obj, eo_event_callback_call(ELM_WIDGET_EVENT_ACCESS_CHANGED, NULL));
931 //TIZEN_ONLY(20160822): When atspi mode is dynamically switched on/off,
932 //register/unregister access objects accordingly.
934 elm_widget_atspi(Evas_Object *obj,
939 Eina_Bool ret = EINA_TRUE;
941 API_ENTRY return EINA_FALSE;
942 EINA_LIST_FOREACH(sd->subobjs, l, child)
944 if (elm_widget_is(child))
945 ret &= elm_widget_atspi(child, is_atspi);
947 eo_do(obj, elm_obj_widget_atspi(is_atspi));
953 _elm_widget_atspi(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool is_atspi EINA_UNUSED)
959 _elm_widget_access(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool is_access EINA_UNUSED)
964 elm_widget_theme(Evas_Object *obj)
970 Elm_Theme_Apply ret = ELM_THEME_APPLY_SUCCESS;
972 API_ENTRY return ELM_THEME_APPLY_FAILED;
974 EINA_LIST_FOREACH(sd->subobjs, l, child)
975 if (_elm_widget_is(child))
976 ret &= elm_widget_theme(child);
978 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
980 EINA_LIST_FOREACH(sd->tooltips, l, tt)
981 elm_tooltip_theme(tt);
982 EINA_LIST_FOREACH(sd->cursors, l, cur)
983 elm_cursor_theme(cur);
985 Elm_Theme_Apply ret2 = ELM_THEME_APPLY_FAILED;
986 eo_do(obj, ret2 = elm_obj_widget_theme_apply());
993 elm_widget_theme_specific(Evas_Object *obj,
1001 Elm_Theme *th2, *thdef;
1005 thdef = elm_theme_default_get();
1006 if (!th) th = thdef;
1010 if (!th2) th2 = thdef;
1018 if (th2 == thdef) break;
1019 th2 = th2->ref_theme;
1020 if (!th2) th2 = thdef;
1024 EINA_LIST_FOREACH(sd->subobjs, l, child)
1026 if (elm_widget_is(child))
1027 elm_widget_theme_specific(child, th, force);
1029 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
1030 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1031 elm_tooltip_theme(tt);
1032 EINA_LIST_FOREACH(sd->cursors, l, cur)
1033 elm_cursor_theme(cur);
1034 eo_do(obj, elm_obj_widget_theme_apply());
1037 EOLIAN static Elm_Theme_Apply
1038 _elm_widget_theme_apply(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
1040 _elm_widget_mirrored_reload(obj);
1041 if (elm_widget_disabled_get(obj))
1042 elm_widget_disabled_internal(obj, elm_widget_disabled_get(obj));
1044 return ELM_THEME_APPLY_SUCCESS;
1050 * Returns the widget's mirrored mode.
1052 * @param obj The widget.
1053 * @return mirrored mode of the object.
1056 EOLIAN static Eina_Bool
1057 _elm_widget_mirrored_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1059 return sd->is_mirrored;
1065 * Sets the widget's mirrored mode.
1067 * @param obj The widget.
1068 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
1071 _elm_widget_mirrored_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool mirrored)
1073 mirrored = !!mirrored;
1075 if (sd->is_mirrored == mirrored) return;
1077 sd->is_mirrored = mirrored;
1078 elm_widget_theme(obj);
1082 * Returns the widget's mirrored mode setting.
1084 * @param obj The widget.
1085 * @return mirrored mode setting of the object.
1088 EOLIAN static Eina_Bool
1089 _elm_widget_mirrored_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1091 return sd->mirrored_auto_mode;
1097 * Sets the widget's mirrored mode setting.
1098 * When widget in automatic mode, it follows the system mirrored mode set by
1099 * elm_mirrored_set().
1100 * @param obj The widget.
1101 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
1104 _elm_widget_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic)
1106 if (sd->mirrored_auto_mode != automatic)
1108 sd->mirrored_auto_mode = automatic;
1112 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
1118 _elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, region_hook_func_type func, void *data)
1120 sd->on_show_region = func;
1121 sd->on_show_region_data = data;
1127 * Add myself as a sub object of parent object
1129 * @see elm_widget_sub_object_add()
1132 elm_widget_sub_object_parent_add(Evas_Object *sobj)
1134 Eina_Bool ret = EINA_FALSE;
1137 eo_do(sobj, parent = eo_parent_get());
1138 if (!eo_isa(parent, ELM_WIDGET_CLASS))
1140 ERR("You passed a wrong parent parameter (%p %s). "
1141 "Elementary widget's parent should be an elementary widget.", parent, evas_object_type_get(parent));
1145 eo_do(parent, ret = elm_obj_widget_sub_object_add(sobj));
1153 * Add sobj to obj's sub object.
1155 * What does elementary sub object mean? This is unique in elementary, it
1156 * handles overall elementary policies between parent and sub objects.
1157 * focus, access, deletion, theme, scale, mirror, scrollable child get,
1158 * translate, name find, display mode set, orientation set, tree dump
1161 * @see elm_widget_sub_object_parent_add()
1163 EOLIAN static Eina_Bool
1164 _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1166 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
1168 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1170 if (sobj == sd->parent_obj)
1172 /* in this case, sobj must be an elm widget, or something
1173 * very wrong is happening */
1174 if (!_elm_widget_is(sobj)) return EINA_FALSE;
1176 if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
1177 WRN("You passed a parent object of obj = %p as the sub object = %p!",
1181 if (_elm_widget_is(sobj))
1183 ELM_WIDGET_DATA_GET(sobj, sdc);
1185 if (sdc->parent_obj == obj) goto end;
1186 if (sdc->parent_obj)
1188 if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
1191 sdc->parent_obj = obj;
1193 if (!sdc->on_create)
1194 eo_do(sobj, elm_obj_widget_orientation_set(sd->orient_mode));
1196 sdc->orient_mode = sd->orient_mode;
1198 if (!sdc->on_create)
1200 if (!sdc->disabled && (elm_widget_disabled_get(obj)))
1202 elm_widget_focus_disabled_handle(sobj);
1203 eo_do(sobj, elm_obj_widget_disable());
1207 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
1209 /* update child focusable-ness on self and parents, now that a
1210 * focusable child got in */
1211 if (!sd->child_can_focus && (_is_focusable(sobj)))
1213 Elm_Widget_Smart_Data *sdp = sd;
1215 sdp->child_can_focus = EINA_TRUE;
1216 while (sdp->parent_obj)
1218 sdp = eo_data_scope_get(sdp->parent_obj, MY_CLASS);
1220 if (sdp->child_can_focus) break;
1222 sdp->child_can_focus = EINA_TRUE;
1228 void *data = evas_object_data_get(sobj, "elm-parent");
1232 if (data == obj) goto end;
1233 if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
1236 sd->subobjs = eina_list_append(sd->subobjs, sobj);
1237 evas_object_data_set(sobj, "elm-parent", obj);
1239 _callbacks_add(sobj, obj);
1240 if (_elm_widget_is(sobj))
1242 ELM_WIDGET_DATA_GET(sobj, sdc);
1244 /* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
1245 * Due to elementary's scale policy, scale and pscale can be different in
1246 * some cases. This happens when sobj's previous parent and new parent have
1247 * different scale value.
1248 * For example, if sobj's previous parent's scale is 5 and new parent's scale
1249 * is 2 while sobj's scale is 0. Then 'pscale' is 5 and 'scale' is 2. So we
1250 * need to reset sobj's scale to 5.
1251 * Note that each widget's scale is 0 by default.
1253 double scale, pscale = elm_widget_scale_get(sobj);
1254 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
1256 scale = elm_widget_scale_get(sobj);
1257 th = elm_widget_theme_get(sobj);
1258 mirrored = elm_widget_mirrored_get(sobj);
1260 if (!sdc->on_create)
1262 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
1263 elm_widget_theme(sobj);
1266 if (_is_focused(sobj)) _parents_focus(obj);
1268 elm_widget_display_mode_set(sobj,
1269 evas_object_size_hint_display_mode_get(obj));
1270 if (_elm_atspi_enabled() && !sdc->on_create)
1272 Elm_Interface_Atspi_Accessible *aparent;
1273 eo_do(sobj, aparent = elm_interface_atspi_accessible_parent_get());
1275 elm_interface_atspi_accessible_children_changed_added_signal_emit(obj, sobj);
1278 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
1279 if (sdc->inherit_paragraph_direction &&
1280 (sdc->paragraph_direction != evas_object_paragraph_direction_get(obj)))
1282 sdc->paragraph_direction = evas_object_paragraph_direction_get(obj);
1283 _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
1284 eo_do_super(sobj, MY_CLASS, evas_obj_paragraph_direction_set(sdc->paragraph_direction));
1293 EOLIAN static Eina_Bool
1294 _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1296 Evas_Object *sobj_parent;
1298 if (!sobj) return EINA_FALSE;
1300 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1302 sobj_parent = evas_object_data_del(sobj, "elm-parent");
1303 if (sobj_parent && sobj_parent != obj)
1305 static int abort_on_warn = -1;
1307 ERR("removing sub object %p (%s) from parent %p (%s), "
1308 "but elm-parent is different %p (%s)!",
1309 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
1310 sobj_parent, elm_widget_type_get(sobj_parent));
1312 if (EINA_UNLIKELY(abort_on_warn == -1))
1314 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
1315 else abort_on_warn = 0;
1317 if (abort_on_warn == 1) abort();
1322 if (_elm_widget_is(sobj))
1324 if (_is_focused(sobj))
1326 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1327 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1329 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1331 Evas_Object *parent = obj;
1333 /* update child focusable-ness on self and parents, now that a
1334 * focusable child is gone */
1338 Evas_Object *subobj;
1340 ELM_WIDGET_DATA_GET(parent, sdp);
1342 sdp->child_can_focus = EINA_FALSE;
1343 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1345 if ((subobj != sobj) && (_is_focusable(subobj)))
1347 sdp->child_can_focus = EINA_TRUE;
1352 /* break again, child_can_focus went back to
1354 if (sdp->child_can_focus) break;
1355 parent = sdp->parent_obj;
1358 if (_elm_atspi_enabled() && !sd->on_destroy)
1360 Elm_Interface_Atspi_Accessible *aparent;
1361 eo_do(sobj, aparent = elm_interface_atspi_accessible_parent_get());
1363 elm_interface_atspi_accessible_children_changed_del_signal_emit(obj, sobj);
1366 ELM_WIDGET_DATA_GET(sobj, sdc);
1367 sdc->parent_obj = NULL;
1369 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
1370 if (sdc->inherit_paragraph_direction &&
1371 (sdc->paragraph_direction != EVAS_BIDI_DIRECTION_NEUTRAL))
1373 sdc->paragraph_direction = EVAS_BIDI_DIRECTION_NEUTRAL;
1374 _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
1375 eo_do_super(sobj, MY_CLASS, evas_obj_paragraph_direction_set(EVAS_BIDI_DIRECTION_NEUTRAL));
1380 if (sd->resize_obj == sobj) sd->resize_obj = NULL;
1382 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1384 _callbacks_del(sobj, obj);
1392 * a resize object is added to and deleted from the smart member and the sub object
1393 * of the parent if the third argument, Eina_Bool sub_obj, is set as EINA_TRUE.
1396 _elm_widget_resize_object_set(Eo *obj, Elm_Widget_Smart_Data *sd,
1400 Evas_Object *parent;
1402 if (sd->resize_obj == sobj) return;
1404 // orphan previous resize obj
1405 if (sd->resize_obj && sub_obj)
1407 evas_object_clip_unset(sd->resize_obj);
1408 evas_object_smart_member_del(sd->resize_obj);
1410 if (_elm_widget_is(sd->resize_obj))
1412 if (_is_focused(sd->resize_obj)) _parents_unfocus(obj);
1414 elm_widget_sub_object_del(obj, sd->resize_obj);
1417 sd->resize_obj = sobj;
1420 // orphan new resize obj
1421 parent = evas_object_data_get(sobj, "elm-parent");
1422 if (parent && parent != obj)
1424 ELM_WIDGET_DATA_GET(parent, sdp);
1426 /* should be there, just being paranoid */
1429 if (sdp->resize_obj == sobj)
1430 elm_widget_resize_object_set(parent, NULL, sub_obj);
1432 elm_widget_sub_object_del(parent, sobj);
1437 elm_widget_sub_object_add(obj, sobj);
1438 evas_object_smart_member_add(sobj, obj);
1441 _smart_reconfigure(sd);
1447 * WARNING: the programmer is responsible, in the scenario of
1448 * exchanging a hover object, of cleaning the old hover "target"
1452 _elm_widget_hover_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1456 _callbacks_del(sd->hover_obj, obj);
1458 sd->hover_obj = sobj;
1461 _callbacks_add(sobj, obj);
1462 _smart_reconfigure(sd);
1467 _elm_widget_can_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can_focus)
1469 can_focus = !!can_focus;
1471 if (sd->can_focus == can_focus) return;
1472 sd->can_focus = can_focus;
1475 /* update child_can_focus of parents */
1476 Evas_Object *o = obj;
1480 o = elm_widget_parent_get(o);
1482 sd = eo_data_scope_get(o, MY_CLASS);
1483 if (!sd || sd->child_can_focus) break;
1484 sd->child_can_focus = EINA_TRUE;
1487 eo_do(obj, eo_event_callback_array_add(focus_callbacks(), NULL));
1491 // update child_can_focus of parents */
1492 Evas_Object *parent = elm_widget_parent_get(obj);
1496 Evas_Object *subobj;
1498 ELM_WIDGET_DATA_GET(parent, sdp);
1500 sdp->child_can_focus = EINA_FALSE;
1501 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1503 if (_is_focusable(subobj))
1505 sdp->child_can_focus = EINA_TRUE;
1509 /* break again, child_can_focus went back to
1511 if (sdp->child_can_focus) break;
1512 parent = sdp->parent_obj;
1514 eo_do(obj, eo_event_callback_array_del(focus_callbacks(), NULL));
1518 EOLIAN static Eina_Bool
1519 _elm_widget_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1521 return sd->can_focus;
1524 EOLIAN static Eina_Bool
1525 _elm_widget_child_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1527 return sd->child_can_focus;
1533 * This API makes the widget object and its children to be unfocusable.
1535 * This API can be helpful for an object to be deleted.
1536 * When an object will be deleted soon, it and its children may not
1537 * want to get focus (by focus reverting or by other focus controls).
1538 * Then, just use this API before deleting.
1540 * @param obj The widget root of sub-tree
1541 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1546 _elm_widget_tree_unfocusable_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool tree_unfocusable)
1548 tree_unfocusable = !!tree_unfocusable;
1549 if (sd->tree_unfocusable == tree_unfocusable) return;
1550 sd->tree_unfocusable = tree_unfocusable;
1551 elm_widget_focus_tree_unfocusable_handle(obj);
1557 * This returns true, if the object sub-tree is unfocusable.
1559 * @param obj The widget root of sub-tree
1560 * @return EINA_TRUE if the object sub-tree is unfocusable
1564 EOLIAN static Eina_Bool
1565 _elm_widget_tree_unfocusable_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1567 return sd->tree_unfocusable;
1573 * Get the list of focusable child objects.
1575 * This function retruns list of child objects which can get focus.
1577 * @param obj The parent widget
1578 * @retrun list of focusable child objects.
1582 EOLIAN static Eina_List*
1583 _elm_widget_can_focus_child_list_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1586 Eina_List *child_list = NULL;
1589 EINA_LIST_FOREACH(sd->subobjs, l, child)
1591 if (!_elm_widget_is(child)) continue;
1592 if ((elm_widget_can_focus_get(child)) &&
1593 (evas_object_visible_get(child)) &&
1594 (!elm_widget_disabled_get(child)))
1595 child_list = eina_list_append(child_list, child);
1598 Eina_List *can_focus_list;
1599 can_focus_list = elm_widget_can_focus_child_list_get(child);
1601 child_list = eina_list_merge(child_list, can_focus_list);
1609 _elm_widget_highlight_ignore_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool ignore)
1611 sd->highlight_ignore = !!ignore;
1614 EOLIAN static Eina_Bool
1615 _elm_widget_highlight_ignore_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1617 return sd->highlight_ignore;
1621 _elm_widget_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1623 sd->highlight_in_theme = !!highlight;
1624 /* FIXME: if focused, it should switch from one mode to the other */
1628 _elm_widget_highlight_in_theme_update(Eo *obj)
1630 Evas_Object *top = elm_widget_top_get(obj);
1632 if (top && eo_isa(top, ELM_WIN_CLASS))
1634 _elm_win_focus_highlight_in_theme_update(
1635 top, elm_widget_highlight_in_theme_get(obj));
1639 EOLIAN static Eina_Bool
1640 _elm_widget_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1642 return sd->highlight_in_theme;
1646 _elm_widget_access_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1648 sd->access_highlight_in_theme = !!highlight;
1651 EOLIAN static Eina_Bool
1652 _elm_widget_access_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1654 return sd->access_highlight_in_theme;
1657 EOLIAN static Eina_Bool
1658 _elm_widget_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1660 return (sd->focused && sd->top_win_focused);
1663 EOLIAN static Eina_Bool
1664 _elm_widget_highlight_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1666 return sd->highlighted;
1669 EOLIAN static Evas_Object*
1670 _elm_widget_focused_object_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1672 const Evas_Object *subobj;
1675 if (!sd->focused || !sd->top_win_focused) return NULL;
1676 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1679 if (!_elm_widget_is(subobj)) continue;
1680 fobj = elm_widget_focused_object_get(subobj);
1681 if (fobj) return fobj;
1683 return (Evas_Object *)obj;
1686 EOLIAN static Evas_Object*
1687 _elm_widget_top_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1691 Evas_Object *ret = NULL;
1692 if (!eo_isa(sd->parent_obj, ELM_WIDGET_CLASS)) return NULL;
1693 eo_do((Eo *) sd->parent_obj, ret = elm_obj_widget_top_get());
1696 return (Evas_Object *)obj;
1700 elm_widget_is(const Evas_Object *obj)
1702 return _elm_widget_is(obj);
1706 elm_widget_parent_widget_get(const Evas_Object *obj)
1708 Evas_Object *parent;
1710 if (_elm_widget_is(obj))
1712 ELM_WIDGET_DATA_GET(obj, sd);
1713 if (!sd) return NULL;
1714 parent = sd->parent_obj;
1718 parent = evas_object_data_get(obj, "elm-parent");
1719 if (!parent) parent = evas_object_smart_parent_get(obj);
1724 Evas_Object *elm_parent;
1725 if (_elm_widget_is(parent)) break;
1726 elm_parent = evas_object_data_get(parent, "elm-parent");
1727 if (elm_parent) parent = elm_parent;
1728 else parent = evas_object_smart_parent_get(parent);
1733 EOLIAN static Evas_Object *
1734 _elm_widget_parent2_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1740 _elm_widget_parent2_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *parent)
1742 sd->parent2 = parent;
1746 _elm_widget_event_callback_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1748 EINA_SAFETY_ON_NULL_RETURN(func);
1750 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1753 ERR("Failed to allocate memory");
1758 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1762 _elm_widget_event_callback_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1764 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1766 Elm_Event_Cb_Data *ecd;
1767 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1768 if ((ecd->func == func) && (ecd->data == data))
1771 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1772 return (void *)data;
1778 EOLIAN static Eina_Bool
1779 _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)
1781 Evas_Object *parent = obj;
1782 Elm_Event_Cb_Data *ecd;
1783 Eina_List *l, *l_prev;
1786 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1788 ELM_WIDGET_CHECK(parent) EINA_FALSE;
1789 Elm_Widget_Smart_Data *sd = eo_data_scope_get(parent, MY_CLASS);
1791 Eina_Bool int_ret = EINA_FALSE;
1793 if (elm_widget_disabled_get(obj))
1795 parent = sd->parent_obj;
1799 eo_do(parent, int_ret = elm_obj_widget_event(obj, type, event_info));
1800 if (int_ret) return EINA_TRUE;
1802 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1804 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1805 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1808 parent = sd->parent_obj;
1817 * Set custom focus chain.
1819 * This function i set one new and overwrite any previous custom focus chain
1820 * with the list of objects. The previous list will be deleted and this list
1821 * will be managed. After setted, don't modity it.
1823 * @note On focus cycle, only will be evaluated children of this container.
1825 * @param obj The container widget
1826 * @param objs Chain of objects to pass focus
1830 _elm_widget_focus_custom_chain_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_List *objs)
1832 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1834 elm_widget_focus_custom_chain_unset(obj);
1839 EINA_LIST_FOREACH(objs, l, o)
1841 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1842 _elm_object_focus_chain_del_cb, obj);
1845 sd->focus_chain = objs;
1851 * Get custom focus chain
1853 * @param obj The container widget
1856 EOLIAN static const Eina_List*
1857 _elm_widget_focus_custom_chain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1859 return (const Eina_List *)sd->focus_chain;
1865 * Unset custom focus chain
1867 * @param obj The container widget
1871 _elm_widget_focus_custom_chain_unset(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1873 Eina_List *l, *l_next;
1876 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1878 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1879 _elm_object_focus_chain_del_cb, obj);
1880 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1887 * Append object to custom focus chain.
1889 * @note If relative_child equal to NULL or not in custom chain, the object
1890 * will be added in end.
1892 * @note On focus cycle, only will be evaluated children of this container.
1894 * @param obj The container widget
1895 * @param child The child to be added in custom chain
1896 * @param relative_child The relative object to position the child
1900 _elm_widget_focus_custom_chain_append(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1902 EINA_SAFETY_ON_NULL_RETURN(child);
1904 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1906 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1907 _elm_object_focus_chain_del_cb, obj);
1909 if (!relative_child)
1910 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1912 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1913 child, relative_child);
1919 * Prepend object to custom focus chain.
1921 * @note If relative_child equal to NULL or not in custom chain, the object
1922 * will be added in begin.
1924 * @note On focus cycle, only will be evaluated children of this container.
1926 * @param obj The container widget
1927 * @param child The child to be added in custom chain
1928 * @param relative_child The relative object to position the child
1932 _elm_widget_focus_custom_chain_prepend(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1934 EINA_SAFETY_ON_NULL_RETURN(child);
1936 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1938 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1939 _elm_object_focus_chain_del_cb, obj);
1941 if (!relative_child)
1942 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1944 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1945 child, relative_child);
1951 * Give focus to next object in object tree.
1953 * Give focus to next object in focus chain of one object sub-tree.
1954 * If the last object of chain already have focus, the focus will go to the
1955 * first object of chain.
1957 * @param obj The widget root of sub-tree
1958 * @param dir Direction to cycle the focus
1963 _elm_widget_focus_cycle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir)
1965 Evas_Object *target = NULL;
1966 Elm_Object_Item *target_item = NULL;
1967 if (!_elm_widget_is(obj))
1969 elm_widget_focus_next_get(obj, dir, &target, &target_item);
1973 if (_elm_config->access_mode)
1975 /* highlight cycle does not steal a focus, only after window gets
1976 the ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE message,
1977 target will steal focus, or focus its own job. */
1978 if (!_elm_access_auto_highlight_get())
1979 elm_widget_focus_steal(target, target_item);
1981 _elm_access_highlight_set(target);
1982 elm_widget_focus_region_show(target);
1984 else elm_widget_focus_steal(target, target_item);
1991 * Give focus to near object(in object tree) in one direction.
1993 * Give focus to near object(in object tree) in direction of current
1994 * focused object. If none focusable object in given direction or
1995 * none focused object in object tree, the focus will not change.
1997 * @param obj The reference widget
1998 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
1999 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2000 * @return EINA_TRUE if focus is moved.
2004 EOLIAN static Eina_Bool
2005 _elm_widget_focus_direction_go(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, double degree)
2007 Evas_Object *target = NULL;
2008 Elm_Object_Item *target_item = NULL;
2009 Evas_Object *current_focused = NULL;
2010 double weight = 0.0;
2012 if (!_elm_widget_is(obj)) return EINA_FALSE;
2013 if (!_is_focused(obj)) return EINA_FALSE;
2015 current_focused = elm_widget_focused_object_get(obj);
2017 if (elm_widget_focus_direction_get
2018 (obj, current_focused, degree, &target, &target_item, &weight))
2020 elm_widget_focus_steal(target, NULL);
2028 _elm_widget_focus_direction_weight_get(const Evas_Object *obj1,
2029 const Evas_Object *obj2,
2032 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
2033 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
2034 double ax, ay, cx, cy;
2035 double weight = -1.0, g = 0.0;
2037 if (obj1 == obj2) return 0.0;
2040 while (degree >= 360.0)
2042 while (degree < 0.0)
2045 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
2046 cx = obj_x1 + (w1 / 2.0);
2047 cy = obj_y1 + (h1 / 2.0);
2048 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
2050 /* For overlapping cases. */
2051 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
2054 /* Change all points to relative one. */
2064 /* Get crossing points (ax, ay) between obj1 and a line extending
2065 * to the direction of current degree. */
2071 else if (degree == 90.0)
2076 else if (degree == 180.0)
2081 else if (degree == 270.0)
2088 g = tan(degree * (M_PI / 180.0));
2089 if ((degree > 0.0) && (degree < 90.0))
2092 if (ay <= yyy1) ax = xx1;
2099 else if ((degree > 90.0) && (degree < 180.0))
2102 if (ay <= yyy1) ax = x1;
2109 else if ((degree > 180.0) && (degree < 270.0))
2112 if (ay >= yy1) ax = x1;
2122 if (ay >= yy1) ax = xx1;
2131 /* Filter obj2, if it is not in the specific derection. */
2133 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
2134 double t1, t2, u1, v1, u2, v2;
2136 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
2146 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
2151 t1 = (u1 * ax) + (v1 * ay);
2152 t2 = (u2 * ax) + (v2 * ay);
2154 #define _R(x) (int)((x + 0.05) * 10.0)
2156 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
2162 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
2168 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
2174 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
2175 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
2184 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2186 else if (degree == 90.0)
2188 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2190 else if (degree == 180.0)
2192 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2194 else if (degree == 270.0)
2196 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2200 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
2202 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
2205 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
2207 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
2210 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
2213 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
2214 && (_R(ay * yy2) > 0)))
2217 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
2218 (_R((1.0 / g) * yyy2) <= _R(xx2)))
2220 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
2221 && (_R(ay * yyy2) > 0))) return 0.0;
2227 /* Calculate the weight for obj2. */
2230 if (_R(xx1) > _R(x2)) weight = -1.0;
2231 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2232 weight = (x2 - xx1) * (x2 - xx1);
2233 else if (_R(yy2) > 0)
2234 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
2235 else if (_R(yyy2) < 0)
2236 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
2237 else weight = (x2 - xx1) * (x2 - xx1);
2239 else if (degree == 90.0)
2241 if (_R(yyy1) > _R(yy2)) weight = -1.0;
2242 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2243 weight = (yy2 - yyy1) * (yy2 - yyy1);
2244 else if (_R(x2) > 0)
2245 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
2246 else if (_R(xx2) < 0)
2247 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
2248 else weight = (yy2 - yyy1) * (yy2 - yyy1);
2250 else if (degree == 180.0)
2252 if (_R(x1) < _R(xx2)) weight = -1.0;
2253 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2254 weight = (x1 - xx2) * (x1 - xx2);
2255 else if (_R(yy2) > 0)
2256 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
2257 else if (_R(yyy2) < 0)
2258 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
2259 else weight = (x1 - xx2) * (x1 - xx2);
2261 else if (degree == 270.0)
2263 if (_R(yy1) < _R(yyy2)) weight = -1.0;
2264 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2265 weight = (yy1 - yyy2) * (yy1 - yyy2);
2266 else if (_R(x2) > 0)
2267 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
2268 else if (_R(xx2) < 0)
2269 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
2270 else weight = (yy1 - yyy2) * (yy1 - yyy2);
2275 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
2276 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
2277 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
2281 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2282 ((ay - (g * x2)) * (ay - (g * x2)));
2284 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2288 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2289 ((ay - (g * xx2)) * (ay - (g * xx2)));
2291 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2293 sx[j] = (1.0 / g) * yy2;
2296 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2297 ((ay - yy2) * (ay - yy2));
2299 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2302 sx[j] = (1.0 / g) * yyy2;
2305 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2306 ((ay - yyy2) * (ay - yyy2));
2309 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2310 (_R(sy[0]) != _R(sy[1])))))
2314 if (_R(t_weight[k]) == 0) return -1.0;
2315 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2322 double ccx, ccy, t1_weight, x_diff, y_diff;
2323 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2325 x_diff = rx[k] - ccx;
2326 if (x_diff < 0) x_diff *= -1.0;
2327 y_diff = ry[k] - ccy;
2328 if (y_diff < 0) y_diff *= -1.0;
2330 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2331 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2332 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2337 /* Return the current object's weight. */
2338 if (weight == -1.0) return 0.0;
2339 if (_R(weight) == 0) return -1.0;
2343 return 1.0 / weight;
2349 * Get near object in one direction of base object.
2351 * Get near object(in the object sub-tree) in one direction of
2352 * base object. Return the near object by reference.
2353 * By initializing weight, you can filter objects locating far
2354 * from base object. If object is in the specific direction,
2355 * weight is (1/(distance^2)). If object is not exactly in one
2356 * direction, some penalty will be added.
2358 * @param obj The widget root of sub-tree
2359 * @param base The base object of the direction
2360 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2361 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2362 * @param direction The near object in one direction
2363 * @param weight The weight is bigger when the object is located near
2364 * @return EINA_TRUE if near object is updated.
2369 EOLIAN static Eina_Bool
2370 _elm_widget_focus_direction_get(const Eo *obj, Elm_Widget_Smart_Data *sd, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
2374 /* -1 means the best was already decided. Don't need any more searching. */
2375 if (!direction || !weight || !base || (obj == base))
2378 /* Ignore if disabled */
2379 if ((!evas_object_visible_get(obj))
2380 || (elm_widget_disabled_get(obj))
2381 || (elm_widget_tree_unfocusable_get(obj)))
2385 if (_internal_elm_widget_focus_direction_manager_is(obj))
2387 Eina_Bool int_ret = EINA_FALSE;
2388 eo_do((Eo *)obj, int_ret = elm_obj_widget_focus_direction(base, degree, direction, direction_item, weight));
2392 if (!elm_widget_can_focus_get(obj) || _is_focused((Eo *)obj))
2395 c_weight = _elm_widget_focus_direction_weight_get(base, obj, degree);
2396 if ((c_weight == -1.0) ||
2397 ((c_weight != 0.0) && (*weight != -1.0) &&
2398 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2401 ((int)(*weight * 1000000) == (int)(c_weight * 1000000)))
2403 ELM_WIDGET_DATA_GET(*direction, sd1);
2406 if (sd->focus_order <= sd1->focus_order)
2410 *direction = (Evas_Object *)obj;
2421 * Get near object in one direction of base object in list.
2423 * Get near object in one direction of base object in the specific
2424 * object list. Return the near object by reference.
2425 * By initializing weight, you can filter objects locating far
2426 * from base object. If object is in the specific direction,
2427 * weight is (1/(distance^2)). If object is not exactly in one
2428 * direction, some penalty will be added.
2430 * @param obj The widget root of sub-tree
2431 * @param base The base object of the direction
2432 * @param items list with ordered objects
2433 * @param list_data_get function to get the object from one item of list
2434 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2435 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2436 * @param direction The near object in one direction
2437 * @param weight The weight is bigger when the object is located near
2438 * @return EINA_TRUE if near object is updated.
2442 EOLIAN static Eina_Bool
2443 _elm_widget_focus_list_direction_get(const 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, Elm_Object_Item **direction_item, double *weight)
2445 if (!direction || !weight || !base || !items)
2448 const Eina_List *l = items;
2449 Evas_Object *current_best = *direction;
2451 for (; l; l = eina_list_next(l))
2453 Evas_Object *cur = list_data_get(l);
2454 if (cur && _elm_widget_is(cur))
2455 elm_widget_focus_direction_get(cur, base, degree, direction, direction_item, weight);
2457 if (current_best != *direction) return EINA_TRUE;
2465 * Get next object in focus chain of object tree.
2467 * Get next object in focus chain of one object sub-tree.
2468 * Return the next object by reference. If don't have any candidate to receive
2469 * focus before chain end, the first candidate will be returned.
2471 * @param obj The widget root of sub-tree
2472 * @param dir Direction of focus chain
2473 * @param next The next object in focus chain
2474 * @return EINA_TRUE if don't need focus chain restart/loop back
2475 * to use 'next' obj.
2479 EOLIAN static Eina_Bool
2480 _elm_widget_focus_next_get(const Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
2482 Elm_Access_Info *ac;
2488 /* Ignore if disabled */
2489 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2491 if (!evas_object_visible_get(obj)
2492 || (elm_widget_tree_unfocusable_get(obj)))
2497 if ((!evas_object_visible_get(obj))
2498 || (elm_widget_disabled_get(obj))
2499 || (elm_widget_tree_unfocusable_get(obj)))
2504 if (_elm_widget_focus_chain_manager_is(obj))
2506 Eina_Bool int_ret = EINA_FALSE;
2507 eo_do((Eo *)obj, int_ret = elm_obj_widget_focus_next(dir, next, next_item));
2508 if (!int_ret && _is_focused((Eo *)obj))
2510 Evas_Object *o = NULL;
2511 if (dir == ELM_FOCUS_PREVIOUS)
2512 *next_item = sd->item_focus_previous;
2513 else if (dir == ELM_FOCUS_NEXT)
2514 *next_item = sd->item_focus_next;
2515 else if (dir == ELM_FOCUS_UP)
2516 *next_item = sd->item_focus_up;
2517 else if (dir == ELM_FOCUS_DOWN)
2518 *next_item = sd->item_focus_down;
2519 else if (dir == ELM_FOCUS_RIGHT)
2520 *next_item = sd->item_focus_right;
2521 else if (dir == ELM_FOCUS_LEFT)
2522 *next_item = sd->item_focus_left;
2523 o = elm_object_item_widget_get(*next_item);
2527 if (dir == ELM_FOCUS_PREVIOUS)
2528 o = sd->focus_previous;
2529 else if (dir == ELM_FOCUS_NEXT)
2531 else if (dir == ELM_FOCUS_UP)
2533 else if (dir == ELM_FOCUS_DOWN)
2535 else if (dir == ELM_FOCUS_RIGHT)
2536 o = sd->focus_right;
2537 else if (dir == ELM_FOCUS_LEFT)
2550 /* access object does not check sd->can_focus, because an object could
2551 have highlight even though the object is not focusable. */
2552 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2554 ac = _elm_access_info_get(obj);
2555 if (!ac) return EINA_FALSE;
2557 /* check whether the hover object is visible or not */
2558 if (!evas_object_visible_get(ac->hoverobj))
2561 else if (!elm_widget_can_focus_get(obj))
2564 if (_is_focused((Eo *)obj))
2566 if (dir == ELM_FOCUS_PREVIOUS)
2567 *next_item = sd->item_focus_previous;
2568 else if (dir == ELM_FOCUS_NEXT)
2569 *next_item = sd->item_focus_next;
2570 else if (dir == ELM_FOCUS_UP)
2571 *next_item = sd->item_focus_up;
2572 else if (dir == ELM_FOCUS_DOWN)
2573 *next_item = sd->item_focus_down;
2574 else if (dir == ELM_FOCUS_RIGHT)
2575 *next_item = sd->item_focus_right;
2576 else if (dir == ELM_FOCUS_LEFT)
2577 *next_item = sd->item_focus_left;
2578 *next = elm_object_item_widget_get(*next_item);
2582 if (dir == ELM_FOCUS_PREVIOUS)
2583 *next = sd->focus_previous;
2584 else if (dir == ELM_FOCUS_NEXT)
2585 *next = sd->focus_next;
2586 else if (dir == ELM_FOCUS_UP)
2587 *next = sd->focus_up;
2588 else if (dir == ELM_FOCUS_DOWN)
2589 *next = sd->focus_down;
2590 else if (dir == ELM_FOCUS_RIGHT)
2591 *next = sd->focus_right;
2592 else if (dir == ELM_FOCUS_LEFT)
2593 *next = sd->focus_left;
2596 if (*next) return EINA_TRUE;
2600 *next = (Evas_Object *)obj;
2601 return !ELM_WIDGET_FOCUS_GET(obj);
2607 * Get next object in focus chain of object tree in list.
2609 * Get next object in focus chain of one object sub-tree ordered by one list.
2610 * Return the next object by reference. If don't have any candidate to receive
2611 * focus before list end, the first candidate will be returned.
2613 * @param obj The widget root of sub-tree
2614 * @param items list with ordered objects
2615 * @param list_data_get function to get the object from one item of list
2616 * @param dir Direction of focus chain
2617 * @param next The next object in focus chain
2618 * @return EINA_TRUE if don't need focus chain restart/loop back
2619 * to use 'next' obj.
2623 EOLIAN static Eina_Bool
2624 _elm_widget_focus_list_next_get(const 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, Elm_Object_Item **next_item)
2626 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2627 Evas_Object *focused_object = NULL;
2633 if (!_elm_widget_is(obj))
2639 /* When Up, Down, Right, or Left, try direction_get first. */
2640 focused_object = elm_widget_focused_object_get(obj);
2643 if ((dir == ELM_FOCUS_UP)
2644 || (dir == ELM_FOCUS_DOWN)
2645 || (dir == ELM_FOCUS_RIGHT)
2646 || (dir == ELM_FOCUS_LEFT))
2648 *next_item = elm_widget_focus_next_item_get(focused_object, dir);
2650 *next = elm_object_item_widget_get(*next_item);
2652 *next = elm_widget_focus_next_object_get(focused_object, dir);
2653 if (*next) return EINA_TRUE;
2656 Evas_Object *n = NULL;
2657 Elm_Object_Item *n_item = NULL;
2659 double weight = 0.0;
2661 if (dir == ELM_FOCUS_UP) degree = 0.0;
2662 else if (dir == ELM_FOCUS_DOWN) degree = 180.0;
2663 else if (dir == ELM_FOCUS_RIGHT) degree = 90.0;
2664 else if (dir == ELM_FOCUS_LEFT) degree = 270.0;
2666 if (elm_widget_focus_list_direction_get(obj, focused_object,
2667 items, list_data_get,
2668 degree, &n, &n_item,
2671 *next_item = n_item;
2680 if (dir == ELM_FOCUS_PREVIOUS)
2682 items = eina_list_last(items);
2683 list_next = eina_list_prev;
2685 else if ((dir == ELM_FOCUS_NEXT)
2686 || (dir == ELM_FOCUS_UP)
2687 || (dir == ELM_FOCUS_DOWN)
2688 || (dir == ELM_FOCUS_RIGHT)
2689 || (dir == ELM_FOCUS_LEFT))
2690 list_next = eina_list_next;
2694 const Eina_List *l = items;
2696 /* Recovery last focused sub item */
2697 if (ELM_WIDGET_FOCUS_GET(obj))
2699 for (; l; l = list_next(l))
2701 Evas_Object *cur = list_data_get(l);
2702 if (ELM_WIDGET_FOCUS_GET(cur)) break;
2705 /* Focused object, but no focused sub item */
2709 const Eina_List *start = l;
2710 Evas_Object *to_focus = NULL;
2711 Elm_Object_Item *to_focus_item = NULL;
2713 /* Iterate sub items */
2714 /* Go to the end of list */
2715 for (; l; l = list_next(l))
2717 Evas_Object *tmp = NULL;
2718 Elm_Object_Item *tmp_item = NULL;
2719 Evas_Object *cur = list_data_get(l);
2722 if (!_elm_widget_is(cur)) continue;
2723 if (elm_widget_parent_get(cur) != obj)
2726 /* Try Focus cycle in subitem */
2727 if (elm_widget_focus_next_get(cur, dir, &tmp, &tmp_item))
2730 *next_item = tmp_item;
2733 else if ((dir == ELM_FOCUS_UP)
2734 || (dir == ELM_FOCUS_DOWN)
2735 || (dir == ELM_FOCUS_RIGHT)
2736 || (dir == ELM_FOCUS_LEFT))
2738 if (tmp && _is_focused(cur))
2741 *next_item = tmp_item;
2745 else if ((tmp) && (!to_focus))
2748 to_focus_item = tmp_item;
2754 /* Get First possible */
2755 for (; l != start; l = list_next(l))
2757 Evas_Object *tmp = NULL;
2758 Elm_Object_Item *tmp_item = NULL;
2759 Evas_Object *cur = list_data_get(l);
2761 if (elm_widget_parent_get(cur) != obj)
2764 /* Try Focus cycle in subitem */
2765 elm_widget_focus_next_get(cur, dir, &tmp, &tmp_item);
2769 *next_item = tmp_item;
2775 *next_item = to_focus_item;
2782 * Get next object which was set with specific focus direction.
2784 * Get next object which was set by elm_widget_focus_next_object_set
2785 * with specific focus directioin.
2787 * @param obj The widget
2788 * @param dir Direction of focus
2789 * @return Widget which was registered with sepecific focus direction.
2793 EOLIAN static Evas_Object*
2794 _elm_widget_focus_next_object_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir)
2796 Evas_Object *ret = NULL;
2798 if (dir == ELM_FOCUS_PREVIOUS)
2799 ret = sd->focus_previous;
2800 else if (dir == ELM_FOCUS_NEXT)
2801 ret = sd->focus_next;
2802 else if (dir == ELM_FOCUS_UP)
2804 else if (dir == ELM_FOCUS_DOWN)
2805 ret = sd->focus_down;
2806 else if (dir == ELM_FOCUS_RIGHT)
2807 ret = sd->focus_right;
2808 else if (dir == ELM_FOCUS_LEFT)
2809 ret = sd->focus_left;
2817 * Set next object with specific focus direction.
2819 * When a widget is set with specific focus direction, this widget will be
2820 * the first candidate when finding the next focus object.
2821 * Focus next object can be registered with six directions that are previous,
2822 * next, up, down, right, and left.
2824 * @param obj The widget
2825 * @param next Next focus object
2826 * @param dir Direction of focus
2831 _elm_widget_focus_next_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *next, Elm_Focus_Direction dir)
2834 if (dir == ELM_FOCUS_PREVIOUS)
2835 sd->focus_previous = next;
2836 else if (dir == ELM_FOCUS_NEXT)
2837 sd->focus_next = next;
2838 else if (dir == ELM_FOCUS_UP)
2839 sd->focus_up = next;
2840 else if (dir == ELM_FOCUS_DOWN)
2841 sd->focus_down = next;
2842 else if (dir == ELM_FOCUS_RIGHT)
2843 sd->focus_right = next;
2844 else if (dir == ELM_FOCUS_LEFT)
2845 sd->focus_left = next;
2848 EOLIAN static Elm_Object_Item*
2849 _elm_widget_focus_next_item_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir)
2851 Elm_Object_Item *ret = NULL;
2853 if (dir == ELM_FOCUS_PREVIOUS)
2854 ret = sd->item_focus_previous;
2855 else if (dir == ELM_FOCUS_NEXT)
2856 ret = sd->item_focus_next;
2857 else if (dir == ELM_FOCUS_UP)
2858 ret = sd->item_focus_up;
2859 else if (dir == ELM_FOCUS_DOWN)
2860 ret = sd->item_focus_down;
2861 else if (dir == ELM_FOCUS_RIGHT)
2862 ret = sd->item_focus_right;
2863 else if (dir == ELM_FOCUS_LEFT)
2864 ret = sd->item_focus_left;
2870 _elm_widget_focus_next_item_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
2872 if (dir == ELM_FOCUS_PREVIOUS)
2873 sd->item_focus_previous = next_item;
2874 else if (dir == ELM_FOCUS_NEXT)
2875 sd->item_focus_next = next_item;
2876 else if (dir == ELM_FOCUS_UP)
2877 sd->item_focus_up = next_item;
2878 else if (dir == ELM_FOCUS_DOWN)
2879 sd->item_focus_down = next_item;
2880 else if (dir == ELM_FOCUS_RIGHT)
2881 sd->item_focus_right = next_item;
2882 else if (dir == ELM_FOCUS_LEFT)
2883 sd->item_focus_left = next_item;
2887 _elm_widget_parent_highlight_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool highlighted)
2889 highlighted = !!highlighted;
2891 Evas_Object *o = elm_widget_parent_get(obj);
2893 if (o) elm_widget_parent_highlight_set(o, highlighted);
2895 sd->highlighted = highlighted;
2899 _elm_widget_signal_emit(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source)
2901 if (evas_object_smart_type_check(obj, "elm_layout"))
2902 elm_layout_signal_emit(obj, emission, source);
2903 else if (evas_object_smart_type_check(obj, "elm_icon"))
2905 WRN("Deprecated function. This functionality on icon objects"
2906 " will be dropped on a next release.");
2907 _elm_icon_signal_emit(obj, emission, source);
2912 _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)
2914 EINA_SAFETY_ON_NULL_RETURN(func);
2916 if (evas_object_smart_type_check(obj, "elm_layout"))
2917 elm_layout_signal_callback_add(obj, emission, source, func, data);
2918 else if (evas_object_smart_type_check(obj, "elm_icon"))
2920 WRN("Deprecated function. This functionality on icon objects"
2921 " will be dropped on a next release.");
2923 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2928 _elm_widget_signal_callback_del(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source, Edje_Signal_Cb func)
2932 if (evas_object_smart_type_check(obj, "elm_layout"))
2933 data = elm_layout_signal_callback_del(obj, emission, source, func);
2934 else if (evas_object_smart_type_check(obj, "elm_icon"))
2936 WRN("Deprecated function. This functionality on icon objects"
2937 " will be dropped on a next release.");
2939 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2946 _elm_widget_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool focus)
2951 sd->focus_order = focus_order;
2952 sd->focused = EINA_TRUE;
2953 eo_do(obj, elm_obj_widget_on_focus(NULL));
2958 if ((_is_focusable(sd->resize_obj)) &&
2959 (!elm_widget_disabled_get(sd->resize_obj)))
2961 elm_widget_focus_set(sd->resize_obj, focus);
2968 EINA_LIST_FOREACH(sd->subobjs, l, child)
2970 if (!_elm_widget_is(child)) continue;
2971 if ((_is_focusable(child)) &&
2972 (!elm_widget_disabled_get(child)))
2974 elm_widget_focus_set(child, focus);
2985 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2987 if (!_elm_widget_is(child)) continue;
2988 if ((_is_focusable(child)) &&
2989 (!elm_widget_disabled_get(child)))
2991 elm_widget_focus_set(child, focus);
2998 EOLIAN static Evas_Object*
2999 _elm_widget_parent_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3001 return sd->parent_obj;
3005 _elm_widget_focused_object_clear(Eo *obj, Elm_Widget_Smart_Data *sd)
3007 if (!sd->focused) return;
3008 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
3009 _is_focused(sd->resize_obj))
3011 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
3017 EINA_LIST_FOREACH(sd->subobjs, l, child)
3019 if (_elm_widget_is(child) && _is_focused(child))
3021 eo_do(child, elm_obj_widget_focused_object_clear());
3026 sd->focused = EINA_FALSE;
3027 if (sd->top_win_focused)
3028 eo_do(obj, elm_obj_widget_on_focus(NULL));
3032 _elm_widget_focus_steal(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Object_Item *item)
3034 Evas_Object *parent, *parent2, *o;
3036 if (sd->focused) return;
3037 if (sd->disabled) return;
3038 if (!sd->can_focus) return;
3039 if (sd->tree_unfocusable) return;
3043 o = elm_widget_parent_get(parent);
3045 sd = eo_data_scope_get(o, MY_CLASS);
3046 if (sd->disabled || sd->tree_unfocusable) return;
3047 if (sd->focused) break;
3050 if ((!elm_widget_parent_get(parent)) &&
3051 (!elm_widget_parent2_get(parent)))
3052 eo_do(parent, elm_obj_widget_focused_object_clear());
3055 parent2 = elm_widget_parent_get(parent);
3056 if (!parent2) parent2 = elm_widget_parent2_get(parent);
3058 sd = eo_data_scope_get(parent, MY_CLASS);
3061 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
3062 _is_focused(sd->resize_obj))
3064 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
3070 EINA_LIST_FOREACH(sd->subobjs, l, child)
3072 if (_elm_widget_is(child) && _is_focused(child))
3074 eo_do(child, elm_obj_widget_focused_object_clear());
3081 /* TIZEN_ONLY(20161212): Some winsets should know whether it's focus target or not in _on_focus */
3082 sd = eo_data_scope_get(obj, MY_CLASS);
3083 sd->is_focus_target = EINA_TRUE;
3085 _parent_focus(obj, item);
3086 /* TIZEN_ONLY(20161212): Some winsets should know whether it's focus target or not in _on_focus */
3087 sd->is_focus_target = EINA_FALSE;
3089 elm_widget_focus_region_show(obj);
3094 _parents_on_focus(Evas_Object *obj)
3097 if (!sd->focused || !sd->top_win_focused) return;
3099 Evas_Object *o = elm_widget_parent_get(obj);
3100 if (o) _parents_on_focus(o);
3101 eo_do(obj, elm_obj_widget_on_focus(NULL));
3105 _elm_widget_focus_restore(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3107 Evas_Object *newest = NULL;
3108 unsigned int newest_focus_order = 0;
3110 newest = elm_widget_newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
3112 _parents_on_focus(newest);
3116 _elm_widget_focus_auto_show(Evas_Object *obj)
3118 Evas_Object *top = elm_widget_top_get(obj);
3119 if (top && eo_isa(top, ELM_WIN_CLASS)) _elm_win_focus_auto_show(top);
3123 _elm_widget_top_win_focused_set(Evas_Object *obj,
3124 Eina_Bool top_win_focused)
3130 if (sd->top_win_focused == top_win_focused) return;
3131 EINA_LIST_FOREACH(sd->subobjs, l, child)
3133 if (elm_widget_is(child))
3134 _elm_widget_top_win_focused_set(child, top_win_focused);
3136 sd->top_win_focused = top_win_focused;
3138 if (sd->focused && !sd->top_win_focused)
3139 eo_do(obj, elm_obj_widget_on_focus(NULL));
3143 _elm_widget_top_win_focused_get(const Evas_Object *obj)
3145 API_ENTRY return EINA_FALSE;
3146 return sd->top_win_focused;
3150 _elm_widget_disabled_eval(const Evas_Object *obj, Eina_Bool disabled)
3154 ELM_WIDGET_DATA_GET(obj, sd);
3158 EINA_LIST_FOREACH(sd->subobjs, l, child)
3160 if (elm_widget_is(child))
3162 elm_widget_focus_disabled_handle(child);
3163 eo_do(child, elm_obj_widget_disable());
3164 _elm_widget_disabled_eval(child, EINA_TRUE);
3170 EINA_LIST_FOREACH(sd->subobjs, l, child)
3172 ELM_WIDGET_DATA_GET(child, sdc);
3173 if (elm_widget_is(child) && !sdc->disabled)
3175 elm_widget_focus_disabled_handle(child);
3176 eo_do(child, elm_obj_widget_disable());
3177 _elm_widget_disabled_eval(child, EINA_FALSE);
3184 elm_widget_disabled_internal(Eo *obj, Eina_Bool disabled)
3186 Eina_Bool parent_state = EINA_FALSE;
3190 elm_widget_focus_disabled_handle(obj);
3191 eo_do(obj, elm_obj_widget_disable());
3192 _elm_widget_disabled_eval(obj, EINA_TRUE);
3196 parent_state = elm_widget_disabled_get(elm_widget_parent_get(obj));
3197 if (parent_state) return;
3198 elm_widget_focus_disabled_handle(obj);
3199 eo_do(obj, elm_obj_widget_disable());
3200 _elm_widget_disabled_eval(obj, EINA_FALSE);
3205 _elm_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
3207 if (sd->disabled == disabled) return;
3208 sd->disabled = !!disabled;
3210 elm_widget_disabled_internal(obj, disabled);
3213 EOLIAN static Eina_Bool
3214 _elm_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3216 Eina_Bool disabled = EINA_FALSE;
3218 if (sd->disabled) disabled = EINA_TRUE;
3219 else disabled = elm_widget_disabled_get(elm_widget_parent_get(obj));
3224 _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)
3227 Evas_Object *parent_obj, *child_obj;
3228 Evas_Coord px, py, cx, cy, nx = 0, ny = 0;
3231 /* TIZEN_ONLY(20161222): Update show region geometry when entry is resized
3232 Move this code to the blow to update show region geometry properly.
3233 evas_smart_objects_calculate(evas_object_evas_get(obj));
3236 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
3237 (w == sd->rw) && (h == sd->rh)) return;
3244 /* TIZEN_ONLY(20161222): Update show region geometry when entry is resized */
3245 /* Block nested call for evas_smart_objects_calculate() and region showing works */
3246 if (sd->on_show_region_set) return;
3248 sd->on_show_region_set = EINA_TRUE;
3250 evas_smart_objects_calculate(evas_object_evas_get(obj));
3252 sd->on_show_region_set = EINA_FALSE;
3254 /* show_region geometry could be changed during processing elm_widget_show_region_set().
3255 evas_smart_objects_calculate() can trigger nested show_region_set calls */
3262 if (sd->on_show_region)
3265 (sd->on_show_region_data, obj);
3267 if (_elm_scrollable_is(obj))
3269 eo_do(obj, elm_interface_scrollable_content_pos_get(&nx, &ny));
3277 parent_obj = sd->parent_obj;
3278 child_obj = sd->obj;
3279 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
3280 sd = eo_data_scope_get(parent_obj, MY_CLASS);
3283 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
3284 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
3293 if (sd->on_show_region)
3296 (sd->on_show_region_data, parent_obj);
3303 _elm_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
3314 * Get the focus region of the given widget.
3316 * @return show region or not
3317 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
3319 * The focus region is the area of a widget that should brought into the
3320 * visible area when the widget is focused. Mostly used to show the part of
3321 * an entry where the cursor is, for example. The area returned is relative
3322 * to the object @p obj.
3324 * @param obj The widget object
3325 * @param x Where to store the x coordinate of the area
3326 * @param y Where to store the y coordinate of the area
3327 * @param w Where to store the width of the area
3328 * @param h Where to store the height of the area
3332 EOLIAN static Eina_Bool
3333 _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)
3335 Eina_Bool int_ret = EINA_FALSE;
3336 eo_do((Eo *)obj, int_ret = elm_obj_widget_on_focus_region(x, y, w, h));
3339 evas_object_geometry_get(obj, NULL, NULL, w, h);
3343 if ((*w <= 0) || (*h <= 0)) return EINA_FALSE;
3348 _elm_widget_parents_bounce_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool *horiz, Eina_Bool *vert)
3350 Evas_Object *parent_obj = obj;
3351 Eina_Bool h = EINA_FALSE, v = EINA_FALSE;
3353 *horiz = EINA_FALSE;
3358 parent_obj = elm_widget_parent_get(parent_obj);
3359 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
3361 if (_elm_scrollable_is(parent_obj))
3363 eo_do(parent_obj, elm_interface_scrollable_bounce_allow_get(&h, &v));
3364 if (h) *horiz = EINA_TRUE;
3365 if (v) *vert = EINA_TRUE;
3371 EOLIAN static Eina_List*
3372 _elm_widget_scrollable_children_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3381 EINA_LIST_FOREACH(sd->subobjs, l, child)
3383 if (elm_widget_is(child) && _elm_scrollable_is(child))
3384 ret = eina_list_append(ret, child);
3391 _elm_widget_scroll_hold_push(Eo *obj, Elm_Widget_Smart_Data *sd)
3394 if (sd->scroll_hold == 1)
3396 if (_elm_scrollable_is(obj))
3397 eo_do(obj, elm_interface_scrollable_hold_set(EINA_TRUE));
3400 Eina_List *scr_children, *l;
3403 scr_children = elm_widget_scrollable_children_get(obj);
3404 EINA_LIST_FOREACH(scr_children, l, child)
3406 eo_do(child, elm_interface_scrollable_hold_set(EINA_TRUE));
3408 eina_list_free(scr_children);
3411 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_push());
3412 // FIXME: on delete/reparent hold pop
3416 _elm_widget_scroll_hold_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
3419 if (!sd->scroll_hold)
3421 if (_elm_scrollable_is(obj))
3422 eo_do(obj, elm_interface_scrollable_hold_set(EINA_FALSE));
3425 Eina_List *scr_children, *l;
3428 scr_children = elm_widget_scrollable_children_get(obj);
3429 EINA_LIST_FOREACH(scr_children, l, child)
3431 eo_do(child, elm_interface_scrollable_hold_set(EINA_FALSE));
3433 eina_list_free(scr_children);
3436 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_pop());
3437 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
3441 _elm_widget_scroll_hold_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3443 return sd->scroll_hold;
3447 _elm_widget_scroll_freeze_push(Eo *obj, Elm_Widget_Smart_Data *sd)
3449 sd->scroll_freeze++;
3450 if (sd->scroll_freeze == 1)
3452 if (_elm_scrollable_is(obj))
3453 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_TRUE));
3456 Eina_List *scr_children, *l;
3459 scr_children = elm_widget_scrollable_children_get(obj);
3460 EINA_LIST_FOREACH(scr_children, l, child)
3462 eo_do(child, elm_interface_scrollable_freeze_set(EINA_TRUE));
3464 eina_list_free(scr_children);
3467 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_push());
3468 // FIXME: on delete/reparent freeze pop
3472 _elm_widget_scroll_freeze_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
3474 sd->scroll_freeze--;
3475 if (!sd->scroll_freeze)
3477 if (_elm_scrollable_is(obj))
3478 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_FALSE));
3481 Eina_List *scr_children, *l;
3484 scr_children = elm_widget_scrollable_children_get(obj);
3485 EINA_LIST_FOREACH(scr_children, l, child)
3487 eo_do(child, elm_interface_scrollable_freeze_set(EINA_FALSE));
3489 eina_list_free(scr_children);
3492 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_pop());
3493 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3497 _elm_widget_scroll_freeze_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3499 return sd->scroll_freeze;
3502 // TIZEN_ONLY(20150705): Genlist item align feature
3504 elm_widget_scroll_item_align_enabled_set(Evas_Object *obj,
3505 Eina_Bool scroll_item_align_enable)
3508 if (sd->scroll_item_align_enable == scroll_item_align_enable) return;
3509 sd->scroll_item_align_enable = scroll_item_align_enable;
3513 elm_widget_scroll_item_align_enabled_get(const Evas_Object *obj)
3515 API_ENTRY return EINA_FALSE;
3516 return sd->scroll_item_align_enable;
3520 elm_widget_scroll_item_valign_set(Evas_Object *obj,
3521 const char *scroll_item_valign)
3524 if (sd->scroll_item_valign) eina_stringshare_del(sd->scroll_item_valign);
3525 if (!scroll_item_valign) sd->scroll_item_valign = NULL;
3526 else sd->scroll_item_valign = eina_stringshare_add(scroll_item_valign);
3530 elm_widget_scroll_item_valign_get(const Evas_Object *obj)
3532 API_ENTRY return NULL;
3533 return sd->scroll_item_valign;
3538 _elm_widget_scale_set(Eo *obj, Elm_Widget_Smart_Data *sd, double scale)
3540 if (scale < 0.0) scale = 0.0;
3541 if (sd->scale != scale)
3544 elm_widget_theme(obj);
3548 EOLIAN static double
3549 _elm_widget_scale_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3551 // FIXME: save walking up the tree by storing/caching parent scale
3552 if (sd->scale == 0.0)
3554 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3556 return elm_widget_scale_get(sd->parent_obj);
3567 _elm_widget_theme_set(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Theme *th)
3569 Eina_Bool apply = EINA_FALSE;
3570 if (sd->theme != th)
3572 if (elm_widget_theme_get(obj) != th) apply = EINA_TRUE;
3573 if (sd->theme) elm_theme_free(sd->theme);
3576 if (apply) elm_widget_theme(obj);
3581 _elm_widget_part_text_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part, const char *label)
3583 if (evas_object_smart_type_check(obj, "elm_layout"))
3584 elm_layout_text_set(obj, part, label);
3587 EOLIAN static const char*
3588 _elm_widget_part_text_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part)
3590 if (evas_object_smart_type_check(obj, "elm_layout"))
3591 return elm_layout_text_get(obj, part);
3596 static Elm_Translate_String_Data *
3597 _translate_string_data_get(Eina_Inlist *translate_strings, const char *part)
3599 Elm_Translate_String_Data *ts;
3600 Eina_Stringshare *str;
3602 if (!translate_strings) return NULL;
3604 str = eina_stringshare_add(part);
3605 EINA_INLIST_FOREACH(translate_strings, ts)
3607 if (ts->id == str) break;
3610 eina_stringshare_del(str);
3615 static Elm_Translate_String_Data *
3616 _part_text_translatable_set(Eina_Inlist **translate_strings, const char *part, Eina_Bool translatable, Eina_Bool preset)
3619 Elm_Translate_String_Data *ts;
3620 t = *translate_strings;
3621 ts = _translate_string_data_get(t, part);
3627 ts = ELM_NEW(Elm_Translate_String_Data);
3628 if (!ts) return NULL;
3630 ts->id = eina_stringshare_add(part);
3631 t = eina_inlist_append(t, (Eina_Inlist*) ts);
3633 if (preset) ts->preset = EINA_TRUE;
3635 //Delete this exist one if this part has been not preset.
3636 //see elm_widget_part_text_translatable_set()
3637 else if (ts && ((preset) || (!ts->preset)))
3639 t = eina_inlist_remove(t, EINA_INLIST_GET(ts));
3640 eina_stringshare_del(ts->id);
3641 eina_stringshare_del(ts->domain);
3642 eina_stringshare_del(ts->string);
3643 ELM_SAFE_FREE(ts, free);
3646 *translate_strings = t;
3652 _elm_widget_domain_translatable_part_text_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, const char *label)
3655 Elm_Translate_String_Data *ts;
3659 _part_text_translatable_set(&sd->translate_strings, part, EINA_FALSE,
3664 ts = _part_text_translatable_set(&sd->translate_strings, part,
3665 EINA_TRUE, EINA_FALSE);
3667 if (!ts->string) ts->string = eina_stringshare_add(label);
3668 else eina_stringshare_replace(&ts->string, label);
3669 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3670 else eina_stringshare_replace(&ts->domain, domain);
3672 if (label[0]) label = dgettext(domain, label);
3676 sd->on_translate = EINA_TRUE;
3677 eo_do(obj, elm_obj_widget_part_text_set(part, label));
3678 sd->on_translate = EINA_FALSE;
3681 EOLIAN static const char*
3682 _elm_widget_translatable_part_text_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part)
3684 Elm_Translate_String_Data *ts;
3686 ts = _translate_string_data_get(sd->translate_strings, part);
3687 if (ts) return ts->string;
3692 _elm_widget_domain_part_text_translatable_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, Eina_Bool translatable)
3694 Elm_Translate_String_Data *ts;
3695 const char *text = NULL;
3697 ts = _part_text_translatable_set(&sd->translate_strings, part,
3698 translatable, EINA_TRUE);
3700 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3701 else eina_stringshare_replace(&ts->domain, domain);
3703 eo_do(obj, text = elm_obj_widget_part_text_get(part));
3704 if (!text || !text[0]) return;
3706 if (!ts->string) ts->string = eina_stringshare_add(text);
3708 //Try to translate text since we don't know the text is already translated.
3710 text = dgettext(domain, text);
3712 sd->on_translate = EINA_TRUE;
3713 eo_do(obj, elm_obj_widget_part_text_set(part, text));
3714 sd->on_translate = EINA_FALSE;
3718 elm_widget_translate(Evas_Object *obj)
3720 ELM_WIDGET_CHECK(obj);
3721 eo_do(obj, elm_obj_widget_translate());
3725 _part_text_translate(Eina_Inlist *translate_strings,
3729 Elm_Translate_String_Data *ts;
3730 ts = _translate_string_data_get(translate_strings, part);
3731 if (!ts) return text;
3733 if (!ts->string) ts->string = eina_stringshare_add(text);
3734 else eina_stringshare_replace(&ts->string, text);
3736 if (text && text[0])
3737 text = dgettext(ts->domain, text);
3742 EOLIAN static const char*
3743 _elm_widget_part_text_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part, const char *text)
3747 if (!sd->translate_strings || sd->on_translate) return text;
3748 return _part_text_translate(sd->translate_strings, part, text);
3751 EOLIAN static Eina_Bool
3752 _elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3756 API_ENTRY return EINA_FALSE;
3758 EINA_LIST_FOREACH(sd->subobjs, l, child)
3760 if (elm_widget_is(child))
3761 elm_widget_translate(child);
3764 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3767 Elm_Translate_String_Data *ts;
3768 EINA_INLIST_FOREACH(sd->translate_strings, ts)
3770 if (!ts->string) continue;
3771 const char *s = dgettext(ts->domain, ts->string);
3772 sd->on_translate = EINA_TRUE;
3773 eo_do(obj, elm_obj_widget_part_text_set(ts->id, s));
3774 sd->on_translate = EINA_FALSE;
3777 eo_do(obj, eo_event_callback_call(ELM_WIDGET_EVENT_LANGUAGE_CHANGED, NULL));
3784 * Resets the focus_move_policy mode from the system one
3785 * for widgets that are in automatic mode.
3787 * @param obj The widget.
3791 _elm_widget_focus_move_policy_reload(Evas_Object *obj)
3794 Elm_Focus_Move_Policy focus_move_policy = elm_config_focus_move_policy_get();
3796 if (elm_widget_focus_move_policy_automatic_get(obj) &&
3797 (sd->focus_move_policy != focus_move_policy))
3799 sd->focus_move_policy = focus_move_policy;
3804 _elm_widget_focus_reconfigure(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3810 EINA_LIST_FOREACH(sd->subobjs, l, child)
3812 if (elm_widget_is(child))
3813 elm_widget_focus_reconfigure(child);
3816 if (sd->hover_obj) elm_widget_focus_reconfigure(sd->hover_obj);
3818 _elm_widget_focus_move_policy_reload(obj);
3821 //TIZEN_ONLY(20160726): add API elm_object_part_access_object_get
3822 EOLIAN static Evas_Object*
3823 _elm_widget_part_access_object_get(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part EINA_UNUSED)
3825 WRN("The %s widget does not implement the \"part_access_object_get\" functions.",
3826 eo_class_name_get(eo_class_get(obj)));
3832 elm_widget_content_part_set(Evas_Object *obj,
3834 Evas_Object *content)
3836 ELM_WIDGET_CHECK(obj);
3837 eo_do(obj, elm_obj_container_content_set(part, content));
3841 * Returns the widget's focus_move_policy mode setting.
3843 * @param obj The widget.
3844 * @return focus_move_policy mode setting of the object.
3847 EOLIAN static Eina_Bool
3848 _elm_widget_focus_move_policy_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3850 return sd->focus_move_policy_auto_mode;
3856 * Sets the widget's focus_move_policy mode setting.
3857 * When widget in automatic mode, it follows the system focus_move_policy mode set by
3858 * elm_config_focus_move_policy_set().
3859 * @param obj The widget.
3860 * @param automatic EINA_TRUE for auto focus_move_policy mode. EINA_FALSE for manual.
3863 _elm_widget_focus_move_policy_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic)
3865 if (sd->focus_move_policy_auto_mode != automatic)
3867 sd->focus_move_policy_auto_mode = automatic;
3871 elm_widget_focus_move_policy_set(obj, elm_config_focus_move_policy_get());
3877 elm_widget_content_part_get(const Evas_Object *obj,
3880 ELM_WIDGET_CHECK(obj) NULL;
3881 Evas_Object *ret = NULL;
3882 eo_do((Eo *) obj, ret = elm_obj_container_content_get(part));
3887 elm_widget_content_part_unset(Evas_Object *obj,
3890 ELM_WIDGET_CHECK(obj) NULL;
3891 Evas_Object *ret = NULL;
3892 eo_do(obj, ret = elm_obj_container_content_unset(part));
3897 _elm_widget_access_info_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *txt)
3899 eina_stringshare_del(sd->access_info);
3900 if (!txt) sd->access_info = NULL;
3901 else sd->access_info = eina_stringshare_add(txt);
3904 EOLIAN static const char*
3905 _elm_widget_access_info_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3907 return sd->access_info;
3910 EOLIAN static Elm_Theme*
3911 _elm_widget_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3915 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3916 return elm_widget_theme_get(sd->parent_obj);
3922 EOLIAN static Elm_Theme_Apply
3923 _elm_widget_style_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *style)
3925 if (eina_stringshare_replace(&sd->style, style))
3926 return elm_widget_theme(obj);
3928 return ELM_THEME_APPLY_SUCCESS;
3931 /* TIZEN_ONLY(20161223): add widget style set furnction for internal usage
3932 this function is same with elm_widget_style_set
3933 but it doesn't apply sub object's theme */
3935 _elm_widget_style_set_internal(Evas_Object *obj, const char *style)
3937 Elm_Theme_Apply ret = ELM_THEME_APPLY_SUCCESS;
3939 API_ENTRY return ELM_THEME_APPLY_FAILED;
3941 if (eina_stringshare_replace(&sd->style, style))
3947 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
3949 EINA_LIST_FOREACH(sd->tooltips, l, tt)
3950 elm_tooltip_theme(tt);
3951 EINA_LIST_FOREACH(sd->cursors, l, cur)
3952 elm_cursor_theme(cur);
3954 Elm_Theme_Apply ret2 = ELM_THEME_APPLY_FAILED;
3955 eo_do(obj, ret2 = elm_obj_widget_theme_apply());
3963 EOLIAN static const char*
3964 _elm_widget_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3968 if (sd->style) ret = sd->style;
3974 _elm_widget_tooltip_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3976 sd->tooltips = eina_list_append(sd->tooltips, tt);
3980 _elm_widget_tooltip_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3982 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3986 _elm_widget_cursor_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3988 sd->cursors = eina_list_append(sd->cursors, cur);
3992 _elm_widget_cursor_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3994 sd->cursors = eina_list_remove(sd->cursors, cur);
3998 _elm_widget_drag_lock_x_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
4000 if (sd->drag_x_locked == lock) return;
4001 sd->drag_x_locked = lock;
4002 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
4003 else _propagate_x_drag_lock(obj, -1);
4007 _elm_widget_drag_lock_y_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
4009 if (sd->drag_y_locked == lock) return;
4010 sd->drag_y_locked = lock;
4011 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
4012 else _propagate_y_drag_lock(obj, -1);
4015 EOLIAN static Eina_Bool
4016 _elm_widget_drag_lock_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4018 return sd->drag_x_locked;
4021 EOLIAN static Eina_Bool
4022 _elm_widget_drag_lock_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4024 return sd->drag_y_locked;
4028 _elm_widget_drag_child_locked_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4030 return sd->child_drag_x_locked;
4034 _elm_widget_drag_child_locked_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4036 return sd->child_drag_y_locked;
4040 _elm_widget_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED, Eina_Bool enable EINA_UNUSED)
4045 EOLIAN static Eina_Bool
4046 _elm_widget_item_loop_enabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED)
4051 EOLIAN static Elm_Theme_Apply
4052 _elm_widget_theme_object_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle)
4054 Elm_Theme_Apply ret = _elm_theme_object_set(obj, edj, wname, welement, wstyle);
4057 return ELM_THEME_APPLY_FAILED;
4060 if (sd->orient_mode != -1)
4063 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
4064 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
4071 _elm_widget_eo_base_dbg_info_get(Eo *eo_obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eo_Dbg_Info *root)
4073 eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
4074 Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
4076 EO_DBG_INFO_APPEND(group, "Wid-Type", EINA_VALUE_TYPE_STRING, elm_widget_type_get(eo_obj));
4077 EO_DBG_INFO_APPEND(group, "Style", EINA_VALUE_TYPE_STRING, elm_widget_style_get(eo_obj));
4078 EO_DBG_INFO_APPEND(group, "Layer", EINA_VALUE_TYPE_INT,
4079 (int) evas_object_layer_get(eo_obj));
4080 EO_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE,
4081 evas_object_scale_get(eo_obj));
4082 EO_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR,
4083 elm_object_focus_get(eo_obj));
4084 EO_DBG_INFO_APPEND(group, "Disabled", EINA_VALUE_TYPE_CHAR,
4085 elm_widget_disabled_get(eo_obj));
4086 EO_DBG_INFO_APPEND(group, "Mirrored", EINA_VALUE_TYPE_CHAR,
4087 elm_widget_mirrored_get(eo_obj));
4088 EO_DBG_INFO_APPEND(group, "Automatic mirroring", EINA_VALUE_TYPE_CHAR,
4089 elm_widget_mirrored_automatic_get(eo_obj));
4093 elm_widget_is_check(const Evas_Object *obj)
4095 static int abort_on_warn = -1;
4096 if (elm_widget_is(obj))
4099 ERR("Passing Object: %p.", obj);
4100 if (abort_on_warn == -1)
4102 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
4103 else abort_on_warn = 0;
4105 if (abort_on_warn == 1) abort();
4110 elm_widget_type_get(const Evas_Object *obj)
4112 API_ENTRY return NULL;
4114 return eo_class_name_get(eo_class_get(obj));
4118 elm_widget_type_check(const Evas_Object *obj,
4122 const char *provided, *expected = "(unknown)";
4123 static int abort_on_warn = -1;
4125 provided = elm_widget_type_get(obj);
4126 /* TODO: eventually migrate to check_ptr version */
4127 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
4128 if (type) expected = type;
4129 if ((!provided) || (!provided[0]))
4131 provided = evas_object_type_get(obj);
4132 if ((!provided) || (!provided[0]))
4133 provided = "(unknown)";
4135 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
4136 " type: '%s'", obj, func, provided, expected);
4137 if (abort_on_warn == -1)
4139 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
4140 else abort_on_warn = 0;
4142 if (abort_on_warn == 1) abort();
4146 static Evas_Object *
4147 _widget_name_find(const Evas_Object *obj,
4154 INTERNAL_ENTRY NULL;
4156 if (!_elm_widget_is(obj)) return NULL;
4157 EINA_LIST_FOREACH(sd->subobjs, l, child)
4159 s = evas_object_name_get(child);
4160 if ((s) && (!strcmp(s, name))) return child;
4161 if ((recurse != 0) &&
4162 ((child = _widget_name_find(child, name, recurse - 1))))
4167 s = evas_object_name_get(sd->hover_obj);
4168 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
4169 if ((recurse != 0) &&
4170 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
4176 EOLIAN static Evas_Object*
4177 _elm_widget_name_find(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *name, int recurse)
4179 if (!name) return NULL;
4180 return _widget_name_find(obj, name, recurse);
4186 * Split string in words
4188 * @param str Source string
4189 * @return List of const words
4191 * @see elm_widget_stringlist_free()
4195 elm_widget_stringlist_get(const char *str)
4197 Eina_List *list = NULL;
4199 if (!str) return NULL;
4200 for (b = s = str; 1; s++)
4202 if ((*s == ' ') || (!*s))
4204 char *t = malloc(s - b + 1);
4207 strncpy(t, b, s - b);
4209 list = eina_list_append(list, eina_stringshare_add(t));
4220 elm_widget_stringlist_free(Eina_List *list)
4223 EINA_LIST_FREE(list, s)
4224 eina_stringshare_del(s);
4228 _elm_widget_focus_hide_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4230 if (!_elm_widget_is(obj))
4232 _if_focused_revert(obj, EINA_TRUE);
4236 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
4238 Evas_Object *o = obj;
4241 if (_elm_widget_is(o)) break;
4242 o = evas_object_smart_parent_get(o);
4246 eo_do(o, elm_obj_widget_focus_mouse_up_handle());
4250 _elm_widget_focus_mouse_up_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4253 if (!_is_focusable(obj)) return;
4255 elm_widget_focus_steal(obj, NULL);
4259 _elm_widget_focus_tree_unfocusable_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4261 if (!elm_widget_parent_get(obj))
4262 elm_widget_focused_object_clear(obj);
4264 _if_focused_revert(obj, EINA_TRUE);
4268 _elm_widget_focus_disabled_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4270 elm_widget_focus_tree_unfocusable_handle(obj);
4273 EOLIAN static unsigned int
4274 _elm_widget_focus_order_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4276 return sd->focus_order;
4279 EOLIAN static Evas_Object*
4280 _elm_widget_newest_focus_order_get(const Eo *obj, Elm_Widget_Smart_Data *sd, unsigned int *newest_focus_order, Eina_Bool can_focus_only)
4283 Evas_Object *child, *cur, *best;
4285 if (!evas_object_visible_get(obj)
4286 || (elm_widget_disabled_get(obj))
4287 || (elm_widget_tree_unfocusable_get(obj)))
4291 if (*newest_focus_order < sd->focus_order)
4293 if (!can_focus_only || elm_widget_can_focus_get(obj))
4295 *newest_focus_order = sd->focus_order;
4296 best = (Evas_Object *)obj;
4299 EINA_LIST_FOREACH(sd->subobjs, l, child)
4301 if (!_elm_widget_is(child)) continue;
4303 cur = elm_widget_newest_focus_order_get
4304 (child, newest_focus_order, can_focus_only);
4314 * Get the focus highlight geometry of an widget.
4316 * @param obj Widget object for the focus highlight
4317 * @param x Focus highlight x coordinate
4318 * @param y Focus highlight y coordinate
4319 * @param w Focus highlight object width
4320 * @param h Focus highlight object height
4321 * @param is_next @c EINA_TRUE if this request is for the new focused object,
4322 * @c EINA_FALSE if this request is for the previously focused object. This
4323 * information becomes important when the focus highlight is changed inside one
4331 * Get the 'focus_part' geometry if there is any
4333 * This queries if there is a 'focus_part' request from the edc style. If edc
4334 * style offers 'focus_part' edje data item, this function requests for the
4335 * geometry of a specific part which is described in 'focus_part' edje data.
4337 * @param obj Widget object for the focus highlight
4338 * @param x Focus highlight x coordinate
4339 * @param y Focus highlight y coordinate
4340 * @param w Focus highlight object width
4341 * @param h Focus highlight object height
4343 * x, y, w, h already contain the object's geometry. If there is a 'focus_part'
4344 * support, these values will be updated accordingly or the values will be
4345 * remained as they were.
4350 elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj,
4356 Evas_Coord tx = 0, ty = 0, tw = 0, th = 0;
4357 const char *target_hl_part = NULL;
4358 const Evas_Object *edje_obj = NULL;
4360 if (obj && eo_isa(obj, EDJE_OBJECT_CLASS))
4363 if (!(target_hl_part = edje_object_data_get(edje_obj, "focus_part")))
4366 else if (obj && eo_isa(obj, ELM_LAYOUT_CLASS))
4368 edje_obj = elm_layout_edje_get(obj);
4369 if (!(target_hl_part = elm_layout_data_get(obj, "focus_part")))
4375 edje_object_part_geometry_get(edje_obj, target_hl_part,
4376 &tx, &ty, &tw, &th);
4379 if (tw != *w) *w = tw;
4380 if (th != *h) *h = th;
4384 _elm_widget_focus_highlight_geometry_get(const Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
4386 Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0;
4387 Evas_Object *scroller = (Evas_Object *)obj;
4389 evas_object_geometry_get(obj, x, y, w, h);
4390 elm_widget_focus_highlight_focus_part_geometry_get(sd->resize_obj, x, y, w, h);
4392 if (_elm_config->focus_autoscroll_mode != ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN)
4397 if (_elm_scrollable_is(scroller))
4400 elm_interface_scrollable_content_viewport_geometry_get(&ox, &oy, &ow, &oh));
4404 else if ((oy + oh) < (*y + *h))
4405 *y = (oy + oh - *h);
4408 else if ((ox + ow) < (*x + *w))
4409 *x = (ox + ow - *w);
4413 scroller = elm_widget_parent_get(scroller);
4417 EOLIAN static Elm_Object_Item*
4418 _elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4424 _elm_widget_focus_region_show_mode_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, Elm_Focus_Region_Show_Mode mode)
4426 _pd->focus_region_show_mode = mode;
4429 EOLIAN static Elm_Focus_Region_Show_Mode
4430 _elm_widget_focus_region_show_mode_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
4432 return _pd->focus_region_show_mode;
4436 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
4438 Evas_Object *parent;
4441 ELM_WIDGET_CHECK(obj);
4445 eo_do(obj, ret = elm_obj_widget_activate(act));
4449 parent = elm_widget_parent_get(obj);
4451 elm_widget_activate(parent, act);
4459 * Sets the widget and child widget's Evas_Display_Mode.
4461 * @param obj The widget.
4462 * @param dispmode Evas_Display_Mode to set widget's mode.
4464 * Widgets are resized by several reasons.
4465 * Evas_Display_Mode can help for widgets to get one more reason of resize.
4466 * For example, elm conform widget resizes it's contents when keypad state changed.
4467 * After keypad showing, conform widget can change child's Evas_Display_Mode.
4471 _elm_widget_display_mode_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Display_Mode dispmode)
4473 Evas_Display_Mode prev_dispmode;
4477 prev_dispmode = evas_object_size_hint_display_mode_get(obj);
4479 if ((prev_dispmode == dispmode) ||
4480 (prev_dispmode == EVAS_DISPLAY_MODE_DONT_CHANGE)) return;
4482 evas_object_size_hint_display_mode_set(obj, dispmode);
4484 EINA_LIST_FOREACH (sd->subobjs, l, child)
4486 if (elm_widget_is(child))
4487 elm_widget_display_mode_set(child, dispmode);
4492 _elm_widget_orientation_mode_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
4494 int orient_mode = -1;
4498 //Get current orient mode from it's parent otherwise, 0.
4499 sd->orient_mode = 0;
4500 ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
4501 if (!sd_parent) orient_mode = 0;
4502 else orient_mode = sd_parent->orient_mode;
4504 eo_do(obj, elm_obj_widget_orientation_set(orient_mode));
4507 EOLIAN static Eina_Bool
4508 _elm_widget_orientation_mode_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4510 if (sd->orient_mode == -1) return EINA_TRUE;
4511 else return EINA_FALSE;
4515 _elm_widget_orientation_set(Eo *obj, Elm_Widget_Smart_Data *sd, int orient_mode)
4520 sd->orient_mode = orient_mode;
4522 EINA_LIST_FOREACH (sd->subobjs, l, child)
4524 if (elm_widget_is(child))
4525 eo_do(child, elm_obj_widget_orientation_set(orient_mode));
4528 if (orient_mode != -1)
4531 snprintf(buf, sizeof(buf), "elm,state,orient,%d", orient_mode);
4532 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
4539 * Returns the widget's focus move policy.
4541 * @param obj The widget.
4542 * @return focus move policy of the object.
4545 EOLIAN static Elm_Focus_Move_Policy
4546 _elm_widget_focus_move_policy_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4548 return sd->focus_move_policy;
4554 * Sets the widget's focus move policy.
4556 * @param obj The widget.
4557 * @param policy Elm_Focus_Move_Policy to set object's focus move policy.
4561 _elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Move_Policy policy)
4563 if (sd->focus_move_policy == policy) return;
4564 sd->focus_move_policy = policy;
4567 _track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
4570 _track_obj_update(Evas_Object *track, Evas_Object *obj)
4573 Evas_Coord x, y, w, h;
4574 evas_object_geometry_get(obj, &x, &y, &w, &h);
4575 evas_object_move(track, x, y);
4576 evas_object_resize(track, w, h);
4579 if (evas_object_visible_get(obj)) evas_object_show(track);
4580 else evas_object_hide(track);
4584 _track_obj_view_update(void *data, Eo *obj,
4585 const Eo_Event_Description *desc EINA_UNUSED,
4586 void *event_info EINA_UNUSED)
4588 Elm_Widget_Item_Data *item = data;
4589 _track_obj_update(item->track_obj, obj);
4590 return EO_CALLBACK_CONTINUE;
4594 _track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
4595 const Eo_Event_Description *desc EINA_UNUSED,
4596 void *event_info EINA_UNUSED);
4598 EO_CALLBACKS_ARRAY_DEFINE(tracker_callbacks,
4599 { EVAS_OBJECT_EVENT_RESIZE, _track_obj_view_update },
4600 { EVAS_OBJECT_EVENT_MOVE, _track_obj_view_update },
4601 { EVAS_OBJECT_EVENT_SHOW, _track_obj_view_update },
4602 { EVAS_OBJECT_EVENT_HIDE, _track_obj_view_update },
4603 { EVAS_OBJECT_EVENT_DEL, _track_obj_view_del });
4606 _track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
4607 const Eo_Event_Description *desc EINA_UNUSED,
4608 void *event_info EINA_UNUSED)
4610 Elm_Widget_Item_Data *item = data;
4612 while (evas_object_ref_get(item->track_obj) > 0)
4613 evas_object_unref(item->track_obj);
4615 evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
4617 evas_object_del(item->track_obj);
4618 item->track_obj = NULL;
4620 return EO_CALLBACK_CONTINUE;
4624 _track_obj_del(void *data, Evas *e EINA_UNUSED,
4625 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
4627 Elm_Widget_Item_Data *item = data;
4628 item->track_obj = NULL;
4630 if (!item->view) return;
4632 eo_do(item->view, eo_event_callback_array_del(tracker_callbacks(), item));
4636 _elm_widget_item_signal_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission,
4639 Elm_Widget_Item_Signal_Data *wisd = data;
4640 wisd->func(wisd->data, wisd->item, emission, source);
4644 _elm_widget_item_signal_callback_list_get(Elm_Widget_Item_Data *item, Eina_List *position)
4646 Elm_Widget_Item_Signal_Data *wisd = eina_list_data_get(position);
4649 item->signals = eina_list_remove_list(item->signals, position);
4652 if (_elm_widget_is(item->view))
4653 elm_object_signal_callback_del(item->view,
4654 wisd->emission, wisd->source,
4655 _elm_widget_item_signal_cb);
4656 else if (eo_isa(item->view, EDJE_OBJECT_CLASS))
4657 edje_object_signal_callback_del_full(item->view,
4658 wisd->emission, wisd->source,
4659 _elm_widget_item_signal_cb, wisd);
4661 eina_stringshare_del(wisd->emission);
4662 eina_stringshare_del(wisd->source);
4668 #define ERR_NOT_SUPPORTED(item, method) ERR("%s does not support %s API.", elm_widget_type_get(item->widget), method);
4671 _eo_del_cb(void *data EINA_UNUSED, Eo *eo_item, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
4673 Elm_Widget_Item_Data *item = eo_data_scope_get(eo_item, ELM_WIDGET_ITEM_CLASS);
4674 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_TRUE);
4676 item->del_func((void *) WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
4683 * Allocate a new Elm_Widget_Item-derived structure.
4685 * The goal of this structure is to provide common ground for actions
4686 * that a widget item have, such as the owner widget, callback to
4687 * notify deletion, data pointer and maybe more.
4689 * @param widget the owner widget that holds this item, must be an elm_widget!
4690 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
4691 * be used to allocate memory.
4693 * @return allocated memory that is already zeroed out, or NULL on errors.
4695 * @see elm_widget_item_new() convenience macro.
4696 * @see elm_widget_item_del() to release memory.
4700 _elm_widget_item_eo_base_constructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4702 Evas_Object *widget;
4703 eo_do (eo_item, widget = eo_parent_get());
4705 if (!_elm_widget_is(widget))
4711 eo_item = eo_do_super_ret(eo_item, ELM_WIDGET_ITEM_CLASS, eo_item, eo_constructor());
4713 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
4715 item->widget = widget;
4716 item->eo_obj = eo_item;
4717 //TIZEN_ONLY(20170717) : expose highlight information on atspi
4718 item->can_highlight = EINA_TRUE;
4721 eo_do(eo_item, eo_event_callback_add(EO_BASE_EVENT_DEL, _eo_del_cb, NULL));
4727 _elm_widget_item_eo_base_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4729 Elm_Translate_String_Data *ts;
4731 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4733 evas_object_del(item->view);
4735 eina_stringshare_del(item->access_info);
4736 eina_stringshare_del(item->accessible_name);
4738 while (item->signals)
4739 _elm_widget_item_signal_callback_list_get(item, item->signals);
4741 while (item->translate_strings)
4743 ts = EINA_INLIST_CONTAINER_GET(item->translate_strings,
4744 Elm_Translate_String_Data);
4745 eina_stringshare_del(ts->id);
4746 eina_stringshare_del(ts->domain);
4747 eina_stringshare_del(ts->string);
4748 item->translate_strings = eina_inlist_remove(item->translate_strings,
4749 item->translate_strings);
4752 eina_hash_free(item->labels);
4755 elm_interface_atspi_accessible_description_set(NULL),
4756 elm_interface_atspi_accessible_name_set(NULL),
4757 //TIZEN_ONLY(20190922): add name callback, description callback.
4758 elm_interface_atspi_accessible_description_cb_set(NULL, NULL),
4759 elm_interface_atspi_accessible_name_cb_set(NULL, NULL),
4761 elm_interface_atspi_accessible_translation_domain_set(NULL),
4762 elm_interface_atspi_accessible_relationships_clear(),
4763 // TIZEN_ONLY(20160930) : endless recursion fix
4764 elm_interface_atspi_accessible_attributes_clear()
4769 eina_stringshare_del(item->name);
4771 if (item->atspi_custom_relations)
4772 elm_atspi_relation_set_free(&item->atspi_custom_relations);
4774 //TIZEN_ONLY(20150731) : add i18n support for name and description
4775 if (item->atspi_translation_domain)
4776 eina_stringshare_del(item->atspi_translation_domain);
4778 //Tizen Only(20160728) free attribute list
4779 if (item->attr_list)
4781 Elm_Atspi_Attribute *attr;
4782 EINA_LIST_FREE(item->attr_list, attr)
4784 eina_stringshare_del(attr->key);
4785 eina_stringshare_del(attr->value);
4791 //TIZEN_ONLY(20161013): clean up elm color class feature
4792 if (item->color_classes)
4793 ELM_SAFE_FREE(item->color_classes, eina_hash_free);
4796 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
4798 eo_do_super(eo_item, ELM_WIDGET_ITEM_CLASS, eo_destructor());
4804 * Releases widget item memory, calling back item_del_pre_hook() and
4805 * item_del_cb() if they exist.
4807 * @param item a valid #Elm_Widget_Item to be deleted.
4809 * If there is an Elm_Widget_Item::del_cb, then it will be called prior
4810 * to memory release. Note that elm_widget_item_pre_notify_del() calls
4811 * this function and then unset it, thus being useful for 2 step
4812 * cleanup whenever the del_cb may use any of the data that must be
4813 * deleted from item.
4815 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
4818 * Note that if item_del_pre_hook() returns @c EINA_TRUE, item free will be
4819 * deferred, or item will be freed here if it returns @c EINA_FALSE.
4821 * @see elm_widget_item_del() convenience macro.
4825 _elm_widget_item_del(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4827 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4828 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4829 item->on_deletion = EINA_TRUE;
4831 //Widget item delete callback
4833 eo_do(item->eo_obj, del_ok = elm_wdg_item_del_pre());
4835 eo_del(item->eo_obj);
4839 EOLIAN static Eina_Bool
4840 _elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
4848 * Notify object will be deleted without actually deleting it.
4850 * This function will callback Elm_Widget_Item::del_cb if it is set
4851 * and then unset it so it is not called twice (ie: from
4852 * elm_widget_item_del()).
4854 * @param item a valid #Elm_Widget_Item to be notified
4855 * @see elm_widget_item_pre_notify_del() convenience macro.
4859 _elm_widget_item_pre_notify_del(Eo *eo_item, Elm_Widget_Item_Data *item)
4861 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4862 if (!item->del_func) return;
4863 item->del_func((void *)WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
4864 item->del_func = NULL;
4870 * Set the function to notify when item is being deleted.
4872 * This function will complain if there was a callback set already,
4873 * however it will set the new one.
4875 * The callback will be called from elm_widget_item_pre_notify_del()
4876 * or elm_widget_item_del() will be called with:
4877 * - data: the Elm_Widget_Item::data value.
4878 * - obj: the Elm_Widget_Item::widget evas object.
4879 * - event_info: the item being deleted.
4881 * @param item a valid #Elm_Widget_Item to be notified
4882 * @see elm_widget_item_del_cb_set() convenience macro.
4886 _elm_widget_item_del_cb_set(Eo *eo_item EINA_UNUSED,
4887 Elm_Widget_Item_Data *item,
4890 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4891 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4893 if ((item->del_func) && (item->del_func != func))
4894 WRN("You're replacing a previously set del_cb %p of item %p with %p",
4895 item->del_func, item->eo_obj, func);
4897 item->del_func = func;
4903 * Get owner widget of this item.
4905 * @param item a valid #Elm_Widget_Item to get data from.
4906 * @return owner widget of this item.
4909 EOLIAN static Evas_Object *
4910 _elm_widget_item_widget_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4912 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4913 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4915 return item->widget;
4919 _elm_widget_onscreen_is(Evas_Object *widget)
4921 Evas_Object *parent = widget;
4922 Evas_Coord x, y, w, h, wx, wy, ww, wh;
4924 Evas *evas = evas_object_evas_get(widget);
4925 if (!evas) return EINA_FALSE;
4927 // check if on canvas
4928 evas_output_viewport_get(evas, &x, &y, &w, &h);
4929 evas_object_geometry_get(widget, &wx, &wy, &ww, &wh);
4930 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4931 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4934 // check if inside scrollable parent viewport
4936 parent = elm_widget_parent_get(parent);
4937 if (parent && !evas_object_visible_get(parent))
4939 if (parent && eo_isa(parent, ELM_INTERFACE_SCROLLABLE_MIXIN))
4941 evas_object_geometry_get(parent, &x, &y, &w, &h);
4942 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4943 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4946 } while (parent && (parent != elm_widget_top_get(widget)));
4952 _elm_widget_item_onscreen_is(Elm_Object_Item *item)
4954 Evas_Coord x, y, w, h, wx, wy, ww, wh;
4955 Elm_Widget_Item_Data *id = eo_data_scope_get(item, ELM_WIDGET_ITEM_CLASS);
4956 if (!id || !id->view) return EINA_FALSE;
4958 if (!evas_object_visible_get(id->view))
4961 if (!_elm_widget_onscreen_is(id->widget))
4964 evas_object_geometry_get(id->view, &x, &y, &w, &h);
4965 evas_object_geometry_get(id->widget, &wx, &wy, &ww, &wh);
4966 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4967 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4973 //TIZEN_ONLY(20161107): enhance elm_atspi_accessible_can_highlight_set to set can_hihglight property to its children
4975 _elm_widget_item_highlightable(Elm_Object_Item *item)
4977 Elm_Widget_Item_Data *id = eo_data_scope_get(item, ELM_WIDGET_ITEM_CLASS);
4978 if (!id) return EINA_FALSE;
4979 if (!id->can_highlight) return EINA_FALSE;
4980 Evas_Object *widget = id->widget;
4981 Evas_Object *parent = widget;
4982 Elm_Widget_Smart_Data *wd;
4983 if (parent && eo_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
4985 wd = eo_data_scope_get(parent, ELM_WIDGET_CLASS);
4986 if (!wd->can_highlight) return EINA_FALSE;
4990 parent = elm_widget_parent_get(parent);
4991 if (parent && eo_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
4993 wd = eo_data_scope_get(parent, ELM_WIDGET_CLASS);
4994 if (!wd->can_highlight) return EINA_FALSE;
4997 while (parent && (parent != elm_widget_top_get(widget)));
5002 EOLIAN static Elm_Atspi_State_Set
5003 _elm_widget_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_item,
5004 Elm_Widget_Item_Data *item)
5006 Elm_Atspi_State_Set states = 0;
5008 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
5010 if (elm_object_item_focus_get(eo_item))
5011 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
5012 if (!elm_object_item_disabled_get(eo_item))
5014 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
5015 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
5016 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
5018 if (_elm_widget_item_onscreen_is(eo_item))
5019 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
5021 //TIZEN_ONLY(20170717) : expose highlight information on atspi
5022 if (_elm_widget_item_highlightable(eo_item))
5023 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
5025 STATE_TYPE_UNSET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
5027 if (_elm_object_accessibility_currently_highlighted_get() == (void*)item->eo_obj)
5028 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTED);
5034 _elm_widget_item_elm_interface_atspi_accessible_parent_get(Eo *eo_item, Elm_Widget_Item_Data *item EINA_UNUSED)
5037 eo_do(eo_item, parent = eo_parent_get());
5042 elm_object_item_data_set(Elm_Object_Item *it, void *data)
5044 WIDGET_ITEM_DATA_SET(it, data);
5048 elm_object_item_data_get(const Elm_Object_Item *it)
5050 return (void *) WIDGET_ITEM_DATA_GET(it);
5054 _elm_widget_item_disabled_set(Eo *eo_item EINA_UNUSED,
5055 Elm_Widget_Item_Data *item,
5058 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5059 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5061 if (item->disabled == disabled) return;
5062 item->disabled = !!disabled;
5063 eo_do(item->eo_obj, elm_wdg_item_disable());
5066 EOLIAN static Eina_Bool
5067 _elm_widget_item_disabled_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5069 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5070 return item->disabled;
5074 _elm_widget_item_style_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, const char *style EINA_UNUSED)
5076 ERR_NOT_SUPPORTED(item, "elm_object_style_set()");
5079 EOLIAN static const char *
5080 _elm_widget_item_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5082 ERR_NOT_SUPPORTED(item, "elm_object_style_get()");
5087 _elm_widget_item_disable(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
5092 _elm_widget_item_focus_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Eina_Bool focused EINA_UNUSED)
5094 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_set");
5097 EOLIAN static Eina_Bool
5098 _elm_widget_item_focus_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5100 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_get");
5105 _elm_widget_item_domain_translatable_part_text_set(Eo *eo_item EINA_UNUSED,
5106 Elm_Widget_Item_Data *item,
5111 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5112 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5113 Elm_Translate_String_Data *ts;
5117 _part_text_translatable_set(&item->translate_strings, part, EINA_FALSE,
5122 ts = _part_text_translatable_set(&item->translate_strings, part,
5123 EINA_TRUE, EINA_FALSE);
5125 if (!ts->string) ts->string = eina_stringshare_add(label);
5126 else eina_stringshare_replace(&ts->string, label);
5127 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5128 else eina_stringshare_replace(&ts->domain, domain);
5130 if (label[0]) label = dgettext(domain, label);
5133 item->on_translate = EINA_TRUE;
5134 eo_do(item->eo_obj, elm_wdg_item_part_text_set(part, label));
5135 item->on_translate = EINA_FALSE;
5138 EOLIAN static const char *
5139 _elm_widget_item_translatable_part_text_get(const Eo *eo_item EINA_UNUSED,
5140 Elm_Widget_Item_Data *item,
5143 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5144 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5146 Elm_Translate_String_Data *ts;
5147 ts = _translate_string_data_get(item->translate_strings, part);
5148 if (ts) return ts->string;
5153 _elm_widget_item_domain_part_text_translatable_set(Eo *eo_item EINA_UNUSED,
5154 Elm_Widget_Item_Data *item,
5157 Eina_Bool translatable)
5159 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5160 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5161 Elm_Translate_String_Data *ts;
5164 ts = _part_text_translatable_set(&item->translate_strings, part,
5165 translatable, EINA_TRUE);
5167 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5168 else eina_stringshare_replace(&ts->domain, domain);
5170 eo_do(item->eo_obj, text = elm_wdg_item_part_text_get(part));
5172 if (!text || !text[0]) return;
5174 if (!ts->string) ts->string = eina_stringshare_add(text);
5176 //Try to translate text since we don't know the text is already translated.
5178 text = dgettext(domain, text);
5180 item->on_translate = EINA_TRUE;
5181 eo_do (item->eo_obj, elm_wdg_item_part_text_set(part, text));
5182 item->on_translate = EINA_FALSE;
5186 _elm_widget_item_track_cancel(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5188 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5189 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5191 if (!item->track_obj) return;
5193 while (evas_object_ref_get(item->track_obj) > 0)
5194 evas_object_unref(item->track_obj);
5196 evas_object_del(item->track_obj);
5199 EOLIAN static Evas_Object *
5200 _elm_widget_item_track(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5202 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5203 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5205 if (item->track_obj)
5207 evas_object_ref(item->track_obj);
5208 return item->track_obj;
5213 WRN("view obj of the item(%p) is invalid. Please make sure the view obj is created!", item);
5217 Evas_Object *track =
5218 evas_object_rectangle_add(evas_object_evas_get(item->widget));
5219 evas_object_color_set(track, 0, 0, 0, 0);
5220 evas_object_pass_events_set(track, EINA_TRUE);
5221 _track_obj_update(track, item->view);
5222 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
5226 eo_event_callback_array_add(tracker_callbacks(), item));
5228 evas_object_ref(track);
5230 item->track_obj = track;
5236 _elm_widget_item_untrack(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5238 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5239 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5241 if (!item->track_obj) return;
5242 evas_object_unref(item->track_obj);
5244 if (evas_object_ref_get(item->track_obj) == 0)
5245 evas_object_del(item->track_obj);
5249 _elm_widget_item_track_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5251 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
5252 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, 0);
5254 if (!item->track_obj) return 0;
5255 return evas_object_ref_get(item->track_obj);
5258 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
5260 struct _Elm_Widget_Item_Tooltip
5262 Elm_Widget_Item_Data *item;
5263 Elm_Tooltip_Item_Content_Cb func;
5264 Evas_Smart_Cb del_cb;
5268 static Evas_Object *
5269 _elm_widget_item_tooltip_label_create(void *data,
5270 Evas_Object *obj EINA_UNUSED,
5271 Evas_Object *tooltip,
5272 void *item EINA_UNUSED)
5274 Evas_Object *label = elm_label_add(tooltip);
5277 elm_object_style_set(label, "tooltip");
5278 elm_object_text_set(label, data);
5282 static Evas_Object *
5283 _elm_widget_item_tooltip_trans_label_create(void *data,
5284 Evas_Object *obj EINA_UNUSED,
5285 Evas_Object *tooltip,
5286 void *item EINA_UNUSED)
5288 Evas_Object *label = elm_label_add(tooltip);
5291 elm_object_style_set(label, "tooltip");
5292 elm_object_translatable_text_set(label, data);
5297 _elm_widget_item_tooltip_label_del_cb(void *data,
5298 Evas_Object *obj EINA_UNUSED,
5299 void *event_info EINA_UNUSED)
5301 eina_stringshare_del(data);
5307 * Set the text to be shown in the widget item.
5309 * @param item Target item
5310 * @param text The text to set in the content
5312 * Setup the text as tooltip to object. The item can have only one tooltip,
5313 * so any previous tooltip data is removed.
5318 _elm_widget_item_tooltip_text_set(Eo *eo_item EINA_UNUSED,
5319 Elm_Widget_Item_Data *item EINA_UNUSED,
5322 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5323 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5324 EINA_SAFETY_ON_NULL_RETURN(text);
5326 text = eina_stringshare_add(text);
5327 eo_do(item->eo_obj, elm_wdg_item_tooltip_content_cb_set(
5328 _elm_widget_item_tooltip_label_create,
5330 _elm_widget_item_tooltip_label_del_cb));
5334 _elm_widget_item_tooltip_translatable_text_set(Eo *eo_item EINA_UNUSED,
5335 Elm_Widget_Item_Data *item EINA_UNUSED,
5338 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5339 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5340 EINA_SAFETY_ON_NULL_RETURN(text);
5342 text = eina_stringshare_add(text);
5343 eo_do(item->eo_obj, elm_wdg_item_tooltip_content_cb_set(
5344 _elm_widget_item_tooltip_trans_label_create,
5346 _elm_widget_item_tooltip_label_del_cb));
5349 static Evas_Object *
5350 _elm_widget_item_tooltip_create(void *data,
5352 Evas_Object *tooltip)
5354 Elm_Widget_Item_Tooltip *wit = data;
5355 return wit->func((void *)wit->data, obj, tooltip, wit->item->eo_obj);
5359 _elm_widget_item_tooltip_del_cb(void *data,
5361 void *event_info EINA_UNUSED)
5363 Elm_Widget_Item_Tooltip *wit = data;
5364 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item->eo_obj);
5371 * Set the content to be shown in the tooltip item
5373 * Setup the tooltip to item. The item can have only one tooltip,
5374 * so any previous tooltip data is removed. @p func(with @p data) will
5375 * be called every time that need show the tooltip and it should
5376 * return a valid Evas_Object. This object is then managed fully by
5377 * tooltip system and is deleted when the tooltip is gone.
5379 * @param item the widget item being attached a tooltip.
5380 * @param func the function used to create the tooltip contents.
5381 * @param data what to provide to @a func as callback data/context.
5382 * @param del_cb called when data is not needed anymore, either when
5383 * another callback replaces @func, the tooltip is unset with
5384 * elm_widget_item_tooltip_unset() or the owner @a item
5385 * dies. This callback receives as the first parameter the
5386 * given @a data, and @c event_info is the item.
5391 _elm_widget_item_tooltip_content_cb_set(Eo *eo_item EINA_UNUSED,
5392 Elm_Widget_Item_Data *item,
5393 Elm_Tooltip_Item_Content_Cb func,
5395 Evas_Smart_Cb del_cb)
5397 Elm_Widget_Item_Tooltip *wit;
5399 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
5400 //ELM_WIDGET_ITEM_RETURN_IF_GOTO(item, error_noitem);
5404 eo_do(item->eo_obj, elm_wdg_item_tooltip_unset());
5408 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
5409 if (!wit) goto error;
5413 wit->del_cb = del_cb;
5415 elm_object_sub_tooltip_content_cb_set
5416 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
5417 _elm_widget_item_tooltip_del_cb);
5422 if (del_cb) del_cb((void *)data, NULL, item);
5425 if (del_cb) del_cb((void *)data, item->widget, item);
5431 * Unset tooltip from item
5433 * @param item widget item to remove previously set tooltip.
5435 * Remove tooltip from item. The callback provided as del_cb to
5436 * elm_widget_item_tooltip_content_cb_set() will be called to notify
5437 * it is not used anymore.
5439 * @see elm_widget_item_tooltip_content_cb_set()
5444 _elm_widget_item_tooltip_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5446 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5447 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5449 elm_object_tooltip_unset(item->view);
5455 * Sets a different style for this item tooltip.
5457 * @note before you set a style you should define a tooltip with
5458 * elm_widget_item_tooltip_content_cb_set() or
5459 * elm_widget_item_tooltip_text_set()
5461 * @param item widget item with tooltip already set.
5462 * @param style the theme style to use (default, transparent, ...)
5467 _elm_widget_item_tooltip_style_set(Eo *eo_item EINA_UNUSED,
5468 Elm_Widget_Item_Data *item,
5471 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5472 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5474 elm_object_tooltip_style_set(item->view, style);
5477 EOLIAN static Eina_Bool
5478 _elm_widget_item_tooltip_window_mode_set(Eo *eo_item EINA_UNUSED,
5479 Elm_Widget_Item_Data *item,
5482 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5483 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5485 return elm_object_tooltip_window_mode_set(item->view, disable);
5488 EOLIAN static Eina_Bool
5489 _elm_widget_item_tooltip_window_mode_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5491 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5492 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5494 return elm_object_tooltip_window_mode_get(item->view);
5500 * Get the style for this item tooltip.
5502 * @param item widget item with tooltip already set.
5503 * @return style the theme style in use, defaults to "default". If the
5504 * object does not have a tooltip set, then NULL is returned.
5508 EOLIAN static const char *
5509 _elm_widget_item_tooltip_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5511 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5513 return elm_object_tooltip_style_get(item->view);
5517 _elm_widget_item_cursor_set(Eo *eo_item EINA_UNUSED,
5518 Elm_Widget_Item_Data *item,
5521 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5522 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5524 elm_object_sub_cursor_set(item->view, item->widget, cursor);
5527 EOLIAN static const char *
5528 _elm_widget_item_cursor_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5530 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5531 return elm_object_cursor_get(item->view);
5535 _elm_widget_item_cursor_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5537 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5538 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5540 elm_object_cursor_unset(item->view);
5546 * Sets a different style for this item cursor.
5548 * @note before you set a style you should define a cursor with
5549 * elm_widget_item_cursor_set()
5551 * @param item widget item with cursor already set.
5552 * @param style the theme style to use (default, transparent, ...)
5557 _elm_widget_item_cursor_style_set(Eo *eo_item EINA_UNUSED,
5558 Elm_Widget_Item_Data *item,
5561 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5562 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5564 elm_object_cursor_style_set(item->view, style);
5570 * Get the style for this item cursor.
5572 * @param item widget item with cursor already set.
5573 * @return style the theme style in use, defaults to "default". If the
5574 * object does not have a cursor set, then NULL is returned.
5578 EOLIAN static const char *
5579 _elm_widget_item_cursor_style_get(Eo *eo_item EINA_UNUSED,
5580 Elm_Widget_Item_Data *item)
5582 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5583 return elm_object_cursor_style_get(item->view);
5589 * Set if the cursor set should be searched on the theme or should use
5590 * the provided by the engine, only.
5592 * @note before you set if should look on theme you should define a cursor
5593 * with elm_object_cursor_set(). By default it will only look for cursors
5594 * provided by the engine.
5596 * @param item widget item with cursor already set.
5597 * @param engine_only boolean to define it cursors should be looked only
5598 * between the provided by the engine or searched on widget's theme as well.
5603 _elm_widget_item_cursor_engine_only_set(Eo *eo_item EINA_UNUSED,
5604 Elm_Widget_Item_Data *item,
5605 Eina_Bool engine_only)
5607 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5608 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5610 elm_object_cursor_theme_search_enabled_set(item->view, !engine_only);
5616 * Get the cursor engine only usage for this item cursor.
5618 * @param item widget item with cursor already set.
5619 * @return engine_only boolean to define it cursors should be looked only
5620 * between the provided by the engine or searched on widget's theme as well. If
5621 * the object does not have a cursor set, then EINA_FALSE is returned.
5625 EOLIAN static Eina_Bool
5626 _elm_widget_item_cursor_engine_only_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5628 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5629 return !elm_object_cursor_theme_search_enabled_get(item->view);
5633 _elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
5634 Elm_Widget_Item_Data *item,
5635 const char *part EINA_UNUSED,
5636 Evas_Object *content EINA_UNUSED)
5638 ERR_NOT_SUPPORTED(item, "elm_object_part_content_set()");
5641 EOLIAN static Evas_Object *
5642 _elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
5643 Elm_Widget_Item_Data *item,
5644 const char *part EINA_UNUSED)
5646 ERR_NOT_SUPPORTED(item, "elm_object_part_content_get()");
5650 EOLIAN static Evas_Object *
5651 _elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED,
5652 Elm_Widget_Item_Data *item,
5653 const char *part EINA_UNUSED)
5655 ERR_NOT_SUPPORTED(item, "elm_object_part_content_unset()");
5660 _elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
5661 Elm_Widget_Item_Data *item,
5662 const char *part EINA_UNUSED,
5663 const char *label EINA_UNUSED)
5665 ERR_NOT_SUPPORTED(item, "elm_object_part_text_set()");
5668 EOLIAN static const char *
5669 _elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
5670 Elm_Widget_Item_Data *item,
5671 const char *part EINA_UNUSED)
5673 ERR_NOT_SUPPORTED(item, "elm_object_part_text_get()");
5678 _elm_widget_item_part_text_custom_free(void *data)
5680 Elm_Label_Data *label;
5682 eina_stringshare_del(label->part);
5683 eina_stringshare_del(label->text);
5688 _elm_widget_item_part_text_custom_set(Eo *eo_item EINA_UNUSED,
5689 Elm_Widget_Item_Data *item,
5693 Elm_Label_Data *label;
5694 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5695 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5699 eina_hash_stringshared_new(_elm_widget_item_part_text_custom_free);
5700 label = eina_hash_find(item->labels, part);
5703 label = malloc(sizeof(Elm_Label_Data));
5706 ERR("Failed to allocate memory");
5709 label->part = eina_stringshare_add(part);
5710 label->text = eina_stringshare_add(text);
5711 eina_hash_add(item->labels, part, label);
5714 eina_stringshare_replace(&label->text, text);
5717 EOLIAN static const char *
5718 _elm_widget_item_part_text_custom_get(Eo *eo_item EINA_UNUSED,
5719 Elm_Widget_Item_Data *item,
5722 Elm_Label_Data *label;
5723 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5724 label = eina_hash_find(item->labels, part);
5725 return label ? label->text : NULL;
5729 _elm_widget_item_part_text_custom_foreach(const Eina_Hash *labels EINA_UNUSED,
5730 const void *key EINA_UNUSED,
5734 Elm_Label_Data *label;
5735 Elm_Widget_Item_Data *item;
5739 eo_do(item->eo_obj, elm_wdg_item_part_text_set(label->part, label->text));
5745 _elm_widget_item_part_text_custom_update(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5747 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5748 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5750 eina_hash_foreach(item->labels,
5751 _elm_widget_item_part_text_custom_foreach, item);
5755 _elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
5756 Elm_Widget_Item_Data *item EINA_UNUSED,
5757 const char *emission EINA_UNUSED,
5758 const char *source EINA_UNUSED)
5764 _elm_widget_item_signal_callback_add(Eo *eo_item,
5765 Elm_Widget_Item_Data *item,
5766 const char *emission,
5768 Elm_Object_Item_Signal_Cb func,
5771 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5772 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5773 EINA_SAFETY_ON_NULL_RETURN(func);
5775 Elm_Widget_Item_Signal_Data *wisd;
5777 wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
5780 wisd->item = eo_item;
5781 wisd->func = (Elm_Widget_Item_Signal_Cb)func;
5783 wisd->emission = eina_stringshare_add(emission);
5784 wisd->source = eina_stringshare_add(source);
5786 if (_elm_widget_is(item->view))
5787 elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5788 else if (eo_isa(item->view, EDJE_OBJECT_CLASS))
5789 edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5792 WRN("The %s widget item doesn't support signal callback add!",
5793 eo_class_name_get(eo_class_get(item->widget)));
5798 item->signals = eina_list_append(item->signals, wisd);
5801 EOLIAN static void *
5802 _elm_widget_item_signal_callback_del(Eo *eo_item EINA_UNUSED,
5803 Elm_Widget_Item_Data *item,
5804 const char *emission,
5806 Elm_Object_Item_Signal_Cb func)
5808 Elm_Widget_Item_Signal_Data *wisd;
5811 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5812 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5813 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
5815 EINA_LIST_FOREACH(item->signals, l, wisd)
5817 if ((wisd->func == (Elm_Widget_Item_Signal_Cb)func) &&
5818 !strcmp(wisd->emission, emission) &&
5819 !strcmp(wisd->source, source))
5820 return _elm_widget_item_signal_callback_list_get(item, l);
5827 _elm_widget_item_access_info_set(Eo *eo_item EINA_UNUSED,
5828 Elm_Widget_Item_Data *item,
5831 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5832 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5834 eina_stringshare_del(item->access_info);
5835 if (!txt) item->access_info = NULL;
5836 else item->access_info = eina_stringshare_add(txt);
5840 _elm_widget_item_translate(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5842 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5843 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5846 Elm_Translate_String_Data *ts;
5847 EINA_INLIST_FOREACH(item->translate_strings, ts)
5849 if (!ts->string) continue;
5850 const char *s = dgettext(ts->domain, ts->string);
5851 item->on_translate = EINA_TRUE;
5852 eo_do(item->eo_obj, elm_wdg_item_part_text_set(ts->id, s));
5853 item->on_translate = EINA_FALSE;
5859 _elm_widget_item_access_order_set(Eo *eo_item EINA_UNUSED,
5860 Elm_Widget_Item_Data *item,
5863 _elm_access_widget_item_access_order_set(item, objs);
5866 EOLIAN static const Eina_List *
5867 _elm_widget_item_access_order_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5869 return _elm_access_widget_item_access_order_get(item);
5873 _elm_widget_item_access_order_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5875 _elm_access_widget_item_access_order_unset(item);
5878 EOLIAN static Evas_Object*
5879 _elm_widget_item_access_register(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5881 _elm_access_widget_item_register(item);
5882 return item->access_obj;
5886 _elm_widget_item_access_unregister(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5888 _elm_access_widget_item_unregister(item);
5891 EOLIAN static Evas_Object*
5892 _elm_widget_item_access_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5894 return item->access_obj;
5897 EOLIAN static Evas_Object *
5898 _elm_widget_item_focus_next_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
5900 Evas_Object *ret = NULL;
5902 if (dir == ELM_FOCUS_PREVIOUS)
5903 ret = item->focus_previous;
5904 else if (dir == ELM_FOCUS_NEXT)
5905 ret = item->focus_next;
5906 else if (dir == ELM_FOCUS_UP)
5907 ret = item->focus_up;
5908 else if (dir == ELM_FOCUS_DOWN)
5909 ret = item->focus_down;
5910 else if (dir == ELM_FOCUS_RIGHT)
5911 ret = item->focus_right;
5912 else if (dir == ELM_FOCUS_LEFT)
5913 ret = item->focus_left;
5919 _elm_widget_item_focus_next_object_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Evas_Object *next, Elm_Focus_Direction dir)
5921 if (dir == ELM_FOCUS_PREVIOUS)
5922 item->focus_previous = next;
5923 else if (dir == ELM_FOCUS_NEXT)
5924 item->focus_next = next;
5925 else if (dir == ELM_FOCUS_UP)
5926 item->focus_up = next;
5927 else if (dir == ELM_FOCUS_DOWN)
5928 item->focus_down = next;
5929 else if (dir == ELM_FOCUS_RIGHT)
5930 item->focus_right = next;
5931 else if (dir == ELM_FOCUS_LEFT)
5932 item->focus_left = next;
5935 EOLIAN static Elm_Object_Item*
5936 _elm_widget_item_focus_next_item_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
5938 Elm_Object_Item *ret = NULL;
5940 if (dir == ELM_FOCUS_PREVIOUS)
5941 ret = item->item_focus_previous;
5942 else if (dir == ELM_FOCUS_NEXT)
5943 ret = item->item_focus_next;
5944 else if (dir == ELM_FOCUS_UP)
5945 ret = item->item_focus_up;
5946 else if (dir == ELM_FOCUS_DOWN)
5947 ret = item->item_focus_down;
5948 else if (dir == ELM_FOCUS_RIGHT)
5949 ret = item->item_focus_right;
5950 else if (dir == ELM_FOCUS_LEFT)
5951 ret = item->item_focus_left;
5957 _elm_widget_item_focus_next_item_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
5959 if (dir == ELM_FOCUS_PREVIOUS)
5960 item->item_focus_previous = next_item;
5961 else if (dir == ELM_FOCUS_NEXT)
5962 item->item_focus_next = next_item;
5963 else if (dir == ELM_FOCUS_UP)
5964 item->item_focus_up = next_item;
5965 else if (dir == ELM_FOCUS_DOWN)
5966 item->item_focus_down = next_item;
5967 else if (dir == ELM_FOCUS_RIGHT)
5968 item->item_focus_right = next_item;
5969 else if (dir == ELM_FOCUS_LEFT)
5970 item->item_focus_left = next_item;
5973 /* happy debug functions */
5976 _sub_obj_tree_dump(const Evas_Object *obj,
5981 for (i = 0; i < lvl * 3; i++)
5984 if (_elm_widget_is(obj))
5989 elm_widget_type_get(obj),
5991 EINA_LIST_FOREACH(sd->subobjs, l, obj)
5992 _sub_obj_tree_dump(obj, lvl + 1);
5995 DBG("+ %s(%p)\n", evas_object_type_get(obj), obj);
5999 _sub_obj_tree_dot_dump(const Evas_Object *obj,
6002 if (!_elm_widget_is(obj))
6006 Eina_Bool visible = evas_object_visible_get(obj);
6007 Eina_Bool disabled = elm_widget_disabled_get(obj);
6008 Eina_Bool focused = elm_widget_focus_get(obj);
6009 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
6013 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
6016 fprintf(output, ", style=bold");
6019 fprintf(output, ", color=gray28");
6021 fprintf(output, " ];\n");
6024 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
6025 "disabled: %d|focused: %d/%d|focus order:%d}\"",
6026 obj, obj, elm_widget_type_get(obj),
6027 evas_object_name_get(obj), visible, disabled, focused, can_focus,
6031 fprintf(output, ", style=bold");
6034 fprintf(output, ", fontcolor=gray28");
6036 if ((disabled) || (!visible))
6037 fprintf(output, ", color=gray");
6039 fprintf(output, " ];\n");
6043 EINA_LIST_FOREACH(sd->subobjs, l, o)
6044 _sub_obj_tree_dot_dump(o, output);
6050 elm_widget_tree_dump(const Evas_Object *top)
6053 if (!_elm_widget_is(top))
6055 _sub_obj_tree_dump(top, 0);
6063 elm_widget_tree_dot_dump(const Evas_Object *top,
6067 if (!_elm_widget_is(top))
6069 fprintf(output, "graph " " { node [shape=record];\n");
6070 _sub_obj_tree_dot_dump(top, output);
6071 fprintf(output, "}\n");
6080 _elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
6084 sd->on_create = EINA_TRUE;
6085 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
6087 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
6088 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
6089 parent = eo_parent_get());
6090 eo_do(obj, elm_obj_widget_parent_set(parent));
6091 sd->on_create = EINA_FALSE;
6092 //TIZEN_ONLY(20170717) : expose highlight information on atspi
6093 sd->can_highlight = EINA_TRUE;
6095 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
6096 sd->inherit_paragraph_direction = EINA_TRUE;
6099 eo_do(obj, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_UNKNOWN));
6101 /* TIZEN_ONLY(20161117): Inherit paragraph direction from widget parent */
6102 if (sd->paragraph_direction != evas_object_paragraph_direction_get(parent))
6104 sd->paragraph_direction = evas_object_paragraph_direction_get(parent);
6105 _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, sd->paragraph_direction);
6106 eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(sd->paragraph_direction));
6114 _elm_widget_eo_base_destructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
6116 sd->on_destroy = EINA_TRUE;
6118 elm_interface_atspi_accessible_description_set(NULL),
6119 elm_interface_atspi_accessible_name_set(NULL),
6120 //TIZEN_ONLY(20190922): add name callback, description callback.
6121 elm_interface_atspi_accessible_description_cb_set(NULL, NULL),
6122 elm_interface_atspi_accessible_name_cb_set(NULL, NULL),
6124 elm_interface_atspi_accessible_translation_domain_set(NULL),
6125 elm_interface_atspi_accessible_relationships_clear(),
6126 // TIZEN_ONLY(20160930) : endless recursion fix
6127 elm_interface_atspi_accessible_attributes_clear()
6130 // TIZEN_ONLY(20150709) : atspi relations api
6131 if (sd->atspi_custom_relations)
6132 elm_atspi_relation_set_free(&sd->atspi_custom_relations);
6134 //TIZEN_ONLY(20150717) add widget name setter
6136 eina_stringshare_del(sd->name);
6139 //TIZEN_ONLY(20150731) : add i18n support for name and description
6140 if (sd->atspi_translation_domain)
6141 eina_stringshare_del(sd->atspi_translation_domain);
6143 //Tizen Only(20160728) free attribute list
6146 Elm_Atspi_Attribute *attr;
6147 EINA_LIST_FREE(sd->attr_list, attr)
6149 eina_stringshare_del(attr->key);
6150 eina_stringshare_del(attr->value);
6156 eo_do_super(obj, ELM_WIDGET_CLASS, eo_destructor());
6157 sd->on_destroy = EINA_FALSE;
6159 elm_interface_atspi_accessible_removed(obj);
6162 EOLIAN static Eina_Bool
6163 _elm_widget_on_focus(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Object_Item *item EINA_UNUSED)
6165 if (elm_widget_can_focus_get(obj))
6167 if (elm_widget_focus_get(obj))
6169 if (!sd->resize_obj)
6170 evas_object_focus_set(obj, EINA_TRUE);
6171 eo_do(obj, eo_event_callback_call
6172 (ELM_WIDGET_EVENT_FOCUSED, NULL));
6173 if (_elm_atspi_enabled() && !elm_widget_child_can_focus_get(obj))
6174 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_FOCUSED, EINA_TRUE);
6178 if (!sd->resize_obj)
6179 evas_object_focus_set(obj, EINA_FALSE);
6180 eo_do(obj, eo_event_callback_call
6181 (ELM_WIDGET_EVENT_UNFOCUSED, NULL));
6182 if (_elm_atspi_enabled() && !elm_widget_child_can_focus_get(obj))
6183 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_FOCUSED, EINA_FALSE);
6192 EOLIAN static Eina_Bool
6193 _elm_widget_disable(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6198 EOLIAN static Eina_Bool
6199 _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)
6204 EOLIAN static Eina_Bool
6205 _elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6207 WRN("The %s widget does not implement the \"focus_next/focus_next_manager_is\" functions.",
6208 eo_class_name_get(eo_class_get(obj)));
6213 _elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6215 WRN("The %s widget does not implement the \"focus_direction/focus_direction_manager_is\" functions.",
6216 eo_class_name_get(eo_class_get(obj)));
6220 EOLIAN static Eina_Bool
6221 _elm_widget_activate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Activate act EINA_UNUSED)
6223 WRN("The %s widget does not implement the \"activate\" functions.",
6224 eo_class_name_get(eo_class_get(obj)));
6229 _elm_widget_class_constructor(Eo_Class *klass)
6231 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
6234 EOLIAN static Eina_Bool
6235 _elm_widget_elm_interface_atspi_component_focus_grab(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6237 if (elm_object_focus_allow_get(obj))
6239 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6240 if (!ee) return EINA_FALSE;
6241 ecore_evas_activate(ee);
6242 elm_object_focus_set(obj, EINA_TRUE);
6248 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods (29e253e2f7ef3c632ac3a64c489bf569df407f30)
6249 EOLIAN static Eina_Bool
6250 _elm_widget_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6252 if(!_elm_atspi_enabled())
6255 elm_widget_focus_region_show(obj);
6257 elm_object_accessibility_highlight_set(obj, EINA_TRUE);
6258 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
6260 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
6261 evas_object_smart_callback_call(obj, SIG_WIDGET_ATSPI_HIGHLIGHTED, NULL);
6266 EOLIAN static Eina_Bool
6267 _elm_widget_elm_interface_atspi_component_highlight_clear(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6269 if(!_elm_atspi_enabled())
6271 elm_object_accessibility_highlight_set(obj, EINA_FALSE);
6272 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_FALSE);
6274 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
6275 evas_object_smart_callback_call(obj, SIG_WIDGET_ATSPI_UNHIGHLIGHTED, NULL);
6281 EOLIAN static const char*
6282 _elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
6284 char *accessible_name;
6285 //TIZEN_ONLY(20190922): add name callback, description callback.
6286 const char *ret = NULL;
6287 eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_name_get());
6288 if (ret) return ret;
6291 //TIZEN_ONLY(20150717) add widget name setter
6295 if (_pd->atspi_translation_domain)
6296 return dgettext(_pd->atspi_translation_domain, _pd->name);
6302 ret = elm_object_text_get(obj);
6303 if (!ret) return NULL;
6305 accessible_name = _elm_util_mkup_to_text(ret);
6306 eina_stringshare_del(_pd->accessible_name);
6307 _pd->accessible_name = eina_stringshare_add(accessible_name);
6308 free(accessible_name);
6309 return _pd->accessible_name;
6311 //TIZEN_ONLY(20161111) add widget/widget_item description get/set
6313 _elm_widget_elm_interface_atspi_accessible_description_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data* _pd EINA_UNUSED, const char *description)
6315 if (_pd->description)
6316 eina_stringshare_del(_pd->description);
6318 _pd->description = eina_stringshare_add(description);
6321 EOLIAN static const char*
6322 _elm_widget_elm_interface_atspi_accessible_description_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6324 const char *ret = NULL;
6325 eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_description_get());
6326 if (ret) return ret;
6329 if (_pd->atspi_translation_domain)
6330 return dgettext(_pd->atspi_translation_domain, _pd->description);
6332 return _pd->description;
6336 //TIZEN_ONLY(20150713) : add atspi name setter to widget_item
6338 _elm_widget_item_elm_interface_atspi_accessible_name_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data* _pd EINA_UNUSED, const char *name)
6341 eina_stringshare_del(_pd->name);
6343 _pd->name = eina_stringshare_add(name);
6347 _elm_widget_item_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6349 //TIZEN_ONLY(20190922): add name callback, description callback.
6350 const char *ret = NULL;
6351 eo_do_super(obj, ELM_WIDGET_ITEM_CLASS, ret = elm_interface_atspi_accessible_name_get());
6352 if (ret) return ret;
6358 if (_pd->atspi_translation_domain)
6359 return dgettext(_pd->atspi_translation_domain, _pd->name);
6367 //TIZEN_ONLY(20161111) add widget/widget_item description get/set
6369 _elm_widget_item_elm_interface_atspi_accessible_description_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data* _pd EINA_UNUSED, const char *description)
6371 if (_pd->description)
6372 eina_stringshare_del(_pd->description);
6374 _pd->description = eina_stringshare_add(description);
6378 _elm_widget_item_elm_interface_atspi_accessible_description_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6380 const char *ret = NULL;
6381 eo_do_super(obj, ELM_WIDGET_ITEM_CLASS, ret = elm_interface_atspi_accessible_description_get());
6382 if (ret) return ret;
6385 if (_pd->atspi_translation_domain)
6386 return dgettext(_pd->atspi_translation_domain, _pd->description);
6388 return _pd->description;
6391 //TIZEN_ONLY(20150709) : spatially sort atspi children
6392 static int _sort_vertically(const void *data1, const void *data2)
6395 evas_object_geometry_get(data1, NULL, &y1, NULL, NULL);
6396 evas_object_geometry_get(data2, NULL, &y2, NULL, NULL);
6398 return y1 < y2 ? -1 : 1;
6401 static int _sort_horizontally(const void *data1, const void *data2)
6404 evas_object_geometry_get(data1, &x1, NULL, NULL, NULL);
6405 evas_object_geometry_get(data2, &x2, NULL, NULL, NULL);
6407 return x1 < x2 ? -1 : 1;
6410 static Eina_List *_lines_split(Eina_List *children)
6413 Eina_List *lines, *line, *l;
6414 Evas_Coord yl, y, hl, h;
6415 lines = line = NULL;
6417 if (!children) return NULL;
6419 EINA_LIST_FOREACH(children, l, c)
6421 evas_object_geometry_get(c, NULL, &yl, NULL, &hl);
6423 /* remove child if its height == 0 */
6427 EINA_LIST_FREE(children, c)
6429 evas_object_geometry_get(c, NULL, &y, NULL, &h);
6431 /* remove child if its height == 0 */
6432 if (h == 0) continue;
6434 if ((yl + (int)(0.25 * hl)) >= y)
6437 line = eina_list_append(line,c);
6441 // finish current line & start new
6442 lines = eina_list_append(lines, line);
6444 line = eina_list_append(NULL, c);
6448 return eina_list_append(lines, line);
6452 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6454 _proxy_widget_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6459 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
6460 elm_atspi_bridge_utils_proxy_offset_set(proxy, x, y);
6465 _on_widget_del(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
6468 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6469 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
6470 _proxy_widget_move_cb, plug);
6476 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6478 _on_proxy_connected_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
6481 Evas_Object *widget = data;
6483 evas_object_geometry_get(widget, &x, &y, NULL, NULL);
6484 elm_atspi_bridge_utils_proxy_offset_set(obj, x, y);
6486 evas_object_event_callback_add(widget, EVAS_CALLBACK_MOVE, _proxy_widget_move_cb, obj);
6492 EOLIAN static Eina_List*
6493 _elm_widget_elm_interface_atspi_accessible_children_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6495 Eina_List *l, *accs = NULL;
6496 Elm_Widget_Smart_Data *wd;
6497 Evas_Object *widget;
6498 // TIZEN_ONLY(20160824): Do not append a child, if its accessible parent is different with widget parent
6502 wd = eo_data_scope_get(obj, ELM_WIDGET_CLASS);
6503 if (!wd) return NULL;
6505 EINA_LIST_FOREACH(wd->subobjs, l, widget)
6507 const char *type = evas_object_type_get(widget);
6509 // Ugly Tizen hack to integrate AT-SPI2 accessibility provided by WebKit/Chromium with elementary one.
6510 // This wrapper class should be implemented in Webkit/Chromium EFL ports
6511 if (type && (!strcmp(type, "EWebView") || !strcmp(type, "WebView"))) {
6512 elm_atspi_ewk_wrapper_a11y_init(obj, widget);
6516 EINA_LIST_FOREACH(wd->subobjs, l, widget)
6518 // TIZEN_ONLY(20160824): Do not append a child, if its accessible parent is different with widget parent
6519 if (eo_isa(widget, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN)) {
6520 eo_do(widget, parent = elm_interface_atspi_accessible_parent_get());
6521 if (parent && (parent != obj)) continue;
6524 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6525 const char *plug_id_2;
6526 if ((plug_id_2 = evas_object_data_get(widget, "___PLUGID")) != NULL)
6528 // TIZEN_ONLY(20160930) : endless recursion fix
6529 eo_do_super(obj, MY_CLASS, elm_interface_atspi_accessible_attribute_append("___PlugID", plug_id_2));
6532 char *svcname, *svcnum;
6534 proxy = evas_object_data_get(widget, "__widget_proxy");
6537 accs = eina_list_append(accs, proxy);
6541 if (_elm_atspi_bridge_plug_id_split(plug_id_2, &svcname, &svcnum))
6543 proxy = _elm_atspi_bridge_utils_proxy_create(obj, svcname, atoi(svcnum), ELM_ATSPI_PROXY_TYPE_PLUG);
6544 evas_object_data_set(widget, "__widget_proxy", proxy);
6545 eo_do(widget, eo_event_callback_add(EO_EV_DEL, _on_widget_del, proxy));
6546 eo_do(proxy, eo_event_callback_add(ELM_ATSPI_PROXY_EVENT_CONNECTED, _on_proxy_connected_cb, widget));
6547 elm_atspi_bridge_utils_proxy_connect(proxy);
6548 accs = eina_list_append(accs, proxy);
6556 if (!elm_object_widget_check(widget)) continue;
6557 if (eo_isa(widget, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
6558 accs = eina_list_append(accs, widget);
6560 //TIZEN_ONLY(20150709) : spatially sort atspi children
6561 // sort children using its top-left coordinate
6562 accs = eina_list_sort(accs, -1, _sort_vertically);
6563 Eina_List *line, *lines = _lines_split(accs);
6565 EINA_LIST_FREE(lines, line)
6566 accs = eina_list_merge(accs, eina_list_sort(line, -1, _sort_horizontally));
6572 _elm_widget_elm_interface_atspi_accessible_parent_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd)
6575 eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_parent_get());
6577 return ret ? ret : pd->parent_obj;
6580 //TIZEN_ONLY(20161107): enhance elm_atspi_accessible_can_highlight_set to set can_hihglight property to its children
6582 _elm_widget_highlightable(Evas_Object *obj)
6584 Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_WIDGET_CLASS);
6585 if (!wd) return EINA_FALSE;
6586 if (!wd->can_highlight) return EINA_FALSE;
6587 Evas_Object *parent = elm_widget_parent_get(obj);
6588 if (parent && eo_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
6590 wd = eo_data_scope_get(parent, ELM_WIDGET_CLASS);
6591 if (!wd->can_highlight) return EINA_FALSE;
6595 parent = elm_widget_parent_get(parent);
6596 if (parent && eo_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
6598 wd = eo_data_scope_get(parent, ELM_WIDGET_CLASS);
6599 if (!wd->can_highlight) return EINA_FALSE;
6602 while (parent && (parent != elm_widget_top_get(obj)));
6607 EOLIAN static Elm_Atspi_State_Set
6608 _elm_widget_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Widget_Smart_Data *pd)
6610 Elm_Atspi_State_Set states = 0;
6612 eo_do_super(obj, ELM_WIDGET_CLASS, states = elm_interface_atspi_accessible_state_set_get());
6614 if (evas_object_visible_get(obj))
6616 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
6617 if (_elm_widget_onscreen_is(obj))
6618 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
6620 if (!elm_widget_child_can_focus_get(obj))
6622 if (elm_object_focus_allow_get(obj))
6623 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
6624 if (elm_object_focus_get(obj))
6625 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
6627 if (!elm_object_disabled_get(obj))
6629 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
6630 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
6633 //TIZEN_ONLY(20170717) : expose highlight information on atspi
6634 if (_elm_widget_highlightable(obj))
6635 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
6637 STATE_TYPE_UNSET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
6639 if (_elm_object_accessibility_currently_highlighted_get() == (void*)pd->obj)
6640 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTED);
6646 //TIZEN_ONLY(20160729): attributes_get, append APIs added/updated.
6647 EOLIAN static Eina_List*
6648 _elm_widget_elm_interface_atspi_accessible_attributes_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6650 Eina_List *attr_list = NULL;
6651 // TIZEN_ONLY(20160930) : endless recursion fix
6652 eo_do_super(obj, MY_CLASS, attr_list = elm_interface_atspi_accessible_attributes_get());
6654 //Add type and style information in addition.
6655 Elm_Atspi_Attribute *attr = NULL;
6656 attr = calloc(1, sizeof(Elm_Atspi_Attribute));
6659 attr->key = eina_stringshare_add("type");
6660 attr->value = eina_stringshare_add(elm_widget_type_get(obj));
6661 attr_list = eina_list_append(attr_list, attr);
6664 attr = calloc(1, sizeof(Elm_Atspi_Attribute));
6667 attr->key = eina_stringshare_add("style");
6668 attr->value = eina_stringshare_add(elm_widget_style_get(obj));
6669 attr_list = eina_list_append(attr_list, attr);
6675 //TIZEN_ONLY(20150709) : atspi relations api
6676 EOLIAN static Elm_Atspi_Relation_Set
6677 _elm_widget_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
6679 return elm_atspi_relation_set_clone(&sd->atspi_custom_relations);
6682 EOLIAN static Elm_Atspi_Relation_Set
6683 _elm_widget_item_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd)
6685 return elm_atspi_relation_set_clone(&sd->atspi_custom_relations);
6690 _elm_widget_item_elm_interface_atspi_component_extents_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords, int *x, int *y, int *w, int *h)
6703 evas_object_geometry_get(sd->view, x, y, w, h);
6706 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(sd->view));
6708 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
6714 EOLIAN static Eina_Bool
6715 _elm_widget_item_elm_interface_atspi_component_extents_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
6721 _elm_widget_item_elm_interface_atspi_component_layer_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6725 return evas_object_layer_get(sd->view);
6728 EOLIAN static Eina_Bool
6729 _elm_widget_item_elm_interface_atspi_component_focus_grab(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6731 elm_object_item_focus_set(obj, EINA_TRUE);
6732 return elm_object_item_focus_get(obj);
6735 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods
6736 EOLIAN static Eina_Bool
6737 _elm_widget_item_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Item_Data *sd)
6740 if (!obj) return EINA_FALSE;
6742 Evas_Object *o = elm_object_parent_widget_get(sd->view);
6743 if (_elm_scrollable_is(o))
6745 Evas_Coord bx, by, bw, bh;
6746 Evas_Coord x, y, w, h;
6747 Evas_Object *w1 = elm_object_parent_widget_get(o);
6748 evas_object_geometry_get(sd->view, &x, &y, &w, &h);
6749 evas_object_geometry_get(o, &bx, &by, &bw, &bh);
6752 switch (_elm_config->focus_autoscroll_mode)
6754 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
6755 eo_do(w1, elm_interface_scrollable_content_region_show(x, y, w, h));
6757 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
6758 eo_do(w1, elm_interface_scrollable_region_bring_in(x, y, w, h));
6765 elm_object_accessibility_highlight_set(sd->eo_obj, EINA_TRUE);
6766 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
6772 EOLIAN static Eina_Bool
6773 _elm_widget_item_elm_interface_atspi_component_highlight_clear(Eo *obj, Elm_Widget_Item_Data *sd)
6775 if (!obj) return EINA_FALSE;
6776 elm_object_accessibility_highlight_set(sd->eo_obj, EINA_FALSE);
6777 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_FALSE);
6782 EOLIAN static double
6783 _elm_widget_item_elm_interface_atspi_component_alpha_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6787 if (!sd->view) return -1.0;
6788 evas_object_color_get(sd->view, NULL, NULL, NULL, &alpha);
6789 return (double)alpha / 255.0;
6792 //TIZEN_ONLY(20150717) add widget name setter
6794 _elm_widget_elm_interface_atspi_accessible_name_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data* _pd EINA_UNUSED, const char *name)
6797 eina_stringshare_del(_pd->name);
6799 _pd->name = eina_stringshare_add(name);
6803 //TIZEN_ONLY(20160329): widget: improve accessibile_at_point getter (a8aff0423202b9a55dbb3843205875226678fbd6)
6805 _coordinate_system_based_point_translate(Eo *obj, Eina_Bool screen_coords, int *x, int *y)
6813 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6816 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
6822 static Evas_Object *
6823 _parent_get(Evas_Object *obj)
6825 Evas_Object *parent;
6827 parent = evas_object_smart_parent_get(obj);
6830 if (strcmp("Elm_Win", eo_class_name_get(eo_class_get(obj))))
6831 parent = elm_widget_parent_get(obj);
6838 _is_inside(Evas_Object *obj, int x, int y)
6840 Eina_Bool ret = EINA_TRUE;
6845 if (eo_isa(obj, ELM_WIDGET_ITEM_CLASS))
6847 Elm_Widget_Item_Data *id = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
6848 evas_object_geometry_get(id->view, &cx, &cy, &cw, &ch);
6851 evas_object_geometry_get(obj, &cx, &cy, &cw, &ch);
6853 /* check the point is out of bound */
6854 if (x < cx || x > cx + cw || y < cy || y > cy + ch)
6862 _is_ancestor_of(Evas_Object *smart_parent, Evas_Object *obj)
6864 Eina_Bool ret = EINA_FALSE;
6865 Evas_Object *parent = elm_widget_parent_get(obj);
6868 /* No need to check more, the smart_parent is parent of obj */
6869 if (smart_parent == parent)
6874 parent = elm_widget_parent_get(parent);
6881 _accessible_at_point_top_down_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool screen_coords, int x, int y)
6883 Eina_List *l, *l2, *children, *valid_children = NULL;
6885 Evas_Object *stack_item;
6887 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6889 Evas_Coord px, py, pw, ph;
6892 _coordinate_system_based_point_translate(obj, screen_coords, &x, &y);
6894 eo_do(obj, children = elm_interface_atspi_accessible_children_get());
6896 EINA_LIST_FOREACH(children, l2, child)
6898 if (_is_inside(child, x, y))
6899 valid_children = eina_list_append(valid_children, child);
6901 /* Get evas_object stacked at given x,y coordinates starting from top */
6902 Eina_List *stack = evas_tree_objects_at_xy_get(evas_object_evas_get(obj), NULL, x, y);
6903 /* Foreach stacked object starting from top */
6904 EINA_LIST_FOREACH(stack, l, stack_item)
6906 /* Foreach at-spi valid children traverse stack_item evas_objects hierarchy */
6907 EINA_LIST_FOREACH(valid_children, l2, child)
6909 Elm_Atspi_Role role;
6910 eo_do(child, role = elm_interface_atspi_accessible_role_get());
6911 if (role == ELM_ATSPI_ROLE_REDUNDANT_OBJECT)
6913 /* The redundant object ignores */
6916 /* Compare object used to compare with stacked evas objects */
6917 compare_obj = child;
6918 /* In case of widget_items compare should be different then elm_widget_ item object */
6919 if (eo_isa(child, ELM_WIDGET_ITEM_CLASS))
6921 Elm_Widget_Item_Data *id = eo_data_scope_get(child, ELM_WIDGET_ITEM_CLASS);
6922 compare_obj = id->view;
6924 /* In case of access object compare should be 'wrapped' evas_object */
6925 if (eo_isa(child, ELM_ACCESS_CLASS))
6927 Elm_Access_Info *info = _elm_access_info_get(child);
6928 if (!info) continue;
6929 compare_obj = info->part_object;
6931 /* In case of widget is registerd by elm_access_object_register */
6932 Evas_Object *ao = elm_access_object_get(child);
6935 eina_list_free(children);
6936 eina_list_free(stack);
6940 /* In case of ewk wrapper object compare with internal ewk_view evas_object */
6941 if (eo_isa(child, ELM_ATSPI_EWK_WRAPPER_CLASS))
6943 compare_obj = elm_atspi_ewk_wrapper_ewk_view_get(child);
6946 /* If spacial eo children do not have backing evas_object continue with search */
6950 Evas_Object *smart_parent = stack_item;
6951 while (smart_parent)
6953 if (smart_parent == compare_obj)
6955 eina_list_free(children);
6956 eina_list_free(stack);
6960 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6961 proxy = evas_object_data_get(smart_parent, "__widget_proxy");
6964 evas_object_geometry_get(smart_parent, &px, &py, &pw, &ph);
6965 if (x >= px && x <= px + pw && y >= py && y <= py +ph)
6967 eina_list_free(children);
6968 eina_list_free(stack);
6974 smart_parent = _parent_get(smart_parent);
6975 if (_is_ancestor_of(smart_parent, obj)) break;
6980 eina_list_free(children);
6981 eina_list_free(stack);
6985 static int _sort_by_repeat_events(const void *data1, const void *data2)
6987 Eina_Bool repeat1, repeat2;
6989 repeat1 = evas_object_repeat_events_get(data1);
6990 repeat2 = evas_object_repeat_events_get(data2);
6992 if (repeat1 != repeat2 && repeat1 == EINA_TRUE) return 1;
6996 static Eo *_item_at_point_get(Evas_Object *obj, int x, int y)
6999 Eina_List *l, *children;
7001 eo_do(obj, children = elm_interface_atspi_accessible_children_get());
7003 EINA_LIST_FOREACH(children, l, child)
7005 if (_is_inside(child, x, y)) return child;
7008 ERR("No child at point (%d, %d) on object %p", x, y, obj);
7013 _elm_widget_elm_interface_atspi_component_accessible_at_point_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool screen_coords, int x, int y)
7016 Evas_Object *stack_item;
7018 if(strcmp("Elm_Win", eo_class_name_get(eo_class_get(obj))))
7019 return _accessible_at_point_top_down_get(obj, _pd, screen_coords, x, y);
7021 _coordinate_system_based_point_translate(obj, screen_coords, &x, &y);
7023 Eina_List *stack = evas_tree_objects_at_xy_get(evas_object_evas_get(obj), NULL, x, y);
7024 stack = eina_list_sort(stack, -1, _sort_by_repeat_events);
7026 EINA_LIST_FOREACH(stack, l, stack_item)
7028 Evas_Object *smart_parent = stack_item;
7029 while (smart_parent)
7031 Evas_Object *ao = elm_access_object_get(smart_parent);
7034 if (eo_isa(smart_parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
7036 Eina_Bool acceptable = EINA_FALSE;
7038 Elm_Atspi_Role role;
7039 eo_do(smart_parent, role = elm_interface_atspi_accessible_role_get());
7042 case ELM_ATSPI_ROLE_FILLER: /* ex: View of colorselector item is layout */
7043 case ELM_ATSPI_ROLE_ICON:
7044 case ELM_ATSPI_ROLE_IMAGE:
7045 case ELM_ATSPI_ROLE_REDUNDANT_OBJECT:
7046 case ELM_ATSPI_ROLE_WINDOW:
7047 DBG("Go for parent: %s (%p)\n", evas_object_type_get(smart_parent), smart_parent);
7050 case ELM_ATSPI_ROLE_LIST:
7051 return _item_at_point_get(smart_parent, x, y);
7055 acceptable = EINA_TRUE;
7059 if (acceptable) return smart_parent;
7062 smart_parent = _parent_get(smart_parent);
7065 return _accessible_at_point_top_down_get(obj, _pd, screen_coords, x, y);
7069 //TIZEN_ONLY(20150709) add relations atpi
7070 EOLIAN static Eina_Bool
7071 _elm_widget_elm_interface_atspi_accessible_relationship_append(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Atspi_Relation_Type type, const Eo *relation_obj)
7073 return elm_atspi_relation_set_relation_append(&sd->atspi_custom_relations, type, relation_obj);
7077 _elm_widget_elm_interface_atspi_accessible_relationship_remove(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Atspi_Relation_Type type, const Eo *relation_obj)
7079 elm_atspi_relation_set_relation_remove(&sd->atspi_custom_relations, type, relation_obj);
7082 EOLIAN static Eina_Bool
7083 _elm_widget_item_elm_interface_atspi_accessible_relationship_append(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd, Elm_Atspi_Relation_Type type, const Eo *relation_obj)
7085 return elm_atspi_relation_set_relation_append(&sd->atspi_custom_relations, type, relation_obj);
7089 _elm_widget_item_elm_interface_atspi_accessible_relationship_remove(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd, Elm_Atspi_Relation_Type type, const Eo *relation_obj)
7091 elm_atspi_relation_set_relation_remove(&sd->atspi_custom_relations, type, relation_obj);
7095 //TIZEN_ONLY(20150731) : add i18n support for name and description
7097 _elm_widget_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, const char *domain)
7099 eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
7102 EOLIAN static const char*
7103 _elm_widget_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
7105 return _pd->atspi_translation_domain;
7109 _elm_widget_item_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd, const char *domain)
7111 eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
7114 EOLIAN static const char*
7115 _elm_widget_item_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd)
7117 return _pd->atspi_translation_domain;
7120 //TIZEN_ONLY(20160726): add API elm_atspi_accessible_can_highlight_set/get
7122 _children_highlight_check(Eo *obj)
7124 Eina_List *children, *l;
7127 if (_elm_object_accessibility_currently_highlighted_get() == (void *)obj)
7129 eo_do(obj, elm_interface_atspi_component_highlight_clear());
7133 eo_do(obj, children = elm_interface_atspi_accessible_children_get());
7134 EINA_LIST_FOREACH(children, l, child)
7136 if (_children_highlight_check(child)) return EINA_TRUE;
7143 _elm_widget_elm_interface_atspi_accessible_can_highlight_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, Eina_Bool can_highlight)
7145 if (!can_highlight) _children_highlight_check(obj);
7146 _pd->can_highlight = !!can_highlight;
7149 EOLIAN static Eina_Bool
7150 _elm_widget_elm_interface_atspi_accessible_can_highlight_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
7152 return _elm_widget_highlightable(obj);
7156 _elm_widget_item_elm_interface_atspi_accessible_can_highlight_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd, Eina_Bool can_highlight)
7158 if (!can_highlight) _children_highlight_check(obj);
7159 _pd->can_highlight = !!can_highlight;
7162 EOLIAN static Eina_Bool
7163 _elm_widget_item_elm_interface_atspi_accessible_can_highlight_get(Eo *obj, Elm_Widget_Item_Data *_pd EINA_UNUSED)
7165 return _elm_widget_item_highlightable(obj);
7169 //TIZEN_ONLY(20160622): Override Paragraph Direction APIs
7171 _elm_widget_evas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
7176 if (sd->on_destroy) return;
7178 EINA_LIST_FOREACH(sd->subobjs, l, child)
7180 if (_elm_widget_is(child))
7182 Elm_Widget_Smart_Data *sdc = eo_data_scope_get(child, MY_CLASS);
7184 if (sdc->inherit_paragraph_direction &&
7185 (sdc->paragraph_direction != dir))
7187 sdc->paragraph_direction = dir;
7188 _elm_widget_evas_object_paragraph_direction_set_internal(child, sdc, dir);
7189 eo_do_super(child, MY_CLASS, evas_obj_paragraph_direction_set(dir));
7193 /* FIXME: There is no way to handle non-widget child object.
7194 * If a non-widget child object has smart parent, it will get the direction
7195 * from the smart parent. */
7200 _elm_widget_evas_object_paragraph_direction_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
7202 if ((!(sd->inherit_paragraph_direction) && (sd->paragraph_direction == dir)) ||
7203 (sd->inherit_paragraph_direction && (dir == EVAS_BIDI_DIRECTION_INHERIT)))
7206 if (dir == EVAS_BIDI_DIRECTION_INHERIT)
7208 sd->inherit_paragraph_direction = EINA_TRUE;
7209 Evas_BiDi_Direction parent_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
7212 parent_dir = evas_object_paragraph_direction_get(sd->parent_obj);
7214 if (parent_dir != sd->paragraph_direction)
7216 sd->paragraph_direction = parent_dir;
7217 _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, parent_dir);
7222 sd->inherit_paragraph_direction = EINA_FALSE;
7223 sd->paragraph_direction = dir;
7224 _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, dir);
7227 eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(dir));
7232 //TIZEN_ONLY(20161013): clean up elm color class feature
7234 _edje_color_class_free(void *data)
7236 Edje_Color_Class *cc = data;
7238 if (cc->name) eina_stringshare_del(cc->name);
7243 _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char *part)
7246 Eina_Stringshare *str;
7248 buf = eina_strbuf_new();
7250 eina_strbuf_append(buf, strchr(eo_class_name_get(klass), '_') + 1);
7251 eina_strbuf_tolower(buf);
7255 eina_strbuf_append_printf(buf, "/%s/%s", style, part);
7259 eina_strbuf_append_printf(buf, "/%s", part);
7262 str = eina_stringshare_add(eina_strbuf_string_get(buf));
7264 eina_strbuf_free(buf);
7268 /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
7270 _elm_widget_color_class_set_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
7271 int r, int g, int b, int a,
7272 int r2, int g2, int b2, int a2,
7273 int r3, int g3, int b3, int a3)
7275 Eina_Bool int_ret = EINA_TRUE;
7276 Eina_Stringshare *buf;
7277 int temp_color[3][4] = { { r, g, b, a },
7279 { r3, g3, b3, a3 } };
7281 if (!color_class) return EINA_FALSE;
7283 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
7285 #define TEMP_COLOR(x, y) \
7286 ((temp_color[x][y] == -1) ? &temp_color[x][y] : NULL)
7288 edje_object_color_class_get(edje, buf,
7289 TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
7290 TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
7291 TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
7295 #define TEMP_COLOR(x, y) \
7296 ((temp_color[x][y] == -1) ? 0 : temp_color[x][y])
7298 int_ret &= edje_object_color_class_set(edje, buf,
7299 TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
7300 TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
7301 TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
7305 eina_stringshare_del(buf);
7311 _elm_widget_color_class_get_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
7312 int *r, int *g, int *b, int *a,
7313 int *r2, int *g2, int *b2, int *a2,
7314 int *r3, int *g3, int *b3, int *a3)
7316 Eina_Bool int_ret = EINA_TRUE;
7317 Eina_Stringshare *buf;
7319 if (!color_class) return EINA_FALSE;
7321 buf = _elm_widget_edje_class_get(eo_class_get(obj), elm_widget_style_get(obj), color_class);
7323 int_ret &= edje_object_color_class_get(edje, buf,
7328 eina_stringshare_del(buf);
7335 _elm_widget_class_color_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
7338 Eina_Bool int_ret = EINA_TRUE;
7340 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7342 edje = elm_layout_edje_get(obj);
7343 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7352 _elm_widget_class_color_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
7355 Eina_Bool int_ret = EINA_TRUE;
7357 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7359 edje = elm_layout_edje_get(obj);
7360 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7362 NULL, NULL, NULL, NULL,
7363 NULL, NULL, NULL, NULL);
7369 _elm_widget_class_color2_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
7372 Eina_Bool int_ret = EINA_TRUE;
7374 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7376 edje = elm_layout_edje_get(obj);
7377 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7386 _elm_widget_class_color2_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
7389 Eina_Bool int_ret = EINA_TRUE;
7391 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7393 edje = elm_layout_edje_get(obj);
7394 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7395 NULL, NULL, NULL, NULL,
7397 NULL, NULL, NULL, NULL);
7403 _elm_widget_class_color3_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
7406 Eina_Bool int_ret = EINA_TRUE;
7408 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7410 edje = elm_layout_edje_get(obj);
7411 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7420 _elm_widget_class_color3_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
7423 Eina_Bool int_ret = EINA_TRUE;
7425 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7427 edje = elm_layout_edje_get(obj);
7428 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7429 NULL, NULL, NULL, NULL,
7430 NULL, NULL, NULL, NULL,
7437 _elm_widget_class_color_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *color_class)
7439 Eina_Stringshare *buf;
7441 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return;
7443 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
7444 edje_object_color_class_del(sd->resize_obj, buf);
7445 eina_stringshare_del(buf);
7449 _elm_widget_class_color_clear(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
7451 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return;
7452 edje_object_color_class_clear(sd->resize_obj);
7455 #define ELM_COLOR_CLASS_UPDATE(obj, hash, cond) \
7456 Evas_Object *edje = NULL; \
7457 Eina_Iterator *itr; \
7458 Edje_Color_Class *cc; \
7459 Eina_Bool int_ret = EINA_TRUE; \
7460 if (cond) return EINA_FALSE; \
7461 if (eo_isa(obj, ELM_LAYOUT_CLASS)) \
7462 edje = elm_layout_edje_get(obj); \
7463 else if (eo_isa(obj, EDJE_OBJECT_CLASS)) \
7465 if (!edje) return EINA_FALSE; \
7466 itr = eina_hash_iterator_data_new(hash); \
7467 EINA_ITERATOR_FOREACH(itr, cc) \
7469 int_ret &= edje_object_color_class_set(edje, cc->name, \
7470 cc->r, cc->g, cc->b, cc->a, \
7471 cc->r2, cc->g2, cc->b2, cc->a2, \
7472 cc->r3, cc->g3, cc->b3, cc->a3); \
7474 eina_iterator_free(itr); \
7478 #define CHECK_BOUND(x) \
7479 if (x > 0xff) x = 0xff; \
7480 else if (x < 0) x = 0
7482 #define ELM_COLOR_CLASS_SET_START(obj, cr, cg, cb, ca) \
7483 Eina_Bool int_ret = EINA_FALSE; \
7484 Edje_Color_Class *cc = NULL; \
7485 Eina_Stringshare *buf; \
7486 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
7491 _elm_color_unpremul(a, &r, &g, &b); \
7492 if (!sd->color_classes) \
7493 sd->color_classes = eina_hash_string_small_new(_edje_color_class_free); \
7495 cc = eina_hash_find(sd->color_classes, buf); \
7498 cc = calloc(1, sizeof(Edje_Color_Class)); \
7499 cc->name = eina_stringshare_add(buf); \
7503 eina_stringshare_del(buf); \
7504 return EINA_FALSE; \
7506 eina_hash_direct_add(sd->color_classes, cc->name, cc); \
7508 else if ((cc->cr == r) && (cc->cg == g) && \
7509 (cc->cb == b) && (cc->ca == a)) \
7511 eina_stringshare_del(buf); \
7520 #define ELM_COLOR_CLASS_SET_END() \
7521 eina_stringshare_del(buf); \
7524 #define ELM_COLOR_CLASS_GET(obj, cr, cg, cb, ca) \
7525 Eina_Bool int_ret = EINA_FALSE; \
7526 Edje_Color_Class *cc; \
7527 Eina_Stringshare *buf; \
7529 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
7530 if ((!sd->color_classes) || !(cc = eina_hash_find(sd->color_classes, buf))) \
7536 int_ret = EINA_FALSE; \
7540 if (r) *r = cc->cr; \
7541 if (g) *g = cc->cg; \
7542 if (b) *b = cc->cb; \
7543 if (a) *a = cc->ca; \
7545 int_ret = EINA_TRUE; \
7547 _elm_color_premul(alpha, r, g, b); \
7548 eina_stringshare_del(buf); \
7552 _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd)
7554 ELM_COLOR_CLASS_UPDATE(sd->view, sd->color_classes, (!sd) || (!sd->color_classes) || (!sd->view));
7558 _elm_widget_item_class_color_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
7560 ELM_COLOR_CLASS_SET_START(obj, r, g, b, a);
7562 int_ret &= _elm_widget_item_color_class_update(sd);
7564 ELM_COLOR_CLASS_SET_END();
7568 _elm_widget_item_class_color_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
7570 ELM_COLOR_CLASS_GET(obj, r, g, b, a);
7574 _elm_widget_item_class_color2_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
7576 ELM_COLOR_CLASS_SET_START(obj, r2, g2, b2, a2);
7578 int_ret &= _elm_widget_item_color_class_update(sd);
7580 ELM_COLOR_CLASS_SET_END();
7584 _elm_widget_item_class_color2_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
7586 ELM_COLOR_CLASS_GET(obj, r2, g2, b2, a2);
7590 _elm_widget_item_class_color3_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
7592 ELM_COLOR_CLASS_SET_START(obj, r3, g3, b3, a3);
7594 int_ret &= _elm_widget_item_color_class_update(sd);
7596 ELM_COLOR_CLASS_SET_END();
7600 _elm_widget_item_class_color3_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
7602 ELM_COLOR_CLASS_GET(obj, r3, g3, b3, a3);
7605 static Evas_Object *
7606 _elm_widget_item_edje_get(Eo *obj, Elm_Widget_Item_Data *sd)
7609 sd = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
7611 if (eo_isa(sd->view, ELM_LAYOUT_CLASS))
7612 return elm_layout_edje_get(sd->view);
7613 else if (eo_isa(sd->view, EDJE_OBJECT_CLASS))
7620 _elm_widget_item_class_color_del(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd, const char *color_class)
7622 Eina_Stringshare *buf;
7624 Edje_Color_Class *cc = NULL;
7626 if (!color_class) return;
7628 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
7629 eina_hash_del(sd->color_classes, buf, cc);
7631 edje = _elm_widget_item_edje_get(obj, sd);
7633 edje_object_color_class_del(edje, color_class);
7635 eina_stringshare_del(buf);
7639 _elm_widget_item_class_color_clear(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd)
7642 ELM_SAFE_FREE(sd->color_classes, eina_hash_free);
7644 edje = _elm_widget_item_edje_get(obj, sd);
7647 edje_object_color_class_clear(edje);
7651 /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
7653 _elm_widget_color_class_parent_set(Evas_Object *obj, Evas_Object *parent)
7655 Evas_Object *edje = NULL, *parent_edje = NULL;
7657 if (!obj || !parent) return;
7659 if (eo_isa(obj, ELM_LAYOUT_CLASS))
7660 edje = elm_layout_edje_get(obj);
7661 else if (eo_isa(obj, EDJE_OBJECT_CLASS))
7664 if (eo_isa(parent, ELM_LAYOUT_CLASS))
7665 parent_edje = elm_layout_edje_get(parent);
7666 else if (eo_isa(parent, EDJE_OBJECT_CLASS))
7667 parent_edje = parent;
7669 if (!edje || !parent_edje) return;
7671 edje_object_color_class_parent_set(edje, parent_edje);
7675 _elm_widget_color_class_parent_unset(Evas_Object *obj)
7677 Evas_Object *edje = NULL;
7681 if (eo_isa(obj, ELM_LAYOUT_CLASS))
7682 edje = elm_layout_edje_get(obj);
7683 else if (eo_isa(obj, EDJE_OBJECT_CLASS))
7688 edje_object_color_class_parent_unset(edje);
7692 //TIZEN_ONLY(20160527): widget: add AtspiAction interface to all widgets and widget_items, add handlers for reading stopped/cancelled
7693 EOLIAN const Elm_Atspi_Action *
7694 _elm_widget_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd EINA_UNUSED)
7699 EOLIAN const Elm_Atspi_Action *
7700 _elm_widget_item_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *pd EINA_UNUSED)
7706 #include "elm_widget_item.eo.c"
7707 #include "elm_widget.eo.c"