[accessability] Initial merge
[framework/uifw/elementary.git] / src / lib / elm_widget.h
1 #ifndef ELM_WIDGET_H
2 #define ELM_WIDGET_H
3
4 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
5  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
6  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK IT
7  * AT RUNTIME
8  *
9  * How to make your own widget? like this:
10  *
11  * #include <Elementary.h>
12  * #include "elm_priv.h"
13  *
14  * typedef struct _Widget_Data Widget_Data;
15  *
16  * struct _Widget_Data
17  * {
18  *   Evas_Object *sub;
19  *   // add any other widget data here too
20  * };
21  *
22  * static const char *widtype = NULL;
23  * static void _del_hook(Evas_Object *obj);
24  * static void _theme_hook(Evas_Object *obj);
25  * static void _disable_hook(Evas_Object *obj);
26  * static void _sizing_eval(Evas_Object *obj);
27  * static void _on_focus_hook(void *data, Evas_Object *obj);
28  *
29  * static const char SIG_CLICKED[] = "clicked";
30  * static const Evas_Smart_Cb_Description _signals[] = {
31  *   {SIG_CLICKED, ""},
32  *   {NULL, NULL}
33  * };
34  *
35  * static void
36  * _del_hook(Evas_Object *obj)
37  * {
38  *    Widget_Data *wd = elm_widget_data_get(obj);
39  *    if (!wd) return;
40  *    // delete hook - on delete of object delete object struct etc.
41  *    free(wd);
42  * }
43  *
44  * static void
45  * _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
46  * {
47  *    Widget_Data *wd = elm_widget_data_get(obj);
48  *    if (!wd) return;
49  *    // handle focus going in and out - optional, but if you want to, set
50  *    // this hook and handle it (eg emit a signal to an edje obj)
51  *    if (elm_widget_focus_get(obj))
52  *      {
53  *         edje_object_signal_emit(wd->sub, "elm,action,focus", "elm");
54  *         evas_object_focus_set(wd->sub, EINA_TRUE);
55  *      }
56  *    else
57  *      {
58  *         edje_object_signal_emit(wd->sub, "elm,action,unfocus", "elm");
59  *         evas_object_focus_set(wd->sub, EINA_FALSE);
60  *      }
61  * }
62  *
63  * static void
64  * _theme_hook(Evas_Object *obj)
65  * {
66  *    Widget_Data *wd = elm_widget_data_get(obj);
67  *    if (!wd) return;
68  *    // handle change in theme/scale etc.
69  *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base",
70  *                                elm_widget_style_get(obj));
71  * }
72  *
73  * static void
74  * _disable_hook(Evas_Object *obj)
75  * {
76  *    Widget_Data *wd = elm_widget_data_get(obj);
77  *    if (!wd) return;
78  *    // optional, but handle if the widget gets disabled or not
79  *    if (elm_widget_disabled_get(obj))
80  *      edje_object_signal_emit(wd->sub, "elm,state,disabled", "elm");
81  *    else
82  *      edje_object_signal_emit(wd->sub, "elm,state,enabled", "elm");
83  * }
84  *
85  * static void
86  * _sizing_eval(Evas_Object *obj)
87  * {
88  *    Widget_Data *wd = elm_widget_data_get(obj);
89  *    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
90  *    if (!wd) return;
91  *    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
92  *    edje_object_size_min_restricted_calc(wd->sub, &minw, &minh, minw, minh);
93  *    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
94  *    evas_object_size_hint_min_set(obj, minw, minh);
95  *    evas_object_size_hint_max_set(obj, maxw, maxh);
96  * }
97  *
98  * // actual api to create your widget. add more to manipulate it as needed
99  * // mark your calls with EAPI to make them "external api" calls.
100  * EAPI Evas_Object *
101  * elm_mywidget_add(Evas_Object *parent)
102  * {
103  *    Evas_Object *obj;
104  *    Evas *e;
105  *    Widget_Data *wd;
106  *
107  *    // ALWAYS call this - this checks that your widget matches that of
108  *    // elementary and that the api hasn't broken. if it has this returns
109  *    // false and you need to handle this error gracefully
110  *    if (!elm_widget_api_check(ELM_INTERNAL_API_VERSION)) return NULL;
111  *
112  *    // standard widget setup and allocate wd, create obj given parent etc.
113  *    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
114  *
115  *    // give it a type name and set up a mywidget type string if needed
116  *    ELM_SET_WIDTYPE(widtype, "mywidget");
117  *    elm_widget_type_set(obj, "mywidget");
118  *    // tell the parent widget that we are a sub object
119  *    elm_widget_sub_object_add(parent, obj);
120  *    // setup hooks we need (some are optional)
121  *    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
122  *    elm_widget_data_set(obj, wd);
123  *    elm_widget_del_hook_set(obj, _del_hook);
124  *    elm_widget_theme_hook_set(obj, _theme_hook);
125  *    elm_widget_disable_hook_set(obj, _disable_hook);
126  *    // this widget can focus (true means yes it can, false means it can't)
127  *    elm_widget_can_focus_set(obj, EINA_TRUE);
128  *
129  *    // for this widget we will add 1 sub object that is an edje object
130  *    wd->sub = edje_object_add(e);
131  *    // set the theme. this follows a scheme for group name like this:
132  *    //   "elm/WIDGETNAME/ELEMENT/STYLE"
133  *    // so here it will be:
134  *    //   "elm/mywidget/base/default"
135  *    // changing style changes style name from default (all widgets start
136  *    // with the default style) and element is for your widget internal
137  *    // structure as you see fit
138  *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base", "default");
139  *    // listen to a signal from the edje object to produce widget smart
140  *    // callback (like click)
141  *    edje_object_signal_callback_add(wd->sub, "elm,action,click", "",
142  *                                    _signal_clicked, obj);
143  *    // set this sub object as the "resize object". widgets get 1 resize
144  *    // object that is resized along with the object wrapper.
145  *    elm_widget_resize_object_set(obj, wd->sub);
146  *
147  *    // evaluate sizing of the widget (minimum size calc etc.). optional but
148  *    // not a bad idea to do here. it will get queued for later anyway
149  *    _sizing_eval(obj);
150  *
151  *    // register the smart callback descriptions so we can have some runtime
152  *    // info as to what the smart callback strings mean
153  *    evas_object_smart_callbacks_descriptions_set(obj, _signals);
154  *    return obj;
155  * }
156  *
157  * // example - do "whatever" to the widget (here just emit a signal)
158  * EAPI void
159  * elm_mywidget_whatever(Evas_Object *obj)
160  * {
161  *    // check if type is correct - check will return if it fails
162  *    ELM_CHECK_WIDTYPE(obj, widtype);
163  *    // get widget data - type is correct and sane by this point, so this
164  *    // should never fail
165  *    Widget_Data *wd = elm_widget_data_get(obj);
166  *    // do whatever you like
167  *    edje_object_signal_emit(wd->sub, "elm,state,action,whatever", "elm");
168  * }
169  *
170  * // you can add more - you need to see elementary's code to know how to
171  * // handle all cases. remember this api is not stable and may change. it's
172  * // internal
173  *
174  */
175
176 #ifndef ELM_INTERNAL_API_ARGESFSDFEFC
177 # warning "You are using an internal elementary API. This API is not stable"
178 # warning "and is subject to change. You use this at your own risk."
179 # warning "Remember to call elm_widget_api_check(ELM_INTERNAL_API_VERSION);"
180 # warning "in your widgets before you call any other elm_widget calls to do"
181 # warning "a correct runtime version check. Also remember - you don't NEED"
182 # warning "to make an Elementary widget is almost ALL cases. You can easily"
183 # warning "make a smart object with Evas's API and do everything you need"
184 # warning "there. You only need a widget if you want to seamlessly be part"
185 # warning "of the focus tree and want to transparently become a container"
186 # warning "for any number of child Elementary widgets"
187 //# error "ERROR. Compile aborted." // Note : Do not merge this from upstream.
188 #endif
189 #define ELM_INTERNAL_API_VERSION 7000
190
191 typedef struct _Elm_Tooltip Elm_Tooltip;
192 typedef struct _Elm_Cursor Elm_Cursor;
193 typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */
194
195 typedef struct _Elm_Access_Info Elm_Access_Info; /**< accessibility information to be able to set and get from the access API */
196 typedef struct _Elm_Access_Item Elm_Access_Item; /**< accessibility info item */
197
198 typedef void (*Elm_Widget_On_Text_Set_Cb)(void *data, const char *part, const char *text);
199 typedef void (*Elm_Widget_On_Content_Set_Cb)(void *data, const char *part, Evas_Object *content);
200 typedef const char *(*Elm_Widget_On_Text_Get_Cb)(const void *data, const char *part);
201 typedef Evas_Object *(*Elm_Widget_On_Content_Get_Cb)(const void *data, const char *part);
202 typedef Evas_Object *(*Elm_Widget_On_Content_Unset_Cb)(const void *data, const char *part);
203 typedef void (*Elm_Widget_On_Signal_Emit_Cb)(void *data, const char *emission, const char *source);
204
205 #define ELM_ACCESS_TYPE     0 // when reading out widget or item this is read first
206 #define ELM_ACCESS_INFO     1 // next read is info - this is normally label
207 #define ELM_ACCESS_STATE    2 // if there is a state (eg checkbox) then read state out
208 #define ELM_ACCESS_CONTENT  3 // read ful content - eg all of the label, not a shortened version
209
210 #define ELM_ACCESS_DONE    -1 // sentence done - send done event here
211 #define ELM_ACCESS_CANCEL  -2 // stop reading immediately
212
213 typedef char *(*Elm_Access_Content_Cb)(const void *data, Evas_Object *obj, Elm_Widget_Item *item);
214
215 struct _Elm_Access_Item
216 {
217    int type;
218    const void *data;
219    Elm_Access_Content_Cb func;
220 };
221
222 struct _Elm_Access_Info
223 {
224    Eina_List *items;
225    Ecore_Timer *delay_timer;
226 };
227
228 EAPI void             _elm_access_clear(Elm_Access_Info *ac);
229 EAPI void             _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text);
230 EAPI void             _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Content_Cb func, const void *data);
231 EAPI char            *_elm_access_text_get(Elm_Access_Info *ac, int type,  Evas_Object *obj, Elm_Widget_Item *item);
232 EAPI void             _elm_access_read(Elm_Access_Info *ac, int type, Evas_Object *obj, Elm_Widget_Item *item);
233 EAPI Elm_Access_Info *_elm_access_object_get(Evas_Object *obj);
234 EAPI void             _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj);
235
236 #define ELM_WIDGET_ITEM Elm_Widget_Item base /**< put this as the first member in your widget item struct */
237 struct _Elm_Widget_Item
238 {
239    /* ef1 ~~ efl, el3 ~~ elm */
240 #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301
241    EINA_MAGIC;
242
243 /* simple accessor macros */
244 #define VIEW(X) X->base.view
245 #define WIDGET(X) X->base.widget
246    Evas_Object   *widget; /**< the owner widget that owns this item */
247    Evas_Object   *view; /**< the base view object */
248    const void    *data; /**< item specific data */
249    Evas_Smart_Cb  del_cb; /**< used to notify the item is being deleted */
250    Elm_Widget_On_Content_Set_Cb on_content_set_func;
251    Elm_Widget_On_Content_Get_Cb on_content_get_func;
252    Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
253    Elm_Widget_On_Text_Set_Cb on_text_set_func;
254    Elm_Widget_On_Text_Get_Cb on_text_get_func;
255    Elm_Widget_On_Signal_Emit_Cb on_signal_emit_func;
256    /* widget variations should have data from here and on */
257    /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */
258 };
259
260 struct _Elm_Object_Item
261 {
262    ELM_WIDGET_ITEM;
263 };
264
265 #define ELM_NEW(t) calloc(1, sizeof(t))
266
267 #define ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ...)                               \
268    ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *) (it), __VA_ARGS__);  \
269    ELM_CHECK_WIDTYPE(it->base.widget, widtype) __VA_ARGS__;
270
271 EAPI Eina_Bool        elm_widget_api_check(int ver);
272 EAPI Evas_Object     *elm_widget_add(Evas *evas);
273 EAPI void             elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
274 EAPI void             elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
275 EAPI void             elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
276 EAPI void             elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
277 EAPI void             elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
278 EAPI void             elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
279 EAPI void             elm_widget_translate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
280 EAPI void             elm_widget_event_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info));
281 EAPI void             elm_widget_changed_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
282 EAPI void             elm_widget_signal_emit_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source));
283 EAPI void             elm_widget_signal_callback_add_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data));
284 EAPI void             elm_widget_signal_callback_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data));
285 EAPI void             elm_widget_theme(Evas_Object *obj);
286 EAPI void             elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
287 EAPI void             elm_widget_translate(Evas_Object *obj);
288 EAPI void             elm_widget_focus_next_hook_set(Evas_Object *obj, Eina_Bool (*func) (const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next));
289 EAPI void             elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
290 EAPI void             elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
291 EAPI void             elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
292 EAPI void             elm_widget_focus_region_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h));
293 EAPI void             elm_widget_text_set_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Set_Cb func);
294 #define elm_widget_text_set_hook_set(obj, func) elm_widget_text_set_hook_set(obj, (Elm_Widget_On_Text_Set_Cb)(func))
295 EAPI void             elm_widget_text_get_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Get_Cb func);
296 #define elm_widget_text_get_hook_set(obj, func) elm_widget_text_get_hook_set(obj, (Elm_Widget_On_Text_Get_Cb)(func))
297 EAPI void             elm_widget_content_set_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Set_Cb func);
298 #define elm_widget_content_set_hook_set(obj, func) elm_widget_content_set_hook_set(obj, (Elm_Widget_On_Content_Set_Cb)(func))
299 EAPI void             elm_widget_content_get_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Get_Cb func);
300 #define elm_widget_content_get_hook_set(obj, func) elm_widget_content_get_hook_set(obj, (Elm_Widget_On_Content_Get_Cb)(func))
301 EAPI void             elm_widget_content_unset_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Unset_Cb func);
302 #define elm_widget_content_unset_hook_set(obj, func) elm_widget_content_unset_hook_set(obj, (Elm_Widget_On_Content_Unset_Cb)(func))
303 EAPI void             elm_widget_on_focus_region_hook_set(Evas_Object *obj, void (*func) (const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h));
304 EAPI void             elm_widget_data_set(Evas_Object *obj, void *data);
305 EAPI void            *elm_widget_data_get(const Evas_Object *obj);
306 EAPI void             elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
307 EAPI void             elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
308 EAPI void             elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);
309 EAPI void             elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj);
310 EAPI void             elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source);
311 EAPI void             elm_widget_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data);
312 EAPI void            *elm_widget_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source));
313 EAPI void             elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
314 EAPI Eina_Bool        elm_widget_can_focus_get(const Evas_Object *obj);
315 EAPI Eina_Bool        elm_widget_child_can_focus_get(const Evas_Object *obj);
316 EAPI void             elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
317 EAPI Eina_Bool        elm_widget_tree_unfocusable_get(const Evas_Object *obj);
318 EAPI void             elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
319 EAPI Eina_Bool        elm_widget_highlight_ignore_get(const Evas_Object *obj);
320 EAPI void             elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
321 EAPI Eina_Bool        elm_widget_highlight_in_theme_get(const Evas_Object *obj);
322 EAPI Eina_Bool        elm_widget_focus_get(const Evas_Object *obj);
323 EAPI Evas_Object     *elm_widget_focused_object_get(const Evas_Object *obj);
324 EAPI Evas_Object     *elm_widget_top_get(const Evas_Object *obj);
325 EAPI Eina_Bool        elm_widget_is(const Evas_Object *obj);
326 EAPI Evas_Object     *elm_widget_parent_widget_get(const Evas_Object *obj);
327 EAPI void             elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data);
328 EAPI void            *elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data);
329 EAPI Eina_Bool        elm_widget_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags);
330 EAPI void             elm_widget_focus_custom_chain_set(Evas_Object *obj, Eina_List *objs);
331 EAPI void             elm_widget_focus_custom_chain_unset(Evas_Object *obj);
332 EAPI const Eina_List *elm_widget_focus_custom_chain_get(const Evas_Object *obj);
333 EAPI void             elm_widget_focus_custom_chain_append(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
334 EAPI void             elm_widget_focus_custom_chain_prepend(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
335 EAPI void             elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir);
336 EAPI void             elm_widget_focus_direction_go(Evas_Object *obj, int x, int y);
337 EAPI Eina_Bool        elm_widget_focus_next_get(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next);
338 EAPI Eina_Bool        elm_widget_focus_list_next_get(const Evas_Object *obj, const Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Evas_Object **next);
339 EAPI void             elm_widget_focus_set(Evas_Object *obj, int first);
340 EAPI void             elm_widget_focused_object_clear(Evas_Object *obj);
341 EAPI Evas_Object     *elm_widget_parent_get(const Evas_Object *obj);
342 EAPI void             elm_widget_focus_steal(Evas_Object *obj);
343
344 /**
345  * @internal
346  *
347  * Restore the focus state of the sub-tree.
348  *
349  * This API will restore the focus state of the sub-tree to the lastest
350  * state. If a sub-tree is unfocused and wants to get back to the lastest
351  * focus state, this API will be helpful.
352  *
353  * @param obj The widget root of sub-tree
354  *
355  * @ingroup Widget
356  */
357 EAPI void             elm_widget_focus_restore(Evas_Object *obj);
358
359 EAPI void             elm_widget_activate(Evas_Object *obj);
360 EAPI void             elm_widget_change(Evas_Object *obj);
361 EAPI void             elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabled);
362 EAPI Eina_Bool        elm_widget_disabled_get(const Evas_Object *obj);
363 EAPI void             elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow);
364 EAPI void             elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
365 EAPI void             elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
366 EAPI void             elm_widget_scroll_hold_push(Evas_Object *obj);
367 EAPI void             elm_widget_scroll_hold_pop(Evas_Object *obj);
368 EAPI int              elm_widget_scroll_hold_get(const Evas_Object *obj);
369 EAPI void             elm_widget_scroll_freeze_push(Evas_Object *obj);
370 EAPI void             elm_widget_scroll_freeze_pop(Evas_Object *obj);
371 EAPI int              elm_widget_scroll_freeze_get(const Evas_Object *obj);
372 EAPI void             elm_widget_scale_set(Evas_Object *obj, double scale);
373 EAPI double           elm_widget_scale_get(const Evas_Object *obj);
374 EAPI Eina_Bool        elm_widget_mirrored_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
375 EAPI void             elm_widget_mirrored_set(Evas_Object *obj, Eina_Bool mirrored) EINA_ARG_NONNULL(1);
376 EAPI Eina_Bool        elm_widget_mirrored_automatic_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
377 EAPI void             elm_widget_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic) EINA_ARG_NONNULL(1);
378 EAPI void             elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th);
379 EAPI Elm_Theme       *elm_widget_theme_get(const Evas_Object *obj);
380 EAPI void             elm_widget_style_set(Evas_Object *obj, const char *style);
381 EAPI const char      *elm_widget_style_get(const Evas_Object *obj);
382 EAPI void             elm_widget_type_set(Evas_Object *obj, const char *type);
383 EAPI const char      *elm_widget_type_get(const Evas_Object *obj);
384 EAPI void             elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt);
385 EAPI void             elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt);
386 EAPI void             elm_widget_cursor_add(Evas_Object *obj, Elm_Cursor *cur);
387 EAPI void             elm_widget_cursor_del(Evas_Object *obj, Elm_Cursor *cur);
388 EAPI void             elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock);
389 EAPI void             elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock);
390 EAPI Eina_Bool        elm_widget_drag_lock_x_get(const Evas_Object *obj);
391 EAPI Eina_Bool        elm_widget_drag_lock_y_get(const Evas_Object *obj);
392 EAPI int              elm_widget_drag_child_locked_x_get(const Evas_Object *obj);
393 EAPI int              elm_widget_drag_child_locked_y_get(const Evas_Object *obj);
394 EAPI Eina_Bool        elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle);
395 EAPI void             elm_widget_type_register(const char **ptr);
396 EAPI void             elm_widget_type_unregister(const char **ptr);
397 EAPI Eina_Bool        elm_widget_type_check(const Evas_Object *obj, const char *type);
398 EAPI Eina_List       *elm_widget_stringlist_get(const char *str);
399 EAPI void             elm_widget_stringlist_free(Eina_List *list);
400 EAPI void             elm_widget_focus_hide_handle(Evas_Object *obj);
401 EAPI void             elm_widget_focus_mouse_up_handle(Evas_Object *obj);
402 EAPI void             elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj);
403 EAPI void             elm_widget_focus_disabled_handle(Evas_Object *obj);
404 EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label);
405 EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *part);
406 EAPI void             elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
407 EAPI const char      *elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part);
408 EAPI void             elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
409 EAPI Evas_Object     *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
410 EAPI Evas_Object     *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
411 EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
412 EAPI void             _elm_widget_item_del(Elm_Widget_Item *item);
413 EAPI void             _elm_widget_item_pre_notify_del(Elm_Widget_Item *item);
414 EAPI void             _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb);
415 EAPI void             _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data);
416 EAPI void            *_elm_widget_item_data_get(const Elm_Widget_Item *item);
417 EAPI void             _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text);
418 EAPI void             _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item, const char *text);
419 EAPI void             _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb);
420 EAPI void             _elm_widget_item_tooltip_unset(Elm_Widget_Item *item);
421 EAPI void             _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style);
422 EAPI const char      *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item);
423 EAPI void             _elm_widget_item_cursor_set(Elm_Widget_Item *item, const char *cursor);
424 EAPI const char      *_elm_widget_item_cursor_get(const Elm_Widget_Item *item);
425 EAPI void             _elm_widget_item_cursor_unset(Elm_Widget_Item *item);
426 EAPI void             _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, const char *style);
427 EAPI const char      *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item);
428 EAPI void             _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only);
429 EAPI Eina_Bool        _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item);
430 EAPI void             _elm_widget_item_content_part_set(Elm_Widget_Item *item, const char *part, Evas_Object *content);
431 EAPI Evas_Object     *_elm_widget_item_content_part_get(const Elm_Widget_Item *item, const char *part);
432 EAPI Evas_Object     *_elm_widget_item_content_part_unset(Elm_Widget_Item *item, const char *part);
433 EAPI void             _elm_widget_item_text_part_set(Elm_Widget_Item *item, const char *part, const char *label);
434 EAPI const char      *_elm_widget_item_text_part_get(const Elm_Widget_Item *item, const char *part);
435 EAPI void             _elm_widget_item_signal_emit(Elm_Widget_Item *item, const char *emission, const char *source);
436 EAPI void             _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Set_Cb func);
437 EAPI void             _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Get_Cb func);
438 EAPI void             _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Unset_Cb func);
439 EAPI void             _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Set_Cb func);
440 EAPI void             _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Get_Cb func);
441 EAPI void             _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *it, Elm_Widget_On_Signal_Emit_Cb func);
442
443 /* debug function. don't use it unless you are tracking parenting issues */
444 EAPI void             elm_widget_tree_dump(const Evas_Object *top);
445 EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output);
446
447 /**
448  * Convenience macro to create new widget item, doing casts for you.
449  * @see _elm_widget_item_new()
450  * @param parent a valid elm_widget variant.
451  * @param type the C type that extends Elm_Widget_Item
452  */
453 #define elm_widget_item_new(parent, type) \
454   (type *)_elm_widget_item_new((parent), sizeof(type))
455 /**
456  * Convenience macro to delete widget item, doing casts for you.
457  * @see _elm_widget_item_del()
458  * @param item a valid item.
459  */
460 #define elm_widget_item_del(item) \
461   _elm_widget_item_del((Elm_Widget_Item *)item)
462 /**
463  * Convenience macro to notify deletion of widget item, doing casts for you.
464  * @see _elm_widget_item_pre_notify_del()
465  */
466 #define elm_widget_item_pre_notify_del(item) \
467   _elm_widget_item_pre_notify_del((Elm_Widget_Item *)item)
468 /**
469  * Convenience macro to set deletion callback of widget item, doing casts for you.
470  * @see _elm_widget_item_del_cb_set()
471  */
472 #define elm_widget_item_del_cb_set(item, del_cb) \
473   _elm_widget_item_del_cb_set((Elm_Widget_Item *)item, del_cb)
474
475 /**
476  * Set item's data
477  * @see _elm_widget_item_data_set()
478  */
479 #define elm_widget_item_data_set(item, data) \
480   _elm_widget_item_data_set((Elm_Widget_Item *)item, data)
481 /**
482  * Get item's data
483  * @see _elm_widget_item_data_get()
484  */
485 #define elm_widget_item_data_get(item) \
486   _elm_widget_item_data_get((const Elm_Widget_Item *)item)
487
488 /**
489  * Convenience function to set widget item tooltip as a text string.
490  * @see _elm_widget_item_tooltip_text_set()
491  */
492 #define elm_widget_item_tooltip_text_set(item, text) \
493   _elm_widget_item_tooltip_text_set((Elm_Widget_Item *)item, text)
494 /**
495  * Convenience function to set widget item tooltip as a text string.
496  * @see _elm_widget_item_tooltip_text_set()
497  */
498 #define elm_widget_item_tooltip_translatable_text_set(item, text) \
499   _elm_widget_item_tooltip_translatable_text_set((Elm_Widget_Item *)item, text)
500 /**
501  * Convenience function to set widget item tooltip.
502  * @see _elm_widget_item_tooltip_content_cb_set()
503  */
504 #define elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb) \
505   _elm_widget_item_tooltip_content_cb_set((Elm_Widget_Item *)item, \
506                                           func, data, del_cb)
507 /**
508  * Convenience function to unset widget item tooltip.
509  * @see _elm_widget_item_tooltip_unset()
510  */
511 #define elm_widget_item_tooltip_unset(item) \
512   _elm_widget_item_tooltip_unset((Elm_Widget_Item *)item)
513 /**
514  * Convenience function to change item's tooltip style.
515  * @see _elm_widget_item_tooltip_style_set()
516  */
517 #define elm_widget_item_tooltip_style_set(item, style) \
518   _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style)
519 /**
520  * Convenience function to query item's tooltip style.
521  * @see _elm_widget_item_tooltip_style_get()
522  */
523 #define elm_widget_item_tooltip_style_get(item) \
524   _elm_widget_item_tooltip_style_get((const Elm_Widget_Item *)item)
525 /**
526  * Convenience function to set widget item cursor.
527  * @see _elm_widget_item_cursor_set()
528  */
529 #define elm_widget_item_cursor_set(item, cursor) \
530   _elm_widget_item_cursor_set((Elm_Widget_Item *)item, cursor)
531 /**
532  * Convenience function to get widget item cursor.
533  * @see _elm_widget_item_cursor_get()
534  */
535 #define elm_widget_item_cursor_get(item) \
536   _elm_widget_item_cursor_get((const Elm_Widget_Item *)item)
537 /**
538  * Convenience function to unset widget item cursor.
539  * @see _elm_widget_item_cursor_unset()
540  */
541 #define elm_widget_item_cursor_unset(item) \
542   _elm_widget_item_cursor_unset((Elm_Widget_Item *)item)
543 /**
544  * Convenience function to change item's cursor style.
545  * @see _elm_widget_item_cursor_style_set()
546  */
547 #define elm_widget_item_cursor_style_set(item, style) \
548   _elm_widget_item_cursor_style_set((Elm_Widget_Item *)item, style)
549 /**
550  * Convenience function to query item's cursor style.
551  * @see _elm_widget_item_cursor_style_get()
552  */
553 #define elm_widget_item_cursor_style_get(item) \
554   _elm_widget_item_cursor_style_get((const Elm_Widget_Item *)item)
555 /**
556  * Convenience function to change item's cursor engine_only.
557  * @see _elm_widget_item_cursor_engine_only_set()
558  */
559 #define elm_widget_item_cursor_engine_only_set(item, engine_only) \
560   _elm_widget_item_cursor_engine_only_set((Elm_Widget_Item *)item, engine_only)
561 /**
562  * Convenience function to query item's cursor engine_only.
563  * @see _elm_widget_item_cursor_engine_only_get()
564  */
565 #define elm_widget_item_cursor_engine_only_get(item) \
566   _elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item)
567 /**
568  * Convenience function to query item's content part set.
569  * @see _elm_widget_item_content_part_set()
570  */
571 #define elm_widget_item_content_part_set(item, part, content) \
572   _elm_widget_item_content_part_set((Elm_Widget_Item *)item, part, content)
573 /**
574  * Convenience function to query item's content part get.
575  * @see _elm_widget_item_content_part_get()
576  */
577 #define elm_widget_item_content_part_get(item, part) \
578   _elm_widget_item_content_part_get((const Elm_Widget_Item *)item, part)
579 /**
580  * Convenience function to query item's content part unset.
581  * @see _elm_widget_item_content_part_unset()
582  */
583 #define elm_widget_item_content_part_unset(item, part) \
584   _elm_widget_item_content_part_unset((Elm_Widget_Item *)item, part)
585 /**
586  * Convenience function to query item's text part set.
587  * @see _elm_widget_item_text_part_set()
588  */
589 #define elm_widget_item_text_part_set(item, part, label) \
590   _elm_widget_item_text_part_set((Elm_Widget_Item *)item, part, label)
591 /**
592  * Convenience function to query item's text part get.
593  * @see _elm_widget_item_text_part_get()
594  */
595 #define elm_widget_item_text_part_get(item, part) \
596   _elm_widget_item_text_part_get((const Elm_Widget_Item *)item, part)
597 /**
598  * Convenience function to query item's signal emit.
599  * @see _elm_widget_item_signal_emit()
600  */
601 #define elm_widget_item_signal_emit(item, emission, source) \
602   _elm_widget_item_signal_emit((Elm_Widget_Item *)item, emission, source)
603 /**
604  * Convenience function to query item's content set hook.
605  * @see _elm_widget_item_content_set_hook_set()
606  */
607 #define elm_widget_item_content_set_hook_set(item, func) \
608   _elm_widget_item_content_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Set_Cb)func)
609 /**
610  * Convenience function to query item's content get hook.
611  * @see _elm_widget_item_content_get_hook_set()
612  */
613 #define elm_widget_item_content_get_hook_set(item, func) \
614   _elm_widget_item_content_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Get_Cb)func)
615 /**
616  * Convenience function to query item's content unset hook.
617  * @see _elm_widget_item_content_unset_hook_set()
618  */
619 #define elm_widget_item_content_unset_hook_set(item, func) \
620   _elm_widget_item_content_unset_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Unset_Cb)func)
621 /**
622  * Convenience function to query item's text set hook.
623  * @see _elm_widget_item_text_set_hook_set()
624  */
625 #define elm_widget_item_text_set_hook_set(item, func) \
626   _elm_widget_item_text_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Set_Cb)func)
627 /**
628  * Convenience function to query item's text get hook.
629  * @see _elm_widget_item_text_get_hook_set()
630  */
631 #define elm_widget_item_text_get_hook_set(item, func) \
632   _elm_widget_item_text_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Get_Cb)func)
633 /**
634  * Convenience function to query item's signal emit hook.
635  * @see _elm_widget_item_signal_emit_hook_set()
636  */
637 #define elm_widget_item_signal_emit_hook_set(item, func) \
638   _elm_widget_item_signal_emit_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Signal_Emit_Cb)func)
639
640
641 #define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \
642    do { \
643       if (!item) { \
644          CRITICAL("Elm_Widget_Item " # item " is NULL!"); \
645          return __VA_ARGS__; \
646       } \
647       if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
648          EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
649          return __VA_ARGS__; \
650       } \
651    } while (0)
652
653 #define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label) \
654    do { \
655       if (!item) { \
656          CRITICAL("Elm_Widget_Item " # item " is NULL!"); \
657          goto label; \
658       } \
659       if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
660          EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
661          goto label; \
662       } \
663    } while (0)
664
665 #define ELM_SET_WIDTYPE(widtype, type) \
666    do { \
667       if (!widtype) { \
668          widtype = eina_stringshare_add(type); \
669          elm_widget_type_register(&widtype); \
670       } \
671    } while (0)
672
673 #define ELM_CHECK_WIDTYPE(obj, widtype) \
674    if (!elm_widget_type_check((obj), (widtype))) return
675
676 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...)                \
677    ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
678    ELM_CHECK_WIDTYPE(it->base.widget, widtype) __VA_ARGS__;
679
680 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, label)                \
681    ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label);         \
682    if (!elm_widget_type_check((it->base.widget), (widtype))) goto label;
683
684 #define ELM_WIDGET_STANDARD_SETUP(wdat, wdtype, par, evas, ob, ret) \
685    do { \
686       EINA_SAFETY_ON_NULL_RETURN_VAL((par), (ret)); \
687       evas = evas_object_evas_get(par); if (!(evas)) return (ret); \
688       wdat = ELM_NEW(wdtype); if (!(wdat)) return (ret); \
689       ob = elm_widget_add(evas); if (!(ob)) { free(wdat); return (ret); } \
690    } while (0)
691
692 /**
693  * The drag and drop API.
694  * Currently experimental, and will change when it does dynamic type
695  * addition RSN.
696  *
697  * Here so applications can start to use it, if they ask elm nicely.
698  *
699  * And yes, elm_widget, should probably be elm_experimental...
700  * Complaints about this code should go to /dev/null, or failing that nash.
701  */
702 typedef struct _Elm_Selection_Data Elm_Selection_Data;
703
704 typedef Eina_Bool (*Elm_Drop_Cb) (void *d, Evas_Object *o, Elm_Selection_Data *data);
705
706 typedef enum _Elm_Sel_Type
707 {
708    ELM_SEL_PRIMARY,
709    ELM_SEL_SECONDARY,
710    ELM_SEL_CLIPBOARD,
711    ELM_SEL_XDND,
712
713    ELM_SEL_MAX,
714 } Elm_Sel_Type;
715
716 typedef enum _Elm_Sel_Format
717 {
718    /** Plain unformated text: Used for things that don't want rich markup */
719    ELM_SEL_FORMAT_TEXT   = 0x01,
720    /** Edje textblock markup, including inline images */
721    ELM_SEL_FORMAT_MARKUP = 0x02,
722    /** Images */
723    ELM_SEL_FORMAT_IMAGE  = 0x04,
724    /** Vcards */
725    ELM_SEL_FORMAT_VCARD =  0x08,
726    /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
727    ELM_SEL_FORMAT_HTML = 0x10,
728 } Elm_Sel_Format;
729
730 struct _Elm_Selection_Data
731 {
732    int                   x, y;
733    Elm_Sel_Format        format;
734    void                 *data;
735    int                   len;
736 };
737
738 Eina_Bool            elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *buf);
739 Eina_Bool            elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget);
740 Eina_Bool            elm_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata);
741 Eina_Bool            elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_Drop_Cb, void *);
742 Eina_Bool            elm_drop_target_del(Evas_Object *widget);
743 Eina_Bool            elm_drag_start(Evas_Object *, Elm_Sel_Format, const char *, void (*)(void *,Evas_Object*),void*);
744
745 #endif