1 #include <Elementary.h>
4 typedef struct _Mod_Api Mod_Api;
8 void (*out_read) (const char *txt);
9 void (*out_read_done) (void);
10 void (*out_cancel) (void);
11 void (*out_done_callback_set) (void (*func) (void *data), const void *data);
14 static int initted = 0;
15 static Mod_Api *mapi = NULL;
22 if (initted > 1) return;
23 if (!(m = _elm_module_find_as("access/api"))) return;
24 m->api = malloc(sizeof(Mod_Api));
27 ((Mod_Api *)(m->api) )->out_read = // called to read out some text
28 _elm_module_symbol_get(m, "out_read");
29 ((Mod_Api *)(m->api) )->out_read_done = // called to set a done marker so when it is reached the done callback is called
30 _elm_module_symbol_get(m, "out_read_done");
31 ((Mod_Api *)(m->api) )->out_cancel = // called to read out some text
32 _elm_module_symbol_get(m, "out_cancel");
33 ((Mod_Api *)(m->api) )->out_done_callback_set = // called when last read done
34 _elm_module_symbol_get(m, "out_done_callback_set");
38 static Elm_Access_Item *
39 _access_add_set(Elm_Access_Info *ac, int type)
45 EINA_LIST_FOREACH(ac->items, l, ai)
51 if (ai->data) eina_stringshare_del(ai->data);
58 ai = calloc(1, sizeof(Elm_Access_Item));
60 ac->items = eina_list_prepend(ac->items, ai);
65 _access_obj_over_timeout_cb(void *data)
67 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
68 if (!ac) return EINA_FALSE;
69 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
71 _elm_access_object_hilight(data);
72 _elm_access_read(ac, ELM_ACCESS_CANCEL, data, NULL);
73 _elm_access_read(ac, ELM_ACCESS_TYPE, data, NULL);
74 _elm_access_read(ac, ELM_ACCESS_INFO, data, NULL);
75 _elm_access_read(ac, ELM_ACCESS_STATE, data, NULL);
76 _elm_access_read(ac, ELM_ACCESS_DONE, data, NULL);
78 ac->delay_timer = NULL;
83 _access_obj_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
85 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
90 ecore_timer_del(ac->delay_timer);
91 ac->delay_timer = NULL;
93 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
94 ac->delay_timer = ecore_timer_add(0.2, _access_obj_over_timeout_cb, data);
98 _access_obj_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
100 Elm_Access_Info *ac = evas_object_data_get(data, "_elm_access");
102 _elm_access_object_unhilight(data);
105 ecore_timer_del(ac->delay_timer);
106 ac->delay_timer = NULL;
111 _access_obj_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
115 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,
116 _access_obj_mouse_in_cb, data);
117 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_OUT,
118 _access_obj_mouse_out_cb, data);
119 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
120 _access_obj_del_cb, data);
121 ac = evas_object_data_get(data, "_elm_access");
122 evas_object_data_del(data, "_elm_access");
125 _elm_access_clear(ac);
131 _access_read_done(void *data __UNUSED__)
133 printf("read done\n");
134 // FIXME: produce event here
138 _access_2nd_click_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
142 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
143 _access_2nd_click_del_cb, NULL);
144 t = evas_object_data_get(obj, "_elm_2nd_timeout");
148 evas_object_data_del(obj, "_elm_2nd_timeout");
153 _access_2nd_click_timeout_cb(void *data)
155 evas_object_event_callback_del_full(data, EVAS_CALLBACK_DEL,
156 _access_2nd_click_del_cb, NULL);
157 evas_object_data_del(data, "_elm_2nd_timeout");
162 _access_obj_hilight_del_cb(void *data __UNUSED__, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
164 _elm_access_object_hilight_disable(e);
168 _access_obj_hilight_hide_cb(void *data __UNUSED__, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
170 _elm_access_object_hilight_disable(e);
174 _access_obj_hilight_move_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
179 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
181 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
182 evas_object_move(o, x, y);
186 _access_obj_hilight_resize_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
191 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
193 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
194 evas_object_resize(o, w, h);
199 //-------------------------------------------------------------------------//
202 _elm_access_clear(Elm_Access_Info *ac)
209 ecore_timer_del(ac->delay_timer);
210 ac->delay_timer = NULL;
212 EINA_LIST_FREE(ac->items, ai)
216 if (ai->data) eina_stringshare_del(ai->data);
223 _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text)
225 Elm_Access_Item *ai = _access_add_set(ac, type);
227 ai->data = eina_stringshare_add(text);
231 _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Content_Cb func, const void *data)
233 Elm_Access_Item *ai = _access_add_set(ac, type);
240 _elm_access_text_get(const Elm_Access_Info *ac, int type, Evas_Object *obj, Elm_Widget_Item *item)
245 if (!ac) return NULL;
246 EINA_LIST_FOREACH(ac->items, l, ai)
248 if (ai->type == type)
250 if (ai->func) return ai->func((void *)(ai->data), obj, item);
251 else if (ai->data) return strdup(ai->data);
259 _elm_access_read(Elm_Access_Info *ac, int type, Evas_Object *obj, Elm_Widget_Item *item)
261 char *txt = _elm_access_text_get(ac, type, obj, item);
266 if (mapi->out_done_callback_set)
267 mapi->out_done_callback_set(_access_read_done, NULL);
268 if (type == ELM_ACCESS_DONE)
270 if (mapi->out_read_done) mapi->out_read_done();
272 else if (type == ELM_ACCESS_CANCEL)
274 if (mapi->out_cancel) mapi->out_cancel();
280 if (mapi->out_read) mapi->out_read(txt);
281 if (mapi->out_read) mapi->out_read(".\n");
289 _elm_access_say(const char *txt)
294 if (mapi->out_done_callback_set)
295 mapi->out_done_callback_set(_access_read_done, NULL);
296 if (mapi->out_cancel) mapi->out_cancel();
299 if (mapi->out_read) mapi->out_read(txt);
300 if (mapi->out_read) mapi->out_read(".\n");
302 if (mapi->out_read_done) mapi->out_read_done();
306 EAPI Elm_Access_Info *
307 _elm_access_object_get(const Evas_Object *obj)
309 return evas_object_data_get(obj, "_elm_access");
312 EAPI Elm_Access_Info *
313 _elm_access_item_get(const Elm_Widget_Item *it)
319 _elm_access_object_hilight(Evas_Object *obj)
322 Evas_Coord x, y, w, h;
324 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
327 o = edje_object_add(evas_object_evas_get(obj));
328 evas_object_name_set(o, "_elm_access_disp");
329 evas_object_layer_set(o, ELM_OBJECT_LAYER_TOOLTIP);
333 Evas_Object *ptarget = evas_object_data_get(o, "_elm_access_target");
336 evas_object_data_del(o, "_elm_access_target");
337 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
338 _access_obj_hilight_del_cb, NULL);
339 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
340 _access_obj_hilight_hide_cb, NULL);
341 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
342 _access_obj_hilight_move_cb, NULL);
343 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
344 _access_obj_hilight_resize_cb, NULL);
347 evas_object_data_set(o, "_elm_access_target", obj);
348 _elm_theme_object_set(obj, o, "access", "base", "default");
349 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
350 _access_obj_hilight_del_cb, NULL);
351 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
352 _access_obj_hilight_hide_cb, NULL);
353 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
354 _access_obj_hilight_move_cb, NULL);
355 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
356 _access_obj_hilight_resize_cb, NULL);
357 evas_object_raise(o);
358 evas_object_geometry_get(obj, &x, &y, &w, &h);
359 evas_object_move(o, x, y);
360 evas_object_resize(o, w, h);
365 _elm_access_object_unhilight(Evas_Object *obj)
367 Evas_Object *o, *ptarget;
369 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
371 ptarget = evas_object_data_get(o, "_elm_access_target");
374 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
375 _access_obj_hilight_del_cb, NULL);
376 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
377 _access_obj_hilight_hide_cb, NULL);
378 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
379 _access_obj_hilight_move_cb, NULL);
380 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
381 _access_obj_hilight_resize_cb, NULL);
387 _elm_access_object_hilight_disable(Evas *e)
389 Evas_Object *o, *ptarget;
391 o = evas_object_name_find(e, "_elm_access_disp");
393 ptarget = evas_object_data_get(o, "_elm_access_target");
396 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_DEL,
397 _access_obj_hilight_del_cb, NULL);
398 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_HIDE,
399 _access_obj_hilight_hide_cb, NULL);
400 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_MOVE,
401 _access_obj_hilight_move_cb, NULL);
402 evas_object_event_callback_del_full(ptarget, EVAS_CALLBACK_RESIZE,
403 _access_obj_hilight_resize_cb, NULL);
409 _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj)
413 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_IN,
414 _access_obj_mouse_in_cb, obj);
415 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_OUT,
416 _access_obj_mouse_out_cb, obj);
417 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_DEL,
418 _access_obj_del_cb, obj);
419 ac = calloc(1, sizeof(Elm_Access_Info));
420 evas_object_data_set(obj, "_elm_access", ac);
424 _access_item_over_timeout_cb(void *data)
426 Elm_Access_Info *ac = ((Elm_Widget_Item *)data)->access;
427 if (!ac) return EINA_FALSE;
428 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
430 _elm_access_object_hilight(((Elm_Widget_Item *)data)->view);
431 _elm_access_read(ac, ELM_ACCESS_CANCEL, NULL, data);
432 _elm_access_read(ac, ELM_ACCESS_TYPE, NULL, data);
433 _elm_access_read(ac, ELM_ACCESS_INFO, NULL, data);
434 _elm_access_read(ac, ELM_ACCESS_STATE, NULL, data);
435 _elm_access_read(ac, ELM_ACCESS_DONE, NULL, data);
437 ac->delay_timer = NULL;
442 _access_item_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
444 Elm_Access_Info *ac = ((Elm_Widget_Item *)data)->access;
449 ecore_timer_del(ac->delay_timer);
450 ac->delay_timer = NULL;
452 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
453 ac->delay_timer = ecore_timer_add(0.2, _access_item_over_timeout_cb, data);
457 _access_item_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
459 Elm_Access_Info *ac = ((Elm_Widget_Item *)data)->access;
462 _elm_access_object_unhilight(((Elm_Widget_Item *)data)->view);
465 ecore_timer_del(ac->delay_timer);
466 ac->delay_timer = NULL;
470 static void _access_item_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__);
473 _elm_access_item_unregister(Elm_Widget_Item *item)
480 evas_object_event_callback_del_full(ac->hoverobj,
481 EVAS_CALLBACK_MOUSE_IN,
482 _access_item_mouse_in_cb, item);
483 evas_object_event_callback_del_full(ac->hoverobj,
484 EVAS_CALLBACK_MOUSE_OUT,
485 _access_item_mouse_out_cb, item);
486 evas_object_event_callback_del_full(ac->hoverobj,
488 _access_item_del_cb, item);
490 _elm_access_clear(ac);
496 _access_item_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
498 _elm_access_item_unregister((Elm_Widget_Item *)data);
502 _elm_access_item_register(Elm_Widget_Item *item, Evas_Object *hoverobj)
506 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_IN,
507 _access_item_mouse_in_cb, item);
508 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_MOUSE_OUT,
509 _access_item_mouse_out_cb, item);
510 evas_object_event_callback_add(hoverobj, EVAS_CALLBACK_DEL,
511 _access_item_del_cb, item);
512 ac = calloc(1, sizeof(Elm_Access_Info));
513 ac->hoverobj = hoverobj;
518 _elm_access_2nd_click_timeout(Evas_Object *obj)
522 t = evas_object_data_get(obj, "_elm_2nd_timeout");
526 evas_object_data_del(obj, "_elm_2nd_timeout");
527 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
528 _access_2nd_click_del_cb, NULL);
531 t = ecore_timer_add(0.3, _access_2nd_click_timeout_cb, obj);
532 evas_object_data_set(obj, "_elm_2nd_timeout", t);
533 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
534 _access_2nd_click_del_cb, NULL);