summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/lib/elm_access.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-06-26 05:54:45 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-06-26 05:54:45 +0000
commitd78b70af51461cd22e3627ffe3b4ed65c6f4d3e2 (patch)
treed2dfeb94f45d7a942041b38f1d3566112374677f /legacy/elementary/src/lib/elm_access.c
parentb5e474ebb150be9e8002f91f02d4a67692326dac (diff)
elementary: use Edje to enable accessibility on TEXTBLOCK.
Patch by Kim Shinwoo <kimcinoo.efl@gmail.com>. SVN revision: 72841
Diffstat (limited to 'legacy/elementary/src/lib/elm_access.c')
-rw-r--r--legacy/elementary/src/lib/elm_access.c148
1 files changed, 148 insertions, 0 deletions
diff --git a/legacy/elementary/src/lib/elm_access.c b/legacy/elementary/src/lib/elm_access.c
index 4ea5582..eb7605d 100644
--- a/legacy/elementary/src/lib/elm_access.c
+++ b/legacy/elementary/src/lib/elm_access.c
@@ -1,6 +1,44 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#include "elm_priv.h" 2#include "elm_priv.h"
3 3
4static const char ACCESS_SMART_NAME[] = "elm_access";
5
6EVAS_SMART_SUBCLASS_NEW
7 (ACCESS_SMART_NAME, _elm_access, Elm_Widget_Smart_Class,
8 Elm_Widget_Smart_Class, elm_widget_smart_class_get, NULL);
9
10static Evas_Object * _elm_access_add(Evas_Object *parent);
11
12static void
13_elm_access_smart_add(Evas_Object *obj)
14{
15 EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data);
16 ELM_WIDGET_CLASS(_elm_access_parent_sc)->base.add(obj);
17
18 elm_widget_can_focus_set(obj, EINA_TRUE);
19}
20
21static Eina_Bool
22_elm_access_smart_on_focus(Evas_Object *obj)
23{
24 evas_object_focus_set(obj, elm_widget_focus_get(obj));
25
26 return EINA_TRUE;
27}
28
29static void
30_elm_access_smart_set_user(Elm_Widget_Smart_Class *sc)
31{
32 sc->base.add = _elm_access_smart_add;
33
34 /* not a 'focus chain manager' */
35 sc->focus_next = NULL;
36 sc->focus_direction = NULL;
37 sc->on_focus = _elm_access_smart_on_focus;
38
39 return;
40}
41
4typedef struct _Mod_Api Mod_Api; 42typedef struct _Mod_Api Mod_Api;
5 43
6struct _Mod_Api 44struct _Mod_Api
@@ -197,6 +235,11 @@ _access_obj_hilight_resize_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Ob
197 235
198 236
199//-------------------------------------------------------------------------// 237//-------------------------------------------------------------------------//
238EAPI void
239_elm_access_highlight_set(Evas_Object* obj)
240{
241 _access_obj_over_timeout_cb(obj);
242}
200 243
201EAPI void 244EAPI void
202_elm_access_clear(Elm_Access_Info *ac) 245_elm_access_clear(Elm_Access_Info *ac)
@@ -383,6 +426,92 @@ _elm_access_object_unhilight(Evas_Object *obj)
383 } 426 }
384} 427}
385 428
429static void
430_content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj,
431 void *event_info __UNUSED__)
432{
433 Evas_Object *accessobj;
434 Evas_Coord w, h;
435
436 accessobj = data;
437 if (!accessobj) return;
438
439 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
440 evas_object_resize(accessobj, w, h);
441}
442
443static void
444_content_move(void *data, Evas *e __UNUSED__, Evas_Object *obj,
445 void *event_info __UNUSED__)
446{
447 Evas_Object *accessobj;
448 Evas_Coord x, y;
449
450 accessobj = data;
451 if (!accessobj) return;
452
453 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
454 evas_object_move(accessobj, x, y);
455}
456
457static char *
458_part_access_info_cb(void *data, Evas_Object *obj,
459 Elm_Widget_Item *item __UNUSED__)
460{
461 Evas_Object *eobj = data;
462 if (!eobj) return NULL;
463
464 const char *part = evas_object_data_get(obj, "_elm_access_part");
465 const char *txt = edje_object_part_text_get(eobj, part);
466 if (txt) return strdup(txt);
467 return NULL;
468}
469
470static void
471_access_obj_del(void *data __UNUSED__, Evas *e __UNUSED__,
472 Evas_Object *obj, void *event_info __UNUSED__)
473{
474 char *part = evas_object_data_get(obj, "_elm_access_part");
475 evas_object_data_del(obj, "_elm_access_part");
476 if (part) free(part);
477}
478
479EAPI Evas_Object *
480_elm_access_edje_object_part_object_register(Evas_Object* obj,
481 const Evas_Object *eobj,
482 const char* part)
483{
484 Evas_Object *ao;
485 Evas_Object *po = (Evas_Object *)edje_object_part_object_get(eobj, part);
486 Evas_Coord x, y, w, h;
487
488 if (!obj || !po) return NULL;
489
490 // create access object
491 ao = _elm_access_add(obj);
492 evas_object_event_callback_add(po, EVAS_CALLBACK_RESIZE,
493 _content_resize, ao);
494 evas_object_event_callback_add(po, EVAS_CALLBACK_MOVE,
495 _content_move, ao);
496
497 evas_object_geometry_get(po, &x, &y, &w, &h);
498 evas_object_move(ao, x, y);
499 evas_object_resize(ao, w, h);
500 evas_object_show(ao);
501
502 // register access object
503 _elm_access_object_register(ao, po);
504 _elm_access_text_set(_elm_access_object_get(ao),
505 ELM_ACCESS_TYPE, evas_object_type_get(po));
506 evas_object_data_set(ao, "_elm_access_part", strdup(part));
507 evas_object_event_callback_add(ao, EVAS_CALLBACK_DEL,
508 _access_obj_del, NULL);
509 _elm_access_callback_set(_elm_access_object_get(ao),
510 ELM_ACCESS_INFO,
511 _part_access_info_cb, eobj);
512 return ao;
513}
514
386EAPI void 515EAPI void
387_elm_access_object_hilight_disable(Evas *e) 516_elm_access_object_hilight_disable(Evas *e)
388{ 517{
@@ -534,3 +663,22 @@ _elm_access_2nd_click_timeout(Evas_Object *obj)
534 _access_2nd_click_del_cb, NULL); 663 _access_2nd_click_del_cb, NULL);
535 return EINA_FALSE; 664 return EINA_FALSE;
536} 665}
666
667static Evas_Object *
668_elm_access_add(Evas_Object *parent)
669{
670 Evas *e;
671 Evas_Object *obj;
672
673 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
674
675 e = evas_object_evas_get(parent);
676 if (!e) return NULL;
677
678 obj = evas_object_smart_add(e, _elm_access_smart_class_new());
679
680 if (!elm_widget_sub_object_add(parent, obj))
681 ERR("could not add %p as sub object of %p", obj, parent);
682
683 return obj;
684}