[access] call a callback function with information
[framework/uifw/elementary.git] / src / lib / elm_access.h
1 /**
2  * @defgroup Access Access
3  * @ingroup Elementary
4  *
5  * TODO: description
6  *
7  */
8
9 enum _Elm_Access_Info_Type
10 {
11    ELM_ACCESS_INFO_FIRST = -1,
12    ELM_ACCESS_INFO,         /* next read is info - this is
13                              * normally label */
14    ELM_ACCESS_TYPE,         /* when reading out widget or item
15                              * this is read first */
16    ELM_ACCESS_STATE,        /* if there is a state (eg checkbox)
17                              * then read state out */
18    ELM_ACCESS_CONTEXT_INFO, /* to give contextual information */
19    ELM_ACCESS_INFO_LAST
20 };
21
22 /**
23  * @typedef Elm_Access_Info_Type
24  */
25 typedef enum _Elm_Access_Info_Type Elm_Access_Info_Type;
26
27 typedef char *(*Elm_Access_Info_Cb)(void *data, Evas_Object *obj);
28 typedef void (*Elm_Access_Activate_Cb)(void *data, Evas_Object *part_obj, Elm_Object_Item *item);
29
30 /**
31  * @typedef Elm_Access_Action_Cb
32  * User callback to make access object do specific action
33  * @param data user data
34  * @param action_info information to classify the action
35  * Returns EINA_TRUE on success, EINA FALSE otherwise
36  *
37  */
38 typedef Eina_Bool (*Elm_Access_Action_Cb)(void *data, Evas_Object *obj, void *action_info);
39
40 /**
41  * @enum _Elm_Access_Action_Type
42  * Enum of supported access action types.
43  */
44 enum _Elm_Access_Action_Type
45 {
46    ELM_ACCESS_ACTION_FIRST = -1,
47
48    ELM_ACCESS_ACTION_HIGHLIGHT, /* highlight an object */
49    ELM_ACCESS_ACTION_UNHIGHLIGHT, /* unhighlight an object */
50    ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, /* set highlight to next object */
51    ELM_ACCESS_ACTION_HIGHLIGHT_PREV, /* set highlight to previous object */
52    ELM_ACCESS_ACTION_ACTIVATE, /* activate a highlight object */
53    ELM_ACCESS_ACTION_VALUE_CHANGE, /* change value of highlight object */
54    ELM_ACCESS_ACTION_SCROLL, /* scroll if one of highlight object parents
55                               * is scrollable */
56    ELM_ACCESS_ACTION_BACK, /* go back to a previous view
57                               ex: pop naviframe item */
58    ELM_ACCESS_ACTION_READ, /* highlight an object */
59
60    ELM_ACCESS_ACTION_LAST
61 };
62
63 /**
64  * @typedef Elm_Access_Action_Type
65  */
66 typedef enum _Elm_Access_Action_Type Elm_Access_Action_Type;
67
68 struct _Elm_Access_Action_Info
69 {
70    Evas_Coord   x;
71    Evas_Coord   y;
72
73    Elm_Access_Action_Type action_type;
74    Eina_Bool              highlight_cycle : 1;
75 };
76
77 typedef struct _Elm_Access_Action_Info Elm_Access_Action_Info;
78
79 /**
80  * @brief Register evas object as an accessible object.
81  * @since 1.8
82  *
83  * @param obj The evas object to register as an accessible object.
84  * @param parent The elementary object which is used for creating
85  * accessible object.
86  *
87  * @ingroup Access
88  */
89 EAPI Evas_Object *elm_access_object_register(Evas_Object *obj, Evas_Object *parent);
90
91 /**
92  * @brief Unregister accessible object.
93  * @since 1.8
94  *
95  * @param obj The Evas object to unregister accessible object.
96  *
97  * @ingroup Access
98  */
99 EAPI void elm_access_object_unregister(Evas_Object *obj);
100
101 /**
102  * @brief Get an accessible object of the evas object.
103  * @since 1.8
104  *
105  * @param obj The evas object.
106  * @return Accessible object of the evas object or NULL for any error
107  *
108  * @ingroup Access
109  */
110 EAPI Evas_Object *elm_access_object_get(const Evas_Object *obj);
111
112 /**
113  * @brief Set text to give information for specific type.
114  * @since 1.8
115  *
116  * @param obj Accessible object.
117  * @param type The type of content that will be read
118  * @param text The text information that will be read
119  *
120  * @see elm_access_info_cb_set
121  * @ingroup Access
122  */
123 EAPI void elm_access_info_set(Evas_Object *obj, int type, const char *text);
124
125 /**
126  * @brief Set text to give information for specific type.
127  * @since 1.8
128  *
129  * @param obj Accessible object.
130  * @param type The type of content that will be read
131  *
132  * @see elm_access_info_cb_set
133  * @ingroup Access
134  */
135 EAPI char *elm_access_info_get(const Evas_Object *obj, int type);
136
137 /**
138  * @brief Set content callback to give information for specific type.
139  * @since 1.8
140  *
141  * @param obj Accessible object.
142  * @param type The type of content that will be read
143  * @param func The function to be called when the content is read
144  * @param data The data pointer to be passed to @p func
145  *
146  * The type would be one of ELM_ACCESS_TYPE, ELM_ACCESS_INFO,
147  * ELM_ACCESS_STATE, ELM_ACCESS_CONTEXT_INFO.
148  *
149  * In the case of button widget, the content of ELM_ACCESS_TYPE would be
150  * "button". The label of button such as "ok", "cancel" is for ELM_ACCESS_INFO.
151  * If the button is disabled, content of ELM_ACCESS_STATE would be "disabled".
152  * And if there is contextual information, use ELM_ACCESS_CONTEXT_INFO.
153  *
154  * @ingroup Access
155  */
156 EAPI void elm_access_info_cb_set(Evas_Object *obj, int type, Elm_Access_Info_Cb func, const void *data);
157
158 /**
159  * @brief Set activate callback to activate highlight object.
160  * @since 1.8
161  *
162  * @param obj Accessible object.
163  * @param func The function to be called when the activate gesture is detected
164  * @param data The data pointer to be passed to @p func
165  *
166  * @ingroup Access
167  */
168 EAPI void elm_access_activate_cb_set(Evas_Object *obj, Elm_Access_Activate_Cb func, void *data);
169
170 /**
171  * @brief Read out text information directly.
172  * @since 1.8
173  *
174  * @param text The text information that will be read
175  *
176  * This function will not free the @p text internally.
177  *
178  * @ingroup Access
179  */
180 EAPI void elm_access_say(const char *text);
181
182 /**
183  * @brief Give the highlight to the object directly.
184  * @since 1.8
185  *
186  * @param obj The object that will have the highlight and its information be read.
187  *
188  * The object should be an elementary object or an access object.
189  *
190  * @see elm_access_object_get
191  * @ingroup Access
192  */
193 EAPI void elm_access_highlight_set(Evas_Object* obj);
194
195 EAPI Eina_Bool elm_access_action(Evas_Object *obj, const Elm_Access_Action_Type type, void *action_info);
196
197 EAPI void elm_access_action_cb_set(Evas_Object *obj, const Elm_Access_Action_Type type, const Elm_Access_Action_Cb cb, const void *data);
198 //TODO: remvoe below - use elm_access_text_set(); or elm_access_cb_set();
199 EINA_DEPRECATED EAPI void elm_access_external_info_set(Evas_Object *obj, const char *text);
200 EINA_DEPRECATED EAPI char *elm_access_external_info_get(const Evas_Object *obj);