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 if (!elm_widget_focus_region_get(o, &x, &y, &w, &h))
829 o = elm_widget_parent_get(o);
840 o = elm_widget_parent_get(o);
844 EOLIAN static Eina_Bool
845 _elm_widget_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *style)
847 if (eina_stringshare_replace(&sd->focus_highlight_style, style)) return EINA_TRUE;
851 EOLIAN static const char*
852 _elm_widget_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
854 return sd->focus_highlight_style;
858 _parent_focus(Evas_Object *obj, Elm_Object_Item *item)
862 if (sd->focused) return;
864 Evas_Object *o = elm_widget_parent_get(obj);
865 sd->focus_order_on_calc = EINA_TRUE;
867 if (o) _parent_focus(o, item);
869 if (!sd->focus_order_on_calc)
870 return; /* we don't want to override it if by means of any of the
871 callbacks below one gets to calculate our order
875 sd->focus_order = focus_order;
876 sd->focused = EINA_TRUE;
878 if (sd->top_win_focused)
879 eo_do(obj, elm_obj_widget_on_focus(item));
880 sd->focus_order_on_calc = EINA_FALSE;
882 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
883 _elm_access_highlight_set(obj);
887 _elm_object_focus_chain_del_cb(void *data,
890 void *event_info EINA_UNUSED)
892 ELM_WIDGET_DATA_GET(data, sd);
894 sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
898 _elm_widget_parent_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Object *parent EINA_UNUSED)
903 elm_widget_api_check(int ver)
905 if (ver != ELM_INTERNAL_API_VERSION)
907 CRI("Elementary widget api versions do not match");
914 elm_widget_access(Evas_Object *obj,
919 Eina_Bool ret = EINA_TRUE;
921 API_ENTRY return EINA_FALSE;
922 EINA_LIST_FOREACH(sd->subobjs, l, child)
924 if (elm_widget_is(child))
925 ret &= elm_widget_access(child, is_access);
928 eo_do(obj, elm_obj_widget_access(is_access));
929 eo_do(obj, eo_event_callback_call(ELM_WIDGET_EVENT_ACCESS_CHANGED, NULL));
934 //TIZEN_ONLY(20160822): When atspi mode is dynamically switched on/off,
935 //register/unregister access objects accordingly.
937 elm_widget_atspi(Evas_Object *obj,
942 Eina_Bool ret = EINA_TRUE;
944 API_ENTRY return EINA_FALSE;
945 EINA_LIST_FOREACH(sd->subobjs, l, child)
947 if (elm_widget_is(child))
948 ret &= elm_widget_atspi(child, is_atspi);
950 eo_do(obj, elm_obj_widget_atspi(is_atspi));
956 _elm_widget_atspi(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool is_atspi EINA_UNUSED)
962 _elm_widget_access(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool is_access EINA_UNUSED)
967 elm_widget_theme(Evas_Object *obj)
973 Elm_Theme_Apply ret = ELM_THEME_APPLY_SUCCESS;
975 API_ENTRY return ELM_THEME_APPLY_FAILED;
977 EINA_LIST_FOREACH(sd->subobjs, l, child)
978 if (_elm_widget_is(child))
979 ret &= elm_widget_theme(child);
981 if (sd->hover_obj) ret &= elm_widget_theme(sd->hover_obj);
983 EINA_LIST_FOREACH(sd->tooltips, l, tt)
984 elm_tooltip_theme(tt);
985 EINA_LIST_FOREACH(sd->cursors, l, cur)
986 elm_cursor_theme(cur);
988 Elm_Theme_Apply ret2 = ELM_THEME_APPLY_FAILED;
989 eo_do(obj, ret2 = elm_obj_widget_theme_apply());
996 elm_widget_theme_specific(Evas_Object *obj,
1004 Elm_Theme *th2, *thdef;
1008 thdef = elm_theme_default_get();
1009 if (!th) th = thdef;
1013 if (!th2) th2 = thdef;
1021 if (th2 == thdef) break;
1022 th2 = th2->ref_theme;
1023 if (!th2) th2 = thdef;
1027 EINA_LIST_FOREACH(sd->subobjs, l, child)
1029 if (elm_widget_is(child))
1030 elm_widget_theme_specific(child, th, force);
1032 if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
1033 EINA_LIST_FOREACH(sd->tooltips, l, tt)
1034 elm_tooltip_theme(tt);
1035 EINA_LIST_FOREACH(sd->cursors, l, cur)
1036 elm_cursor_theme(cur);
1037 eo_do(obj, elm_obj_widget_theme_apply());
1040 EOLIAN static Elm_Theme_Apply
1041 _elm_widget_theme_apply(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
1043 _elm_widget_mirrored_reload(obj);
1044 if (elm_widget_disabled_get(obj))
1045 elm_widget_disabled_internal(obj, elm_widget_disabled_get(obj));
1047 return ELM_THEME_APPLY_SUCCESS;
1053 * Returns the widget's mirrored mode.
1055 * @param obj The widget.
1056 * @return mirrored mode of the object.
1059 EOLIAN static Eina_Bool
1060 _elm_widget_mirrored_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1062 return sd->is_mirrored;
1068 * Sets the widget's mirrored mode.
1070 * @param obj The widget.
1071 * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
1074 _elm_widget_mirrored_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool mirrored)
1076 mirrored = !!mirrored;
1078 if (sd->is_mirrored == mirrored) return;
1080 sd->is_mirrored = mirrored;
1081 elm_widget_theme(obj);
1085 * Returns the widget's mirrored mode setting.
1087 * @param obj The widget.
1088 * @return mirrored mode setting of the object.
1091 EOLIAN static Eina_Bool
1092 _elm_widget_mirrored_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1094 return sd->mirrored_auto_mode;
1100 * Sets the widget's mirrored mode setting.
1101 * When widget in automatic mode, it follows the system mirrored mode set by
1102 * elm_mirrored_set().
1103 * @param obj The widget.
1104 * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
1107 _elm_widget_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic)
1109 if (sd->mirrored_auto_mode != automatic)
1111 sd->mirrored_auto_mode = automatic;
1115 elm_widget_mirrored_set(obj, elm_config_mirrored_get());
1121 _elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, region_hook_func_type func, void *data)
1123 sd->on_show_region = func;
1124 sd->on_show_region_data = data;
1130 * Add myself as a sub object of parent object
1132 * @see elm_widget_sub_object_add()
1135 elm_widget_sub_object_parent_add(Evas_Object *sobj)
1137 Eina_Bool ret = EINA_FALSE;
1140 eo_do(sobj, parent = eo_parent_get());
1141 if (!eo_isa(parent, ELM_WIDGET_CLASS))
1143 ERR("You passed a wrong parent parameter (%p %s). "
1144 "Elementary widget's parent should be an elementary widget.", parent, evas_object_type_get(parent));
1148 eo_do(parent, ret = elm_obj_widget_sub_object_add(sobj));
1156 * Add sobj to obj's sub object.
1158 * What does elementary sub object mean? This is unique in elementary, it
1159 * handles overall elementary policies between parent and sub objects.
1160 * focus, access, deletion, theme, scale, mirror, scrollable child get,
1161 * translate, name find, display mode set, orientation set, tree dump
1164 * @see elm_widget_sub_object_parent_add()
1166 EOLIAN static Eina_Bool
1167 _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1169 Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
1171 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1173 if (sobj == sd->parent_obj)
1175 /* in this case, sobj must be an elm widget, or something
1176 * very wrong is happening */
1177 if (!_elm_widget_is(sobj)) return EINA_FALSE;
1179 if (!elm_widget_sub_object_del(sobj, obj)) return EINA_FALSE;
1180 WRN("You passed a parent object of obj = %p as the sub object = %p!",
1184 if (_elm_widget_is(sobj))
1186 ELM_WIDGET_DATA_GET(sobj, sdc);
1188 if (sdc->parent_obj == obj) goto end;
1189 if (sdc->parent_obj)
1191 if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
1194 sdc->parent_obj = obj;
1196 if (!sdc->on_create)
1197 eo_do(sobj, elm_obj_widget_orientation_set(sd->orient_mode));
1199 sdc->orient_mode = sd->orient_mode;
1201 if (!sdc->on_create)
1203 if (!sdc->disabled && (elm_widget_disabled_get(obj)))
1205 elm_widget_focus_disabled_handle(sobj);
1206 eo_do(sobj, elm_obj_widget_disable());
1210 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
1212 /* update child focusable-ness on self and parents, now that a
1213 * focusable child got in */
1214 if (!sd->child_can_focus && (_is_focusable(sobj)))
1216 Elm_Widget_Smart_Data *sdp = sd;
1218 sdp->child_can_focus = EINA_TRUE;
1219 while (sdp->parent_obj)
1221 sdp = eo_data_scope_get(sdp->parent_obj, MY_CLASS);
1223 if (sdp->child_can_focus) break;
1225 sdp->child_can_focus = EINA_TRUE;
1231 void *data = evas_object_data_get(sobj, "elm-parent");
1235 if (data == obj) goto end;
1236 if (!elm_widget_sub_object_del(data, sobj)) return EINA_FALSE;
1239 sd->subobjs = eina_list_append(sd->subobjs, sobj);
1240 evas_object_data_set(sobj, "elm-parent", obj);
1242 _callbacks_add(sobj, obj);
1243 if (_elm_widget_is(sobj))
1245 ELM_WIDGET_DATA_GET(sobj, sdc);
1247 /* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
1248 * Due to elementary's scale policy, scale and pscale can be different in
1249 * some cases. This happens when sobj's previous parent and new parent have
1250 * different scale value.
1251 * For example, if sobj's previous parent's scale is 5 and new parent's scale
1252 * is 2 while sobj's scale is 0. Then 'pscale' is 5 and 'scale' is 2. So we
1253 * need to reset sobj's scale to 5.
1254 * Note that each widget's scale is 0 by default.
1256 double scale, pscale = elm_widget_scale_get(sobj);
1257 Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
1259 scale = elm_widget_scale_get(sobj);
1260 th = elm_widget_theme_get(sobj);
1261 mirrored = elm_widget_mirrored_get(sobj);
1263 if (!sdc->on_create)
1265 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
1266 elm_widget_theme(sobj);
1269 if (_is_focused(sobj)) _parents_focus(obj);
1271 elm_widget_display_mode_set(sobj,
1272 evas_object_size_hint_display_mode_get(obj));
1273 if (_elm_atspi_enabled() && !sdc->on_create)
1275 Elm_Interface_Atspi_Accessible *aparent;
1276 eo_do(sobj, aparent = elm_interface_atspi_accessible_parent_get());
1278 elm_interface_atspi_accessible_children_changed_added_signal_emit(obj, sobj);
1281 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
1282 if (sdc->inherit_paragraph_direction &&
1283 (sdc->paragraph_direction != evas_object_paragraph_direction_get(obj)))
1285 sdc->paragraph_direction = evas_object_paragraph_direction_get(obj);
1286 _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
1295 EOLIAN static Eina_Bool
1296 _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1298 Evas_Object *sobj_parent;
1300 if (!sobj) return EINA_FALSE;
1302 EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
1304 sobj_parent = evas_object_data_del(sobj, "elm-parent");
1305 if (sobj_parent && sobj_parent != obj)
1307 static int abort_on_warn = -1;
1309 ERR("removing sub object %p (%s) from parent %p (%s), "
1310 "but elm-parent is different %p (%s)!",
1311 sobj, elm_widget_type_get(sobj), obj, elm_widget_type_get(obj),
1312 sobj_parent, elm_widget_type_get(sobj_parent));
1314 if (EINA_UNLIKELY(abort_on_warn == -1))
1316 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
1317 else abort_on_warn = 0;
1319 if (abort_on_warn == 1) abort();
1324 if (_elm_widget_is(sobj))
1326 if (_is_focused(sobj))
1328 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1329 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1331 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1333 Evas_Object *parent = obj;
1335 /* update child focusable-ness on self and parents, now that a
1336 * focusable child is gone */
1340 Evas_Object *subobj;
1342 ELM_WIDGET_DATA_GET(parent, sdp);
1344 sdp->child_can_focus = EINA_FALSE;
1345 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1347 if ((subobj != sobj) && (_is_focusable(subobj)))
1349 sdp->child_can_focus = EINA_TRUE;
1354 /* break again, child_can_focus went back to
1356 if (sdp->child_can_focus) break;
1357 parent = sdp->parent_obj;
1360 if (_elm_atspi_enabled() && !sd->on_destroy)
1362 Elm_Interface_Atspi_Accessible *aparent;
1363 eo_do(sobj, aparent = elm_interface_atspi_accessible_parent_get());
1365 elm_interface_atspi_accessible_children_changed_del_signal_emit(obj, sobj);
1368 ELM_WIDGET_DATA_GET(sobj, sdc);
1369 sdc->parent_obj = NULL;
1371 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
1372 if (sdc->inherit_paragraph_direction &&
1373 (sdc->paragraph_direction != EVAS_BIDI_DIRECTION_NEUTRAL))
1375 sdc->paragraph_direction = EVAS_BIDI_DIRECTION_NEUTRAL;
1376 _elm_widget_evas_object_paragraph_direction_set_internal(sobj, sdc, sdc->paragraph_direction);
1381 if (sd->resize_obj == sobj) sd->resize_obj = NULL;
1383 sd->subobjs = eina_list_remove(sd->subobjs, sobj);
1385 _callbacks_del(sobj, obj);
1393 * a resize object is added to and deleted from the smart member and the sub object
1394 * of the parent if the third argument, Eina_Bool sub_obj, is set as EINA_TRUE.
1397 _elm_widget_resize_object_set(Eo *obj, Elm_Widget_Smart_Data *sd,
1401 Evas_Object *parent;
1403 if (sd->resize_obj == sobj) return;
1405 // orphan previous resize obj
1406 if (sd->resize_obj && sub_obj)
1408 evas_object_clip_unset(sd->resize_obj);
1409 evas_object_smart_member_del(sd->resize_obj);
1411 if (_elm_widget_is(sd->resize_obj))
1413 if (_is_focused(sd->resize_obj)) _parents_unfocus(obj);
1415 elm_widget_sub_object_del(obj, sd->resize_obj);
1418 sd->resize_obj = sobj;
1421 // orphan new resize obj
1422 parent = evas_object_data_get(sobj, "elm-parent");
1423 if (parent && parent != obj)
1425 ELM_WIDGET_DATA_GET(parent, sdp);
1427 /* should be there, just being paranoid */
1430 if (sdp->resize_obj == sobj)
1431 elm_widget_resize_object_set(parent, NULL, sub_obj);
1433 elm_widget_sub_object_del(parent, sobj);
1438 elm_widget_sub_object_add(obj, sobj);
1439 evas_object_smart_member_add(sobj, obj);
1442 _smart_reconfigure(sd);
1448 * WARNING: the programmer is responsible, in the scenario of
1449 * exchanging a hover object, of cleaning the old hover "target"
1453 _elm_widget_hover_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
1457 _callbacks_del(sd->hover_obj, obj);
1459 sd->hover_obj = sobj;
1462 _callbacks_add(sobj, obj);
1463 _smart_reconfigure(sd);
1468 _elm_widget_can_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can_focus)
1470 can_focus = !!can_focus;
1472 if (sd->can_focus == can_focus) return;
1473 sd->can_focus = can_focus;
1476 /* update child_can_focus of parents */
1477 Evas_Object *o = obj;
1481 o = elm_widget_parent_get(o);
1483 sd = eo_data_scope_get(o, MY_CLASS);
1484 if (!sd || sd->child_can_focus) break;
1485 sd->child_can_focus = EINA_TRUE;
1488 eo_do(obj, eo_event_callback_array_add(focus_callbacks(), NULL));
1492 // update child_can_focus of parents */
1493 Evas_Object *parent = elm_widget_parent_get(obj);
1497 Evas_Object *subobj;
1499 ELM_WIDGET_DATA_GET(parent, sdp);
1501 sdp->child_can_focus = EINA_FALSE;
1502 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1504 if (_is_focusable(subobj))
1506 sdp->child_can_focus = EINA_TRUE;
1510 /* break again, child_can_focus went back to
1512 if (sdp->child_can_focus) break;
1513 parent = sdp->parent_obj;
1515 eo_do(obj, eo_event_callback_array_del(focus_callbacks(), NULL));
1519 EOLIAN static Eina_Bool
1520 _elm_widget_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1522 return sd->can_focus;
1525 EOLIAN static Eina_Bool
1526 _elm_widget_child_can_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1528 return sd->child_can_focus;
1534 * This API makes the widget object and its children to be unfocusable.
1536 * This API can be helpful for an object to be deleted.
1537 * When an object will be deleted soon, it and its children may not
1538 * want to get focus (by focus reverting or by other focus controls).
1539 * Then, just use this API before deleting.
1541 * @param obj The widget root of sub-tree
1542 * @param tree_unfocusable If true, set the object sub-tree as unfocusable
1547 _elm_widget_tree_unfocusable_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool tree_unfocusable)
1549 tree_unfocusable = !!tree_unfocusable;
1550 if (sd->tree_unfocusable == tree_unfocusable) return;
1551 sd->tree_unfocusable = tree_unfocusable;
1552 elm_widget_focus_tree_unfocusable_handle(obj);
1558 * This returns true, if the object sub-tree is unfocusable.
1560 * @param obj The widget root of sub-tree
1561 * @return EINA_TRUE if the object sub-tree is unfocusable
1565 EOLIAN static Eina_Bool
1566 _elm_widget_tree_unfocusable_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1568 return sd->tree_unfocusable;
1574 * Get the list of focusable child objects.
1576 * This function retruns list of child objects which can get focus.
1578 * @param obj The parent widget
1579 * @retrun list of focusable child objects.
1583 EOLIAN static Eina_List*
1584 _elm_widget_can_focus_child_list_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1587 Eina_List *child_list = NULL;
1590 EINA_LIST_FOREACH(sd->subobjs, l, child)
1592 if (!_elm_widget_is(child)) continue;
1593 if ((elm_widget_can_focus_get(child)) &&
1594 (evas_object_visible_get(child)) &&
1595 (!elm_widget_disabled_get(child)))
1596 child_list = eina_list_append(child_list, child);
1599 Eina_List *can_focus_list;
1600 can_focus_list = elm_widget_can_focus_child_list_get(child);
1602 child_list = eina_list_merge(child_list, can_focus_list);
1610 _elm_widget_highlight_ignore_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool ignore)
1612 sd->highlight_ignore = !!ignore;
1615 EOLIAN static Eina_Bool
1616 _elm_widget_highlight_ignore_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1618 return sd->highlight_ignore;
1622 _elm_widget_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1624 sd->highlight_in_theme = !!highlight;
1625 /* FIXME: if focused, it should switch from one mode to the other */
1629 _elm_widget_highlight_in_theme_update(Eo *obj)
1631 Evas_Object *top = elm_widget_top_get(obj);
1633 if (top && eo_isa(top, ELM_WIN_CLASS))
1635 _elm_win_focus_highlight_in_theme_update(
1636 top, elm_widget_highlight_in_theme_get(obj));
1640 EOLIAN static Eina_Bool
1641 _elm_widget_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1643 return sd->highlight_in_theme;
1647 _elm_widget_access_highlight_in_theme_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Eina_Bool highlight)
1649 sd->access_highlight_in_theme = !!highlight;
1652 EOLIAN static Eina_Bool
1653 _elm_widget_access_highlight_in_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1655 return sd->access_highlight_in_theme;
1658 EOLIAN static Eina_Bool
1659 _elm_widget_focus_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1661 return (sd->focused && sd->top_win_focused);
1664 EOLIAN static Eina_Bool
1665 _elm_widget_highlight_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1667 return sd->highlighted;
1670 EOLIAN static Evas_Object*
1671 _elm_widget_focused_object_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1673 const Evas_Object *subobj;
1676 if (!sd->focused || !sd->top_win_focused) return NULL;
1677 EINA_LIST_FOREACH(sd->subobjs, l, subobj)
1680 if (!_elm_widget_is(subobj)) continue;
1681 fobj = elm_widget_focused_object_get(subobj);
1682 if (fobj) return fobj;
1684 return (Evas_Object *)obj;
1687 EOLIAN static Evas_Object*
1688 _elm_widget_top_get(Eo *obj, Elm_Widget_Smart_Data *sd)
1692 Evas_Object *ret = NULL;
1693 if (!eo_isa(sd->parent_obj, ELM_WIDGET_CLASS)) return NULL;
1694 eo_do((Eo *) sd->parent_obj, ret = elm_obj_widget_top_get());
1697 return (Evas_Object *)obj;
1701 elm_widget_is(const Evas_Object *obj)
1703 return _elm_widget_is(obj);
1707 elm_widget_parent_widget_get(const Evas_Object *obj)
1709 Evas_Object *parent;
1711 if (_elm_widget_is(obj))
1713 ELM_WIDGET_DATA_GET(obj, sd);
1714 if (!sd) return NULL;
1715 parent = sd->parent_obj;
1719 parent = evas_object_data_get(obj, "elm-parent");
1720 if (!parent) parent = evas_object_smart_parent_get(obj);
1725 Evas_Object *elm_parent;
1726 if (_elm_widget_is(parent)) break;
1727 elm_parent = evas_object_data_get(parent, "elm-parent");
1728 if (elm_parent) parent = elm_parent;
1729 else parent = evas_object_smart_parent_get(parent);
1734 EOLIAN static Evas_Object *
1735 _elm_widget_parent2_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1741 _elm_widget_parent2_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *parent)
1743 sd->parent2 = parent;
1747 _elm_widget_event_callback_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1749 EINA_SAFETY_ON_NULL_RETURN(func);
1751 Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1754 ERR("Failed to allocate memory");
1759 sd->event_cb = eina_list_append(sd->event_cb, ecb);
1763 _elm_widget_event_callback_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Event_Cb func, const void *data)
1765 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1767 Elm_Event_Cb_Data *ecd;
1768 EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1769 if ((ecd->func == func) && (ecd->data == data))
1772 sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1773 return (void *)data;
1779 EOLIAN static Eina_Bool
1780 _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)
1782 Evas_Object *parent = obj;
1783 Elm_Event_Cb_Data *ecd;
1784 Eina_List *l, *l_prev;
1787 (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1789 ELM_WIDGET_CHECK(parent) EINA_FALSE;
1790 Elm_Widget_Smart_Data *sd = eo_data_scope_get(parent, MY_CLASS);
1792 Eina_Bool int_ret = EINA_FALSE;
1794 if (elm_widget_disabled_get(obj))
1796 parent = sd->parent_obj;
1800 eo_do(parent, int_ret = elm_obj_widget_event(obj, type, event_info));
1801 if (int_ret) return EINA_TRUE;
1803 EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1805 if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1806 (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1809 parent = sd->parent_obj;
1818 * Set custom focus chain.
1820 * This function i set one new and overwrite any previous custom focus chain
1821 * with the list of objects. The previous list will be deleted and this list
1822 * will be managed. After setted, don't modity it.
1824 * @note On focus cycle, only will be evaluated children of this container.
1826 * @param obj The container widget
1827 * @param objs Chain of objects to pass focus
1831 _elm_widget_focus_custom_chain_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_List *objs)
1833 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1835 elm_widget_focus_custom_chain_unset(obj);
1840 EINA_LIST_FOREACH(objs, l, o)
1842 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1843 _elm_object_focus_chain_del_cb, obj);
1846 sd->focus_chain = objs;
1852 * Get custom focus chain
1854 * @param obj The container widget
1857 EOLIAN static const Eina_List*
1858 _elm_widget_focus_custom_chain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1860 return (const Eina_List *)sd->focus_chain;
1866 * Unset custom focus chain
1868 * @param obj The container widget
1872 _elm_widget_focus_custom_chain_unset(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
1874 Eina_List *l, *l_next;
1877 EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1879 evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1880 _elm_object_focus_chain_del_cb, obj);
1881 sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1888 * Append object to custom focus chain.
1890 * @note If relative_child equal to NULL or not in custom chain, the object
1891 * will be added in end.
1893 * @note On focus cycle, only will be evaluated children of this container.
1895 * @param obj The container widget
1896 * @param child The child to be added in custom chain
1897 * @param relative_child The relative object to position the child
1901 _elm_widget_focus_custom_chain_append(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1903 EINA_SAFETY_ON_NULL_RETURN(child);
1905 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1907 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1908 _elm_object_focus_chain_del_cb, obj);
1910 if (!relative_child)
1911 sd->focus_chain = eina_list_append(sd->focus_chain, child);
1913 sd->focus_chain = eina_list_append_relative(sd->focus_chain,
1914 child, relative_child);
1920 * Prepend object to custom focus chain.
1922 * @note If relative_child equal to NULL or not in custom chain, the object
1923 * will be added in begin.
1925 * @note On focus cycle, only will be evaluated children of this container.
1927 * @param obj The container widget
1928 * @param child The child to be added in custom chain
1929 * @param relative_child The relative object to position the child
1933 _elm_widget_focus_custom_chain_prepend(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *child, Evas_Object *relative_child)
1935 EINA_SAFETY_ON_NULL_RETURN(child);
1937 if (!_elm_widget_focus_chain_manager_is(obj)) return;
1939 evas_object_event_callback_add(child, EVAS_CALLBACK_DEL,
1940 _elm_object_focus_chain_del_cb, obj);
1942 if (!relative_child)
1943 sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1945 sd->focus_chain = eina_list_prepend_relative(sd->focus_chain,
1946 child, relative_child);
1952 * Give focus to next object in object tree.
1954 * Give focus to next object in focus chain of one object sub-tree.
1955 * If the last object of chain already have focus, the focus will go to the
1956 * first object of chain.
1958 * @param obj The widget root of sub-tree
1959 * @param dir Direction to cycle the focus
1964 _elm_widget_focus_cycle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir)
1966 Evas_Object *target = NULL;
1967 Elm_Object_Item *target_item = NULL;
1968 if (!_elm_widget_is(obj))
1970 elm_widget_focus_next_get(obj, dir, &target, &target_item);
1974 if (_elm_config->access_mode)
1976 /* highlight cycle does not steal a focus, only after window gets
1977 the ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE message,
1978 target will steal focus, or focus its own job. */
1979 if (!_elm_access_auto_highlight_get())
1980 elm_widget_focus_steal(target, target_item);
1982 _elm_access_highlight_set(target);
1983 elm_widget_focus_region_show(target);
1985 else elm_widget_focus_steal(target, target_item);
1992 * Give focus to near object(in object tree) in one direction.
1994 * Give focus to near object(in object tree) in direction of current
1995 * focused object. If none focusable object in given direction or
1996 * none focused object in object tree, the focus will not change.
1998 * @param obj The reference widget
1999 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2000 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2001 * @return EINA_TRUE if focus is moved.
2005 EOLIAN static Eina_Bool
2006 _elm_widget_focus_direction_go(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, double degree)
2008 Evas_Object *target = NULL;
2009 Elm_Object_Item *target_item = NULL;
2010 Evas_Object *current_focused = NULL;
2011 double weight = 0.0;
2013 if (!_elm_widget_is(obj)) return EINA_FALSE;
2014 if (!_is_focused(obj)) return EINA_FALSE;
2016 current_focused = elm_widget_focused_object_get(obj);
2018 if (elm_widget_focus_direction_get
2019 (obj, current_focused, degree, &target, &target_item, &weight))
2021 elm_widget_focus_steal(target, NULL);
2029 _elm_widget_focus_direction_weight_get(const Evas_Object *obj1,
2030 const Evas_Object *obj2,
2033 Evas_Coord obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2;
2034 double x1, yy1, x2, yy2, xx1, yyy1, xx2, yyy2;
2035 double ax, ay, cx, cy;
2036 double weight = -1.0, g = 0.0;
2038 if (obj1 == obj2) return 0.0;
2041 while (degree >= 360.0)
2043 while (degree < 0.0)
2046 evas_object_geometry_get(obj1, &obj_x1, &obj_y1, &w1, &h1);
2047 cx = obj_x1 + (w1 / 2.0);
2048 cy = obj_y1 + (h1 / 2.0);
2049 evas_object_geometry_get(obj2, &obj_x2, &obj_y2, &w2, &h2);
2051 /* For overlapping cases. */
2052 if (ELM_RECTS_INTERSECT(obj_x1, obj_y1, w1, h1, obj_x2, obj_y2, w2, h2))
2055 /* Change all points to relative one. */
2065 /* Get crossing points (ax, ay) between obj1 and a line extending
2066 * to the direction of current degree. */
2072 else if (degree == 90.0)
2077 else if (degree == 180.0)
2082 else if (degree == 270.0)
2089 g = tan(degree * (M_PI / 180.0));
2090 if ((degree > 0.0) && (degree < 90.0))
2093 if (ay <= yyy1) ax = xx1;
2100 else if ((degree > 90.0) && (degree < 180.0))
2103 if (ay <= yyy1) ax = x1;
2110 else if ((degree > 180.0) && (degree < 270.0))
2113 if (ay >= yy1) ax = x1;
2123 if (ay >= yy1) ax = xx1;
2132 /* Filter obj2, if it is not in the specific derection. */
2134 double rx[4] = {0.0, 0.0, 0.0, 0.0}, ry[4] = {0.0, 0.0, 0.0, 0.0};
2135 double t1, t2, u1, v1, u2, v2;
2137 if ((degree == 45.0) || (degree == 225.0) || (degree == 135.0) ||
2147 double g2 = tan((degree + 45.0) * (M_PI / 180.0));
2152 t1 = (u1 * ax) + (v1 * ay);
2153 t2 = (u2 * ax) + (v2 * ay);
2155 #define _R(x) (int)((x + 0.05) * 10.0)
2157 if ((_R(t1 * ((u1 * x2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * x2) +
2163 if ((_R(t1 * ((u1 * x2) + (v1 * yyy2))) > 0) && (_R(t2 * ((u2 * x2) +
2169 if ((_R(t1 * ((u1 * xx2) + (v1 * yy2))) > 0) && (_R(t2 * ((u2 * xx2) +
2175 if ((_R(t1 * ((u1 * xx2) + (v1 * yyy2))) > 0) &&
2176 (_R(t2 * ((u2 * xx2) + (v2 * yyy2))) > 0))
2185 if ((_R(xx2) < 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2187 else if (degree == 90.0)
2189 if ((_R(yyy2) < 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2191 else if (degree == 180.0)
2193 if ((_R(x2) > 0) || (_R(yy2) > 0) || (_R(yyy2) < 0)) return 0.0;
2195 else if (degree == 270.0)
2197 if ((_R(yy2) > 0) || (_R(x2) > 0) || (_R(xx2) < 0)) return 0.0;
2201 if ((_R(g * x2) >= _R(yy2)) && (_R((g * x2)) <= _R(yyy2)))
2203 if (!((_R(ax * x2) > 0) && (_R(ay * (g * x2)) > 0)))
2206 else if ((_R(g * xx2) >= _R(yy2)) && (_R((g * xx2)) <= _R(yyy2)))
2208 if (!((_R(ax * xx2) > 0) && (_R(ay * (g * xx2)) > 0)))
2211 else if ((_R((1.0 / g) * yy2) >= _R(xx2)) && (_R((1.0 / g) * yy2)
2214 if (!((_R(ax * ((1.0 / g) * yy2)) > 0)
2215 && (_R(ay * yy2) > 0)))
2218 else if ((_R((1.0 / g) * yyy2) >= _R(xx2)) &&
2219 (_R((1.0 / g) * yyy2) <= _R(xx2)))
2221 if (!((_R(ax * ((1.0 / g) * yyy2)) > 0)
2222 && (_R(ay * yyy2) > 0))) return 0.0;
2228 /* Calculate the weight for obj2. */
2231 if (_R(xx1) > _R(x2)) weight = -1.0;
2232 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2233 weight = (x2 - xx1) * (x2 - xx1);
2234 else if (_R(yy2) > 0)
2235 weight = ((x2 - xx1) * (x2 - xx1)) + (yy2 * yy2);
2236 else if (_R(yyy2) < 0)
2237 weight = ((x2 - xx1) * (x2 - xx1)) + (yyy2 * yyy2);
2238 else weight = (x2 - xx1) * (x2 - xx1);
2240 else if (degree == 90.0)
2242 if (_R(yyy1) > _R(yy2)) weight = -1.0;
2243 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2244 weight = (yy2 - yyy1) * (yy2 - yyy1);
2245 else if (_R(x2) > 0)
2246 weight = (x2 * x2) + ((yy2 - yyy1) * (yy2 - yyy1));
2247 else if (_R(xx2) < 0)
2248 weight = (xx2 * xx2) + ((yy2 - yyy1) * (yy2 - yyy1));
2249 else weight = (yy2 - yyy1) * (yy2 - yyy1);
2251 else if (degree == 180.0)
2253 if (_R(x1) < _R(xx2)) weight = -1.0;
2254 else if ((_R(yy2) >= _R(yy1)) && (_R(yyy2) <= _R(yyy1)))
2255 weight = (x1 - xx2) * (x1 - xx2);
2256 else if (_R(yy2) > 0)
2257 weight = ((x1 - xx2) * (x1 - xx2)) + (yy2 * yy2);
2258 else if (_R(yyy2) < 0)
2259 weight = ((x1 - xx2) * (x1 - xx2)) + (yyy2 * yyy2);
2260 else weight = (x1 - xx2) * (x1 - xx2);
2262 else if (degree == 270.0)
2264 if (_R(yy1) < _R(yyy2)) weight = -1.0;
2265 else if ((_R(x2) >= _R(x1)) && (_R(xx2) <= _R(xx1)))
2266 weight = (yy1 - yyy2) * (yy1 - yyy2);
2267 else if (_R(x2) > 0)
2268 weight = (x2 * x2) + ((yy1 - yyy2) * (yy1 - yyy2));
2269 else if (_R(xx2) < 0)
2270 weight = (xx2 * xx2) + ((yy1 - yyy2) * (yy1 - yyy2));
2271 else weight = (yy1 - yyy2) * (yy1 - yyy2);
2276 double sx[4] = {0.0, 0.0, 0.0, 0.0}, sy[4] = {0.0, 0.0, 0.0, 0.0};
2277 double t_weight[4] = {-1.0, -1.0, -1.0, -1.0};
2278 if ((_R(g * x2) >= _R(yy2)) && (_R(g * x2) <= _R(yyy2)))
2282 t_weight[j++] = ((ax - x2) * (ax - x2)) +
2283 ((ay - (g * x2)) * (ay - (g * x2)));
2285 if ((_R(g * xx2) >= _R(yy2)) && (_R(g * xx2) <= _R(yyy2)))
2289 t_weight[j++] = ((ax - xx2) * (ax - xx2)) +
2290 ((ay - (g * xx2)) * (ay - (g * xx2)));
2292 if ((_R((1.0 / g) * yy2) >= _R(x2)) && (_R((1.0 / g) * yy2) <= _R(xx2)))
2294 sx[j] = (1.0 / g) * yy2;
2297 ((ax - ((1.0 / g) * yy2)) * (ax - ((1.0 / g) * yy2))) +
2298 ((ay - yy2) * (ay - yy2));
2300 if ((_R((1.0 / g) * yyy2) >= _R(x2)) && (_R((1.0 / g) * yyy2)
2303 sx[j] = (1.0 / g) * yyy2;
2306 ((ax - ((1.0 / g) * yyy2)) * (ax - ((1.0 / g) * yyy2))) +
2307 ((ay - yyy2) * (ay - yyy2));
2310 if ((j > 2) || ((j == 2) && ((_R(sx[0]) != _R(sx[1])) ||
2311 (_R(sy[0]) != _R(sy[1])))))
2315 if (_R(t_weight[k]) == 0) return -1.0;
2316 if ((1 / weight) < (1 / t_weight[k])) weight = t_weight[k];
2323 double ccx, ccy, t1_weight, x_diff, y_diff;
2324 ccx = ((1.0 / g) * rx[k] + ry[k]) / (g + (1.0 / g));
2326 x_diff = rx[k] - ccx;
2327 if (x_diff < 0) x_diff *= -1.0;
2328 y_diff = ry[k] - ccy;
2329 if (y_diff < 0) y_diff *= -1.0;
2331 (((ax - ccx) * (ax - ccx)) + ((ay - ccy) * (ay - ccy))) +
2332 ((x_diff * x_diff * x_diff) + (y_diff * y_diff * y_diff));
2333 if ((_R(t1_weight) != 0) && ((1 / weight) < (1 / t1_weight)))
2338 /* Return the current object's weight. */
2339 if (weight == -1.0) return 0.0;
2340 if (_R(weight) == 0) return -1.0;
2344 return 1.0 / weight;
2350 * Get near object in one direction of base object.
2352 * Get near object(in the object sub-tree) in one direction of
2353 * base object. Return the near object by reference.
2354 * By initializing weight, you can filter objects locating far
2355 * from base object. If object is in the specific direction,
2356 * weight is (1/(distance^2)). If object is not exactly in one
2357 * direction, some penalty will be added.
2359 * @param obj The widget root of sub-tree
2360 * @param base The base object of the direction
2361 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2362 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2363 * @param direction The near object in one direction
2364 * @param weight The weight is bigger when the object is located near
2365 * @return EINA_TRUE if near object is updated.
2370 EOLIAN static Eina_Bool
2371 _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)
2375 /* -1 means the best was already decided. Don't need any more searching. */
2376 if (!direction || !weight || !base || (obj == base))
2379 /* Ignore if disabled */
2380 if ((!evas_object_visible_get(obj))
2381 || (elm_widget_disabled_get(obj))
2382 || (elm_widget_tree_unfocusable_get(obj)))
2386 if (_internal_elm_widget_focus_direction_manager_is(obj))
2388 Eina_Bool int_ret = EINA_FALSE;
2389 eo_do((Eo *)obj, int_ret = elm_obj_widget_focus_direction(base, degree, direction, direction_item, weight));
2393 if (!elm_widget_can_focus_get(obj) || _is_focused((Eo *)obj))
2396 c_weight = _elm_widget_focus_direction_weight_get(base, obj, degree);
2397 if ((c_weight == -1.0) ||
2398 ((c_weight != 0.0) && (*weight != -1.0) &&
2399 ((int)(*weight * 1000000) <= (int)(c_weight * 1000000))))
2402 ((int)(*weight * 1000000) == (int)(c_weight * 1000000)))
2404 ELM_WIDGET_DATA_GET(*direction, sd1);
2407 if (sd->focus_order <= sd1->focus_order)
2411 *direction = (Evas_Object *)obj;
2422 * Get near object in one direction of base object in list.
2424 * Get near object in one direction of base object in the specific
2425 * object list. Return the near object by reference.
2426 * By initializing weight, you can filter objects locating far
2427 * from base object. If object is in the specific direction,
2428 * weight is (1/(distance^2)). If object is not exactly in one
2429 * direction, some penalty will be added.
2431 * @param obj The widget root of sub-tree
2432 * @param base The base object of the direction
2433 * @param items list with ordered objects
2434 * @param list_data_get function to get the object from one item of list
2435 * @param degree Degree changes clockwise. i.e. 0-degree: Up,
2436 * 90-degree: Right, 180-degree: Down, and 270-degree: Left
2437 * @param direction The near object in one direction
2438 * @param weight The weight is bigger when the object is located near
2439 * @return EINA_TRUE if near object is updated.
2443 EOLIAN static Eina_Bool
2444 _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)
2446 if (!direction || !weight || !base || !items)
2449 const Eina_List *l = items;
2450 Evas_Object *current_best = *direction;
2452 for (; l; l = eina_list_next(l))
2454 Evas_Object *cur = list_data_get(l);
2455 if (cur && _elm_widget_is(cur))
2456 elm_widget_focus_direction_get(cur, base, degree, direction, direction_item, weight);
2458 if (current_best != *direction) return EINA_TRUE;
2466 * Get next object in focus chain of object tree.
2468 * Get next object in focus chain of one object sub-tree.
2469 * Return the next object by reference. If don't have any candidate to receive
2470 * focus before chain end, the first candidate will be returned.
2472 * @param obj The widget root of sub-tree
2473 * @param dir Direction of focus chain
2474 * @param next The next object in focus chain
2475 * @return EINA_TRUE if don't need focus chain restart/loop back
2476 * to use 'next' obj.
2480 EOLIAN static Eina_Bool
2481 _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)
2483 Elm_Access_Info *ac;
2489 /* Ignore if disabled */
2490 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2492 if (!evas_object_visible_get(obj)
2493 || (elm_widget_tree_unfocusable_get(obj)))
2498 if ((!evas_object_visible_get(obj))
2499 || (elm_widget_disabled_get(obj))
2500 || (elm_widget_tree_unfocusable_get(obj)))
2505 if (_elm_widget_focus_chain_manager_is(obj))
2507 Eina_Bool int_ret = EINA_FALSE;
2508 eo_do((Eo *)obj, int_ret = elm_obj_widget_focus_next(dir, next, next_item));
2509 if (!int_ret && _is_focused((Eo *)obj))
2511 Evas_Object *o = NULL;
2512 if (dir == ELM_FOCUS_PREVIOUS)
2513 *next_item = sd->item_focus_previous;
2514 else if (dir == ELM_FOCUS_NEXT)
2515 *next_item = sd->item_focus_next;
2516 else if (dir == ELM_FOCUS_UP)
2517 *next_item = sd->item_focus_up;
2518 else if (dir == ELM_FOCUS_DOWN)
2519 *next_item = sd->item_focus_down;
2520 else if (dir == ELM_FOCUS_RIGHT)
2521 *next_item = sd->item_focus_right;
2522 else if (dir == ELM_FOCUS_LEFT)
2523 *next_item = sd->item_focus_left;
2524 o = elm_object_item_widget_get(*next_item);
2528 if (dir == ELM_FOCUS_PREVIOUS)
2529 o = sd->focus_previous;
2530 else if (dir == ELM_FOCUS_NEXT)
2532 else if (dir == ELM_FOCUS_UP)
2534 else if (dir == ELM_FOCUS_DOWN)
2536 else if (dir == ELM_FOCUS_RIGHT)
2537 o = sd->focus_right;
2538 else if (dir == ELM_FOCUS_LEFT)
2551 /* access object does not check sd->can_focus, because an object could
2552 have highlight even though the object is not focusable. */
2553 if (_elm_config->access_mode && _elm_access_auto_highlight_get())
2555 ac = _elm_access_info_get(obj);
2556 if (!ac) return EINA_FALSE;
2558 /* check whether the hover object is visible or not */
2559 if (!evas_object_visible_get(ac->hoverobj))
2562 else if (!elm_widget_can_focus_get(obj))
2565 if (_is_focused((Eo *)obj))
2567 if (dir == ELM_FOCUS_PREVIOUS)
2568 *next_item = sd->item_focus_previous;
2569 else if (dir == ELM_FOCUS_NEXT)
2570 *next_item = sd->item_focus_next;
2571 else if (dir == ELM_FOCUS_UP)
2572 *next_item = sd->item_focus_up;
2573 else if (dir == ELM_FOCUS_DOWN)
2574 *next_item = sd->item_focus_down;
2575 else if (dir == ELM_FOCUS_RIGHT)
2576 *next_item = sd->item_focus_right;
2577 else if (dir == ELM_FOCUS_LEFT)
2578 *next_item = sd->item_focus_left;
2579 *next = elm_object_item_widget_get(*next_item);
2583 if (dir == ELM_FOCUS_PREVIOUS)
2584 *next = sd->focus_previous;
2585 else if (dir == ELM_FOCUS_NEXT)
2586 *next = sd->focus_next;
2587 else if (dir == ELM_FOCUS_UP)
2588 *next = sd->focus_up;
2589 else if (dir == ELM_FOCUS_DOWN)
2590 *next = sd->focus_down;
2591 else if (dir == ELM_FOCUS_RIGHT)
2592 *next = sd->focus_right;
2593 else if (dir == ELM_FOCUS_LEFT)
2594 *next = sd->focus_left;
2597 if (*next) return EINA_TRUE;
2601 *next = (Evas_Object *)obj;
2602 return !ELM_WIDGET_FOCUS_GET(obj);
2608 * Get next object in focus chain of object tree in list.
2610 * Get next object in focus chain of one object sub-tree ordered by one list.
2611 * Return the next object by reference. If don't have any candidate to receive
2612 * focus before list end, the first candidate will be returned.
2614 * @param obj The widget root of sub-tree
2615 * @param items list with ordered objects
2616 * @param list_data_get function to get the object from one item of list
2617 * @param dir Direction of focus chain
2618 * @param next The next object in focus chain
2619 * @return EINA_TRUE if don't need focus chain restart/loop back
2620 * to use 'next' obj.
2624 EOLIAN static Eina_Bool
2625 _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)
2627 Eina_List *(*list_next)(const Eina_List *list) = NULL;
2628 Evas_Object *focused_object = NULL;
2634 if (!_elm_widget_is(obj))
2640 /* When Up, Down, Right, or Left, try direction_get first. */
2641 focused_object = elm_widget_focused_object_get(obj);
2644 if ((dir == ELM_FOCUS_UP)
2645 || (dir == ELM_FOCUS_DOWN)
2646 || (dir == ELM_FOCUS_RIGHT)
2647 || (dir == ELM_FOCUS_LEFT))
2649 *next_item = elm_widget_focus_next_item_get(focused_object, dir);
2651 *next = elm_object_item_widget_get(*next_item);
2653 *next = elm_widget_focus_next_object_get(focused_object, dir);
2654 if (*next) return EINA_TRUE;
2657 Evas_Object *n = NULL;
2658 Elm_Object_Item *n_item = NULL;
2660 double weight = 0.0;
2662 if (dir == ELM_FOCUS_UP) degree = 0.0;
2663 else if (dir == ELM_FOCUS_DOWN) degree = 180.0;
2664 else if (dir == ELM_FOCUS_RIGHT) degree = 90.0;
2665 else if (dir == ELM_FOCUS_LEFT) degree = 270.0;
2667 if (elm_widget_focus_list_direction_get(obj, focused_object,
2668 items, list_data_get,
2669 degree, &n, &n_item,
2672 *next_item = n_item;
2681 if (dir == ELM_FOCUS_PREVIOUS)
2683 items = eina_list_last(items);
2684 list_next = eina_list_prev;
2686 else if ((dir == ELM_FOCUS_NEXT)
2687 || (dir == ELM_FOCUS_UP)
2688 || (dir == ELM_FOCUS_DOWN)
2689 || (dir == ELM_FOCUS_RIGHT)
2690 || (dir == ELM_FOCUS_LEFT))
2691 list_next = eina_list_next;
2695 const Eina_List *l = items;
2697 /* Recovery last focused sub item */
2698 if (ELM_WIDGET_FOCUS_GET(obj))
2700 for (; l; l = list_next(l))
2702 Evas_Object *cur = list_data_get(l);
2703 if (ELM_WIDGET_FOCUS_GET(cur)) break;
2706 /* Focused object, but no focused sub item */
2710 const Eina_List *start = l;
2711 Evas_Object *to_focus = NULL;
2712 Elm_Object_Item *to_focus_item = NULL;
2714 /* Iterate sub items */
2715 /* Go to the end of list */
2716 for (; l; l = list_next(l))
2718 Evas_Object *tmp = NULL;
2719 Elm_Object_Item *tmp_item = NULL;
2720 Evas_Object *cur = list_data_get(l);
2723 if (!_elm_widget_is(cur)) continue;
2724 if (elm_widget_parent_get(cur) != obj)
2727 /* Try Focus cycle in subitem */
2728 if (elm_widget_focus_next_get(cur, dir, &tmp, &tmp_item))
2731 *next_item = tmp_item;
2734 else if ((dir == ELM_FOCUS_UP)
2735 || (dir == ELM_FOCUS_DOWN)
2736 || (dir == ELM_FOCUS_RIGHT)
2737 || (dir == ELM_FOCUS_LEFT))
2739 if (tmp && _is_focused(cur))
2742 *next_item = tmp_item;
2746 else if ((tmp) && (!to_focus))
2749 to_focus_item = tmp_item;
2755 /* Get First possible */
2756 for (; l != start; l = list_next(l))
2758 Evas_Object *tmp = NULL;
2759 Elm_Object_Item *tmp_item = NULL;
2760 Evas_Object *cur = list_data_get(l);
2762 if (elm_widget_parent_get(cur) != obj)
2765 /* Try Focus cycle in subitem */
2766 elm_widget_focus_next_get(cur, dir, &tmp, &tmp_item);
2770 *next_item = tmp_item;
2776 *next_item = to_focus_item;
2783 * Get next object which was set with specific focus direction.
2785 * Get next object which was set by elm_widget_focus_next_object_set
2786 * with specific focus directioin.
2788 * @param obj The widget
2789 * @param dir Direction of focus
2790 * @return Widget which was registered with sepecific focus direction.
2794 EOLIAN static Evas_Object*
2795 _elm_widget_focus_next_object_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir)
2797 Evas_Object *ret = NULL;
2799 if (dir == ELM_FOCUS_PREVIOUS)
2800 ret = sd->focus_previous;
2801 else if (dir == ELM_FOCUS_NEXT)
2802 ret = sd->focus_next;
2803 else if (dir == ELM_FOCUS_UP)
2805 else if (dir == ELM_FOCUS_DOWN)
2806 ret = sd->focus_down;
2807 else if (dir == ELM_FOCUS_RIGHT)
2808 ret = sd->focus_right;
2809 else if (dir == ELM_FOCUS_LEFT)
2810 ret = sd->focus_left;
2818 * Set next object with specific focus direction.
2820 * When a widget is set with specific focus direction, this widget will be
2821 * the first candidate when finding the next focus object.
2822 * Focus next object can be registered with six directions that are previous,
2823 * next, up, down, right, and left.
2825 * @param obj The widget
2826 * @param next Next focus object
2827 * @param dir Direction of focus
2832 _elm_widget_focus_next_object_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_Object *next, Elm_Focus_Direction dir)
2835 if (dir == ELM_FOCUS_PREVIOUS)
2836 sd->focus_previous = next;
2837 else if (dir == ELM_FOCUS_NEXT)
2838 sd->focus_next = next;
2839 else if (dir == ELM_FOCUS_UP)
2840 sd->focus_up = next;
2841 else if (dir == ELM_FOCUS_DOWN)
2842 sd->focus_down = next;
2843 else if (dir == ELM_FOCUS_RIGHT)
2844 sd->focus_right = next;
2845 else if (dir == ELM_FOCUS_LEFT)
2846 sd->focus_left = next;
2849 EOLIAN static Elm_Object_Item*
2850 _elm_widget_focus_next_item_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Direction dir)
2852 Elm_Object_Item *ret = NULL;
2854 if (dir == ELM_FOCUS_PREVIOUS)
2855 ret = sd->item_focus_previous;
2856 else if (dir == ELM_FOCUS_NEXT)
2857 ret = sd->item_focus_next;
2858 else if (dir == ELM_FOCUS_UP)
2859 ret = sd->item_focus_up;
2860 else if (dir == ELM_FOCUS_DOWN)
2861 ret = sd->item_focus_down;
2862 else if (dir == ELM_FOCUS_RIGHT)
2863 ret = sd->item_focus_right;
2864 else if (dir == ELM_FOCUS_LEFT)
2865 ret = sd->item_focus_left;
2871 _elm_widget_focus_next_item_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
2873 if (dir == ELM_FOCUS_PREVIOUS)
2874 sd->item_focus_previous = next_item;
2875 else if (dir == ELM_FOCUS_NEXT)
2876 sd->item_focus_next = next_item;
2877 else if (dir == ELM_FOCUS_UP)
2878 sd->item_focus_up = next_item;
2879 else if (dir == ELM_FOCUS_DOWN)
2880 sd->item_focus_down = next_item;
2881 else if (dir == ELM_FOCUS_RIGHT)
2882 sd->item_focus_right = next_item;
2883 else if (dir == ELM_FOCUS_LEFT)
2884 sd->item_focus_left = next_item;
2888 _elm_widget_parent_highlight_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool highlighted)
2890 highlighted = !!highlighted;
2892 Evas_Object *o = elm_widget_parent_get(obj);
2894 if (o) elm_widget_parent_highlight_set(o, highlighted);
2896 sd->highlighted = highlighted;
2900 _elm_widget_signal_emit(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source)
2902 if (evas_object_smart_type_check(obj, "elm_layout"))
2903 elm_layout_signal_emit(obj, emission, source);
2904 else if (evas_object_smart_type_check(obj, "elm_icon"))
2906 WRN("Deprecated function. This functionality on icon objects"
2907 " will be dropped on a next release.");
2908 _elm_icon_signal_emit(obj, emission, source);
2913 _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)
2915 EINA_SAFETY_ON_NULL_RETURN(func);
2917 if (evas_object_smart_type_check(obj, "elm_layout"))
2918 elm_layout_signal_callback_add(obj, emission, source, func, data);
2919 else if (evas_object_smart_type_check(obj, "elm_icon"))
2921 WRN("Deprecated function. This functionality on icon objects"
2922 " will be dropped on a next release.");
2924 _elm_icon_signal_callback_add(obj, emission, source, func, data);
2929 _elm_widget_signal_callback_del(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *emission, const char *source, Edje_Signal_Cb func)
2933 if (evas_object_smart_type_check(obj, "elm_layout"))
2934 data = elm_layout_signal_callback_del(obj, emission, source, func);
2935 else if (evas_object_smart_type_check(obj, "elm_icon"))
2937 WRN("Deprecated function. This functionality on icon objects"
2938 " will be dropped on a next release.");
2940 data = _elm_icon_signal_callback_del(obj, emission, source, func);
2947 _elm_widget_focus_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool focus)
2952 sd->focus_order = focus_order;
2953 sd->focused = EINA_TRUE;
2954 eo_do(obj, elm_obj_widget_on_focus(NULL));
2959 if ((_is_focusable(sd->resize_obj)) &&
2960 (!elm_widget_disabled_get(sd->resize_obj)))
2962 elm_widget_focus_set(sd->resize_obj, focus);
2969 EINA_LIST_FOREACH(sd->subobjs, l, child)
2971 if (!_elm_widget_is(child)) continue;
2972 if ((_is_focusable(child)) &&
2973 (!elm_widget_disabled_get(child)))
2975 elm_widget_focus_set(child, focus);
2986 EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
2988 if (!_elm_widget_is(child)) continue;
2989 if ((_is_focusable(child)) &&
2990 (!elm_widget_disabled_get(child)))
2992 elm_widget_focus_set(child, focus);
2999 EOLIAN static Evas_Object*
3000 _elm_widget_parent_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3002 return sd->parent_obj;
3006 _elm_widget_focused_object_clear(Eo *obj, Elm_Widget_Smart_Data *sd)
3008 if (!sd->focused) return;
3009 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
3010 _is_focused(sd->resize_obj))
3012 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
3018 EINA_LIST_FOREACH(sd->subobjs, l, child)
3020 if (_elm_widget_is(child) && _is_focused(child))
3022 eo_do(child, elm_obj_widget_focused_object_clear());
3027 sd->focused = EINA_FALSE;
3028 if (sd->top_win_focused)
3029 eo_do(obj, elm_obj_widget_on_focus(NULL));
3033 _elm_widget_focus_steal(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Object_Item *item)
3035 Evas_Object *parent, *parent2, *o;
3037 if (sd->focused) return;
3038 if (sd->disabled) return;
3039 if (!sd->can_focus) return;
3040 if (sd->tree_unfocusable) return;
3044 o = elm_widget_parent_get(parent);
3046 sd = eo_data_scope_get(o, MY_CLASS);
3047 if (sd->disabled || sd->tree_unfocusable) return;
3048 if (sd->focused) break;
3051 if ((!elm_widget_parent_get(parent)) &&
3052 (!elm_widget_parent2_get(parent)))
3053 eo_do(parent, elm_obj_widget_focused_object_clear());
3056 parent2 = elm_widget_parent_get(parent);
3057 if (!parent2) parent2 = elm_widget_parent2_get(parent);
3059 sd = eo_data_scope_get(parent, MY_CLASS);
3062 if (sd->resize_obj && elm_widget_is(sd->resize_obj) &&
3063 _is_focused(sd->resize_obj))
3065 eo_do(sd->resize_obj, elm_obj_widget_focused_object_clear());
3071 EINA_LIST_FOREACH(sd->subobjs, l, child)
3073 if (_elm_widget_is(child) && _is_focused(child))
3075 eo_do(child, elm_obj_widget_focused_object_clear());
3082 _parent_focus(obj, item);
3083 elm_widget_focus_region_show(obj);
3088 _parents_on_focus(Evas_Object *obj)
3091 if (!sd->focused || !sd->top_win_focused) return;
3093 Evas_Object *o = elm_widget_parent_get(obj);
3094 if (o) _parents_on_focus(o);
3095 eo_do(obj, elm_obj_widget_on_focus(NULL));
3099 _elm_widget_focus_restore(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3101 Evas_Object *newest = NULL;
3102 unsigned int newest_focus_order = 0;
3104 newest = elm_widget_newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
3106 _parents_on_focus(newest);
3110 _elm_widget_focus_auto_show(Evas_Object *obj)
3112 Evas_Object *top = elm_widget_top_get(obj);
3113 if (top && eo_isa(top, ELM_WIN_CLASS)) _elm_win_focus_auto_show(top);
3117 _elm_widget_top_win_focused_set(Evas_Object *obj,
3118 Eina_Bool top_win_focused)
3124 if (sd->top_win_focused == top_win_focused) return;
3125 EINA_LIST_FOREACH(sd->subobjs, l, child)
3127 if (elm_widget_is(child))
3128 _elm_widget_top_win_focused_set(child, top_win_focused);
3130 sd->top_win_focused = top_win_focused;
3132 if (sd->focused && !sd->top_win_focused)
3133 eo_do(obj, elm_obj_widget_on_focus(NULL));
3137 _elm_widget_top_win_focused_get(const Evas_Object *obj)
3139 API_ENTRY return EINA_FALSE;
3140 return sd->top_win_focused;
3144 _elm_widget_disabled_eval(const Evas_Object *obj, Eina_Bool disabled)
3148 ELM_WIDGET_DATA_GET(obj, sd);
3152 EINA_LIST_FOREACH(sd->subobjs, l, child)
3154 if (elm_widget_is(child))
3156 elm_widget_focus_disabled_handle(child);
3157 eo_do(child, elm_obj_widget_disable());
3158 _elm_widget_disabled_eval(child, EINA_TRUE);
3164 EINA_LIST_FOREACH(sd->subobjs, l, child)
3166 ELM_WIDGET_DATA_GET(child, sdc);
3167 if (elm_widget_is(child) && !sdc->disabled)
3169 elm_widget_focus_disabled_handle(child);
3170 eo_do(child, elm_obj_widget_disable());
3171 _elm_widget_disabled_eval(child, EINA_FALSE);
3178 elm_widget_disabled_internal(Eo *obj, Eina_Bool disabled)
3180 Eina_Bool parent_state = EINA_FALSE;
3184 elm_widget_focus_disabled_handle(obj);
3185 eo_do(obj, elm_obj_widget_disable());
3186 _elm_widget_disabled_eval(obj, EINA_TRUE);
3190 parent_state = elm_widget_disabled_get(elm_widget_parent_get(obj));
3191 if (parent_state) return;
3192 elm_widget_focus_disabled_handle(obj);
3193 eo_do(obj, elm_obj_widget_disable());
3194 _elm_widget_disabled_eval(obj, EINA_FALSE);
3199 _elm_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
3201 if (sd->disabled == disabled) return;
3202 sd->disabled = !!disabled;
3204 elm_widget_disabled_internal(obj, disabled);
3207 EOLIAN static Eina_Bool
3208 _elm_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3210 Eina_Bool disabled = EINA_FALSE;
3212 if (sd->disabled) disabled = EINA_TRUE;
3213 else disabled = elm_widget_disabled_get(elm_widget_parent_get(obj));
3218 _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)
3221 Evas_Object *parent_obj, *child_obj;
3222 Evas_Coord px, py, cx, cy, nx = 0, ny = 0;
3225 evas_smart_objects_calculate(evas_object_evas_get(obj));
3227 if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
3228 (w == sd->rw) && (h == sd->rh)) return;
3234 if (sd->on_show_region)
3237 (sd->on_show_region_data, obj);
3239 if (_elm_scrollable_is(obj))
3241 eo_do(obj, elm_interface_scrollable_content_pos_get(&nx, &ny));
3249 parent_obj = sd->parent_obj;
3250 child_obj = sd->obj;
3251 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
3252 sd = eo_data_scope_get(parent_obj, MY_CLASS);
3255 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
3256 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
3265 if (sd->on_show_region)
3268 (sd->on_show_region_data, parent_obj);
3275 _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)
3286 * Get the focus region of the given widget.
3288 * @return show region or not
3289 * (@c EINA_TRUE = show region/@c EINA_FALSE = do not show region). Default is @c EINA_FALSE.
3291 * The focus region is the area of a widget that should brought into the
3292 * visible area when the widget is focused. Mostly used to show the part of
3293 * an entry where the cursor is, for example. The area returned is relative
3294 * to the object @p obj.
3296 * @param obj The widget object
3297 * @param x Where to store the x coordinate of the area
3298 * @param y Where to store the y coordinate of the area
3299 * @param w Where to store the width of the area
3300 * @param h Where to store the height of the area
3304 EOLIAN static Eina_Bool
3305 _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)
3307 Eina_Bool int_ret = EINA_FALSE;
3308 eo_do((Eo *)obj, int_ret = elm_obj_widget_on_focus_region(x, y, w, h));
3311 evas_object_geometry_get(obj, NULL, NULL, w, h);
3315 if ((*w <= 0) || (*h <= 0)) return EINA_FALSE;
3320 _elm_widget_parents_bounce_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool *horiz, Eina_Bool *vert)
3322 Evas_Object *parent_obj = obj;
3323 Eina_Bool h = EINA_FALSE, v = EINA_FALSE;
3325 *horiz = EINA_FALSE;
3330 parent_obj = elm_widget_parent_get(parent_obj);
3331 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
3333 if (_elm_scrollable_is(parent_obj))
3335 eo_do(parent_obj, elm_interface_scrollable_bounce_allow_get(&h, &v));
3336 if (h) *horiz = EINA_TRUE;
3337 if (v) *vert = EINA_TRUE;
3343 EOLIAN static Eina_List*
3344 _elm_widget_scrollable_children_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3353 EINA_LIST_FOREACH(sd->subobjs, l, child)
3355 if (elm_widget_is(child) && _elm_scrollable_is(child))
3356 ret = eina_list_append(ret, child);
3363 _elm_widget_scroll_hold_push(Eo *obj, Elm_Widget_Smart_Data *sd)
3366 if (sd->scroll_hold == 1)
3368 if (_elm_scrollable_is(obj))
3369 eo_do(obj, elm_interface_scrollable_hold_set(EINA_TRUE));
3372 Eina_List *scr_children, *l;
3375 scr_children = elm_widget_scrollable_children_get(obj);
3376 EINA_LIST_FOREACH(scr_children, l, child)
3378 eo_do(child, elm_interface_scrollable_hold_set(EINA_TRUE));
3380 eina_list_free(scr_children);
3383 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_push());
3384 // FIXME: on delete/reparent hold pop
3388 _elm_widget_scroll_hold_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
3391 if (!sd->scroll_hold)
3393 if (_elm_scrollable_is(obj))
3394 eo_do(obj, elm_interface_scrollable_hold_set(EINA_FALSE));
3397 Eina_List *scr_children, *l;
3400 scr_children = elm_widget_scrollable_children_get(obj);
3401 EINA_LIST_FOREACH(scr_children, l, child)
3403 eo_do(child, elm_interface_scrollable_hold_set(EINA_FALSE));
3405 eina_list_free(scr_children);
3408 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_hold_pop());
3409 if (sd->scroll_hold < 0) sd->scroll_hold = 0;
3413 _elm_widget_scroll_hold_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3415 return sd->scroll_hold;
3419 _elm_widget_scroll_freeze_push(Eo *obj, Elm_Widget_Smart_Data *sd)
3421 sd->scroll_freeze++;
3422 if (sd->scroll_freeze == 1)
3424 if (_elm_scrollable_is(obj))
3425 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_TRUE));
3428 Eina_List *scr_children, *l;
3431 scr_children = elm_widget_scrollable_children_get(obj);
3432 EINA_LIST_FOREACH(scr_children, l, child)
3434 eo_do(child, elm_interface_scrollable_freeze_set(EINA_TRUE));
3436 eina_list_free(scr_children);
3439 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_push());
3440 // FIXME: on delete/reparent freeze pop
3444 _elm_widget_scroll_freeze_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
3446 sd->scroll_freeze--;
3447 if (!sd->scroll_freeze)
3449 if (_elm_scrollable_is(obj))
3450 eo_do(obj, elm_interface_scrollable_freeze_set(EINA_FALSE));
3453 Eina_List *scr_children, *l;
3456 scr_children = elm_widget_scrollable_children_get(obj);
3457 EINA_LIST_FOREACH(scr_children, l, child)
3459 eo_do(child, elm_interface_scrollable_freeze_set(EINA_FALSE));
3461 eina_list_free(scr_children);
3464 if (sd->parent_obj) eo_do(sd->parent_obj, elm_obj_widget_scroll_freeze_pop());
3465 if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
3469 _elm_widget_scroll_freeze_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3471 return sd->scroll_freeze;
3474 // TIZEN_ONLY(20150705): Genlist item align feature
3476 elm_widget_scroll_item_align_enabled_set(Evas_Object *obj,
3477 Eina_Bool scroll_item_align_enable)
3480 if (sd->scroll_item_align_enable == scroll_item_align_enable) return;
3481 sd->scroll_item_align_enable = scroll_item_align_enable;
3485 elm_widget_scroll_item_align_enabled_get(const Evas_Object *obj)
3487 API_ENTRY return EINA_FALSE;
3488 return sd->scroll_item_align_enable;
3492 elm_widget_scroll_item_valign_set(Evas_Object *obj,
3493 const char *scroll_item_valign)
3496 if (sd->scroll_item_valign) eina_stringshare_del(sd->scroll_item_valign);
3497 if (!scroll_item_valign) sd->scroll_item_valign = NULL;
3498 else sd->scroll_item_valign = eina_stringshare_add(scroll_item_valign);
3502 elm_widget_scroll_item_valign_get(const Evas_Object *obj)
3504 API_ENTRY return NULL;
3505 return sd->scroll_item_valign;
3510 _elm_widget_scale_set(Eo *obj, Elm_Widget_Smart_Data *sd, double scale)
3512 if (scale < 0.0) scale = 0.0;
3513 if (sd->scale != scale)
3516 elm_widget_theme(obj);
3520 EOLIAN static double
3521 _elm_widget_scale_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3523 // FIXME: save walking up the tree by storing/caching parent scale
3524 if (sd->scale == 0.0)
3526 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3528 return elm_widget_scale_get(sd->parent_obj);
3539 _elm_widget_theme_set(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Theme *th)
3541 Eina_Bool apply = EINA_FALSE;
3542 if (sd->theme != th)
3544 if (elm_widget_theme_get(obj) != th) apply = EINA_TRUE;
3545 if (sd->theme) elm_theme_free(sd->theme);
3548 if (apply) elm_widget_theme(obj);
3553 _elm_widget_part_text_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part, const char *label)
3555 if (evas_object_smart_type_check(obj, "elm_layout"))
3556 elm_layout_text_set(obj, part, label);
3559 EOLIAN static const char*
3560 _elm_widget_part_text_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part)
3562 if (evas_object_smart_type_check(obj, "elm_layout"))
3563 return elm_layout_text_get(obj, part);
3568 static Elm_Translate_String_Data *
3569 _translate_string_data_get(Eina_Inlist *translate_strings, const char *part)
3571 Elm_Translate_String_Data *ts;
3572 Eina_Stringshare *str;
3574 if (!translate_strings) return NULL;
3576 str = eina_stringshare_add(part);
3577 EINA_INLIST_FOREACH(translate_strings, ts)
3579 if (ts->id == str) break;
3582 eina_stringshare_del(str);
3587 static Elm_Translate_String_Data *
3588 _part_text_translatable_set(Eina_Inlist **translate_strings, const char *part, Eina_Bool translatable, Eina_Bool preset)
3591 Elm_Translate_String_Data *ts;
3592 t = *translate_strings;
3593 ts = _translate_string_data_get(t, part);
3599 ts = ELM_NEW(Elm_Translate_String_Data);
3600 if (!ts) return NULL;
3602 ts->id = eina_stringshare_add(part);
3603 t = eina_inlist_append(t, (Eina_Inlist*) ts);
3605 if (preset) ts->preset = EINA_TRUE;
3607 //Delete this exist one if this part has been not preset.
3608 //see elm_widget_part_text_translatable_set()
3609 else if (ts && ((preset) || (!ts->preset)))
3611 t = eina_inlist_remove(t, EINA_INLIST_GET(ts));
3612 eina_stringshare_del(ts->id);
3613 eina_stringshare_del(ts->domain);
3614 eina_stringshare_del(ts->string);
3615 ELM_SAFE_FREE(ts, free);
3618 *translate_strings = t;
3624 _elm_widget_domain_translatable_part_text_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, const char *label)
3627 Elm_Translate_String_Data *ts;
3631 _part_text_translatable_set(&sd->translate_strings, part, EINA_FALSE,
3636 ts = _part_text_translatable_set(&sd->translate_strings, part,
3637 EINA_TRUE, EINA_FALSE);
3639 if (!ts->string) ts->string = eina_stringshare_add(label);
3640 else eina_stringshare_replace(&ts->string, label);
3641 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3642 else eina_stringshare_replace(&ts->domain, domain);
3644 if (label[0]) label = dgettext(domain, label);
3648 sd->on_translate = EINA_TRUE;
3649 eo_do(obj, elm_obj_widget_part_text_set(part, label));
3650 sd->on_translate = EINA_FALSE;
3653 EOLIAN static const char*
3654 _elm_widget_translatable_part_text_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part)
3656 Elm_Translate_String_Data *ts;
3658 ts = _translate_string_data_get(sd->translate_strings, part);
3659 if (ts) return ts->string;
3664 _elm_widget_domain_part_text_translatable_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *part, const char *domain, Eina_Bool translatable)
3666 Elm_Translate_String_Data *ts;
3667 const char *text = NULL;
3669 ts = _part_text_translatable_set(&sd->translate_strings, part,
3670 translatable, EINA_TRUE);
3672 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
3673 else eina_stringshare_replace(&ts->domain, domain);
3675 eo_do(obj, text = elm_obj_widget_part_text_get(part));
3676 if (!text || !text[0]) return;
3678 if (!ts->string) ts->string = eina_stringshare_add(text);
3680 //Try to translate text since we don't know the text is already translated.
3682 text = dgettext(domain, text);
3684 sd->on_translate = EINA_TRUE;
3685 eo_do(obj, elm_obj_widget_part_text_set(part, text));
3686 sd->on_translate = EINA_FALSE;
3690 elm_widget_translate(Evas_Object *obj)
3692 ELM_WIDGET_CHECK(obj);
3693 eo_do(obj, elm_obj_widget_translate());
3697 _part_text_translate(Eina_Inlist *translate_strings,
3701 Elm_Translate_String_Data *ts;
3702 ts = _translate_string_data_get(translate_strings, part);
3703 if (!ts) return text;
3705 if (!ts->string) ts->string = eina_stringshare_add(text);
3706 else eina_stringshare_replace(&ts->string, text);
3708 if (text && text[0])
3709 text = dgettext(ts->domain, text);
3714 EOLIAN static const char*
3715 _elm_widget_part_text_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *part, const char *text)
3719 if (!sd->translate_strings || sd->on_translate) return text;
3720 return _part_text_translate(sd->translate_strings, part, text);
3723 EOLIAN static Eina_Bool
3724 _elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3728 API_ENTRY return EINA_FALSE;
3730 EINA_LIST_FOREACH(sd->subobjs, l, child)
3732 if (elm_widget_is(child))
3733 elm_widget_translate(child);
3736 if (sd->hover_obj) elm_widget_translate(sd->hover_obj);
3739 Elm_Translate_String_Data *ts;
3740 EINA_INLIST_FOREACH(sd->translate_strings, ts)
3742 if (!ts->string) continue;
3743 const char *s = dgettext(ts->domain, ts->string);
3744 sd->on_translate = EINA_TRUE;
3745 eo_do(obj, elm_obj_widget_part_text_set(ts->id, s));
3746 sd->on_translate = EINA_FALSE;
3749 eo_do(obj, eo_event_callback_call(ELM_WIDGET_EVENT_LANGUAGE_CHANGED, NULL));
3756 * Resets the focus_move_policy mode from the system one
3757 * for widgets that are in automatic mode.
3759 * @param obj The widget.
3763 _elm_widget_focus_move_policy_reload(Evas_Object *obj)
3766 Elm_Focus_Move_Policy focus_move_policy = elm_config_focus_move_policy_get();
3768 if (elm_widget_focus_move_policy_automatic_get(obj) &&
3769 (sd->focus_move_policy != focus_move_policy))
3771 sd->focus_move_policy = focus_move_policy;
3776 _elm_widget_focus_reconfigure(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
3782 EINA_LIST_FOREACH(sd->subobjs, l, child)
3784 if (elm_widget_is(child))
3785 elm_widget_focus_reconfigure(child);
3788 if (sd->hover_obj) elm_widget_focus_reconfigure(sd->hover_obj);
3790 _elm_widget_focus_move_policy_reload(obj);
3793 //TIZEN_ONLY(20160726): add API elm_object_part_access_object_get
3794 EOLIAN static Evas_Object*
3795 _elm_widget_part_access_object_get(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part EINA_UNUSED)
3797 WRN("The %s widget does not implement the \"part_access_object_get\" functions.",
3798 eo_class_name_get(eo_class_get(obj)));
3804 elm_widget_content_part_set(Evas_Object *obj,
3806 Evas_Object *content)
3808 ELM_WIDGET_CHECK(obj);
3809 eo_do(obj, elm_obj_container_content_set(part, content));
3813 * Returns the widget's focus_move_policy mode setting.
3815 * @param obj The widget.
3816 * @return focus_move_policy mode setting of the object.
3819 EOLIAN static Eina_Bool
3820 _elm_widget_focus_move_policy_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3822 return sd->focus_move_policy_auto_mode;
3828 * Sets the widget's focus_move_policy mode setting.
3829 * When widget in automatic mode, it follows the system focus_move_policy mode set by
3830 * elm_config_focus_move_policy_set().
3831 * @param obj The widget.
3832 * @param automatic EINA_TRUE for auto focus_move_policy mode. EINA_FALSE for manual.
3835 _elm_widget_focus_move_policy_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic)
3837 if (sd->focus_move_policy_auto_mode != automatic)
3839 sd->focus_move_policy_auto_mode = automatic;
3843 elm_widget_focus_move_policy_set(obj, elm_config_focus_move_policy_get());
3849 elm_widget_content_part_get(const Evas_Object *obj,
3852 ELM_WIDGET_CHECK(obj) NULL;
3853 Evas_Object *ret = NULL;
3854 eo_do((Eo *) obj, ret = elm_obj_container_content_get(part));
3859 elm_widget_content_part_unset(Evas_Object *obj,
3862 ELM_WIDGET_CHECK(obj) NULL;
3863 Evas_Object *ret = NULL;
3864 eo_do(obj, ret = elm_obj_container_content_unset(part));
3869 _elm_widget_access_info_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, const char *txt)
3871 eina_stringshare_del(sd->access_info);
3872 if (!txt) sd->access_info = NULL;
3873 else sd->access_info = eina_stringshare_add(txt);
3876 EOLIAN static const char*
3877 _elm_widget_access_info_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3879 return sd->access_info;
3882 EOLIAN static Elm_Theme*
3883 _elm_widget_theme_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3887 if (sd->parent_obj && elm_widget_is(sd->parent_obj))
3888 return elm_widget_theme_get(sd->parent_obj);
3894 EOLIAN static Elm_Theme_Apply
3895 _elm_widget_style_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *style)
3897 if (eina_stringshare_replace(&sd->style, style))
3898 return elm_widget_theme(obj);
3900 return ELM_THEME_APPLY_SUCCESS;
3903 EOLIAN static const char*
3904 _elm_widget_style_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3908 if (sd->style) ret = sd->style;
3914 _elm_widget_tooltip_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3916 sd->tooltips = eina_list_append(sd->tooltips, tt);
3920 _elm_widget_tooltip_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Tooltip *tt)
3922 sd->tooltips = eina_list_remove(sd->tooltips, tt);
3926 _elm_widget_cursor_add(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3928 sd->cursors = eina_list_append(sd->cursors, cur);
3932 _elm_widget_cursor_del(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Cursor *cur)
3934 sd->cursors = eina_list_remove(sd->cursors, cur);
3938 _elm_widget_drag_lock_x_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
3940 if (sd->drag_x_locked == lock) return;
3941 sd->drag_x_locked = lock;
3942 if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
3943 else _propagate_x_drag_lock(obj, -1);
3947 _elm_widget_drag_lock_y_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool lock)
3949 if (sd->drag_y_locked == lock) return;
3950 sd->drag_y_locked = lock;
3951 if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
3952 else _propagate_y_drag_lock(obj, -1);
3955 EOLIAN static Eina_Bool
3956 _elm_widget_drag_lock_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3958 return sd->drag_x_locked;
3961 EOLIAN static Eina_Bool
3962 _elm_widget_drag_lock_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3964 return sd->drag_y_locked;
3968 _elm_widget_drag_child_locked_x_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3970 return sd->child_drag_x_locked;
3974 _elm_widget_drag_child_locked_y_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
3976 return sd->child_drag_y_locked;
3980 _elm_widget_item_loop_enabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED, Eina_Bool enable EINA_UNUSED)
3985 EOLIAN static Eina_Bool
3986 _elm_widget_item_loop_enabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EINA_UNUSED)
3991 EOLIAN static Elm_Theme_Apply
3992 _elm_widget_theme_object_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle)
3994 Elm_Theme_Apply ret = _elm_theme_object_set(obj, edj, wname, welement, wstyle);
3997 return ELM_THEME_APPLY_FAILED;
4000 if (sd->orient_mode != -1)
4003 snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
4004 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
4011 _elm_widget_eo_base_dbg_info_get(Eo *eo_obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eo_Dbg_Info *root)
4013 eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
4014 Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
4016 EO_DBG_INFO_APPEND(group, "Wid-Type", EINA_VALUE_TYPE_STRING, elm_widget_type_get(eo_obj));
4017 EO_DBG_INFO_APPEND(group, "Style", EINA_VALUE_TYPE_STRING, elm_widget_style_get(eo_obj));
4018 EO_DBG_INFO_APPEND(group, "Layer", EINA_VALUE_TYPE_INT,
4019 (int) evas_object_layer_get(eo_obj));
4020 EO_DBG_INFO_APPEND(group, "Scale", EINA_VALUE_TYPE_DOUBLE,
4021 evas_object_scale_get(eo_obj));
4022 EO_DBG_INFO_APPEND(group, "Has focus", EINA_VALUE_TYPE_CHAR,
4023 elm_object_focus_get(eo_obj));
4024 EO_DBG_INFO_APPEND(group, "Disabled", EINA_VALUE_TYPE_CHAR,
4025 elm_widget_disabled_get(eo_obj));
4026 EO_DBG_INFO_APPEND(group, "Mirrored", EINA_VALUE_TYPE_CHAR,
4027 elm_widget_mirrored_get(eo_obj));
4028 EO_DBG_INFO_APPEND(group, "Automatic mirroring", EINA_VALUE_TYPE_CHAR,
4029 elm_widget_mirrored_automatic_get(eo_obj));
4033 elm_widget_is_check(const Evas_Object *obj)
4035 static int abort_on_warn = -1;
4036 if (elm_widget_is(obj))
4039 ERR("Passing Object: %p.", obj);
4040 if (abort_on_warn == -1)
4042 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
4043 else abort_on_warn = 0;
4045 if (abort_on_warn == 1) abort();
4050 elm_widget_type_get(const Evas_Object *obj)
4052 API_ENTRY return NULL;
4054 return eo_class_name_get(eo_class_get(obj));
4058 elm_widget_type_check(const Evas_Object *obj,
4062 const char *provided, *expected = "(unknown)";
4063 static int abort_on_warn = -1;
4065 provided = elm_widget_type_get(obj);
4066 /* TODO: eventually migrate to check_ptr version */
4067 if (evas_object_smart_type_check(obj, type)) return EINA_TRUE;
4068 if (type) expected = type;
4069 if ((!provided) || (!provided[0]))
4071 provided = evas_object_type_get(obj);
4072 if ((!provided) || (!provided[0]))
4073 provided = "(unknown)";
4075 ERR("Passing Object: %p in function: %s, of type: '%s' when expecting"
4076 " type: '%s'", obj, func, provided, expected);
4077 if (abort_on_warn == -1)
4079 if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
4080 else abort_on_warn = 0;
4082 if (abort_on_warn == 1) abort();
4086 static Evas_Object *
4087 _widget_name_find(const Evas_Object *obj,
4094 INTERNAL_ENTRY NULL;
4096 if (!_elm_widget_is(obj)) return NULL;
4097 EINA_LIST_FOREACH(sd->subobjs, l, child)
4099 s = evas_object_name_get(child);
4100 if ((s) && (!strcmp(s, name))) return child;
4101 if ((recurse != 0) &&
4102 ((child = _widget_name_find(child, name, recurse - 1))))
4107 s = evas_object_name_get(sd->hover_obj);
4108 if ((s) && (!strcmp(s, name))) return sd->hover_obj;
4109 if ((recurse != 0) &&
4110 ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
4116 EOLIAN static Evas_Object*
4117 _elm_widget_name_find(const Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *name, int recurse)
4119 if (!name) return NULL;
4120 return _widget_name_find(obj, name, recurse);
4126 * Split string in words
4128 * @param str Source string
4129 * @return List of const words
4131 * @see elm_widget_stringlist_free()
4135 elm_widget_stringlist_get(const char *str)
4137 Eina_List *list = NULL;
4139 if (!str) return NULL;
4140 for (b = s = str; 1; s++)
4142 if ((*s == ' ') || (!*s))
4144 char *t = malloc(s - b + 1);
4147 strncpy(t, b, s - b);
4149 list = eina_list_append(list, eina_stringshare_add(t));
4160 elm_widget_stringlist_free(Eina_List *list)
4163 EINA_LIST_FREE(list, s)
4164 eina_stringshare_del(s);
4168 _elm_widget_focus_hide_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4170 if (!_elm_widget_is(obj))
4172 _if_focused_revert(obj, EINA_TRUE);
4176 elm_widget_focus_mouse_up_handle(Evas_Object *obj)
4178 Evas_Object *o = obj;
4181 if (_elm_widget_is(o)) break;
4182 o = evas_object_smart_parent_get(o);
4186 eo_do(o, elm_obj_widget_focus_mouse_up_handle());
4190 _elm_widget_focus_mouse_up_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4193 if (!_is_focusable(obj)) return;
4195 elm_widget_focus_steal(obj, NULL);
4199 _elm_widget_focus_tree_unfocusable_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4201 if (!elm_widget_parent_get(obj))
4202 elm_widget_focused_object_clear(obj);
4204 _if_focused_revert(obj, EINA_TRUE);
4208 _elm_widget_focus_disabled_handle(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4210 elm_widget_focus_tree_unfocusable_handle(obj);
4213 EOLIAN static unsigned int
4214 _elm_widget_focus_order_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4216 return sd->focus_order;
4219 EOLIAN static Evas_Object*
4220 _elm_widget_newest_focus_order_get(const Eo *obj, Elm_Widget_Smart_Data *sd, unsigned int *newest_focus_order, Eina_Bool can_focus_only)
4223 Evas_Object *child, *cur, *best;
4225 if (!evas_object_visible_get(obj)
4226 || (elm_widget_disabled_get(obj))
4227 || (elm_widget_tree_unfocusable_get(obj)))
4231 if (*newest_focus_order < sd->focus_order)
4233 if (!can_focus_only || elm_widget_can_focus_get(obj))
4235 *newest_focus_order = sd->focus_order;
4236 best = (Evas_Object *)obj;
4239 EINA_LIST_FOREACH(sd->subobjs, l, child)
4241 if (!_elm_widget_is(child)) continue;
4243 cur = elm_widget_newest_focus_order_get
4244 (child, newest_focus_order, can_focus_only);
4254 * Get the focus highlight geometry of an widget.
4256 * @param obj Widget object for the focus highlight
4257 * @param x Focus highlight x coordinate
4258 * @param y Focus highlight y coordinate
4259 * @param w Focus highlight object width
4260 * @param h Focus highlight object height
4261 * @param is_next @c EINA_TRUE if this request is for the new focused object,
4262 * @c EINA_FALSE if this request is for the previously focused object. This
4263 * information becomes important when the focus highlight is changed inside one
4271 * Get the 'focus_part' geometry if there is any
4273 * This queries if there is a 'focus_part' request from the edc style. If edc
4274 * style offers 'focus_part' edje data item, this function requests for the
4275 * geometry of a specific part which is described in 'focus_part' edje data.
4277 * @param obj Widget object for the focus highlight
4278 * @param x Focus highlight x coordinate
4279 * @param y Focus highlight y coordinate
4280 * @param w Focus highlight object width
4281 * @param h Focus highlight object height
4283 * x, y, w, h already contain the object's geometry. If there is a 'focus_part'
4284 * support, these values will be updated accordingly or the values will be
4285 * remained as they were.
4290 elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj,
4296 Evas_Coord tx = 0, ty = 0, tw = 0, th = 0;
4297 const char *target_hl_part = NULL;
4298 const Evas_Object *edje_obj = NULL;
4300 if (obj && eo_isa(obj, EDJE_OBJECT_CLASS))
4303 if (!(target_hl_part = edje_object_data_get(edje_obj, "focus_part")))
4306 else if (obj && eo_isa(obj, ELM_LAYOUT_CLASS))
4308 edje_obj = elm_layout_edje_get(obj);
4309 if (!(target_hl_part = elm_layout_data_get(obj, "focus_part")))
4315 edje_object_part_geometry_get(edje_obj, target_hl_part,
4316 &tx, &ty, &tw, &th);
4319 if (tw != *w) *w = tw;
4320 if (th != *h) *h = th;
4324 _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)
4326 Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0;
4327 Evas_Object *scroller = (Evas_Object *)obj;
4329 evas_object_geometry_get(obj, x, y, w, h);
4330 elm_widget_focus_highlight_focus_part_geometry_get(sd->resize_obj, x, y, w, h);
4332 if (_elm_config->focus_autoscroll_mode != ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN)
4337 if (_elm_scrollable_is(scroller))
4340 elm_interface_scrollable_content_viewport_geometry_get(&ox, &oy, &ow, &oh));
4344 else if ((oy + oh) < (*y + *h))
4345 *y = (oy + oh - *h);
4348 else if ((ox + ow) < (*x + *w))
4349 *x = (ox + ow - *w);
4353 scroller = elm_widget_parent_get(scroller);
4357 EOLIAN static Elm_Object_Item*
4358 _elm_widget_focused_item_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
4364 _elm_widget_focus_region_show_mode_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, Elm_Focus_Region_Show_Mode mode)
4366 _pd->focus_region_show_mode = mode;
4369 EOLIAN static Elm_Focus_Region_Show_Mode
4370 _elm_widget_focus_region_show_mode_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
4372 return _pd->focus_region_show_mode;
4376 elm_widget_activate(Evas_Object *obj, Elm_Activate act)
4378 Evas_Object *parent;
4381 ELM_WIDGET_CHECK(obj);
4385 eo_do(obj, ret = elm_obj_widget_activate(act));
4389 parent = elm_widget_parent_get(obj);
4391 elm_widget_activate(parent, act);
4399 * Sets the widget and child widget's Evas_Display_Mode.
4401 * @param obj The widget.
4402 * @param dispmode Evas_Display_Mode to set widget's mode.
4404 * Widgets are resized by several reasons.
4405 * Evas_Display_Mode can help for widgets to get one more reason of resize.
4406 * For example, elm conform widget resizes it's contents when keypad state changed.
4407 * After keypad showing, conform widget can change child's Evas_Display_Mode.
4411 _elm_widget_display_mode_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Display_Mode dispmode)
4413 Evas_Display_Mode prev_dispmode;
4417 prev_dispmode = evas_object_size_hint_display_mode_get(obj);
4419 if ((prev_dispmode == dispmode) ||
4420 (prev_dispmode == EVAS_DISPLAY_MODE_DONT_CHANGE)) return;
4422 evas_object_size_hint_display_mode_set(obj, dispmode);
4424 EINA_LIST_FOREACH (sd->subobjs, l, child)
4426 if (elm_widget_is(child))
4427 elm_widget_display_mode_set(child, dispmode);
4432 _elm_widget_orientation_mode_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
4434 int orient_mode = -1;
4438 //Get current orient mode from it's parent otherwise, 0.
4439 sd->orient_mode = 0;
4440 ELM_WIDGET_DATA_GET(sd->parent_obj, sd_parent);
4441 if (!sd_parent) orient_mode = 0;
4442 else orient_mode = sd_parent->orient_mode;
4444 eo_do(obj, elm_obj_widget_orientation_set(orient_mode));
4447 EOLIAN static Eina_Bool
4448 _elm_widget_orientation_mode_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4450 if (sd->orient_mode == -1) return EINA_TRUE;
4451 else return EINA_FALSE;
4455 _elm_widget_orientation_set(Eo *obj, Elm_Widget_Smart_Data *sd, int orient_mode)
4460 sd->orient_mode = orient_mode;
4462 EINA_LIST_FOREACH (sd->subobjs, l, child)
4464 if (elm_widget_is(child))
4465 eo_do(child, elm_obj_widget_orientation_set(orient_mode));
4468 if (orient_mode != -1)
4471 snprintf(buf, sizeof(buf), "elm,state,orient,%d", orient_mode);
4472 eo_do(obj, elm_obj_widget_signal_emit(buf, "elm"));
4479 * Returns the widget's focus move policy.
4481 * @param obj The widget.
4482 * @return focus move policy of the object.
4485 EOLIAN static Elm_Focus_Move_Policy
4486 _elm_widget_focus_move_policy_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
4488 return sd->focus_move_policy;
4494 * Sets the widget's focus move policy.
4496 * @param obj The widget.
4497 * @param policy Elm_Focus_Move_Policy to set object's focus move policy.
4501 _elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Elm_Focus_Move_Policy policy)
4503 if (sd->focus_move_policy == policy) return;
4504 sd->focus_move_policy = policy;
4507 _track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
4510 _track_obj_update(Evas_Object *track, Evas_Object *obj)
4513 Evas_Coord x, y, w, h;
4514 evas_object_geometry_get(obj, &x, &y, &w, &h);
4515 evas_object_move(track, x, y);
4516 evas_object_resize(track, w, h);
4519 if (evas_object_visible_get(obj)) evas_object_show(track);
4520 else evas_object_hide(track);
4524 _track_obj_view_update(void *data, Eo *obj,
4525 const Eo_Event_Description *desc EINA_UNUSED,
4526 void *event_info EINA_UNUSED)
4528 Elm_Widget_Item_Data *item = data;
4529 _track_obj_update(item->track_obj, obj);
4530 return EO_CALLBACK_CONTINUE;
4534 _track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
4535 const Eo_Event_Description *desc EINA_UNUSED,
4536 void *event_info EINA_UNUSED);
4538 EO_CALLBACKS_ARRAY_DEFINE(tracker_callbacks,
4539 { EVAS_OBJECT_EVENT_RESIZE, _track_obj_view_update },
4540 { EVAS_OBJECT_EVENT_MOVE, _track_obj_view_update },
4541 { EVAS_OBJECT_EVENT_SHOW, _track_obj_view_update },
4542 { EVAS_OBJECT_EVENT_HIDE, _track_obj_view_update },
4543 { EVAS_OBJECT_EVENT_DEL, _track_obj_view_del });
4546 _track_obj_view_del(void *data, Eo *obj EINA_UNUSED,
4547 const Eo_Event_Description *desc EINA_UNUSED,
4548 void *event_info EINA_UNUSED)
4550 Elm_Widget_Item_Data *item = data;
4552 while (evas_object_ref_get(item->track_obj) > 0)
4553 evas_object_unref(item->track_obj);
4555 evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
4557 evas_object_del(item->track_obj);
4558 item->track_obj = NULL;
4560 return EO_CALLBACK_CONTINUE;
4564 _track_obj_del(void *data, Evas *e EINA_UNUSED,
4565 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
4567 Elm_Widget_Item_Data *item = data;
4568 item->track_obj = NULL;
4570 if (!item->view) return;
4572 eo_do(item->view, eo_event_callback_array_del(tracker_callbacks(), item));
4576 _elm_widget_item_signal_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission,
4579 Elm_Widget_Item_Signal_Data *wisd = data;
4580 wisd->func(wisd->data, wisd->item, emission, source);
4584 _elm_widget_item_signal_callback_list_get(Elm_Widget_Item_Data *item, Eina_List *position)
4586 Elm_Widget_Item_Signal_Data *wisd = eina_list_data_get(position);
4589 item->signals = eina_list_remove_list(item->signals, position);
4592 if (_elm_widget_is(item->view))
4593 elm_object_signal_callback_del(item->view,
4594 wisd->emission, wisd->source,
4595 _elm_widget_item_signal_cb);
4596 else if (eo_isa(item->view, EDJE_OBJECT_CLASS))
4597 edje_object_signal_callback_del_full(item->view,
4598 wisd->emission, wisd->source,
4599 _elm_widget_item_signal_cb, wisd);
4601 eina_stringshare_del(wisd->emission);
4602 eina_stringshare_del(wisd->source);
4608 #define ERR_NOT_SUPPORTED(item, method) ERR("%s does not support %s API.", elm_widget_type_get(item->widget), method);
4611 _eo_del_cb(void *data EINA_UNUSED, Eo *eo_item, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
4613 Elm_Widget_Item_Data *item = eo_data_scope_get(eo_item, ELM_WIDGET_ITEM_CLASS);
4614 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_TRUE);
4616 item->del_func((void *) WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
4623 * Allocate a new Elm_Widget_Item-derived structure.
4625 * The goal of this structure is to provide common ground for actions
4626 * that a widget item have, such as the owner widget, callback to
4627 * notify deletion, data pointer and maybe more.
4629 * @param widget the owner widget that holds this item, must be an elm_widget!
4630 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
4631 * be used to allocate memory.
4633 * @return allocated memory that is already zeroed out, or NULL on errors.
4635 * @see elm_widget_item_new() convenience macro.
4636 * @see elm_widget_item_del() to release memory.
4640 _elm_widget_item_eo_base_constructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4642 Evas_Object *widget;
4643 eo_do (eo_item, widget = eo_parent_get());
4645 if (!_elm_widget_is(widget))
4651 eo_item = eo_do_super_ret(eo_item, ELM_WIDGET_ITEM_CLASS, eo_item, eo_constructor());
4653 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
4655 item->widget = widget;
4656 item->eo_obj = eo_item;
4657 //TIZEN_ONLY(20170717) : expose highlight information on atspi
4658 item->can_highlight = EINA_TRUE;
4661 eo_do(eo_item, eo_event_callback_add(EO_BASE_EVENT_DEL, _eo_del_cb, NULL));
4667 _elm_widget_item_eo_base_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4669 Elm_Translate_String_Data *ts;
4671 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4673 evas_object_del(item->view);
4675 eina_stringshare_del(item->access_info);
4676 eina_stringshare_del(item->accessible_name);
4678 while (item->signals)
4679 _elm_widget_item_signal_callback_list_get(item, item->signals);
4681 while (item->translate_strings)
4683 ts = EINA_INLIST_CONTAINER_GET(item->translate_strings,
4684 Elm_Translate_String_Data);
4685 eina_stringshare_del(ts->id);
4686 eina_stringshare_del(ts->domain);
4687 eina_stringshare_del(ts->string);
4688 item->translate_strings = eina_inlist_remove(item->translate_strings,
4689 item->translate_strings);
4692 eina_hash_free(item->labels);
4695 elm_interface_atspi_accessible_description_set(NULL),
4696 elm_interface_atspi_accessible_name_set(NULL),
4697 //TIZEN_ONLY(20190922): add name callback, description callback.
4698 elm_interface_atspi_accessible_description_cb_set(NULL, NULL),
4699 elm_interface_atspi_accessible_name_cb_set(NULL, NULL),
4701 elm_interface_atspi_accessible_translation_domain_set(NULL),
4702 elm_interface_atspi_accessible_relationships_clear(),
4703 // TIZEN_ONLY(20160930) : endless recursion fix
4704 elm_interface_atspi_accessible_attributes_clear()
4709 eina_stringshare_del(item->name);
4711 if (item->atspi_custom_relations)
4712 elm_atspi_relation_set_free(&item->atspi_custom_relations);
4714 //TIZEN_ONLY(20150731) : add i18n support for name and description
4715 if (item->atspi_translation_domain)
4716 eina_stringshare_del(item->atspi_translation_domain);
4718 //Tizen Only(20160728) free attribute list
4719 if (item->attr_list)
4721 Elm_Atspi_Attribute *attr;
4722 EINA_LIST_FREE(item->attr_list, attr)
4724 eina_stringshare_del(attr->key);
4725 eina_stringshare_del(attr->value);
4731 //TIZEN_ONLY(20161013): clean up elm color class feature
4732 if (item->color_classes)
4733 ELM_SAFE_FREE(item->color_classes, eina_hash_free);
4736 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
4738 eo_do_super(eo_item, ELM_WIDGET_ITEM_CLASS, eo_destructor());
4744 * Releases widget item memory, calling back item_del_pre_hook() and
4745 * item_del_cb() if they exist.
4747 * @param item a valid #Elm_Widget_Item to be deleted.
4749 * If there is an Elm_Widget_Item::del_cb, then it will be called prior
4750 * to memory release. Note that elm_widget_item_pre_notify_del() calls
4751 * this function and then unset it, thus being useful for 2 step
4752 * cleanup whenever the del_cb may use any of the data that must be
4753 * deleted from item.
4755 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
4758 * Note that if item_del_pre_hook() returns @c EINA_TRUE, item free will be
4759 * deferred, or item will be freed here if it returns @c EINA_FALSE.
4761 * @see elm_widget_item_del() convenience macro.
4765 _elm_widget_item_del(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4767 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4768 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4769 item->on_deletion = EINA_TRUE;
4771 //Widget item delete callback
4773 eo_do(item->eo_obj, del_ok = elm_wdg_item_del_pre());
4775 eo_del(item->eo_obj);
4779 EOLIAN static Eina_Bool
4780 _elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
4788 * Notify object will be deleted without actually deleting it.
4790 * This function will callback Elm_Widget_Item::del_cb if it is set
4791 * and then unset it so it is not called twice (ie: from
4792 * elm_widget_item_del()).
4794 * @param item a valid #Elm_Widget_Item to be notified
4795 * @see elm_widget_item_pre_notify_del() convenience macro.
4799 _elm_widget_item_pre_notify_del(Eo *eo_item, Elm_Widget_Item_Data *item)
4801 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4802 if (!item->del_func) return;
4803 item->del_func((void *)WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
4804 item->del_func = NULL;
4810 * Set the function to notify when item is being deleted.
4812 * This function will complain if there was a callback set already,
4813 * however it will set the new one.
4815 * The callback will be called from elm_widget_item_pre_notify_del()
4816 * or elm_widget_item_del() will be called with:
4817 * - data: the Elm_Widget_Item::data value.
4818 * - obj: the Elm_Widget_Item::widget evas object.
4819 * - event_info: the item being deleted.
4821 * @param item a valid #Elm_Widget_Item to be notified
4822 * @see elm_widget_item_del_cb_set() convenience macro.
4826 _elm_widget_item_del_cb_set(Eo *eo_item EINA_UNUSED,
4827 Elm_Widget_Item_Data *item,
4830 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4831 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4833 if ((item->del_func) && (item->del_func != func))
4834 WRN("You're replacing a previously set del_cb %p of item %p with %p",
4835 item->del_func, item->eo_obj, func);
4837 item->del_func = func;
4843 * Get owner widget of this item.
4845 * @param item a valid #Elm_Widget_Item to get data from.
4846 * @return owner widget of this item.
4849 EOLIAN static Evas_Object *
4850 _elm_widget_item_widget_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4852 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
4853 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
4855 return item->widget;
4859 _elm_widget_onscreen_is(Evas_Object *widget)
4861 Evas_Object *parent = widget;
4862 Evas_Coord x, y, w, h, wx, wy, ww, wh;
4864 Evas *evas = evas_object_evas_get(widget);
4865 if (!evas) return EINA_FALSE;
4867 // check if on canvas
4868 evas_output_viewport_get(evas, &x, &y, &w, &h);
4869 evas_object_geometry_get(widget, &wx, &wy, &ww, &wh);
4870 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4871 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4874 // check if inside scrollable parent viewport
4876 parent = elm_widget_parent_get(parent);
4877 if (parent && !evas_object_visible_get(parent))
4879 if (parent && eo_isa(parent, ELM_INTERFACE_SCROLLABLE_MIXIN))
4881 evas_object_geometry_get(parent, &x, &y, &w, &h);
4882 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4883 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4886 } while (parent && (parent != elm_widget_top_get(widget)));
4892 _elm_widget_item_onscreen_is(Elm_Object_Item *item)
4894 Evas_Coord x, y, w, h, wx, wy, ww, wh;
4895 Elm_Widget_Item_Data *id = eo_data_scope_get(item, ELM_WIDGET_ITEM_CLASS);
4896 if (!id || !id->view) return EINA_FALSE;
4898 if (!evas_object_visible_get(id->view))
4901 if (!_elm_widget_onscreen_is(id->widget))
4904 evas_object_geometry_get(id->view, &x, &y, &w, &h);
4905 evas_object_geometry_get(id->widget, &wx, &wy, &ww, &wh);
4906 if (((wx < x) && (wx + ww < x)) || ((wx > x + w) && (wx + ww > x + w)) ||
4907 ((wy < y) && (wy + wh < y)) || ((wy > y+ h) && (wy + wh > y + h)))
4913 EOLIAN static Elm_Atspi_State_Set
4914 _elm_widget_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_item,
4915 Elm_Widget_Item_Data *item)
4917 Elm_Atspi_State_Set states = 0;
4919 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
4921 if (elm_object_item_focus_get(eo_item))
4922 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
4923 if (!elm_object_item_disabled_get(eo_item))
4925 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
4926 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
4927 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
4929 if (_elm_widget_item_onscreen_is(eo_item))
4930 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
4932 //TIZEN_ONLY(20170717) : expose highlight information on atspi
4933 if (item->can_highlight)
4934 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
4936 STATE_TYPE_UNSET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
4938 if (_elm_object_accessibility_currently_highlighted_get() == (void*)item->eo_obj)
4939 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTED);
4945 _elm_widget_item_elm_interface_atspi_accessible_parent_get(Eo *eo_item, Elm_Widget_Item_Data *item EINA_UNUSED)
4948 eo_do(eo_item, parent = eo_parent_get());
4953 elm_object_item_data_set(Elm_Object_Item *it, void *data)
4955 WIDGET_ITEM_DATA_SET(it, data);
4959 elm_object_item_data_get(const Elm_Object_Item *it)
4961 return (void *) WIDGET_ITEM_DATA_GET(it);
4965 _elm_widget_item_disabled_set(Eo *eo_item EINA_UNUSED,
4966 Elm_Widget_Item_Data *item,
4969 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4970 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4972 if (item->disabled == disabled) return;
4973 item->disabled = !!disabled;
4974 eo_do(item->eo_obj, elm_wdg_item_disable());
4977 EOLIAN static Eina_Bool
4978 _elm_widget_item_disabled_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4980 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
4981 return item->disabled;
4985 _elm_widget_item_style_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, const char *style EINA_UNUSED)
4987 ERR_NOT_SUPPORTED(item, "elm_object_style_set()");
4990 EOLIAN static const char *
4991 _elm_widget_item_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4993 ERR_NOT_SUPPORTED(item, "elm_object_style_get()");
4998 _elm_widget_item_disable(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
5003 _elm_widget_item_focus_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Eina_Bool focused EINA_UNUSED)
5005 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_set");
5008 EOLIAN static Eina_Bool
5009 _elm_widget_item_focus_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5011 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_get");
5016 _elm_widget_item_domain_translatable_part_text_set(Eo *eo_item EINA_UNUSED,
5017 Elm_Widget_Item_Data *item,
5022 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5023 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5024 Elm_Translate_String_Data *ts;
5028 _part_text_translatable_set(&item->translate_strings, part, EINA_FALSE,
5033 ts = _part_text_translatable_set(&item->translate_strings, part,
5034 EINA_TRUE, EINA_FALSE);
5036 if (!ts->string) ts->string = eina_stringshare_add(label);
5037 else eina_stringshare_replace(&ts->string, label);
5038 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5039 else eina_stringshare_replace(&ts->domain, domain);
5041 if (label[0]) label = dgettext(domain, label);
5044 item->on_translate = EINA_TRUE;
5045 eo_do(item->eo_obj, elm_wdg_item_part_text_set(part, label));
5046 item->on_translate = EINA_FALSE;
5049 EOLIAN static const char *
5050 _elm_widget_item_translatable_part_text_get(const Eo *eo_item EINA_UNUSED,
5051 Elm_Widget_Item_Data *item,
5054 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5055 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5057 Elm_Translate_String_Data *ts;
5058 ts = _translate_string_data_get(item->translate_strings, part);
5059 if (ts) return ts->string;
5064 _elm_widget_item_domain_part_text_translatable_set(Eo *eo_item EINA_UNUSED,
5065 Elm_Widget_Item_Data *item,
5068 Eina_Bool translatable)
5070 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5071 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5072 Elm_Translate_String_Data *ts;
5075 ts = _part_text_translatable_set(&item->translate_strings, part,
5076 translatable, EINA_TRUE);
5078 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5079 else eina_stringshare_replace(&ts->domain, domain);
5081 eo_do(item->eo_obj, text = elm_wdg_item_part_text_get(part));
5083 if (!text || !text[0]) return;
5085 if (!ts->string) ts->string = eina_stringshare_add(text);
5087 //Try to translate text since we don't know the text is already translated.
5089 text = dgettext(domain, text);
5091 item->on_translate = EINA_TRUE;
5092 eo_do (item->eo_obj, elm_wdg_item_part_text_set(part, text));
5093 item->on_translate = EINA_FALSE;
5097 _elm_widget_item_track_cancel(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5099 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5100 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5102 if (!item->track_obj) return;
5104 while (evas_object_ref_get(item->track_obj) > 0)
5105 evas_object_unref(item->track_obj);
5107 evas_object_del(item->track_obj);
5110 EOLIAN static Evas_Object *
5111 _elm_widget_item_track(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5113 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5114 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5116 if (item->track_obj)
5118 evas_object_ref(item->track_obj);
5119 return item->track_obj;
5124 WRN("view obj of the item(%p) is invalid. Please make sure the view obj is created!", item);
5128 Evas_Object *track =
5129 evas_object_rectangle_add(evas_object_evas_get(item->widget));
5130 evas_object_color_set(track, 0, 0, 0, 0);
5131 evas_object_pass_events_set(track, EINA_TRUE);
5132 _track_obj_update(track, item->view);
5133 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
5137 eo_event_callback_array_add(tracker_callbacks(), item));
5139 evas_object_ref(track);
5141 item->track_obj = track;
5147 _elm_widget_item_untrack(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5149 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5150 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5152 if (!item->track_obj) return;
5153 evas_object_unref(item->track_obj);
5155 if (evas_object_ref_get(item->track_obj) == 0)
5156 evas_object_del(item->track_obj);
5160 _elm_widget_item_track_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5162 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
5163 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, 0);
5165 if (!item->track_obj) return 0;
5166 return evas_object_ref_get(item->track_obj);
5169 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
5171 struct _Elm_Widget_Item_Tooltip
5173 Elm_Widget_Item_Data *item;
5174 Elm_Tooltip_Item_Content_Cb func;
5175 Evas_Smart_Cb del_cb;
5179 static Evas_Object *
5180 _elm_widget_item_tooltip_label_create(void *data,
5181 Evas_Object *obj EINA_UNUSED,
5182 Evas_Object *tooltip,
5183 void *item EINA_UNUSED)
5185 Evas_Object *label = elm_label_add(tooltip);
5188 elm_object_style_set(label, "tooltip");
5189 elm_object_text_set(label, data);
5193 static Evas_Object *
5194 _elm_widget_item_tooltip_trans_label_create(void *data,
5195 Evas_Object *obj EINA_UNUSED,
5196 Evas_Object *tooltip,
5197 void *item EINA_UNUSED)
5199 Evas_Object *label = elm_label_add(tooltip);
5202 elm_object_style_set(label, "tooltip");
5203 elm_object_translatable_text_set(label, data);
5208 _elm_widget_item_tooltip_label_del_cb(void *data,
5209 Evas_Object *obj EINA_UNUSED,
5210 void *event_info EINA_UNUSED)
5212 eina_stringshare_del(data);
5218 * Set the text to be shown in the widget item.
5220 * @param item Target item
5221 * @param text The text to set in the content
5223 * Setup the text as tooltip to object. The item can have only one tooltip,
5224 * so any previous tooltip data is removed.
5229 _elm_widget_item_tooltip_text_set(Eo *eo_item EINA_UNUSED,
5230 Elm_Widget_Item_Data *item EINA_UNUSED,
5233 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5234 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5235 EINA_SAFETY_ON_NULL_RETURN(text);
5237 text = eina_stringshare_add(text);
5238 eo_do(item->eo_obj, elm_wdg_item_tooltip_content_cb_set(
5239 _elm_widget_item_tooltip_label_create,
5241 _elm_widget_item_tooltip_label_del_cb));
5245 _elm_widget_item_tooltip_translatable_text_set(Eo *eo_item EINA_UNUSED,
5246 Elm_Widget_Item_Data *item EINA_UNUSED,
5249 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5250 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5251 EINA_SAFETY_ON_NULL_RETURN(text);
5253 text = eina_stringshare_add(text);
5254 eo_do(item->eo_obj, elm_wdg_item_tooltip_content_cb_set(
5255 _elm_widget_item_tooltip_trans_label_create,
5257 _elm_widget_item_tooltip_label_del_cb));
5260 static Evas_Object *
5261 _elm_widget_item_tooltip_create(void *data,
5263 Evas_Object *tooltip)
5265 Elm_Widget_Item_Tooltip *wit = data;
5266 return wit->func((void *)wit->data, obj, tooltip, wit->item->eo_obj);
5270 _elm_widget_item_tooltip_del_cb(void *data,
5272 void *event_info EINA_UNUSED)
5274 Elm_Widget_Item_Tooltip *wit = data;
5275 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item->eo_obj);
5282 * Set the content to be shown in the tooltip item
5284 * Setup the tooltip to item. The item can have only one tooltip,
5285 * so any previous tooltip data is removed. @p func(with @p data) will
5286 * be called every time that need show the tooltip and it should
5287 * return a valid Evas_Object. This object is then managed fully by
5288 * tooltip system and is deleted when the tooltip is gone.
5290 * @param item the widget item being attached a tooltip.
5291 * @param func the function used to create the tooltip contents.
5292 * @param data what to provide to @a func as callback data/context.
5293 * @param del_cb called when data is not needed anymore, either when
5294 * another callback replaces @func, the tooltip is unset with
5295 * elm_widget_item_tooltip_unset() or the owner @a item
5296 * dies. This callback receives as the first parameter the
5297 * given @a data, and @c event_info is the item.
5302 _elm_widget_item_tooltip_content_cb_set(Eo *eo_item EINA_UNUSED,
5303 Elm_Widget_Item_Data *item,
5304 Elm_Tooltip_Item_Content_Cb func,
5306 Evas_Smart_Cb del_cb)
5308 Elm_Widget_Item_Tooltip *wit;
5310 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
5311 //ELM_WIDGET_ITEM_RETURN_IF_GOTO(item, error_noitem);
5315 eo_do(item->eo_obj, elm_wdg_item_tooltip_unset());
5319 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
5320 if (!wit) goto error;
5324 wit->del_cb = del_cb;
5326 elm_object_sub_tooltip_content_cb_set
5327 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
5328 _elm_widget_item_tooltip_del_cb);
5333 if (del_cb) del_cb((void *)data, NULL, item);
5336 if (del_cb) del_cb((void *)data, item->widget, item);
5342 * Unset tooltip from item
5344 * @param item widget item to remove previously set tooltip.
5346 * Remove tooltip from item. The callback provided as del_cb to
5347 * elm_widget_item_tooltip_content_cb_set() will be called to notify
5348 * it is not used anymore.
5350 * @see elm_widget_item_tooltip_content_cb_set()
5355 _elm_widget_item_tooltip_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5357 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5358 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5360 elm_object_tooltip_unset(item->view);
5366 * Sets a different style for this item tooltip.
5368 * @note before you set a style you should define a tooltip with
5369 * elm_widget_item_tooltip_content_cb_set() or
5370 * elm_widget_item_tooltip_text_set()
5372 * @param item widget item with tooltip already set.
5373 * @param style the theme style to use (default, transparent, ...)
5378 _elm_widget_item_tooltip_style_set(Eo *eo_item EINA_UNUSED,
5379 Elm_Widget_Item_Data *item,
5382 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5383 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5385 elm_object_tooltip_style_set(item->view, style);
5388 EOLIAN static Eina_Bool
5389 _elm_widget_item_tooltip_window_mode_set(Eo *eo_item EINA_UNUSED,
5390 Elm_Widget_Item_Data *item,
5393 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5394 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5396 return elm_object_tooltip_window_mode_set(item->view, disable);
5399 EOLIAN static Eina_Bool
5400 _elm_widget_item_tooltip_window_mode_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5402 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5403 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5405 return elm_object_tooltip_window_mode_get(item->view);
5411 * Get the style for this item tooltip.
5413 * @param item widget item with tooltip already set.
5414 * @return style the theme style in use, defaults to "default". If the
5415 * object does not have a tooltip set, then NULL is returned.
5419 EOLIAN static const char *
5420 _elm_widget_item_tooltip_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5422 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5424 return elm_object_tooltip_style_get(item->view);
5428 _elm_widget_item_cursor_set(Eo *eo_item EINA_UNUSED,
5429 Elm_Widget_Item_Data *item,
5432 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5433 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5435 elm_object_sub_cursor_set(item->view, item->widget, cursor);
5438 EOLIAN static const char *
5439 _elm_widget_item_cursor_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5441 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5442 return elm_object_cursor_get(item->view);
5446 _elm_widget_item_cursor_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5448 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5449 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5451 elm_object_cursor_unset(item->view);
5457 * Sets a different style for this item cursor.
5459 * @note before you set a style you should define a cursor with
5460 * elm_widget_item_cursor_set()
5462 * @param item widget item with cursor already set.
5463 * @param style the theme style to use (default, transparent, ...)
5468 _elm_widget_item_cursor_style_set(Eo *eo_item EINA_UNUSED,
5469 Elm_Widget_Item_Data *item,
5472 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5473 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5475 elm_object_cursor_style_set(item->view, style);
5481 * Get the style for this item cursor.
5483 * @param item widget item with cursor already set.
5484 * @return style the theme style in use, defaults to "default". If the
5485 * object does not have a cursor set, then NULL is returned.
5489 EOLIAN static const char *
5490 _elm_widget_item_cursor_style_get(Eo *eo_item EINA_UNUSED,
5491 Elm_Widget_Item_Data *item)
5493 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5494 return elm_object_cursor_style_get(item->view);
5500 * Set if the cursor set should be searched on the theme or should use
5501 * the provided by the engine, only.
5503 * @note before you set if should look on theme you should define a cursor
5504 * with elm_object_cursor_set(). By default it will only look for cursors
5505 * provided by the engine.
5507 * @param item widget item with cursor already set.
5508 * @param engine_only boolean to define it cursors should be looked only
5509 * between the provided by the engine or searched on widget's theme as well.
5514 _elm_widget_item_cursor_engine_only_set(Eo *eo_item EINA_UNUSED,
5515 Elm_Widget_Item_Data *item,
5516 Eina_Bool engine_only)
5518 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5519 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5521 elm_object_cursor_theme_search_enabled_set(item->view, !engine_only);
5527 * Get the cursor engine only usage for this item cursor.
5529 * @param item widget item with cursor already set.
5530 * @return engine_only boolean to define it cursors should be looked only
5531 * between the provided by the engine or searched on widget's theme as well. If
5532 * the object does not have a cursor set, then EINA_FALSE is returned.
5536 EOLIAN static Eina_Bool
5537 _elm_widget_item_cursor_engine_only_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5539 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5540 return !elm_object_cursor_theme_search_enabled_get(item->view);
5544 _elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
5545 Elm_Widget_Item_Data *item,
5546 const char *part EINA_UNUSED,
5547 Evas_Object *content EINA_UNUSED)
5549 ERR_NOT_SUPPORTED(item, "elm_object_part_content_set()");
5552 EOLIAN static Evas_Object *
5553 _elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
5554 Elm_Widget_Item_Data *item,
5555 const char *part EINA_UNUSED)
5557 ERR_NOT_SUPPORTED(item, "elm_object_part_content_get()");
5561 EOLIAN static Evas_Object *
5562 _elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED,
5563 Elm_Widget_Item_Data *item,
5564 const char *part EINA_UNUSED)
5566 ERR_NOT_SUPPORTED(item, "elm_object_part_content_unset()");
5571 _elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
5572 Elm_Widget_Item_Data *item,
5573 const char *part EINA_UNUSED,
5574 const char *label EINA_UNUSED)
5576 ERR_NOT_SUPPORTED(item, "elm_object_part_text_set()");
5579 EOLIAN static const char *
5580 _elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
5581 Elm_Widget_Item_Data *item,
5582 const char *part EINA_UNUSED)
5584 ERR_NOT_SUPPORTED(item, "elm_object_part_text_get()");
5589 _elm_widget_item_part_text_custom_free(void *data)
5591 Elm_Label_Data *label;
5593 eina_stringshare_del(label->part);
5594 eina_stringshare_del(label->text);
5599 _elm_widget_item_part_text_custom_set(Eo *eo_item EINA_UNUSED,
5600 Elm_Widget_Item_Data *item,
5604 Elm_Label_Data *label;
5605 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5606 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5610 eina_hash_stringshared_new(_elm_widget_item_part_text_custom_free);
5611 label = eina_hash_find(item->labels, part);
5614 label = malloc(sizeof(Elm_Label_Data));
5617 ERR("Failed to allocate memory");
5620 label->part = eina_stringshare_add(part);
5621 label->text = eina_stringshare_add(text);
5622 eina_hash_add(item->labels, part, label);
5625 eina_stringshare_replace(&label->text, text);
5628 EOLIAN static const char *
5629 _elm_widget_item_part_text_custom_get(Eo *eo_item EINA_UNUSED,
5630 Elm_Widget_Item_Data *item,
5633 Elm_Label_Data *label;
5634 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5635 label = eina_hash_find(item->labels, part);
5636 return label ? label->text : NULL;
5640 _elm_widget_item_part_text_custom_foreach(const Eina_Hash *labels EINA_UNUSED,
5641 const void *key EINA_UNUSED,
5645 Elm_Label_Data *label;
5646 Elm_Widget_Item_Data *item;
5650 eo_do(item->eo_obj, elm_wdg_item_part_text_set(label->part, label->text));
5656 _elm_widget_item_part_text_custom_update(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5658 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5659 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5661 eina_hash_foreach(item->labels,
5662 _elm_widget_item_part_text_custom_foreach, item);
5666 _elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
5667 Elm_Widget_Item_Data *item EINA_UNUSED,
5668 const char *emission EINA_UNUSED,
5669 const char *source EINA_UNUSED)
5675 _elm_widget_item_signal_callback_add(Eo *eo_item,
5676 Elm_Widget_Item_Data *item,
5677 const char *emission,
5679 Elm_Object_Item_Signal_Cb func,
5682 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5683 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5684 EINA_SAFETY_ON_NULL_RETURN(func);
5686 Elm_Widget_Item_Signal_Data *wisd;
5688 wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
5691 wisd->item = eo_item;
5692 wisd->func = (Elm_Widget_Item_Signal_Cb)func;
5694 wisd->emission = eina_stringshare_add(emission);
5695 wisd->source = eina_stringshare_add(source);
5697 if (_elm_widget_is(item->view))
5698 elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5699 else if (eo_isa(item->view, EDJE_OBJECT_CLASS))
5700 edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5703 WRN("The %s widget item doesn't support signal callback add!",
5704 eo_class_name_get(eo_class_get(item->widget)));
5709 item->signals = eina_list_append(item->signals, wisd);
5712 EOLIAN static void *
5713 _elm_widget_item_signal_callback_del(Eo *eo_item EINA_UNUSED,
5714 Elm_Widget_Item_Data *item,
5715 const char *emission,
5717 Elm_Object_Item_Signal_Cb func)
5719 Elm_Widget_Item_Signal_Data *wisd;
5722 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5723 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5724 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
5726 EINA_LIST_FOREACH(item->signals, l, wisd)
5728 if ((wisd->func == (Elm_Widget_Item_Signal_Cb)func) &&
5729 !strcmp(wisd->emission, emission) &&
5730 !strcmp(wisd->source, source))
5731 return _elm_widget_item_signal_callback_list_get(item, l);
5738 _elm_widget_item_access_info_set(Eo *eo_item EINA_UNUSED,
5739 Elm_Widget_Item_Data *item,
5742 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5743 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5745 eina_stringshare_del(item->access_info);
5746 if (!txt) item->access_info = NULL;
5747 else item->access_info = eina_stringshare_add(txt);
5751 _elm_widget_item_translate(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5753 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5754 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5757 Elm_Translate_String_Data *ts;
5758 EINA_INLIST_FOREACH(item->translate_strings, ts)
5760 if (!ts->string) continue;
5761 const char *s = dgettext(ts->domain, ts->string);
5762 item->on_translate = EINA_TRUE;
5763 eo_do(item->eo_obj, elm_wdg_item_part_text_set(ts->id, s));
5764 item->on_translate = EINA_FALSE;
5770 _elm_widget_item_access_order_set(Eo *eo_item EINA_UNUSED,
5771 Elm_Widget_Item_Data *item,
5774 _elm_access_widget_item_access_order_set(item, objs);
5777 EOLIAN static const Eina_List *
5778 _elm_widget_item_access_order_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5780 return _elm_access_widget_item_access_order_get(item);
5784 _elm_widget_item_access_order_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5786 _elm_access_widget_item_access_order_unset(item);
5789 EOLIAN static Evas_Object*
5790 _elm_widget_item_access_register(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5792 _elm_access_widget_item_register(item);
5793 return item->access_obj;
5797 _elm_widget_item_access_unregister(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5799 _elm_access_widget_item_unregister(item);
5802 EOLIAN static Evas_Object*
5803 _elm_widget_item_access_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5805 return item->access_obj;
5808 EOLIAN static Evas_Object *
5809 _elm_widget_item_focus_next_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
5811 Evas_Object *ret = NULL;
5813 if (dir == ELM_FOCUS_PREVIOUS)
5814 ret = item->focus_previous;
5815 else if (dir == ELM_FOCUS_NEXT)
5816 ret = item->focus_next;
5817 else if (dir == ELM_FOCUS_UP)
5818 ret = item->focus_up;
5819 else if (dir == ELM_FOCUS_DOWN)
5820 ret = item->focus_down;
5821 else if (dir == ELM_FOCUS_RIGHT)
5822 ret = item->focus_right;
5823 else if (dir == ELM_FOCUS_LEFT)
5824 ret = item->focus_left;
5830 _elm_widget_item_focus_next_object_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Evas_Object *next, Elm_Focus_Direction dir)
5832 if (dir == ELM_FOCUS_PREVIOUS)
5833 item->focus_previous = next;
5834 else if (dir == ELM_FOCUS_NEXT)
5835 item->focus_next = next;
5836 else if (dir == ELM_FOCUS_UP)
5837 item->focus_up = next;
5838 else if (dir == ELM_FOCUS_DOWN)
5839 item->focus_down = next;
5840 else if (dir == ELM_FOCUS_RIGHT)
5841 item->focus_right = next;
5842 else if (dir == ELM_FOCUS_LEFT)
5843 item->focus_left = next;
5846 EOLIAN static Elm_Object_Item*
5847 _elm_widget_item_focus_next_item_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
5849 Elm_Object_Item *ret = NULL;
5851 if (dir == ELM_FOCUS_PREVIOUS)
5852 ret = item->item_focus_previous;
5853 else if (dir == ELM_FOCUS_NEXT)
5854 ret = item->item_focus_next;
5855 else if (dir == ELM_FOCUS_UP)
5856 ret = item->item_focus_up;
5857 else if (dir == ELM_FOCUS_DOWN)
5858 ret = item->item_focus_down;
5859 else if (dir == ELM_FOCUS_RIGHT)
5860 ret = item->item_focus_right;
5861 else if (dir == ELM_FOCUS_LEFT)
5862 ret = item->item_focus_left;
5868 _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)
5870 if (dir == ELM_FOCUS_PREVIOUS)
5871 item->item_focus_previous = next_item;
5872 else if (dir == ELM_FOCUS_NEXT)
5873 item->item_focus_next = next_item;
5874 else if (dir == ELM_FOCUS_UP)
5875 item->item_focus_up = next_item;
5876 else if (dir == ELM_FOCUS_DOWN)
5877 item->item_focus_down = next_item;
5878 else if (dir == ELM_FOCUS_RIGHT)
5879 item->item_focus_right = next_item;
5880 else if (dir == ELM_FOCUS_LEFT)
5881 item->item_focus_left = next_item;
5884 /* happy debug functions */
5887 _sub_obj_tree_dump(const Evas_Object *obj,
5892 for (i = 0; i < lvl * 3; i++)
5895 if (_elm_widget_is(obj))
5900 elm_widget_type_get(obj),
5902 EINA_LIST_FOREACH(sd->subobjs, l, obj)
5903 _sub_obj_tree_dump(obj, lvl + 1);
5906 DBG("+ %s(%p)\n", evas_object_type_get(obj), obj);
5910 _sub_obj_tree_dot_dump(const Evas_Object *obj,
5913 if (!_elm_widget_is(obj))
5917 Eina_Bool visible = evas_object_visible_get(obj);
5918 Eina_Bool disabled = elm_widget_disabled_get(obj);
5919 Eina_Bool focused = elm_widget_focus_get(obj);
5920 Eina_Bool can_focus = elm_widget_can_focus_get(obj);
5924 fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
5927 fprintf(output, ", style=bold");
5930 fprintf(output, ", color=gray28");
5932 fprintf(output, " ];\n");
5935 fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
5936 "disabled: %d|focused: %d/%d|focus order:%d}\"",
5937 obj, obj, elm_widget_type_get(obj),
5938 evas_object_name_get(obj), visible, disabled, focused, can_focus,
5942 fprintf(output, ", style=bold");
5945 fprintf(output, ", fontcolor=gray28");
5947 if ((disabled) || (!visible))
5948 fprintf(output, ", color=gray");
5950 fprintf(output, " ];\n");
5954 EINA_LIST_FOREACH(sd->subobjs, l, o)
5955 _sub_obj_tree_dot_dump(o, output);
5961 elm_widget_tree_dump(const Evas_Object *top)
5964 if (!_elm_widget_is(top))
5966 _sub_obj_tree_dump(top, 0);
5974 elm_widget_tree_dot_dump(const Evas_Object *top,
5978 if (!_elm_widget_is(top))
5980 fprintf(output, "graph " " { node [shape=record];\n");
5981 _sub_obj_tree_dot_dump(top, output);
5982 fprintf(output, "}\n");
5991 _elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
5995 sd->on_create = EINA_TRUE;
5996 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
5998 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
5999 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
6000 parent = eo_parent_get());
6001 eo_do(obj, elm_obj_widget_parent_set(parent));
6002 sd->on_create = EINA_FALSE;
6003 //TIZEN_ONLY(20170717) : expose highlight information on atspi
6004 sd->can_highlight = EINA_TRUE;
6006 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
6007 sd->inherit_paragraph_direction = EINA_TRUE;
6010 eo_do(obj, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_UNKNOWN));
6015 _elm_widget_eo_base_destructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
6017 sd->on_destroy = EINA_TRUE;
6019 elm_interface_atspi_accessible_description_set(NULL),
6020 elm_interface_atspi_accessible_name_set(NULL),
6021 //TIZEN_ONLY(20190922): add name callback, description callback.
6022 elm_interface_atspi_accessible_description_cb_set(NULL, NULL),
6023 elm_interface_atspi_accessible_name_cb_set(NULL, NULL),
6025 elm_interface_atspi_accessible_translation_domain_set(NULL),
6026 elm_interface_atspi_accessible_relationships_clear(),
6027 // TIZEN_ONLY(20160930) : endless recursion fix
6028 elm_interface_atspi_accessible_attributes_clear()
6031 // TIZEN_ONLY(20150709) : atspi relations api
6032 if (sd->atspi_custom_relations)
6033 elm_atspi_relation_set_free(&sd->atspi_custom_relations);
6035 //TIZEN_ONLY(20150717) add widget name setter
6037 eina_stringshare_del(sd->name);
6040 //TIZEN_ONLY(20150731) : add i18n support for name and description
6041 if (sd->atspi_translation_domain)
6042 eina_stringshare_del(sd->atspi_translation_domain);
6044 //Tizen Only(20160728) free attribute list
6047 Elm_Atspi_Attribute *attr;
6048 EINA_LIST_FREE(sd->attr_list, attr)
6050 eina_stringshare_del(attr->key);
6051 eina_stringshare_del(attr->value);
6057 eo_do_super(obj, ELM_WIDGET_CLASS, eo_destructor());
6058 sd->on_destroy = EINA_FALSE;
6060 elm_interface_atspi_accessible_removed(obj);
6063 EOLIAN static Eina_Bool
6064 _elm_widget_on_focus(Eo *obj, Elm_Widget_Smart_Data *sd, Elm_Object_Item *item EINA_UNUSED)
6066 if (elm_widget_can_focus_get(obj))
6068 if (elm_widget_focus_get(obj))
6070 if (!sd->resize_obj)
6071 evas_object_focus_set(obj, EINA_TRUE);
6072 eo_do(obj, eo_event_callback_call
6073 (ELM_WIDGET_EVENT_FOCUSED, NULL));
6074 if (_elm_atspi_enabled() && !elm_widget_child_can_focus_get(obj))
6075 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_FOCUSED, EINA_TRUE);
6079 if (!sd->resize_obj)
6080 evas_object_focus_set(obj, EINA_FALSE);
6081 eo_do(obj, eo_event_callback_call
6082 (ELM_WIDGET_EVENT_UNFOCUSED, NULL));
6083 if (_elm_atspi_enabled() && !elm_widget_child_can_focus_get(obj))
6084 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_FOCUSED, EINA_FALSE);
6093 EOLIAN static Eina_Bool
6094 _elm_widget_disable(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6099 EOLIAN static Eina_Bool
6100 _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)
6105 EOLIAN static Eina_Bool
6106 _elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6108 WRN("The %s widget does not implement the \"focus_next/focus_next_manager_is\" functions.",
6109 eo_class_name_get(eo_class_get(obj)));
6114 _elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
6116 WRN("The %s widget does not implement the \"focus_direction/focus_direction_manager_is\" functions.",
6117 eo_class_name_get(eo_class_get(obj)));
6121 EOLIAN static Eina_Bool
6122 _elm_widget_activate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Elm_Activate act EINA_UNUSED)
6124 WRN("The %s widget does not implement the \"activate\" functions.",
6125 eo_class_name_get(eo_class_get(obj)));
6130 _elm_widget_class_constructor(Eo_Class *klass)
6132 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
6135 EOLIAN static Eina_Bool
6136 _elm_widget_elm_interface_atspi_component_focus_grab(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6138 if (elm_object_focus_allow_get(obj))
6140 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6141 if (!ee) return EINA_FALSE;
6142 ecore_evas_activate(ee);
6143 elm_object_focus_set(obj, EINA_TRUE);
6149 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods (29e253e2f7ef3c632ac3a64c489bf569df407f30)
6150 EOLIAN static Eina_Bool
6151 _elm_widget_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6153 if(!_elm_atspi_enabled())
6156 Evas_Coord sx, sy, sw, sh;
6157 Evas_Coord x, y, w, h;
6158 Evas_Object *parent, *scroll_parent;
6159 evas_object_geometry_get(obj, &x, &y, &w, &h);
6160 sx = sy = sw = sh = 0;
6161 parent = evas_object_smart_parent_get(obj);
6162 scroll_parent = evas_object_smart_parent_get(obj);
6163 while (scroll_parent)
6165 if (eo_isa(scroll_parent, ELM_INTERFACE_SCROLLABLE_MIXIN))
6167 evas_object_geometry_get(parent, &sx, &sy, &sw, &sh);
6170 switch (_elm_config->focus_autoscroll_mode)
6172 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
6173 eo_do(scroll_parent, elm_interface_scrollable_content_region_show(x, y, w, h));
6175 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
6176 eo_do(scroll_parent, elm_interface_scrollable_region_bring_in(x, y, w, h));
6183 scroll_parent = evas_object_smart_parent_get(scroll_parent);
6185 elm_object_accessibility_highlight_set(obj, EINA_TRUE);
6186 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
6188 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
6189 evas_object_smart_callback_call(obj, SIG_WIDGET_ATSPI_HIGHLIGHTED, NULL);
6194 EOLIAN static Eina_Bool
6195 _elm_widget_elm_interface_atspi_component_highlight_clear(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6197 if(!_elm_atspi_enabled())
6199 elm_object_accessibility_highlight_set(obj, EINA_FALSE);
6200 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_FALSE);
6202 // TIZEN_ONLY(20161018): add highlighted/unhighlighted signal for atspi
6203 evas_object_smart_callback_call(obj, SIG_WIDGET_ATSPI_UNHIGHLIGHTED, NULL);
6209 EOLIAN static const char*
6210 _elm_widget_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
6212 char *accessible_name;
6213 //TIZEN_ONLY(20190922): add name callback, description callback.
6214 const char *ret = NULL;
6215 eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_name_get());
6216 if (ret) return ret;
6219 //TIZEN_ONLY(20150717) add widget name setter
6223 if (_pd->atspi_translation_domain)
6224 return dgettext(_pd->atspi_translation_domain, _pd->name);
6230 ret = elm_object_text_get(obj);
6231 if (!ret) return NULL;
6233 accessible_name = _elm_util_mkup_to_text(ret);
6234 eina_stringshare_del(_pd->accessible_name);
6235 _pd->accessible_name = eina_stringshare_add(accessible_name);
6236 free(accessible_name);
6237 return _pd->accessible_name;
6240 //TIZEN_ONLY(20150713) : add atspi name setter to widget_item
6242 _elm_widget_item_elm_interface_atspi_accessible_name_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data* _pd EINA_UNUSED, const char *name)
6245 eina_stringshare_del(_pd->name);
6247 _pd->name = eina_stringshare_add(name);
6251 _elm_widget_item_elm_interface_atspi_accessible_name_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6253 //TIZEN_ONLY(20190922): add name callback, description callback.
6254 const char *ret = NULL;
6255 eo_do_super(obj, ELM_WIDGET_ITEM_CLASS, ret = elm_interface_atspi_accessible_name_get());
6256 if (ret) return ret;
6262 if (_pd->atspi_translation_domain)
6263 return dgettext(_pd->atspi_translation_domain, _pd->name);
6272 //TIZEN_ONLY(20150709) : spatially sort atspi children
6273 static int _sort_vertically(const void *data1, const void *data2)
6276 evas_object_geometry_get(data1, NULL, &y1, NULL, NULL);
6277 evas_object_geometry_get(data2, NULL, &y2, NULL, NULL);
6279 return y1 < y2 ? -1 : 1;
6282 static int _sort_horizontally(const void *data1, const void *data2)
6285 evas_object_geometry_get(data1, &x1, NULL, NULL, NULL);
6286 evas_object_geometry_get(data2, &x2, NULL, NULL, NULL);
6288 return x1 < x2 ? -1 : 1;
6291 static Eina_List *_lines_split(Eina_List *children)
6294 Eina_List *lines, *line, *l;
6295 Evas_Coord yl, y, hl, h;
6296 lines = line = NULL;
6298 if (!children) return NULL;
6300 EINA_LIST_FOREACH(children, l, c)
6302 evas_object_geometry_get(c, NULL, &yl, NULL, &hl);
6304 /* remove child if its height == 0 */
6308 EINA_LIST_FREE(children, c)
6310 evas_object_geometry_get(c, NULL, &y, NULL, &h);
6312 /* remove child if its height == 0 */
6313 if (h == 0) continue;
6315 if ((yl + (int)(0.25 * hl)) >= y)
6318 line = eina_list_append(line,c);
6322 // finish current line & start new
6323 lines = eina_list_append(lines, line);
6325 line = eina_list_append(NULL, c);
6329 return eina_list_append(lines, line);
6333 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6335 _proxy_widget_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
6340 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
6341 elm_atspi_bridge_utils_proxy_offset_set(proxy, x, y);
6346 _on_widget_del(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
6349 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6350 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
6351 _proxy_widget_move_cb, plug);
6357 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6359 _on_proxy_connected_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
6362 Evas_Object *widget = data;
6364 evas_object_geometry_get(widget, &x, &y, NULL, NULL);
6365 elm_atspi_bridge_utils_proxy_offset_set(obj, x, y);
6367 evas_object_event_callback_add(widget, EVAS_CALLBACK_MOVE, _proxy_widget_move_cb, obj);
6373 EOLIAN static Eina_List*
6374 _elm_widget_elm_interface_atspi_accessible_children_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6376 Eina_List *l, *accs = NULL;
6377 Elm_Widget_Smart_Data *wd;
6378 Evas_Object *widget;
6379 // TIZEN_ONLY(20160824): Do not append a child, if its accessible parent is different with widget parent
6383 wd = eo_data_scope_get(obj, ELM_WIDGET_CLASS);
6384 if (!wd) return NULL;
6386 EINA_LIST_FOREACH(wd->subobjs, l, widget)
6388 const char *type = evas_object_type_get(widget);
6390 // Ugly Tizen hack to integrate AT-SPI2 accessibility provided by WebKit/Chromium with elementary one.
6391 // This wrapper class should be implemented in Webkit/Chromium EFL ports
6392 if (type && (!strcmp(type, "EWebView") || !strcmp(type, "WebView"))) {
6393 elm_atspi_ewk_wrapper_a11y_init(obj, widget);
6397 EINA_LIST_FOREACH(wd->subobjs, l, widget)
6399 // TIZEN_ONLY(20160824): Do not append a child, if its accessible parent is different with widget parent
6400 if (eo_isa(widget, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN)) {
6401 eo_do(widget, parent = elm_interface_atspi_accessible_parent_get());
6402 if (parent && (parent != obj)) continue;
6405 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6406 const char *plug_id_2;
6407 if ((plug_id_2 = evas_object_data_get(widget, "___PLUGID")) != NULL)
6409 // TIZEN_ONLY(20160930) : endless recursion fix
6410 eo_do_super(obj, MY_CLASS, elm_interface_atspi_accessible_attribute_append("___PlugID", plug_id_2));
6413 char *svcname, *svcnum;
6415 proxy = evas_object_data_get(widget, "__widget_proxy");
6418 accs = eina_list_append(accs, proxy);
6422 if (_elm_atspi_bridge_plug_id_split(plug_id_2, &svcname, &svcnum))
6424 proxy = _elm_atspi_bridge_utils_proxy_create(obj, svcname, atoi(svcnum), ELM_ATSPI_PROXY_TYPE_PLUG);
6425 evas_object_data_set(widget, "__widget_proxy", proxy);
6426 eo_do(widget, eo_event_callback_add(EO_EV_DEL, _on_widget_del, proxy));
6427 eo_do(proxy, eo_event_callback_add(ELM_ATSPI_PROXY_EVENT_CONNECTED, _on_proxy_connected_cb, widget));
6428 elm_atspi_bridge_utils_proxy_connect(proxy);
6429 accs = eina_list_append(accs, proxy);
6437 if (!elm_object_widget_check(widget)) continue;
6438 if (eo_isa(widget, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
6439 accs = eina_list_append(accs, widget);
6441 //TIZEN_ONLY(20150709) : spatially sort atspi children
6442 // sort children using its top-left coordinate
6443 accs = eina_list_sort(accs, -1, _sort_vertically);
6444 Eina_List *line, *lines = _lines_split(accs);
6446 EINA_LIST_FREE(lines, line)
6447 accs = eina_list_merge(accs, eina_list_sort(line, -1, _sort_horizontally));
6453 _elm_widget_elm_interface_atspi_accessible_parent_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd)
6456 eo_do_super(obj, ELM_WIDGET_CLASS, ret = elm_interface_atspi_accessible_parent_get());
6458 return ret ? ret : pd->parent_obj;
6461 EOLIAN static Elm_Atspi_State_Set
6462 _elm_widget_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Widget_Smart_Data *pd)
6464 Elm_Atspi_State_Set states = 0;
6466 eo_do_super(obj, ELM_WIDGET_CLASS, states = elm_interface_atspi_accessible_state_set_get());
6468 if (evas_object_visible_get(obj))
6470 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
6471 if (_elm_widget_onscreen_is(obj))
6472 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
6474 if (!elm_widget_child_can_focus_get(obj))
6476 if (elm_object_focus_allow_get(obj))
6477 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
6478 if (elm_object_focus_get(obj))
6479 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
6481 if (!elm_object_disabled_get(obj))
6483 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
6484 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
6487 //TIZEN_ONLY(20170717) : expose highlight information on atspi
6488 if (pd->can_highlight)
6489 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
6491 STATE_TYPE_UNSET(states, ELM_ATSPI_STATE_HIGHLIGHTABLE);
6493 if (_elm_object_accessibility_currently_highlighted_get() == (void*)pd->obj)
6494 STATE_TYPE_SET(states, ELM_ATSPI_STATE_HIGHLIGHTED);
6500 //TIZEN_ONLY(20160729): attributes_get, append APIs added/updated.
6501 EOLIAN static Eina_List*
6502 _elm_widget_elm_interface_atspi_accessible_attributes_get(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
6504 Eina_List *attr_list = NULL;
6505 // TIZEN_ONLY(20160930) : endless recursion fix
6506 eo_do_super(obj, MY_CLASS, attr_list = elm_interface_atspi_accessible_attributes_get());
6508 //Add type and style information in addition.
6509 Elm_Atspi_Attribute *attr = NULL;
6510 attr = calloc(1, sizeof(Elm_Atspi_Attribute));
6513 attr->key = eina_stringshare_add("type");
6514 attr->value = eina_stringshare_add(elm_widget_type_get(obj));
6515 attr_list = eina_list_append(attr_list, attr);
6518 attr = calloc(1, sizeof(Elm_Atspi_Attribute));
6521 attr->key = eina_stringshare_add("style");
6522 attr->value = eina_stringshare_add(elm_widget_style_get(obj));
6523 attr_list = eina_list_append(attr_list, attr);
6529 //TIZEN_ONLY(20150709) : atspi relations api
6530 EOLIAN static Elm_Atspi_Relation_Set
6531 _elm_widget_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
6533 return elm_atspi_relation_set_clone(&sd->atspi_custom_relations);
6536 EOLIAN static Elm_Atspi_Relation_Set
6537 _elm_widget_item_elm_interface_atspi_accessible_relation_set_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd)
6539 return elm_atspi_relation_set_clone(&sd->atspi_custom_relations);
6544 _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)
6557 evas_object_geometry_get(sd->view, x, y, w, h);
6560 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(sd->view));
6562 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
6568 EOLIAN static Eina_Bool
6569 _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)
6575 _elm_widget_item_elm_interface_atspi_component_layer_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6579 return evas_object_layer_get(sd->view);
6582 EOLIAN static Eina_Bool
6583 _elm_widget_item_elm_interface_atspi_component_focus_grab(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6585 elm_object_item_focus_set(obj, EINA_TRUE);
6586 return elm_object_item_focus_get(obj);
6589 //TIZEN_ONLY(20160329): atspi: implement HighlightGrab and HighlightClear methods
6590 EOLIAN static Eina_Bool
6591 _elm_widget_item_elm_interface_atspi_component_highlight_grab(Eo *obj, Elm_Widget_Item_Data *sd)
6594 if (!obj) return EINA_FALSE;
6596 Evas_Object *o = elm_object_parent_widget_get(sd->view);
6597 if (_elm_scrollable_is(o))
6599 Evas_Coord bx, by, bw, bh;
6600 Evas_Coord x, y, w, h;
6601 Evas_Object *w1 = elm_object_parent_widget_get(o);
6602 evas_object_geometry_get(sd->view, &x, &y, &w, &h);
6603 evas_object_geometry_get(o, &bx, &by, &bw, &bh);
6606 switch (_elm_config->focus_autoscroll_mode)
6608 case ELM_FOCUS_AUTOSCROLL_MODE_SHOW:
6609 eo_do(w1, elm_interface_scrollable_content_region_show(x, y, w, h));
6611 case ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN:
6612 eo_do(w1, elm_interface_scrollable_region_bring_in(x, y, w, h));
6619 elm_object_accessibility_highlight_set(sd->eo_obj, EINA_TRUE);
6620 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_TRUE);
6626 EOLIAN static Eina_Bool
6627 _elm_widget_item_elm_interface_atspi_component_highlight_clear(Eo *obj, Elm_Widget_Item_Data *sd)
6629 if (!obj) return EINA_FALSE;
6630 elm_object_accessibility_highlight_set(sd->eo_obj, EINA_FALSE);
6631 elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_HIGHLIGHTED, EINA_FALSE);
6636 EOLIAN static double
6637 _elm_widget_item_elm_interface_atspi_component_alpha_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6641 if (!sd->view) return -1.0;
6642 evas_object_color_get(sd->view, NULL, NULL, NULL, &alpha);
6643 return (double)alpha / 255.0;
6646 //TIZEN_ONLY(20150717) add widget name setter
6648 _elm_widget_elm_interface_atspi_accessible_name_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data* _pd EINA_UNUSED, const char *name)
6651 eina_stringshare_del(_pd->name);
6653 _pd->name = eina_stringshare_add(name);
6657 //TIZEN_ONLY(20160329): widget: improve accessibile_at_point getter (a8aff0423202b9a55dbb3843205875226678fbd6)
6659 _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)
6661 Eina_List *l, *l2, *children;
6663 Evas_Object *stack_item;
6665 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6667 Evas_Coord px, py, pw, ph;
6673 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6674 if (!ee) return NULL;
6675 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
6680 eo_do(obj, children = elm_interface_atspi_accessible_children_get());
6682 /* Get evas_object stacked at given x,y coordinates starting from top */
6683 Eina_List *stack = evas_tree_objects_at_xy_get(evas_object_evas_get(obj), NULL, x, y);
6684 /* Foreach stacked object starting from top */
6685 EINA_LIST_FOREACH(stack, l, stack_item)
6687 /* Foreach at-spi children traverse stack_item evas_objects hierarchy */
6688 EINA_LIST_FOREACH(children, l2, child)
6690 Elm_Atspi_Role role;
6691 eo_do(child, role = elm_interface_atspi_accessible_role_get());
6692 if (role == ELM_ATSPI_ROLE_REDUNDANT_OBJECT)
6694 /* The redundant object ignores */
6697 /* Compare object used to compare with stacked evas objects */
6698 compare_obj = child;
6699 /* In case of widget_items compare should be different then elm_widget_ item object */
6700 if (eo_isa(child, ELM_WIDGET_ITEM_CLASS))
6702 Elm_Widget_Item_Data *id = eo_data_scope_get(child, ELM_WIDGET_ITEM_CLASS);
6703 compare_obj = id->view;
6705 /* In case of access object compare should be 'wrapped' evas_object */
6706 if (eo_isa(child, ELM_ACCESS_CLASS))
6708 Elm_Access_Info *info = _elm_access_info_get(child);
6709 compare_obj = info->part_object;
6712 /* In case of ewk wrapper object compare with internal ewk_view evas_object */
6713 if (eo_isa(child, ELM_ATSPI_EWK_WRAPPER_CLASS))
6715 compare_obj = elm_atspi_ewk_wrapper_ewk_view_get(child);
6718 /* If spacial eo children do not have backing evas_object continue with search */
6722 Evas_Object *smart_parent = stack_item;
6723 while (smart_parent)
6725 if (smart_parent == compare_obj)
6727 eina_list_free(children);
6728 eina_list_free(stack);
6732 // TIZEN_ONLY(20160705) - enable atspi_proxy to work
6733 proxy = evas_object_data_get(smart_parent, "__widget_proxy");
6736 evas_object_geometry_get(smart_parent, &px, &py, &pw, &ph);
6737 if (x >= px && x <= px + pw && y >= py && y <= py +ph)
6739 eina_list_free(children);
6740 eina_list_free(stack);
6745 smart_parent = evas_object_smart_parent_get(smart_parent);
6750 eina_list_free(children);
6751 eina_list_free(stack);
6756 //TIZEN_ONLY(20150709) add relations atpi
6757 EOLIAN static Eina_Bool
6758 _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)
6760 return elm_atspi_relation_set_relation_append(&sd->atspi_custom_relations, type, relation_obj);
6764 _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)
6766 elm_atspi_relation_set_relation_remove(&sd->atspi_custom_relations, type, relation_obj);
6769 EOLIAN static Eina_Bool
6770 _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)
6772 return elm_atspi_relation_set_relation_append(&sd->atspi_custom_relations, type, relation_obj);
6776 _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)
6778 elm_atspi_relation_set_relation_remove(&sd->atspi_custom_relations, type, relation_obj);
6782 //TIZEN_ONLY(20150731) : add i18n support for name and description
6784 _elm_widget_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, const char *domain)
6786 eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
6789 EOLIAN static const char*
6790 _elm_widget_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
6792 return _pd->atspi_translation_domain;
6796 _elm_widget_item_elm_interface_atspi_accessible_translation_domain_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd, const char *domain)
6798 eina_stringshare_replace(&_pd->atspi_translation_domain, domain);
6801 EOLIAN static const char*
6802 _elm_widget_item_elm_interface_atspi_accessible_translation_domain_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd)
6804 return _pd->atspi_translation_domain;
6807 //TIZEN_ONLY(20160726): add API elm_atspi_accessible_can_highlight_set/get
6809 _elm_widget_elm_interface_atspi_accessible_can_highlight_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd, Eina_Bool can_highlight)
6811 _pd->can_highlight = !!can_highlight;
6814 EOLIAN static Eina_Bool
6815 _elm_widget_elm_interface_atspi_accessible_can_highlight_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd)
6817 return _pd->can_highlight;
6821 _elm_widget_item_elm_interface_atspi_accessible_can_highlight_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd, Eina_Bool can_highlight)
6823 _pd->can_highlight = !!can_highlight;
6826 EOLIAN static Eina_Bool
6827 _elm_widget_item_elm_interface_atspi_accessible_can_highlight_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd)
6829 return _pd->can_highlight;
6833 //TIZEN_ONLY(20160622): Override Paragraph Direction APIs
6835 _elm_widget_evas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
6840 if (sd->on_destroy) return;
6842 EINA_LIST_FOREACH(sd->subobjs, l, child)
6844 if (_elm_widget_is(child))
6846 Elm_Widget_Smart_Data *sdc = eo_data_scope_get(child, MY_CLASS);
6848 if (sdc->inherit_paragraph_direction &&
6849 (sdc->paragraph_direction != dir))
6851 sdc->paragraph_direction = dir;
6852 _elm_widget_evas_object_paragraph_direction_set_internal(child, sdc, dir);
6853 eo_do_super(child, MY_CLASS, evas_obj_paragraph_direction_set(dir));
6857 /* FIXME: There is no way to handle non-widget child object.
6858 * If a non-widget child object has smart parent, it will get the direction
6859 * from the smart parent. */
6864 _elm_widget_evas_object_paragraph_direction_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_BiDi_Direction dir)
6866 if ((!(sd->inherit_paragraph_direction) && (sd->paragraph_direction == dir)) ||
6867 (sd->inherit_paragraph_direction && (dir == EVAS_BIDI_DIRECTION_INHERIT)))
6870 if (dir == EVAS_BIDI_DIRECTION_INHERIT)
6872 sd->inherit_paragraph_direction = EINA_TRUE;
6873 Evas_BiDi_Direction parent_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
6876 parent_dir = evas_object_paragraph_direction_get(sd->parent_obj);
6878 if (parent_dir != sd->paragraph_direction)
6880 sd->paragraph_direction = parent_dir;
6881 _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, parent_dir);
6886 sd->inherit_paragraph_direction = EINA_FALSE;
6887 sd->paragraph_direction = dir;
6888 _elm_widget_evas_object_paragraph_direction_set_internal(obj, sd, dir);
6891 eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(dir));
6896 //TIZEN_ONLY(20161013): clean up elm color class feature
6898 _edje_color_class_free(void *data)
6900 Edje_Color_Class *cc = data;
6902 if (cc->name) eina_stringshare_del(cc->name);
6907 _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char *part)
6910 Eina_Stringshare *str;
6912 buf = eina_strbuf_new();
6914 eina_strbuf_append(buf, strchr(eo_class_name_get(klass), '_') + 1);
6915 eina_strbuf_tolower(buf);
6919 eina_strbuf_append_printf(buf, "/%s/%s", style, part);
6923 eina_strbuf_append_printf(buf, "/%s", part);
6926 str = eina_stringshare_add(eina_strbuf_string_get(buf));
6928 eina_strbuf_free(buf);
6932 /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
6934 _elm_widget_color_class_set_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
6935 int r, int g, int b, int a,
6936 int r2, int g2, int b2, int a2,
6937 int r3, int g3, int b3, int a3)
6939 Eina_Bool int_ret = EINA_TRUE;
6940 Eina_Stringshare *buf;
6941 int temp_color[3][4] = { { r, g, b, a },
6943 { r3, g3, b3, a3 } };
6945 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
6947 #define TEMP_COLOR(x, y) \
6948 ((temp_color[x][y] == -1) ? &temp_color[x][y] : NULL)
6950 edje_object_color_class_get(edje, buf,
6951 TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
6952 TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
6953 TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
6957 #define TEMP_COLOR(x, y) \
6958 ((temp_color[x][y] == -1) ? 0 : temp_color[x][y])
6960 int_ret &= edje_object_color_class_set(edje, buf,
6961 TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
6962 TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
6963 TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
6967 eina_stringshare_del(buf);
6973 _elm_widget_color_class_get_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
6974 int *r, int *g, int *b, int *a,
6975 int *r2, int *g2, int *b2, int *a2,
6976 int *r3, int *g3, int *b3, int *a3)
6978 Eina_Bool int_ret = EINA_TRUE;
6979 Eina_Stringshare *buf;
6981 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
6983 int_ret &= edje_object_color_class_get(edje, buf,
6988 eina_stringshare_del(buf);
6995 _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)
6998 Eina_Bool int_ret = EINA_TRUE;
7000 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7002 edje = elm_layout_edje_get(obj);
7003 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7012 _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)
7015 Eina_Bool int_ret = EINA_TRUE;
7017 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7019 edje = elm_layout_edje_get(obj);
7020 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7022 NULL, NULL, NULL, NULL,
7023 NULL, NULL, NULL, NULL);
7029 _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)
7032 Eina_Bool int_ret = EINA_TRUE;
7034 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7036 edje = elm_layout_edje_get(obj);
7037 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7046 _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)
7049 Eina_Bool int_ret = EINA_TRUE;
7051 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7053 edje = elm_layout_edje_get(obj);
7054 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7055 NULL, NULL, NULL, NULL,
7057 NULL, NULL, NULL, NULL);
7063 _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)
7066 Eina_Bool int_ret = EINA_TRUE;
7068 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7070 edje = elm_layout_edje_get(obj);
7071 int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
7080 _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)
7083 Eina_Bool int_ret = EINA_TRUE;
7085 if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
7087 edje = elm_layout_edje_get(obj);
7088 int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
7089 NULL, NULL, NULL, NULL,
7090 NULL, NULL, NULL, NULL,
7096 #define ELM_COLOR_CLASS_UPDATE(obj, hash, cond) \
7097 Evas_Object *edje = NULL; \
7098 Eina_Iterator *itr; \
7099 Edje_Color_Class *cc; \
7100 Eina_Bool int_ret = EINA_TRUE; \
7101 if (cond) return EINA_FALSE; \
7102 if (eo_isa(obj, ELM_LAYOUT_CLASS)) \
7103 edje = elm_layout_edje_get(obj); \
7104 else if (eo_isa(obj, EDJE_OBJECT_CLASS)) \
7106 if (!edje) return EINA_FALSE; \
7107 itr = eina_hash_iterator_data_new(hash); \
7108 EINA_ITERATOR_FOREACH(itr, cc) \
7110 int_ret &= edje_object_color_class_set(edje, cc->name, \
7111 cc->r, cc->g, cc->b, cc->a, \
7112 cc->r2, cc->g2, cc->b2, cc->a2, \
7113 cc->r3, cc->g3, cc->b3, cc->a3); \
7115 eina_iterator_free(itr); \
7119 #define CHECK_BOUND(x) \
7120 if (x > 0xff) x = 0xff; \
7121 else if (x < 0) x = 0
7123 #define ELM_COLOR_CLASS_SET_START(obj, cr, cg, cb, ca) \
7124 Eina_Bool int_ret = EINA_FALSE; \
7125 Edje_Color_Class *cc = NULL; \
7126 Eina_Stringshare *buf; \
7127 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
7132 _elm_color_unpremul(a, &r, &g, &b); \
7133 if (!sd->color_classes) \
7134 sd->color_classes = eina_hash_string_small_new(_edje_color_class_free); \
7136 cc = eina_hash_find(sd->color_classes, buf); \
7139 cc = calloc(1, sizeof(Edje_Color_Class)); \
7140 cc->name = eina_stringshare_add(buf); \
7144 eina_stringshare_del(buf); \
7145 return EINA_FALSE; \
7147 eina_hash_direct_add(sd->color_classes, cc->name, cc); \
7149 else if ((cc->cr == r) && (cc->cg == g) && \
7150 (cc->cb == b) && (cc->ca == a)) \
7152 eina_stringshare_del(buf); \
7161 #define ELM_COLOR_CLASS_SET_END() \
7162 eina_stringshare_del(buf); \
7165 #define ELM_COLOR_CLASS_GET(obj, cr, cg, cb, ca) \
7166 Eina_Bool int_ret = EINA_FALSE; \
7167 Edje_Color_Class *cc; \
7168 Eina_Stringshare *buf; \
7170 buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
7171 if ((!sd->color_classes) || !(cc = eina_hash_find(sd->color_classes, buf))) \
7177 int_ret = EINA_FALSE; \
7181 if (r) *r = cc->cr; \
7182 if (g) *g = cc->cg; \
7183 if (b) *b = cc->cb; \
7184 if (a) *a = cc->ca; \
7186 int_ret = EINA_TRUE; \
7188 _elm_color_premul(alpha, r, g, b); \
7189 eina_stringshare_del(buf); \
7193 _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd)
7195 ELM_COLOR_CLASS_UPDATE(sd->view, sd->color_classes, (!sd) || (!sd->color_classes) || (!sd->view));
7199 _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)
7201 ELM_COLOR_CLASS_SET_START(obj, r, g, b, a);
7203 int_ret &= _elm_widget_item_color_class_update(sd);
7205 ELM_COLOR_CLASS_SET_END();
7209 _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)
7211 ELM_COLOR_CLASS_GET(obj, r, g, b, a);
7215 _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)
7217 ELM_COLOR_CLASS_SET_START(obj, r2, g2, b2, a2);
7219 int_ret &= _elm_widget_item_color_class_update(sd);
7221 ELM_COLOR_CLASS_SET_END();
7225 _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)
7227 ELM_COLOR_CLASS_GET(obj, r2, g2, b2, a2);
7231 _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)
7233 ELM_COLOR_CLASS_SET_START(obj, r3, g3, b3, a3);
7235 int_ret &= _elm_widget_item_color_class_update(sd);
7237 ELM_COLOR_CLASS_SET_END();
7241 _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)
7243 ELM_COLOR_CLASS_GET(obj, r3, g3, b3, a3);
7247 /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
7249 _elm_widget_color_class_parent_set(Evas_Object *obj, Evas_Object *parent)
7251 Evas_Object *edje = NULL, *parent_edje = NULL;
7253 if (!obj || !parent) return;
7255 if (eo_isa(obj, ELM_LAYOUT_CLASS))
7256 edje = elm_layout_edje_get(obj);
7257 else if (eo_isa(obj, EDJE_OBJECT_CLASS))
7260 if (eo_isa(parent, ELM_LAYOUT_CLASS))
7261 parent_edje = elm_layout_edje_get(parent);
7262 else if (eo_isa(parent, EDJE_OBJECT_CLASS))
7263 parent_edje = parent;
7265 if (!edje || !parent_edje) return;
7267 edje_object_color_class_parent_set(edje, parent_edje);
7271 _elm_widget_color_class_parent_unset(Evas_Object *obj)
7273 Evas_Object *edje = NULL;
7277 if (eo_isa(obj, ELM_LAYOUT_CLASS))
7278 edje = elm_layout_edje_get(obj);
7279 else if (eo_isa(obj, EDJE_OBJECT_CLASS))
7284 edje_object_color_class_parent_unset(edje);
7288 //TIZEN_ONLY(20160527): widget: add AtspiAction interface to all widgets and widget_items, add handlers for reading stopped/cancelled
7289 EOLIAN const Elm_Atspi_Action *
7290 _elm_widget_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd EINA_UNUSED)
7295 EOLIAN const Elm_Atspi_Action *
7296 _elm_widget_item_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *pd EINA_UNUSED)
7302 #include "elm_widget_item.eo.c"
7303 #include "elm_widget.eo.c"