1 #include <Elementary.h>
3 #include "elm_interface_scrollable.h"
5 static const char ACCESS_SMART_NAME[] = "elm_access";
7 ELM_INTERNAL_SMART_SUBCLASS_NEW
8 (ACCESS_SMART_NAME, _elm_access, Elm_Widget_Smart_Class,
9 Elm_Widget_Smart_Class, elm_widget_smart_class_get, NULL);
13 void *user_data; /* Holds user data to CB */
14 Elm_Access_Action_Cb cb;
17 typedef struct _Func_Data Func_Data;
22 Func_Data fn[ELM_ACCESS_ACTION_LAST + 1]; /* Callback for specific action */
25 typedef struct _Action_Info Action_Info;
27 static Eina_Bool mouse_event_enable = EINA_TRUE;
28 static Eina_Bool read_mode = EINA_FALSE;
29 static Evas_Coord_Point offset;
30 static Evas_Object *s_parent; /* scrollable parent */
31 static Elm_Access_Action_Type action_type = ELM_ACCESS_ACTION_FIRST;
33 static Evas_Object * _elm_access_add(Evas_Object *parent);
36 _elm_access_smart_add(Evas_Object *obj)
38 EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data);
39 ELM_WIDGET_CLASS(_elm_access_parent_sc)->base.add(obj);
41 elm_widget_can_focus_set(obj, EINA_TRUE);
45 _elm_access_smart_on_focus(Evas_Object *obj)
47 evas_object_focus_set(obj, elm_widget_focus_get(obj));
53 _elm_access_smart_activate(Evas_Object *obj, Elm_Activate act)
55 int type = ELM_ACCESS_ACTION_FIRST;
58 a = evas_object_data_get(obj, "_elm_access_action_info");
62 case ELM_ACTIVATE_DEFAULT:
63 type = ELM_ACCESS_ACTION_ACTIVATE;
67 type = ELM_ACCESS_ACTION_VALUE_CHANGE;
70 case ELM_ACTIVATE_DOWN:
71 type = ELM_ACCESS_ACTION_VALUE_CHANGE;
74 case ELM_ACTIVATE_RIGHT:
77 case ELM_ACTIVATE_LEFT:
80 case ELM_ACTIVATE_BACK:
81 type = ELM_ACCESS_ACTION_BACK;
88 if ((a) && (type > ELM_ACCESS_ACTION_FIRST) &&
89 (type < ELM_ACCESS_ACTION_LAST) &&
92 a->fn[type].cb(a->fn[type].user_data, obj, NULL);
96 /* TODO: deprecate below? and change above with _access_action_callback_call(); */
97 if (act != ELM_ACTIVATE_DEFAULT) return EINA_FALSE;
99 Elm_Access_Info *ac = evas_object_data_get(obj, "_elm_access");
100 if (!ac) return EINA_FALSE;
103 ac->activate(ac->activate_data, ac->part_object,
104 (Elm_Object_Item *)ac->widget_item);
110 _elm_access_smart_set_user(Elm_Widget_Smart_Class *sc)
112 sc->base.add = _elm_access_smart_add;
114 /* not a 'focus chain manager' */
115 sc->focus_next = NULL;
116 sc->focus_direction = NULL;
117 sc->on_focus = _elm_access_smart_on_focus;
118 sc->activate = _elm_access_smart_activate;
123 typedef struct _Mod_Api Mod_Api;
127 void (*out_read) (const char *txt);
128 void (*out_read_done) (void);
129 void (*out_cancel) (void);
130 void (*out_done_callback_set) (void (*func) (void *data), const void *data);
133 static int initted = 0;
134 static Mod_Api *mapi = NULL;
141 if (initted > 1) return;
142 if (!(m = _elm_module_find_as("access/api"))) return;
143 m->api = malloc(sizeof(Mod_Api));
146 ((Mod_Api *)(m->api) )->out_read = // called to read out some text
147 _elm_module_symbol_get(m, "out_read");
148 ((Mod_Api *)(m->api) )->out_read_done = // called to set a done marker so when it is reached the done callback is called
149 _elm_module_symbol_get(m, "out_read_done");
150 ((Mod_Api *)(m->api) )->out_cancel = // called to read out some text
151 _elm_module_symbol_get(m, "out_cancel");
152 ((Mod_Api *)(m->api) )->out_done_callback_set = // called when last read done
153 _elm_module_symbol_get(m, "out_done_callback_set");
158 _access_shutdown(void)
161 if (initted == 0) return;
162 if (!(m = _elm_module_find_as("access/api"))) return;
172 static Elm_Access_Item *
173 _access_add_set(Elm_Access_Info *ac, int type)
178 if (!ac) return NULL;
179 EINA_LIST_FOREACH(ac->items, l, ai)
181 if (ai->type == type)
185 if (ai->data) eina_stringshare_del(ai->data);
192 ai = calloc(1, sizeof(Elm_Access_Item));
194 ac->items = eina_list_prepend(ac->items, ai);
199 _access_highlight_object_get(Evas_Object *obj)
203 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
206 ho = evas_object_data_get(o, "_elm_access_target");
212 _access_highlight_read(Elm_Access_Info *ac, Evas_Object *obj)
218 /*FIXME: TIZEN only - read at once because Tizen TTS engine performance is not good */
219 strbuf = eina_strbuf_new();
221 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
224 if (ac->on_highlight) ac->on_highlight(ac->on_highlight_data);
225 _elm_access_object_hilight(obj);
227 for (type = ELM_ACCESS_INFO_FIRST + 1; type < ELM_ACCESS_INFO_LAST; type++)
229 txt = _elm_access_text_get(ac, type, obj);
230 if (txt && (strlen(txt) > 0))
232 if (eina_strbuf_length_get(strbuf) > 0)
233 eina_strbuf_append_printf(strbuf, ", %s", txt);
235 eina_strbuf_append(strbuf, txt);
242 txt = eina_strbuf_string_steal(strbuf);
243 eina_strbuf_free(strbuf);
245 _elm_access_say(txt);
250 _access_obj_over_timeout_cb(void *data)
255 if (!data) return EINA_FALSE;
257 ac = evas_object_data_get(data, "_elm_access");
258 if (!ac) return EINA_FALSE;
260 ho = _access_highlight_object_get(data);
261 if (ho != data) _access_highlight_read(ac, data);
263 ac->delay_timer = NULL;
268 _access_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
271 if (!mouse_event_enable) return;
273 ac = evas_object_data_get(data, "_elm_access");
278 ecore_timer_del(ac->delay_timer);
279 ac->delay_timer = NULL;
281 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
282 ac->delay_timer = ecore_timer_add(0.2, _access_obj_over_timeout_cb, data);
286 _access_obj_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
289 if (!mouse_event_enable) return;
291 ac = evas_object_data_get(data, "_elm_access");
294 _elm_access_object_unhilight(data);
297 ecore_timer_del(ac->delay_timer);
298 ac->delay_timer = NULL;
303 _access_obj_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
305 _elm_access_object_unregister(data, obj);
307 // _elm_access_edje_object_part_object_register(); set below object data
308 evas_object_data_del(obj, "_part_access_obj");
312 _access_read_done(void *data __UNUSED__)
314 printf("read done\n");
315 // FIXME: produce event here
319 _access_2nd_click_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
323 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
324 _access_2nd_click_del_cb, NULL);
325 t = evas_object_data_get(obj, "_elm_2nd_timeout");
329 evas_object_data_del(obj, "_elm_2nd_timeout");
334 _access_2nd_click_timeout_cb(void *data)
336 evas_object_event_callback_del_full(data, EVAS_CALLBACK_DEL,
337 _access_2nd_click_del_cb, NULL);
338 evas_object_data_del(data, "_elm_2nd_timeout");
343 _access_obj_hilight_del_cb(void *data __UNUSED__, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
345 _elm_access_object_hilight_disable(e);
349 _access_obj_hilight_hide_cb(void *data __UNUSED__, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
351 _elm_access_object_hilight_disable(e);
355 _access_obj_hilight_move_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
360 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
362 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
363 evas_object_move(o, x, y);
367 _access_obj_hilight_resize_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
372 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
374 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
375 evas_object_resize(o, w, h);
379 _elm_access_mouse_event_enabled_set(Eina_Bool enabled)
382 if (mouse_event_enable == enabled) return;
383 mouse_event_enable = enabled;
387 _elm_access_read_mode_set(Eina_Bool enabled)
390 if (read_mode == enabled) return;
395 _elm_access_read_mode_get()
401 _elm_access_shutdown()
407 _access_order_del_cb(void *data,
410 void *event_info __UNUSED__)
412 Elm_Widget_Item *item = data;
414 item->access_order = eina_list_remove(item->access_order, obj);
418 _elm_access_widget_item_access_order_set(Elm_Widget_Item *item,
426 _elm_access_widget_item_access_order_unset(item);
428 EINA_LIST_FOREACH(objs, l, o)
430 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
431 _access_order_del_cb, item);
434 item->access_order = objs;
438 _elm_access_widget_item_access_order_get(const Elm_Widget_Item *item)
440 if (!item) return NULL;
441 return item->access_order;
445 _elm_access_widget_item_access_order_unset(Elm_Widget_Item *item)
447 Eina_List *l, *l_next;
452 EINA_LIST_FOREACH_SAFE(item->access_order, l, l_next, o)
454 evas_object_event_callback_del_full
455 (o, EVAS_CALLBACK_DEL, _access_order_del_cb, item);
456 item->access_order = eina_list_remove_list(item->access_order, l);
461 _elm_access_highlight_object_scroll(Evas_Object *obj, int type, int x, int y)
465 Evas_Coord_Rectangle ho_area;
469 evas = evas_object_evas_get(obj);
475 ho = _access_highlight_object_get(obj);
483 /* find scrollable parent */
484 s_parent = elm_widget_parent_get(ho);
487 if(!!evas_object_smart_interface_get(s_parent, ELM_SCROLLABLE_IFACE_NAME))
489 s_parent = elm_widget_parent_get(s_parent);
492 if (!s_parent) return;
494 ELM_SCROLLABLE_IFACE_GET(s_parent, s_iface);
495 s_iface->repeat_events_set(s_parent, EINA_FALSE);
497 evas_object_geometry_get
498 (ho, &ho_area.x, &ho_area.y, &ho_area.w, &ho_area.h);
500 offset.x = x - (ho_area.x + (ho_area.w / 2));
501 offset.y = y - (ho_area.y + (ho_area.h / 2));
504 evas_event_feed_mouse_in(evas, 0, NULL);
505 evas_event_feed_mouse_move(evas, x - offset.x, y - offset.y, 0, NULL);
506 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
510 if (!s_parent) return;
511 evas_event_feed_mouse_move(evas, x - offset.x, y - offset.y, 0, NULL);
515 if (!s_parent) return;
516 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
518 ELM_SCROLLABLE_IFACE_GET(s_parent, s_iface);
519 s_iface->repeat_events_set(s_parent, EINA_TRUE);
528 _access_action_callback_call(Evas_Object *obj,
529 Elm_Access_Action_Type type,
536 a = evas_object_data_get(obj, "_elm_access_action_info");
538 if (a && (a->fn[type].cb))
539 ret = a->fn[type].cb(a->fn[type].user_data, obj, data);
545 _access_highlight_next_get(Evas_Object *obj, Elm_Focus_Direction dir)
548 Evas_Object *ho, *parent, *target;
554 if (!elm_widget_is(obj)) return ret;
556 ho = _access_highlight_object_get(obj);
561 /* find highlight root */
564 ELM_WIDGET_DATA_GET(parent, sd);
565 if (sd->highlight_root)
567 /* change highlight root */
571 parent = elm_widget_parent_get(parent);
575 _elm_access_read_mode_set(EINA_TRUE);
577 ret = elm_widget_focus_next_get(obj, dir, &target);
580 if (dir == ELM_FOCUS_NEXT)
581 type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
583 type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
585 if (!_access_action_callback_call(ho, type, NULL))
587 /* change highlight object */
590 _elm_access_highlight_set(target);
593 action_type = ELM_ACCESS_ACTION_FIRST;
597 _elm_access_read_mode_set(EINA_FALSE);
602 //-------------------------------------------------------------------------//
604 _elm_access_highlight_set(Evas_Object* obj)
609 Evas_Coord_Point ho_point = { 0, 0 };
613 ho = _access_highlight_object_get(obj);
614 if (ho == obj) return;
616 ac = evas_object_data_get(obj, "_elm_access");
619 _access_highlight_read(ac, obj);
621 /* move mouse position to inside of highlight object. if an object has a
622 highlight by highlight_cycle();, the mouse still positions at previous
623 position which would be made by MOUSE_IN event. */
624 evas = evas_object_evas_get(obj);
627 evas_object_geometry_get(obj, &ho_point.x, &ho_point.y, 0, 0);
628 evas_event_feed_mouse_move(evas, ho_point.x, ho_point.y, 0, NULL);
632 _elm_access_clear(Elm_Access_Info *ac)
639 ecore_timer_del(ac->delay_timer);
640 ac->delay_timer = NULL;
642 EINA_LIST_FREE(ac->items, ai)
646 if (ai->data) eina_stringshare_del(ai->data);
653 _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text)
655 Elm_Access_Item *ai = _access_add_set(ac, type);
658 ai->data = eina_stringshare_add(text);
662 _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Info_Cb func, const void *data)
664 Elm_Access_Item *ai = _access_add_set(ac, type);
671 _elm_access_on_highlight_hook_set(Elm_Access_Info *ac,
672 Elm_Access_On_Highlight_Cb func,
676 ac->on_highlight = func;
677 ac->on_highlight_data = data;
681 _elm_access_activate_callback_set(Elm_Access_Info *ac,
682 Elm_Access_Activate_Cb func,
687 ac->activate_data = data;
691 _elm_access_highlight_object_activate(Evas_Object *obj, Elm_Activate act)
695 ho = _access_highlight_object_get(obj);
700 case ELM_ACTIVATE_DEFAULT:
701 case ELM_ACTIVATE_UP:
702 case ELM_ACTIVATE_DOWN:
703 _elm_access_read_mode_set(EINA_FALSE);
705 if (!elm_object_focus_get(ho))
706 elm_object_focus_set(ho, EINA_TRUE);
708 elm_widget_activate(ho, act);
711 case ELM_ACTIVATE_BACK:
712 elm_widget_activate(ho, act);
723 _elm_access_highlight_cycle(Evas_Object *obj, Elm_Focus_Direction dir)
726 Evas_Object *ho, *parent;
728 ho = _access_highlight_object_get(obj);
733 /* find highlight root */
736 ELM_WIDGET_DATA_GET(parent, sd);
737 if (sd->highlight_root)
739 /* change highlight root */
743 parent = elm_widget_parent_get(parent);
747 _elm_access_read_mode_set(EINA_TRUE);
749 if (dir == ELM_FOCUS_NEXT)
750 type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
752 type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
756 if (!_access_action_callback_call(ho, type, NULL))
757 elm_widget_focus_cycle(obj, dir);
759 action_type = ELM_ACCESS_ACTION_FIRST;
761 _elm_access_read_mode_set(EINA_FALSE);
765 _elm_access_text_get(const Elm_Access_Info *ac, int type, const Evas_Object *obj)
770 if (!ac) return NULL;
771 EINA_LIST_FOREACH(ac->items, l, ai)
773 if (ai->type == type)
775 if (ai->func) return ai->func((void *)(ai->data), (Evas_Object *)obj);
776 else if (ai->data) return strdup(ai->data);
784 _elm_access_read(Elm_Access_Info *ac, int type, const Evas_Object *obj)
786 char *txt = _elm_access_text_get(ac, type, obj);
788 if (txt && strlen(txt) == 0) return; /* Tizen only: TTS engine does not work properly */
793 if (mapi->out_done_callback_set)
794 mapi->out_done_callback_set(_access_read_done, NULL);
795 if (type == ELM_ACCESS_DONE)
797 if (mapi->out_read_done) mapi->out_read_done();
799 else if (type == ELM_ACCESS_CANCEL)
801 if (mapi->out_cancel) mapi->out_cancel();
805 if (txt && mapi->out_read) mapi->out_read(txt);
812 _elm_access_say(const char *txt)
814 if (!_elm_config->access_mode) return;
816 if (txt && strlen(txt) == 0) return; /* Tizen only: TTS engine does not work properly */
821 if (mapi->out_done_callback_set)
822 mapi->out_done_callback_set(_access_read_done, NULL);
823 if (mapi->out_cancel) mapi->out_cancel();
826 if (mapi->out_read) mapi->out_read(txt);
827 //if (mapi->out_read) mapi->out_read(".\n"); /* TIZEN only: Tizen TTS engine performance is not good */
829 if (mapi->out_read_done) mapi->out_read_done();
833 EAPI Elm_Access_Info *
834 _elm_access_object_get(const Evas_Object *obj)
836 return evas_object_data_get(obj, "_elm_access");
840 _elm_access_object_hilight(Evas_Object *obj)
843 Evas_Coord x, y, w, h;
844 Elm_Access_Action_Info *a;
846 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
849 o = edje_object_add(evas_object_evas_get(obj));
850 evas_object_name_set(o, "_elm_access_disp");
851 evas_object_layer_set(o, ELM_OBJECT_LAYER_TOOLTIP);
855 Evas_Object *ptarget = evas_object_data_get(o, "_elm_access_target");
858 evas_object_data_del(o, "_elm_access_target");
859 elm_widget_parent_highlight_set(ptarget, EINA_FALSE);
861 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
862 _access_obj_hilight_del_cb, NULL);
863 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
864 _access_obj_hilight_hide_cb, NULL);
865 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
866 _access_obj_hilight_move_cb, NULL);
867 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
868 _access_obj_hilight_resize_cb, NULL);
869 _access_action_callback_call(ptarget, ELM_ACCESS_ACTION_UNHIGHLIGHT, NULL);
872 evas_object_data_set(o, "_elm_access_target", obj);
873 elm_widget_parent_highlight_set(obj, EINA_TRUE);
875 elm_widget_theme_object_set(obj, o, "access", "base", "default");
877 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
878 _access_obj_hilight_del_cb, NULL);
879 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
880 _access_obj_hilight_hide_cb, NULL);
881 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
882 _access_obj_hilight_move_cb, NULL);
883 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
884 _access_obj_hilight_resize_cb, NULL);
885 evas_object_raise(o);
886 evas_object_geometry_get(obj, &x, &y, &w, &h);
887 evas_object_move(o, x, y);
888 evas_object_resize(o, w, h);
890 /* use callback, should an access object do below every time when
891 * a window gets a client message ECORE_X_ATOM_E_ILLMUE_ACTION_READ? */
892 a = calloc(1, sizeof(Elm_Access_Action_Info));
893 a->action_type = action_type;
894 if (!_access_action_callback_call(obj, ELM_ACCESS_ACTION_HIGHLIGHT, a))
902 _elm_access_object_unhilight(Evas_Object *obj)
904 Evas_Object *o, *ptarget;
906 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
908 ptarget = evas_object_data_get(o, "_elm_access_target");
911 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
912 _access_obj_hilight_del_cb, NULL);
913 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
914 _access_obj_hilight_hide_cb, NULL);
915 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
916 _access_obj_hilight_move_cb, NULL);
917 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
918 _access_obj_hilight_resize_cb, NULL);
920 elm_widget_parent_highlight_set(ptarget, EINA_FALSE);
921 _access_action_callback_call(ptarget, ELM_ACCESS_ACTION_UNHIGHLIGHT, NULL);
926 _content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj,
927 void *event_info __UNUSED__)
929 Evas_Object *accessobj;
933 if (!accessobj) return;
935 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
936 evas_object_resize(accessobj, w, h);
940 _content_move(void *data, Evas *e __UNUSED__, Evas_Object *obj,
941 void *event_info __UNUSED__)
943 Evas_Object *accessobj;
947 if (!accessobj) return;
949 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
950 evas_object_move(accessobj, x, y);
954 _access_object_register(Evas_Object *obj, Evas_Object *parent)
958 Evas_Coord x, y, w, h;
960 if (!obj) return NULL;
962 /* create access object */
963 ao = _elm_access_add(parent);
964 if (!ao) return NULL;
966 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
967 _content_resize, ao);
968 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
971 evas_object_geometry_get(obj, &x, &y, &w, &h);
972 evas_object_move(ao, x, y);
973 evas_object_resize(ao, w, h);
974 evas_object_show(ao);
976 /* register access object */
977 _elm_access_object_register(ao, obj);
979 /* set access object */
980 evas_object_data_set(obj, "_part_access_obj", ao);
982 /* set owner part object */
983 ac = evas_object_data_get(ao, "_elm_access");
984 ac->part_object = obj;
990 _access_object_unregister(Evas_Object *obj)
997 ao = evas_object_data_get(obj, "_part_access_obj");
1001 evas_object_data_del(obj, "_part_access_obj");
1003 /* delete callbacks */
1004 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1005 _content_resize, ao);
1006 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1009 /* unregister access object */
1010 _elm_access_object_unregister(ao, obj);
1012 evas_object_del(ao);
1016 /* button, check, label etc. */
1017 ac = evas_object_data_get(obj, "_elm_access");
1018 if (ac && ac->hoverobj)
1019 _elm_access_object_unregister(obj, ac->hoverobj);
1024 _elm_access_edje_object_part_object_register(Evas_Object* obj,
1025 const Evas_Object *eobj,
1028 Evas_Object *ao, *po;
1030 po = (Evas_Object *)edje_object_part_object_get(eobj, part);
1031 if (!obj || !po) return NULL;
1033 /* check previous access object */
1034 ao = evas_object_data_get(po, "_part_access_obj");
1036 _elm_access_edje_object_part_object_unregister(obj, eobj, part);
1038 ao = _access_object_register(po, obj);
1043 //FIXME: unused obj should be removed from here and each widget.
1045 _elm_access_edje_object_part_object_unregister(Evas_Object* obj __UNUSED__,
1046 const Evas_Object *eobj,
1051 po = (Evas_Object *)edje_object_part_object_get(eobj, part);
1054 _access_object_unregister(po);
1058 _elm_access_object_hilight_disable(Evas *e)
1060 Evas_Object *o, *ptarget;
1062 o = evas_object_name_find(e, "_elm_access_disp");
1064 ptarget = evas_object_data_get(o, "_elm_access_target");
1067 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
1068 _access_obj_hilight_del_cb, NULL);
1069 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
1070 _access_obj_hilight_hide_cb, NULL);
1071 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
1072 _access_obj_hilight_move_cb, NULL);
1073 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
1074 _access_obj_hilight_resize_cb, NULL);
1077 elm_widget_parent_highlight_set(ptarget, EINA_FALSE);
1081 _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj)
1083 Elm_Access_Info *ac;
1085 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_IN,
1086 _access_obj_mouse_in_cb, obj);
1087 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_OUT,
1088 _access_obj_mouse_out_cb, obj);
1089 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_DEL,
1090 _access_obj_del_cb, obj);
1091 ac = calloc(1, sizeof(Elm_Access_Info));
1092 evas_object_data_set(obj, "_elm_access", ac);
1094 ac->hoverobj = hoverobj;
1098 _elm_access_object_unregister(Evas_Object *obj, Evas_Object *hoverobj)
1100 Elm_Access_Info *ac;
1102 evas_object_event_callback_del_full(hoverobj, EVAS_CALLBACK_MOUSE_IN,
1103 _access_obj_mouse_in_cb, obj);
1104 evas_object_event_callback_del_full(hoverobj, EVAS_CALLBACK_MOUSE_OUT,
1105 _access_obj_mouse_out_cb, obj);
1106 evas_object_event_callback_del_full(hoverobj, EVAS_CALLBACK_DEL,
1107 _access_obj_del_cb, obj);
1109 ac = evas_object_data_get(obj, "_elm_access");
1110 evas_object_data_del(obj, "_elm_access");
1113 _elm_access_clear(ac);
1118 a = evas_object_data_get(obj, "_elm_access_action_info");
1123 _elm_access_widget_item_register(Elm_Widget_Item *item)
1125 Evas_Object *ao, *ho;
1126 Evas_Coord x, y, w, h;
1127 Elm_Access_Info *ac;
1129 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1131 /* check previous access object */
1132 if (item->access_obj)
1133 _elm_access_widget_item_unregister(item);
1135 // create access object
1137 ao = _elm_access_add(item->widget);
1140 evas_object_event_callback_add(ho, EVAS_CALLBACK_RESIZE,
1141 _content_resize, ao);
1142 evas_object_event_callback_add(ho, EVAS_CALLBACK_MOVE,
1145 evas_object_geometry_get(ho, &x, &y, &w, &h);
1146 evas_object_move(ao, x, y);
1147 evas_object_resize(ao, w, h);
1148 evas_object_show(ao);
1150 // register access object
1151 _elm_access_object_register(ao, ho);
1153 item->access_obj = ao;
1155 /* set owner widget item */
1156 ac = evas_object_data_get(ao, "_elm_access");
1157 ac->widget_item = item;
1161 _elm_access_widget_item_unregister(Elm_Widget_Item *item)
1165 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1167 if (!item->access_obj) return;
1170 evas_object_event_callback_del_full(ho, EVAS_CALLBACK_RESIZE,
1171 _content_resize, item->access_obj);
1172 evas_object_event_callback_del_full(ho, EVAS_CALLBACK_MOVE,
1173 _content_move, item->access_obj);
1175 _elm_access_object_unregister(item->access_obj, ho);
1177 evas_object_del(item->access_obj);
1178 item->access_obj = NULL;
1182 _elm_access_2nd_click_timeout(Evas_Object *obj)
1186 t = evas_object_data_get(obj, "_elm_2nd_timeout");
1190 evas_object_data_del(obj, "_elm_2nd_timeout");
1191 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1192 _access_2nd_click_del_cb, NULL);
1195 t = ecore_timer_add(0.3, _access_2nd_click_timeout_cb, obj);
1196 evas_object_data_set(obj, "_elm_2nd_timeout", t);
1197 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1198 _access_2nd_click_del_cb, NULL);
1202 static Evas_Object *
1203 _elm_access_add(Evas_Object *parent)
1207 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
1209 obj = elm_widget_add(_elm_access_smart_class_new(), parent);
1210 if (!obj) return NULL;
1212 if (!elm_widget_sub_object_add(parent, obj))
1213 ERR("could not add %p as sub object of %p", obj, parent);
1219 elm_access_object_register(Evas_Object *obj, Evas_Object *parent)
1221 return _access_object_register(obj, parent);
1225 elm_access_object_unregister(Evas_Object *obj)
1227 _access_object_unregister(obj);
1231 elm_access_object_get(const Evas_Object *obj)
1233 return evas_object_data_get(obj, "_part_access_obj");
1237 elm_access_info_set(Evas_Object *obj, int type, const char *text)
1239 _elm_access_text_set(_elm_access_object_get(obj), type, text);
1243 elm_access_info_get(const Evas_Object *obj, int type)
1245 return _elm_access_text_get(_elm_access_object_get(obj), type, obj);
1249 elm_access_info_cb_set(Evas_Object *obj, int type,
1250 Elm_Access_Info_Cb func, const void *data)
1252 _elm_access_callback_set(_elm_access_object_get(obj), type, func, data);
1256 elm_access_activate_cb_set(Evas_Object *obj,
1257 Elm_Access_Activate_Cb func, void *data)
1259 Elm_Access_Info *ac;
1261 ac = _elm_access_object_get(obj);
1264 ac->activate = func;
1265 ac->activate_data = data;
1269 elm_access_say(const char *text)
1273 _elm_access_say(text);
1277 elm_access_highlight_set(Evas_Object* obj)
1279 _elm_access_highlight_set(obj);
1283 elm_access_action(Evas_Object *obj, const Elm_Access_Action_Type type, void *action_info)
1287 Elm_Access_Action_Info *a;
1289 a = (Elm_Access_Action_Info *) action_info;
1293 case ELM_ACCESS_ACTION_READ:
1294 case ELM_ACCESS_ACTION_HIGHLIGHT:
1295 evas = evas_object_evas_get(obj);
1296 if (!evas) return EINA_FALSE;
1298 _elm_access_mouse_event_enabled_set(EINA_TRUE);
1300 evas_event_feed_mouse_in(evas, 0, NULL);
1301 evas_event_feed_mouse_move(evas, a->x, a->y, 0, NULL);
1302 _elm_access_mouse_event_enabled_set(EINA_FALSE);
1304 ho = _access_highlight_object_get(obj);
1306 _access_action_callback_call(ho, ELM_ACCESS_ACTION_READ, a);
1309 case ELM_ACCESS_ACTION_UNHIGHLIGHT:
1312 case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
1313 if (a->highlight_cycle)
1314 _elm_access_highlight_cycle(obj, ELM_FOCUS_NEXT);
1316 return _access_highlight_next_get(obj, ELM_FOCUS_NEXT);
1319 case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
1320 if (a->highlight_cycle)
1321 _elm_access_highlight_cycle(obj, ELM_FOCUS_PREVIOUS);
1323 return _access_highlight_next_get(obj, ELM_FOCUS_PREVIOUS);
1326 case ELM_ACCESS_ACTION_ACTIVATE:
1327 _elm_access_highlight_object_activate(obj, ELM_ACTIVATE_DEFAULT);
1330 case ELM_ACCESS_ACTION_VALUE_CHANGE:
1331 _elm_access_highlight_object_activate(obj, ELM_ACTIVATE_UP);
1334 case ELM_ACCESS_ACTION_SCROLL:
1335 _elm_access_highlight_object_scroll(obj, a->mouse_type, a->x, a->y);
1338 case ELM_ACCESS_ACTION_BACK:
1349 elm_access_action_cb_set(Evas_Object *obj, const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data)
1352 a = evas_object_data_get(obj, "_elm_access_action_info");
1356 a = calloc(1, sizeof(Action_Info));
1357 evas_object_data_set(obj, "_elm_access_action_info", a);
1361 a->fn[type].cb = cb;
1362 a->fn[type].user_data = (void *)data;
1366 elm_access_external_info_set(Evas_Object *obj, const char *text)
1368 _elm_access_text_set
1369 (_elm_access_object_get(obj), ELM_ACCESS_CONTEXT_INFO, text);
1373 elm_access_external_info_get(const Evas_Object *obj)
1375 Elm_Access_Info *ac;
1377 ac = _elm_access_object_get(obj);
1378 return _elm_access_text_get(ac, ELM_ACCESS_CONTEXT_INFO, obj);