[Focus] Add APIs. elm_object_focus_next_set/get && elm_object_focused_object_get...
[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
7  * IT AT RUNTIME.
8  *
9  * How to make your own widget? like this (where wname is your widget
10  * name (space) and wparentname is you widget's parent widget name
11  * (the base widget class if its a 'root' one).
12  *
13  * #include <Elementary.h>
14  * #include "elm_priv.h"
15  *
16  * static const char ELM_WNAME_SMART_NAME[] = "elm_wname";
17  *
18  * #define ELM_WNAME_DATA_GET(o, sd) \
19  *   Elm_WName_Smart_Data * sd = evas_object_smart_data_get(o)
20  *
21  * #define ELM_WNAME_CHECK(obj)                                      \
22  *   if (!obj || !elm_widget_type_check((obj), ELM_WNAME_SMART_NAME, \
23  *                                      __func__))                   \
24  *     return
25  *
26  * typedef struct _Elm_WName_Smart_Class
27  * {
28  *    Elm_WParentName_Smart_Class base;
29  * } Elm_WName_Smart_Class;
30  *
31  * typedef struct _Elm_WName_Smart_Data Elm_WName_Smart_Data;
32  * struct _Elm_WName_Smart_Data
33  * {
34  *   Elm_WParentName_Smart_Data base;
35  *   Evas_Object *sub; // or any private data needed for an instance
36  *   // add any other instance data here too
37  * };
38  *
39  * static const char SIG_CLICKED[] = "clicked";
40  * static const Evas_Smart_Cb_Description _smart_callbacks[] = {
41  *   {SIG_CLICKED, ""},
42  *   {NULL, NULL}
43  * };
44  *
45  * EVAS_SMART_SUBCLASS_NEW
46  *   (ELM_WNAME_SMART_NAME, _elm_wname, Elm_WName_Smart_Class,
47  *   Elm_WParentName_Smart_Class, elm_wparentname_smart_class_get,
48  *   _smart_callbacks);
49  *
50  * static Eina_Bool
51  * _elm_wname_smart_on_focus(Evas_Object *obj)
52  * {
53  *    ELM_WNAME_DATA_GET(obj, sd);
54  *
55  *    // handle focus going in and out - optional, but if you want to,
56  *    // define this virtual function to handle it (e.g. to emit a
57  *    // signal to an edje object)
58  *
59  *    if (elm_widget_focus_get(obj))
60  *      {
61  *         edje_object_signal_emit(sd->sub, "elm,action,focus", "elm");
62  *         evas_object_focus_set(sd->sub, EINA_TRUE);
63  *      }
64  *    else
65  *      {
66  *         edje_object_signal_emit(sd->sub, "elm,action,unfocus", "elm");
67  *         evas_object_focus_set(sd->sub, EINA_FALSE);
68  *      }
69  *
70  *    return EINA_TRUE;
71  * }
72  *
73  * static Eina_Bool
74  * _elm_wname_smart_theme(Evas_Object *obj)
75  * {
76  *    ELM_WNAME_DATA_GET(obj, sd);
77  *
78  *   if (!ELM_WIDGET_CLASS(_elm_wname_parent_sc)->theme(obj))
79  *     return EINA_FALSE;
80  *
81  *    // handle changes in theme/scale etc here. always call the
82  *    // parent class's version, as even the base class implements it.
83  *
84  *    elm_widget_theme_object_set(obj, sd->sub, "wname", "base",
85  *                                elm_widget_style_get(obj));
86  *
87  *    return EINA_TRUE;
88  * }
89  *
90  * static Eina_Bool
91  * _elm_widget_smart_disable(Evas_Object *obj)
92  * {
93  *    ELM_WNAME_DATA_GET(obj, sd);
94  *
95  *    // optional, but handle if the widget gets disabled or not
96  *    if (elm_widget_disabled_get(obj))
97  *      edje_object_signal_emit(sd->sub, "elm,state,disabled", "elm");
98  *    else
99  *      edje_object_signal_emit(sd->sub, "elm,state,enabled", "elm");
100  *
101  *    return EINA_TRUE;
102  * }
103  *
104  * static void
105  * _elm_wname_smart_add(Evas_Object *obj)
106  * {
107  *    EVAS_SMART_DATA_ALLOC(obj, Elm_WName_Smart_Data);
108  *
109  *    ELM_WIDGET_CLASS(_elm_wname_parent_sc)->base.add(obj);
110  *
111  *    priv->sub = edje_object_add(evas_object_evas_get(obj));
112  *    // just an example having an Edje object here. if it's really the case
113  *    // you have a sub edje object as a resize object, consider inheriting
114  *    // from @ref elm-layout-class.
115  *    elm_widget_can_focus_set(obj, EINA_TRUE);
116  *
117  *    // for this widget we will add 1 sub object that is an edje object
118  *    priv->sub = edje_object_add(e);
119  *    // set the theme. this follows a scheme for group name like this:
120  *    //   "elm/WIDGETNAME/ELEMENT/STYLE"
121  *    // so here it will be:
122  *    //   "elm/wname/base/default"
123  *    // changing style changes style name from default (all widgets start
124  *    // with the default style) and element is for your widget internal
125  *    // structure as you see fit
126  *    elm_widget_theme_object_set
127  *      (obj, priv->sub, "wname", "base", "default");
128  *    // listen to a signal from the edje object to produce widget smart
129  *    // callback (like click)
130  *    edje_object_signal_callback_add
131  *      (priv->sub, "elm,action,click", "", _clicked_signal_cb, obj);
132  *    // set this sub object as the "resize object". widgets get 1 resize
133  *    // object that is resized along with the object wrapper.
134  *    elm_widget_resize_object_set(obj, priv->sub);
135  * }
136  *
137  * static void
138  * _elm_wname_smart_del(Evas_Object *obj)
139  * {
140  *    ELM_WNAME_DATA_GET(obj, sd);
141  *
142  *    // deleting 'virtual' function implementation - on deletion of
143  *    // object delete object struct, etc.
144  *
145  *    ELM_WIDGET_CLASS(_elm_wname_parent_sc)->base.del(obj);
146  * }
147  *
148  * static void
149  * _elm_wname_smart_set_user(Elm_WName_Smart_Class *sc)
150  * {
151  *    ELM_WIDGET_CLASS(sc)->base.add = _elm_wname_smart_add;
152  *    ELM_WIDGET_CLASS(sc)->base.del = _elm_wname_smart_del;
153  *
154  *    ELM_WIDGET_CLASS(sc)->theme = _elm_wname_smart_theme;
155  *    ELM_WIDGET_CLASS(sc)->disable = _elm_wname_smart_disable;
156  *    ELM_WIDGET_CLASS(sc)->on_focus = _elm_wname_smart_on_focus;
157  * }
158  *
159  * // actual API to create your widget. add more to manipulate it as
160  * // needed mark your calls with EAPI to make them "external api"
161  * // calls.
162  *
163  * EAPI Evas_Object *
164  * elm_wname_add(Evas_Object *parent)
165  * {
166  *    Evas_Object *obj;
167  *
168  *    EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
169  *
170  *    obj = elm_widget_add(_elm_check_smart_class_new(), parent);
171  *    if (!obj) return NULL;
172  *
173  *    if (!elm_widget_sub_object_add(parent, obj))
174  *      ERR("could not add %p as sub object of %p", obj, parent);
175  *
176  *    return obj;
177  * }
178  *
179  * // example - do "whatever" to the widget (here just emit a signal)
180  * EAPI void
181  * elm_wname_whatever(Evas_Object *obj)
182  * {
183  *    // check if type is correct - check will return if it fails
184  *    ELM_WNAME_CHECK(obj);
185  *    // get widget data - type is correct and sane by this point, so this
186  *    // should never fail
187  *    ELM_WNAME_DATA_GET(obj, sd);
188  *    // do whatever you like
189  *    edje_object_signal_emit(sd->sub, "elm,state,action,whatever", "elm");
190  * }
191  *
192  * // you can add more - you need to see elementary's code to know how
193  * // to handle all cases. remember this api is not stable and may
194  * change. it's internal
195  */
196
197 #ifndef ELM_INTERNAL_API_ARGESFSDFEFC
198 #warning "You are using an internal elementary API. This API is not stable"
199 #warning "and is subject to change. You use this at your own risk."
200 #warning "Remember to call elm_widget_api_check(ELM_INTERNAL_API_VERSION);"
201 #warning "in your widgets before you call any other elm_widget calls to do"
202 #warning "a correct runtime version check. Also remember - you don't NEED"
203 #warning "to make an Elementary widget is almost ALL cases. You can easily"
204 #warning "make a smart object with Evas's API and do everything you need"
205 #warning "there. You only need a widget if you want to seamlessly be part"
206 #warning "of the focus tree and want to transparently become a container"
207 #warning "for any number of child Elementary widgets"
208 //#error "ERROR. Compile aborted."
209 #endif
210 #define ELM_INTERNAL_API_VERSION 7000
211
212 /**
213  * @defgroup Widget Widgets Extension Infrastructure
214  *
215  * This section is intended for people willing to create @b custom
216  * Elementary widgets or to contribute new (useful, unique) widgets
217  * upstream. If neither is your case, this text won't be of any use
218  * for you.
219  *
220  * Elementary widgets are built in a @b hierarchical fashion. The idea
221  * is to factorize as much code as possible between widgets with
222  * behavioral similarities, as long as to facilitate the creation of
223  * @b custom, new widgets, may the user need them.
224  *
225  * It all starts with a base class, which aggregates behaviour
226  * @b every Elementary widget is supposed to have:
227  * #Elm_Widget_Smart_Class. Every Elementary widget will be of that
228  * type, be it directly or by means of @b inheriting from it.
229  *
230  * #Elm_Widget_Smart_Class happens to be an @c Evas_Smart_Class. If
231  * you check out Evas' documentation on it, you'll see it's how one is
232  * supposed to create custom Evas objects, what Elementary widgets
233  * are.
234  *
235  * Once one instantiates an Elementary widget, since it inherits from
236  * #Elm_Widget_Smart_Class, the system will raise a class instance of
237  * that type for you. But that happens only @b once: the first time
238  * you ask for an Elementary widget (of a given type). All subsequent
239  * ones will only point to the very same class instance. Since it's
240  * the class which points to the functions implementing the behavior
241  * of objects of that type, all of the live instances of Elementary
242  * widgets (of that type) will share the same blob of code loaded in
243  * memory to execute their routines.
244  *
245  * Now go and take a look at #Elm_Widget_Smart_Class's fields. Because
246  * it inherits from Evas' base smart class, we got a field of that
247  * type as the first member, so that Evas can handle Elementary
248  * objects internally as if they were 'normal' Evas objects. Evas has
249  * the Evas-only behavior function pointers in there, so it's all it
250  * needs.
251  *
252  * Then, comes a version field, so that whenever we got to update or
253  * change the fields on our base smart class, there'll be a runtime
254  * check of the version expected by Elementary and the one provided by
255  * any code linking with it. A mismatch will show the developer of
256  * that code he/she needs to recompile and link its code to a newer
257  * version of Elementary.
258  *
259  * The next fields are the class functions themselves. We call them
260  * 'virtual' because, as in object-oriented languages, one is supposed
261  * here to override them on inheriting classes. On most of
262  * inheritances you'll probably want to call the parent's version of
263  * the class function too: you must analyse each case to tell.
264  *
265  * Take a look at #Elm_Widget_Smart_Data. That's private data bound to
266  * each Elementary object @b instance. It aggregates data needed for
267  * all widgets, since it's meant for the #Elm_Widget_Smart_Class-typed
268  * ones.
269  *
270  * When inheriting from that base type, instance data for this new
271  * class has to have, as the first member, a field of type
272  * #Elm_Widget_Smart_Data. This has to be respected recursively -- if
273  * a third class is to be created inheriting from the one that is a
274  * direct 'child' of #Elm_Widget_Smart_Class, then the private data on
275  * this third class has to have, as its first field, a variable of the
276  * type of the private data of the second class (its parent), direct
277  * child of #Elm_Widget_Smart_Class.
278  *
279  * It is from the base private data, #Elm_Widget_Smart_Data, that we
280  * reach an object's class functions, by the given object
281  * instance. This is the reason of the first field of that struct: a
282  * pointer set to point to its class when the object is instantiated.
283  *
284  * The following figure illustrates the widget inheritance schema.
285  *
286  * @image html elm-widget-hierarchy.png
287  * @image rtf elm-widget-hierarchy.png
288  * @image latex elm-widget-hierarchy.eps
289  *
290  * @section elm-hierarchy-tree Elementary Widgets Hierarchy Tree
291  *
292  * The following figure illustrates the Elementary widget inheritance
293  * tree.
294  *
295  * @image html elm-widget-tree.png
296  * @image rtf elm-widget-tree.png
297  * @image latex elm-widget-tree.eps
298  */
299
300 /**
301  * @addtogroup Widget
302  * @{
303  */
304
305 /**
306  * @def ELM_WIDGET_CLASS
307  *
308  * Use this macro to cast whichever subclass of
309  * #Elm_Widget_Smart_Class into it, so to access its fields.
310  *
311  * @ingroup Widget
312  */
313 #define ELM_WIDGET_CLASS(x) ((Elm_Widget_Smart_Class *) x)
314
315 /**
316  * @def ELM_WIDGET_DATA
317  *
318  * Use this macro to cast whichever subdata of
319  * #Elm_Widget_Smart_Data into it, so to access its fields.
320  *
321  * @ingroup Widget
322  */
323 #define ELM_WIDGET_DATA(x) ((Elm_Widget_Smart_Data *) x)
324
325 /**
326  * @def ELM_WIDGET_SMART_CLASS_VERSION
327  *
328  * Current version for Elementary widget @b base smart class, a value
329  * which goes to _Elm_Widget_Smart_Class::version.
330  *
331  * @ingroup Wiget
332  */
333 #define ELM_WIDGET_SMART_CLASS_VERSION 1
334
335 /**
336  * @def ELM_WIDGET_SMART_CLASS_INIT
337  *
338  * Initializer for a whole #Elm_Widget_Smart_Class structure, with
339  * @c NULL values on its specific fields.
340  *
341  * @param smart_class_init initializer to use for the "base" field
342  * (#Evas_Smart_Class).
343  *
344  * @see EVAS_SMART_CLASS_INIT_NULL
345  * @see EVAS_SMART_CLASS_INIT_VERSION
346  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
347  * @see ELM_WIDGET_SMART_CLASS_INIT_NULL
348  * @see ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION
349  *
350  * @ingroup Widget
351  */
352 #define ELM_WIDGET_SMART_CLASS_INIT(smart_class_init)                        \
353   {smart_class_init, ELM_WIDGET_SMART_CLASS_VERSION, NULL, NULL, NULL, NULL, \
354    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
355
356 /**
357  * @def ELM_WIDGET_SMART_CLASS_INIT_NULL
358  *
359  * Initializer to zero out a whole #Elm_Widget_Smart_Class structure.
360  *
361  * @see ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION
362  * @see ELM_WIDGET_SMART_CLASS_INIT
363  *
364  * @ingroup Widget
365  */
366 #define ELM_WIDGET_SMART_CLASS_INIT_NULL \
367   ELM_WIDGET_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
368
369 /**
370  * @def ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION
371  *
372  * Initializer to zero out a whole #Elm_Widget_Smart_Class structure and
373  * set its name and version.
374  *
375  * This is similar to #ELM_WIDGET_SMART_CLASS_INIT_NULL, but it will
376  * also set the version field of #Elm_Widget_Smart_Class (base field)
377  * to the latest #ELM_WIDGET_SMART_CLASS_VERSION and name it to the
378  * specific value.
379  *
380  * It will keep a reference to the name field as a <c>"const char *"</c>,
381  * i.e., the name must be available while the structure is
382  * used (hint: static or global variable!) and must not be modified.
383  *
384  * @see ELM_WIDGET_SMART_CLASS_INIT_NULL
385  * @see ELM_WIDGET_SMART_CLASS_INIT
386  *
387  * @ingroup Widget
388  */
389 #define ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name) \
390   ELM_WIDGET_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
391
392 /* Elm_Activate is used in 'Virtual' function Eina_Bool (*activate)
393  * (Evas_Object *obj, Elm_Activate act); of Elm_Widget_Smart_Class */
394 typedef enum
395 {
396    ELM_ACTIVATE_DEFAULT = 0,
397    ELM_ACTIVATE_UP,
398    ELM_ACTIVATE_DOWN,
399    ELM_ACTIVATE_RIGHT,
400    ELM_ACTIVATE_LEFT
401 } Elm_Activate;
402
403 /* Please, ALWAYS update the ELM_WIDGET_SMART_CLASS_INIT macro
404  * whenever you change the following struct! */
405
406 /**
407  * Base widget smart class. It has the 'virtual' functions for all
408  * general, common actions on Elementary widgets.
409  */
410 typedef struct _Elm_Widget_Smart_Class
411 {
412    Evas_Smart_Class base; /**< Base smart class struct, needed for all smart objects */
413    int              version; /**< Version of this smart class definition */
414
415    void             (*parent_set)(Evas_Object *obj,
416                                   Evas_Object *parent); /**< 'Virtual' function handling parent widget attachment to new object */
417    Eina_Bool        (*on_focus)(Evas_Object *obj); /**< 'Virtual' function handling focus in/out events on the widget */
418    Eina_Bool        (*disable)(Evas_Object *obj); /**< 'Virtual' function on the widget being disabled */
419    Eina_Bool        (*theme)(Evas_Object *obj); /**< 'Virtual' function on the widget being re-themed */
420    Eina_Bool        (*translate)(Evas_Object *obj); /**< 'Virtual' function handling language changes on Elementary */
421    Eina_Bool        (*event)(Evas_Object *obj,
422                              Evas_Object *source,
423                              Evas_Callback_Type type,
424                              void *event_info); /**< 'Virtual' function handling input events on the widget */
425    Eina_Bool        (*on_focus_region)(const Evas_Object *obj,
426                                        Evas_Coord *x,
427                                        Evas_Coord *y,
428                                        Evas_Coord *w,
429                                        Evas_Coord *h); /**< 'Virtual' function returning an inner area of a widget that should be brought into the visible are of a broader viewport, may this context arise. On the base Elementary widget class, it defaults to the object's total area, so only override it if you have to. */
430    Eina_Bool        (*focus_next)(const Evas_Object *obj,
431                                   Elm_Focus_Direction dir,
432                                   Evas_Object **next); /**< 'Virtual' function handling passing focus to sub-objects */
433    Eina_Bool        (*focus_direction)(const Evas_Object *obj,
434                                        const Evas_Object *base,
435                                        double degree,
436                                        Evas_Object **target,
437                                        double *weight); /**< 'Virtual' function handling passing focus to sub-objects <b>given a direction, in degrees</b> */
438
439    Eina_Bool        (*sub_object_add)(Evas_Object *obj,
440                                       Evas_Object *sobj); /**< 'Virtual' function handling sub objects being added */
441
442    Eina_Bool        (*sub_object_del)(Evas_Object *obj,
443                                       Evas_Object *sobj); /**< 'Virtual' function handling sub objects being removed */
444    void             (*access)(Evas_Object *obj,
445                               Eina_Bool is_access); /**< 'Virtual' function on the widget being set access */
446    Eina_Bool        (*activate)(Evas_Object *obj,
447                                 Elm_Activate act); /**< 'Virtual' function to activate widget  */
448 } Elm_Widget_Smart_Class;
449
450 /**
451  * Base widget smart data. This is data bound to an Elementary object
452  * @b instance, so its particular to that specific object and not
453  * shared between all objects in its class. It is here, though, that
454  * we got a pointer to the object's class, the first field -- @c
455  * 'api'.
456  */
457 typedef struct _Elm_Widget_Smart_Data
458 {
459    const Elm_Widget_Smart_Class *api; /**< This is the pointer to the object's class, from where we can reach/call its class functions */
460
461    Evas_Object                  *obj;
462    Evas_Object                  *parent_obj;
463    Evas_Object                  *parent2;
464    Evas_Coord                    x, y, w, h;
465    Eina_List                    *subobjs;
466    Evas_Object                  *resize_obj;
467    Evas_Object                  *hover_obj;
468    Eina_List                    *tooltips, *cursors;
469    Evas_Object                  *focus_previous, *focus_next;
470    Evas_Object                  *focus_up, *focus_down, *focus_right, *focus_left;
471
472    /* "show region" coordinates. all widgets got those because this
473     * info may be set and queried recursively through the widget
474     * parenting tree */
475    Evas_Coord                    rx, ry, rw, rh;
476
477    /* scrolling hold/freeze hints. all widgets got those because this
478     * info may be set and queried recursively through the widget
479     * parenting tree */
480    int                           scroll_hold;
481    int                           scroll_freeze;
482
483    double                        scale;
484    Elm_Theme                    *theme;
485    const char                   *style;
486    const char                   *access_info;
487    unsigned int                  focus_order;
488    Eina_Bool                     focus_order_on_calc;
489
490    int                           child_drag_x_locked;
491    int                           child_drag_y_locked;
492
493    Eina_List                    *translate_strings;
494    Eina_List                    *focus_chain;
495    Eina_List                    *event_cb;
496
497    /* this is a hook to be set on-the-fly on widgets. this is code
498     * handling the request of showing a specific region from an inner
499     * widget (mainly issued by entries, on cursor moving) */
500    void                         *on_show_region_data;
501    void                        (*on_show_region)(void *data,
502                                                  Evas_Object *obj);
503
504    int                           frozen;
505    int                           orient_mode; /* -1 is disabled */
506
507    Eina_Bool                     drag_x_locked : 1;
508    Eina_Bool                     drag_y_locked : 1;
509
510    Eina_Bool                     can_focus : 1;
511    Eina_Bool                     child_can_focus : 1;
512    Eina_Bool                     focused : 1;
513    Eina_Bool                     top_win_focused : 1;
514    Eina_Bool                     tree_unfocusable : 1;
515    Eina_Bool                     highlight_ignore : 1;
516    Eina_Bool                     highlight_in_theme : 1;
517    Eina_Bool                     disabled : 1;
518    Eina_Bool                     is_mirrored : 1;
519    Eina_Bool                     mirrored_auto_mode : 1; /* This is
520                                                           * TRUE by
521                                                           * default */
522    Eina_Bool                     still_in : 1;
523    Eina_Bool                     can_access : 1;
524    Eina_Bool                     highlighted : 1;
525    Eina_Bool                     highlight_root : 1;
526 } Elm_Widget_Smart_Data;
527
528 /**
529  * @}
530  */
531
532 typedef struct _Elm_Tooltip     Elm_Tooltip;
533 typedef struct _Elm_Cursor      Elm_Cursor;
534
535 /**< base structure for all widget items that are not Elm_Widget themselves */
536 typedef struct _Elm_Widget_Item Elm_Widget_Item;
537
538 /**< accessibility information to be able to set and get from the access API */
539 typedef struct _Elm_Access_Info Elm_Access_Info;
540
541 /**< accessibility info item */
542 typedef struct _Elm_Access_Item Elm_Access_Item;
543
544 typedef void                  (*Elm_Widget_Text_Set_Cb)(void *data, const char *part, const char *text);
545 typedef void                  (*Elm_Widget_Content_Set_Cb)(void *data, const char *part, Evas_Object *content);
546 typedef const char           *(*Elm_Widget_Text_Get_Cb)(const void *data, const char *part);
547 typedef Evas_Object          *(*Elm_Widget_Content_Get_Cb)(const void *data, const char *part);
548 typedef Evas_Object          *(*Elm_Widget_Content_Unset_Cb)(const void *data, const char *part);
549 typedef void                  (*Elm_Widget_Signal_Emit_Cb)(void *data, const char *emission, const char *source);
550 typedef void                  (*Elm_Widget_Disable_Cb)(void *data);
551 typedef Eina_Bool             (*Elm_Widget_Del_Pre_Cb)(void *data);
552
553 #define ELM_ACCESS_DONE          -1   /* sentence done - send done event here */
554 #define ELM_ACCESS_CANCEL        -2   /* stop reading immediately */
555
556 typedef void (*Elm_Access_On_Highlight_Cb)(void *data);
557
558 struct _Elm_Access_Item
559 {
560    int                   type;
561    const void           *data;
562    Elm_Access_Info_Cb    func;
563 };
564
565 struct _Elm_Access_Info
566 {
567    Evas_Object               *hoverobj;
568    Eina_List                 *items;
569    Ecore_Timer               *delay_timer;
570    void                      *on_highlight_data;
571    Elm_Access_On_Highlight_Cb on_highlight;
572
573    void                      *activate_data;
574    Elm_Access_Activate_Cb    activate;
575
576    /* the owner widget item that owns this access info */
577    Elm_Widget_Item           *widget_item;
578
579    /* the owner part object that owns this access info */
580    Evas_Object               *part_object;
581 };
582
583 void                  _elm_access_shutdown();
584 void                  _elm_access_mouse_event_enabled_set(Eina_Bool enabled);
585 /* elm_widget_focus_list_next_get();, elm_widget_focus_next_get();
586    and elm_widget_focus_cycle(); use _elm_access_read_mode to use
587    focus chain */
588 void                  _elm_access_read_mode_set(Eina_Bool enabled);
589 Eina_Bool             _elm_access_read_mode_get();
590 void                  _elm_access_widget_item_access_order_set(Elm_Widget_Item *item, Eina_List *objs);
591 const Eina_List      *_elm_access_widget_item_access_order_get(const Elm_Widget_Item *item);
592 void                  _elm_access_widget_item_access_order_unset(Elm_Widget_Item *item);
593
594 EAPI void             _elm_access_clear(Elm_Access_Info *ac);
595 EAPI void             _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text);
596 EAPI void             _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Info_Cb func, const void *data);
597 EAPI char            *_elm_access_text_get(const Elm_Access_Info *ac, int type, const Evas_Object *obj); /* this is ok it actually returns a strduped string - it's meant to! */
598 EAPI void             _elm_access_read(Elm_Access_Info *ac, int type, const Evas_Object *obj);
599 EAPI void             _elm_access_say(const char *txt);
600 EAPI Elm_Access_Info *_elm_access_object_get(const Evas_Object *obj);
601 EAPI void             _elm_access_object_hilight(Evas_Object *obj);
602 EAPI void             _elm_access_object_unhilight(Evas_Object *obj);
603 EAPI void             _elm_access_object_hilight_disable(Evas *e);
604 EAPI void             _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj);
605 EAPI void             _elm_access_object_unregister(Evas_Object *obj, Evas_Object *hoverobj);
606 EAPI Eina_Bool        _elm_access_2nd_click_timeout(Evas_Object *obj);
607 EAPI void             _elm_access_highlight_set(Evas_Object* obj);
608 EAPI Evas_Object *    _elm_access_edje_object_part_object_register(Evas_Object *obj, const Evas_Object *partobj, const char* part);
609 EAPI void             _elm_access_edje_object_part_object_unregister(Evas_Object* obj, const Evas_Object *eobj, const char* part);
610 EAPI void             _elm_access_widget_item_register(Elm_Widget_Item *item);
611 EAPI void             _elm_access_widget_item_unregister(Elm_Widget_Item *item);
612 EAPI void             _elm_access_on_highlight_hook_set(Elm_Access_Info *ac, Elm_Access_On_Highlight_Cb func, void *data);
613 EAPI void             _elm_access_activate_callback_set(Elm_Access_Info *ac, Elm_Access_Activate_Cb func, void *data);
614 EAPI void             _elm_access_highlight_object_activate(Evas_Object *obj, Elm_Activate act);
615 EAPI void             _elm_access_highlight_cycle(Evas_Object *obj, Elm_Focus_Direction dir);
616
617 /**< put this as the first member in your widget item struct */
618 #define ELM_WIDGET_ITEM       Elm_Widget_Item base
619
620 struct _Elm_Widget_Item
621 {
622 /* ef1 ~~ efl, el3 ~~ elm */
623 #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301
624    EINA_MAGIC;
625 /* simple accessor macros */
626 #define VIEW(X)   X->base.view
627 #define WIDGET(X) X->base.widget
628    /**< the owner widget that owns this item */
629    Evas_Object                   *widget;
630    /**< the base view object */
631    Evas_Object                   *view;
632    /**< item specific data. used for del callback */
633    const void                    *data;
634    /**< user delete callback function */
635    Evas_Smart_Cb                  del_func;
636    /**< widget delete callback function. don't expose this callback call */
637    Elm_Widget_Del_Pre_Cb          del_pre_func;
638
639    Elm_Widget_Content_Set_Cb      content_set_func;
640    Elm_Widget_Content_Get_Cb      content_get_func;
641    Elm_Widget_Content_Unset_Cb    content_unset_func;
642    Elm_Widget_Text_Set_Cb         text_set_func;
643    Elm_Widget_Text_Get_Cb         text_get_func;
644    Elm_Widget_Signal_Emit_Cb      signal_emit_func;
645    Elm_Widget_Disable_Cb          disable_func;
646    Evas_Object                   *access_obj;
647    const char                    *access_info;
648    Eina_List                     *access_order;
649
650    Eina_Bool                      disabled : 1;
651    Eina_Bool                      on_deletion : 1;
652 };
653
654 struct _Elm_Object_Item
655 {
656    ELM_WIDGET_ITEM;
657 };
658
659 #define ELM_NEW(t) calloc(1, sizeof(t))
660
661 EAPI Evas_Object     *elm_widget_add(Evas_Smart *, Evas_Object *);
662 EAPI void             elm_widget_parent_set(Evas_Object *, Evas_Object *);
663 EAPI Eina_Bool        elm_widget_api_check(int ver);
664 EAPI Eina_Bool        elm_widget_access(Evas_Object *obj, Eina_Bool is_access);
665 EAPI Eina_Bool        elm_widget_theme(Evas_Object *obj);
666 EAPI void             elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
667 EAPI void             elm_widget_translate(Evas_Object *obj);
668 EAPI void             elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data);
669 EAPI Eina_Bool        elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
670 EAPI Eina_Bool        elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
671
672 //SHKWAK : This is temp for Indicator Issue
673 //THIS MUST BE REMOVED
674
675 EAPI const Eina_List *elm_widget_sub_object_list_get(const Evas_Object *obj);
676
677 //SHKWAK : END
678
679 EAPI void             elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);
680 EAPI void             elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj);
681 EAPI void             elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source);
682 EAPI void             elm_widget_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
683 EAPI void            *elm_widget_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func);
684 EAPI void             elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
685 EAPI Eina_Bool        elm_widget_can_focus_get(const Evas_Object *obj);
686 EAPI Eina_Bool        elm_widget_child_can_focus_get(const Evas_Object *obj);
687 EAPI Eina_List       *elm_widget_can_focus_child_list_get(const Evas_Object *obj);
688 EAPI void             elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
689 EAPI Eina_Bool        elm_widget_tree_unfocusable_get(const Evas_Object *obj);
690 EAPI void             elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
691 EAPI Eina_Bool        elm_widget_highlight_ignore_get(const Evas_Object *obj);
692 EAPI void             elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
693 EAPI Eina_Bool        elm_widget_highlight_in_theme_get(const Evas_Object *obj);
694 EAPI Eina_Bool        elm_widget_focus_get(const Evas_Object *obj);
695 EAPI Evas_Object     *elm_widget_focused_object_get(const Evas_Object *obj);
696 EAPI Evas_Object     *elm_widget_top_get(const Evas_Object *obj);
697 EAPI Eina_Bool        elm_widget_is(const Evas_Object *obj);
698 EAPI Evas_Object     *elm_widget_parent_widget_get(const Evas_Object *obj);
699 EAPI void             elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data);
700 EAPI void            *elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data);
701 EAPI Eina_Bool        elm_widget_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags);
702 EAPI void             elm_widget_focus_custom_chain_set(Evas_Object *obj, Eina_List *objs);
703 EAPI void             elm_widget_focus_custom_chain_unset(Evas_Object *obj);
704 EAPI const Eina_List *elm_widget_focus_custom_chain_get(const Evas_Object *obj);
705 EAPI void             elm_widget_focus_custom_chain_append(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
706 EAPI void             elm_widget_focus_custom_chain_prepend(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
707 EAPI void             elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir);
708 EAPI Eina_Bool        elm_widget_focus_direction_go(Evas_Object *obj, double degree);
709 EAPI Eina_Bool        elm_widget_focus_direction_get(const Evas_Object *obj, const Evas_Object *base, double degree, Evas_Object **direction, double *weight);
710 EAPI Eina_Bool        elm_widget_focus_next_get(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next);
711 EAPI Eina_Bool        elm_widget_focus_list_direction_get(const Evas_Object  *obj, const Evas_Object *base, const Eina_List *items, void *(*list_data_get)(const Eina_List *list), double degree, Evas_Object **direction, double *weight);
712 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);
713 EAPI Evas_Object     *elm_widget_focus_next_object_get(const Evas_Object *obj, Elm_Focus_Direction dir);
714 EAPI void             elm_widget_focus_next_object_set(Evas_Object *obj, Evas_Object *next, Elm_Focus_Direction dir);
715 EAPI void             elm_widget_focus_set(Evas_Object *obj, int first);
716 EAPI void             elm_widget_focused_object_clear(Evas_Object *obj);
717 EAPI Evas_Object     *elm_widget_parent_get(const Evas_Object *obj);
718 EAPI Evas_Object     *elm_widget_parent2_get(const Evas_Object *obj);
719 EAPI void             elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent);
720 EAPI void             elm_widget_focus_steal(Evas_Object *obj);
721 EAPI Evas_Display_Mode elm_widget_display_mode_get(const Evas_Object *obj);
722 EAPI void             elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode);
723 EAPI const Elm_Widget_Smart_Class *elm_widget_smart_class_get(void);
724
725 EAPI Eina_Bool        elm_widget_highlight_get(const Evas_Object *obj);
726 EAPI void             elm_widget_parent_highlight_set(Evas_Object *obj, Eina_Bool highlighted);
727 /**
728  * @internal
729  *
730  * Restore the focus state of the sub-tree.
731  *
732  * This API will restore the focus state of the sub-tree to the latest
733  * state. If a sub-tree is unfocused and wants to get back to the latest
734  * focus state, this API will be helpful.
735  *
736  * @param obj The widget root of sub-tree
737  *
738  * @ingroup Widget
739  */
740 EAPI void             elm_widget_focus_restore(Evas_Object *obj);
741
742 EAPI void             elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabled);
743 EAPI Eina_Bool        elm_widget_disabled_get(const Evas_Object *obj);
744 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);
745 EAPI void             elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
746 EAPI Eina_Bool        elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
747 EAPI void             elm_widget_scroll_hold_push(Evas_Object *obj);
748 EAPI void             elm_widget_scroll_hold_pop(Evas_Object *obj);
749 EAPI int              elm_widget_scroll_hold_get(const Evas_Object *obj);
750 EAPI void             elm_widget_scroll_freeze_push(Evas_Object *obj);
751 EAPI void             elm_widget_scroll_freeze_pop(Evas_Object *obj);
752 EAPI int              elm_widget_scroll_freeze_get(const Evas_Object *obj);
753 EAPI void             elm_widget_scale_set(Evas_Object *obj, double scale);
754 EAPI double           elm_widget_scale_get(const Evas_Object *obj);
755 EAPI Eina_Bool        elm_widget_mirrored_get(const Evas_Object *obj);
756 EAPI void             elm_widget_mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
757 EAPI Eina_Bool        elm_widget_mirrored_automatic_get(const Evas_Object *obj);
758 EAPI void             elm_widget_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic);
759 EAPI void             elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th);
760 EAPI Elm_Theme       *elm_widget_theme_get(const Evas_Object *obj);
761 EAPI Eina_Bool        elm_widget_style_set(Evas_Object *obj, const char *style);
762 EAPI const char      *elm_widget_style_get(const Evas_Object *obj);
763 EAPI void             elm_widget_type_set(Evas_Object *obj, const char *type);
764 EAPI const char      *elm_widget_type_get(const Evas_Object *obj);
765 EAPI void             elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt);
766 EAPI void             elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt);
767 EAPI void             elm_widget_cursor_add(Evas_Object *obj, Elm_Cursor *cur);
768 EAPI void             elm_widget_cursor_del(Evas_Object *obj, Elm_Cursor *cur);
769 EAPI void             elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock);
770 EAPI void             elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock);
771 EAPI Eina_Bool        elm_widget_drag_lock_x_get(const Evas_Object *obj);
772 EAPI Eina_Bool        elm_widget_drag_lock_y_get(const Evas_Object *obj);
773 EAPI int              elm_widget_drag_child_locked_x_get(const Evas_Object *obj);
774 EAPI int              elm_widget_drag_child_locked_y_get(const Evas_Object *obj);
775 EAPI Eina_Bool        elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle);
776 EAPI Eina_Bool        elm_widget_type_check(const Evas_Object *obj, const char *type, const char *func);
777 EAPI Evas_Object     *elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse);
778 EAPI Eina_List       *elm_widget_stringlist_get(const char *str);
779 EAPI void             elm_widget_stringlist_free(Eina_List *list);
780 EAPI void             elm_widget_focus_hide_handle(Evas_Object *obj);
781 EAPI void             elm_widget_focus_mouse_up_handle(Evas_Object *obj);
782 EAPI void             elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj);
783 EAPI void             elm_widget_focus_disabled_handle(Evas_Object *obj);
784 EAPI unsigned int     elm_widget_focus_order_get(const Evas_Object *obj);
785 EAPI Evas_Object     *elm_widget_newest_focus_order_get(const Evas_Object *obj, unsigned int *newest_focus_order, Eina_Bool can_focus_only);
786 EAPI void             elm_widget_activate(Evas_Object *obj, Elm_Activate act);
787 EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label);
788 EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *part);
789 EAPI void             elm_widget_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
790 EAPI const char      *elm_widget_translatable_text_part_get(const Evas_Object *obj, const char *part);
791 EAPI void             elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
792 EAPI Evas_Object     *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
793 EAPI Evas_Object     *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
794 EAPI void             elm_widget_access_info_set(Evas_Object *obj, const char *txt);
795 EAPI const char      *elm_widget_access_info_get(const Evas_Object *obj);
796 EAPI void             elm_widget_orientation_set(Evas_Object *obj, int rotation);
797 EAPI void             elm_widget_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled);
798 EAPI Eina_Bool        elm_widget_orientation_mode_disabled_get(const Evas_Object *obj);
799 EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
800 EAPI void             _elm_widget_item_free(Elm_Widget_Item *item);
801 EAPI Evas_Object     *_elm_widget_item_widget_get(const Elm_Widget_Item *item);
802 EAPI void             _elm_widget_item_del(Elm_Widget_Item *item);
803 EAPI void             _elm_widget_item_pre_notify_del(Elm_Widget_Item *item);
804 EAPI void             _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb);
805 EAPI void             _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data);
806 EAPI void            *_elm_widget_item_data_get(const Elm_Widget_Item *item);
807 EAPI void             _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text);
808 EAPI void             _elm_widget_item_tooltip_translatable_text_set(Elm_Widget_Item *item, const char *text);
809 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);
810 EAPI void             _elm_widget_item_tooltip_unset(Elm_Widget_Item *item);
811 EAPI void             _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style);
812 EAPI Eina_Bool        _elm_widget_item_tooltip_window_mode_set(Elm_Widget_Item *item, Eina_Bool disable);
813 EAPI Eina_Bool        _elm_widget_item_tooltip_window_mode_get(const Elm_Widget_Item *item);
814 EAPI const char      *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item);
815 EAPI void             _elm_widget_item_cursor_set(Elm_Widget_Item *item, const char *cursor);
816 EAPI const char      *_elm_widget_item_cursor_get(const Elm_Widget_Item *item);
817 EAPI void             _elm_widget_item_cursor_unset(Elm_Widget_Item *item);
818 EAPI void             _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, const char *style);
819 EAPI const char      *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item);
820 EAPI void             _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only);
821 EAPI Eina_Bool        _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item);
822 EAPI void             _elm_widget_item_part_content_set(Elm_Widget_Item *item, const char *part, Evas_Object *content);
823 EAPI Evas_Object     *_elm_widget_item_part_content_get(const Elm_Widget_Item *item, const char *part);
824 EAPI Evas_Object     *_elm_widget_item_part_content_unset(Elm_Widget_Item *item, const char *part);
825 EAPI void             _elm_widget_item_part_text_set(Elm_Widget_Item *item, const char *part, const char *label);
826 EAPI const char      *_elm_widget_item_part_text_get(const Elm_Widget_Item *item, const char *part);
827 EAPI void             _elm_widget_item_signal_emit(Elm_Widget_Item *item, const char *emission, const char *source);
828 EAPI void             _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Content_Set_Cb func);
829 EAPI void             _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item, Elm_Widget_Content_Get_Cb func);
830 EAPI void             _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item, Elm_Widget_Content_Unset_Cb func);
831 EAPI void             _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item, Elm_Widget_Text_Set_Cb func);
832 EAPI void             _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item, Elm_Widget_Text_Get_Cb func);
833 EAPI void             _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *it, Elm_Widget_Signal_Emit_Cb func);
834 EAPI void             _elm_widget_item_access_info_set(Elm_Widget_Item *item, const char *txt);
835 EAPI void             _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled);
836 EAPI Eina_Bool        _elm_widget_item_disabled_get(const Elm_Widget_Item *item);
837 EAPI void             _elm_widget_item_disable_hook_set(Elm_Widget_Item *item, Elm_Widget_Disable_Cb func);
838 EAPI void             _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Del_Pre_Cb func);
839
840 /**
841  * Function to operate on a given widget's scrollabe children when necessary.
842  * @warning free the returned list with eina_list_free().
843  */
844 EAPI Eina_List       *elm_widget_scrollable_children_get(Evas_Object *obj);
845
846 /* debug function. don't use it unless you are tracking parenting issues */
847 EAPI void             elm_widget_tree_dump(const Evas_Object *top);
848 EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output);
849
850 #define ELM_WIDGET_DATA_GET(o, sd) \
851   Elm_Widget_Smart_Data * sd = evas_object_smart_data_get(o)
852
853 #define ELM_WIDGET_DATA_GET_OR_RETURN(o, ptr)        \
854   ELM_WIDGET_DATA_GET(o, ptr);                       \
855   if (!ptr)                                          \
856     {                                                \
857        CRITICAL("no widget data for object %p (%s)", \
858                 o, evas_object_type_get(o));         \
859        return;                                       \
860     }
861
862 /**
863  * Convenience macro to create new widget item, doing casts for you.
864  * @see _elm_widget_item_new()
865  * @param parent a valid elm_widget variant.
866  * @param type the C type that extends Elm_Widget_Item
867  */
868 #define elm_widget_item_new(parent, type) \
869   (type *)_elm_widget_item_new((parent), sizeof(type))
870 /**
871  * Convenience macro to free widget item, doing casts for you.
872  * @see _elm_widget_item_free()
873  * @param item a valid item.
874  */
875 #define elm_widget_item_free(item) \
876   _elm_widget_item_free((Elm_Widget_Item *)item)
877
878 /**
879  * Convenience macro to delete widget item, doing casts for you.
880  * @see _elm_widget_item_del()
881  * @param item a valid item.
882  */
883 #define elm_widget_item_del(item) \
884   _elm_widget_item_del((Elm_Widget_Item *)item)
885 /**
886  * Convenience macro to notify deletion of widget item, doing casts for you.
887  * @see _elm_widget_item_pre_notify_del()
888  */
889 #define elm_widget_item_pre_notify_del(item) \
890   _elm_widget_item_pre_notify_del((Elm_Widget_Item *)item)
891 /**
892  * Convenience macro to set deletion callback of widget item, doing casts for you.
893  * @see _elm_widget_item_del_cb_set()
894  */
895 #define elm_widget_item_del_cb_set(item, del_cb) \
896   _elm_widget_item_del_cb_set((Elm_Widget_Item *)item, del_cb)
897
898 /**
899  * Get item's owner widget
900  * @see _elm_widget_item_widget_get()
901  */
902 #define elm_widget_item_widget_get(item) \
903   _elm_widget_item_widget_get((const Elm_Widget_Item *)item)
904
905 /**
906  * Set item's data
907  * @see _elm_widget_item_data_set()
908  */
909 #define elm_widget_item_data_set(item, data) \
910   _elm_widget_item_data_set((Elm_Widget_Item *)item, data)
911 /**
912  * Get item's data
913  * @see _elm_widget_item_data_get()
914  */
915 #define elm_widget_item_data_get(item) \
916   _elm_widget_item_data_get((const Elm_Widget_Item *)item)
917
918 /**
919  * Convenience function to set widget item tooltip as a text string.
920  * @see _elm_widget_item_tooltip_text_set()
921  */
922 #define elm_widget_item_tooltip_text_set(item, text) \
923   _elm_widget_item_tooltip_text_set((Elm_Widget_Item *)item, text)
924 /**
925  * Convenience function to set widget item tooltip as a text string.
926  * @see _elm_widget_item_tooltip_text_set()
927  */
928 #define elm_widget_item_tooltip_translatable_text_set(item, text) \
929   _elm_widget_item_tooltip_translatable_text_set((Elm_Widget_Item *)item, text)
930 /**
931  * Convenience function to set widget item tooltip.
932  * @see _elm_widget_item_tooltip_content_cb_set()
933  */
934 #define elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb) \
935   _elm_widget_item_tooltip_content_cb_set((Elm_Widget_Item *)item,       \
936                                           func, data, del_cb)
937 /**
938  * Convenience function to unset widget item tooltip.
939  * @see _elm_widget_item_tooltip_unset()
940  */
941 #define elm_widget_item_tooltip_unset(item) \
942   _elm_widget_item_tooltip_unset((Elm_Widget_Item *)item)
943 /**
944  * Convenience function to change item's tooltip style.
945  * @see _elm_widget_item_tooltip_style_set()
946  */
947 #define elm_widget_item_tooltip_style_set(item, style) \
948   _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style)
949
950 #define elm_widget_item_tooltip_window_mode_set(item, disable) \
951   _elm_widget_item_tooltip_window_mode_set((Elm_Widget_Item *)item, disable)
952
953 #define elm_widget_item_tooltip_window_mode_get(item) \
954   _elm_widget_item_tooltip_window_mode_get((Elm_Widget_Item *)item)
955 /**
956  * Convenience function to query item's tooltip style.
957  * @see _elm_widget_item_tooltip_style_get()
958  */
959 #define elm_widget_item_tooltip_style_get(item) \
960   _elm_widget_item_tooltip_style_get((const Elm_Widget_Item *)item)
961 /**
962  * Convenience function to set widget item cursor.
963  * @see _elm_widget_item_cursor_set()
964  */
965 #define elm_widget_item_cursor_set(item, cursor) \
966   _elm_widget_item_cursor_set((Elm_Widget_Item *)item, cursor)
967 /**
968  * Convenience function to get widget item cursor.
969  * @see _elm_widget_item_cursor_get()
970  */
971 #define elm_widget_item_cursor_get(item) \
972   _elm_widget_item_cursor_get((const Elm_Widget_Item *)item)
973 /**
974  * Convenience function to unset widget item cursor.
975  * @see _elm_widget_item_cursor_unset()
976  */
977 #define elm_widget_item_cursor_unset(item) \
978   _elm_widget_item_cursor_unset((Elm_Widget_Item *)item)
979 /**
980  * Convenience function to change item's cursor style.
981  * @see _elm_widget_item_cursor_style_set()
982  */
983 #define elm_widget_item_cursor_style_set(item, style) \
984   _elm_widget_item_cursor_style_set((Elm_Widget_Item *)item, style)
985 /**
986  * Convenience function to query item's cursor style.
987  * @see _elm_widget_item_cursor_style_get()
988  */
989 #define elm_widget_item_cursor_style_get(item) \
990   _elm_widget_item_cursor_style_get((const Elm_Widget_Item *)item)
991 /**
992  * Convenience function to change item's cursor engine_only.
993  * @see _elm_widget_item_cursor_engine_only_set()
994  */
995 #define elm_widget_item_cursor_engine_only_set(item, engine_only) \
996   _elm_widget_item_cursor_engine_only_set((Elm_Widget_Item *)item, engine_only)
997 /**
998  * Convenience function to query item's cursor engine_only.
999  * @see _elm_widget_item_cursor_engine_only_get()
1000  */
1001 #define elm_widget_item_cursor_engine_only_get(item) \
1002   _elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item)
1003 /**
1004  * Convenience function to query item's content set hook.
1005  * @see _elm_widget_item_content_set_hook_set()
1006  */
1007 #define elm_widget_item_content_set_hook_set(item, func) \
1008   _elm_widget_item_content_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Content_Set_Cb)func)
1009 /**
1010  * Convenience function to query item's content get hook.
1011  * @see _elm_widget_item_content_get_hook_set()
1012  */
1013 #define elm_widget_item_content_get_hook_set(item, func) \
1014   _elm_widget_item_content_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Content_Get_Cb)func)
1015 /**
1016  * Convenience function to query item's content unset hook.
1017  * @see _elm_widget_item_content_unset_hook_set()
1018  */
1019 #define elm_widget_item_content_unset_hook_set(item, func) \
1020   _elm_widget_item_content_unset_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Content_Unset_Cb)func)
1021 /**
1022  * Convenience function to query item's text set hook.
1023  * @see _elm_widget_item_text_set_hook_set()
1024  */
1025 #define elm_widget_item_text_set_hook_set(item, func) \
1026   _elm_widget_item_text_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Text_Set_Cb)func)
1027 /**
1028  * Convenience function to query item's text get hook.
1029  * @see _elm_widget_item_text_get_hook_set()
1030  */
1031 #define elm_widget_item_text_get_hook_set(item, func) \
1032   _elm_widget_item_text_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Text_Get_Cb)func)
1033 /**
1034  * Convenience function to query item's signal emit hook.
1035  * @see _elm_widget_item_signal_emit_hook_set()
1036  */
1037 #define elm_widget_item_signal_emit_hook_set(item, func) \
1038   _elm_widget_item_signal_emit_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Signal_Emit_Cb)func)
1039 /**
1040  * Convenience function to query disable get hook.
1041  * @see _elm_widget_item_disabled_get()
1042  */
1043 #define elm_widget_item_disabled_get(item) \
1044   _elm_widget_item_disabled_get((Elm_Widget_Item *)item)
1045 /**
1046  * Convenience function to query disable set hook.
1047  * @see _elm_widget_item_disable_hook_set()
1048  */
1049 #define elm_widget_item_disable_hook_set(item, func) \
1050   _elm_widget_item_disable_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Disable_Cb)func)
1051 /**
1052  * Convenience function to query del pre hook.
1053  * @see _elm_widget_item_del_pre_hook_set()
1054  */
1055 #define elm_widget_item_del_pre_hook_set(item, func) \
1056   _elm_widget_item_del_pre_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Del_Pre_Cb)func)
1057
1058 #define ELM_WIDGET_CHECK_OR_RETURN(obj, ...)                    \
1059    do {                                                         \
1060         if (!obj || !evas_object_smart_data_get(obj))           \
1061           {                                                     \
1062              WRN("Object [%p] is already deleted", obj);        \
1063              return __VA_ARGS__;                                \
1064           }                                                     \
1065    } while (0)
1066
1067 #define ELM_WIDGET_CHECK_OR_GOTO(obj, label)                    \
1068    do {                                                         \
1069         if (!obj || !evas_object_smart_data_get(obj))           \
1070           {                                                     \
1071              WRN("Object [%p] is already deleted", obj);        \
1072              goto label;                                        \
1073           }                                                     \
1074    } while (0)
1075
1076 #define ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, ...)              \
1077    do {                                                         \
1078        if (item && (item)->on_deletion) {                       \
1079             CRITICAL("Elm_Widget_Item " # item " is deleting"); \
1080             return __VA_ARGS__;                                 \
1081         }                                                       \
1082            ELM_WIDGET_CHECK_OR_RETURN((item)->widget, __VA_ARGS__); \
1083    } while (0)
1084
1085
1086 #define ELM_WIDGET_ITEM_GOTO_IF_ONDEL(item, label)              \
1087    do {                                                         \
1088        if (item && (item)->on_deletion) {                       \
1089             CRITICAL("Elm_Widget_Item " # item " is deleting"); \
1090             goto label;                                         \
1091         }                                                       \
1092        ELM_WIDGET_CHECK_OR_GOTO((item)->widget, label);         \
1093    } while (0)
1094
1095 #define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...)               \
1096    do {                                                          \
1097        if (!item) {                                              \
1098             CRITICAL("Elm_Widget_Item " # item " is NULL");      \
1099             return __VA_ARGS__;                                  \
1100        }                                                         \
1101        if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) {     \
1102             EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC);        \
1103             return __VA_ARGS__;                                  \
1104        }                                                         \
1105        ELM_WIDGET_CHECK_OR_RETURN((item)->widget, __VA_ARGS__);  \
1106   } while (0)
1107
1108 #define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label)              \
1109   do {                                                          \
1110        if (!item) {                                             \
1111             CRITICAL("Elm_Widget_Item " # item " is NULL");     \
1112             goto label;                                         \
1113        }                                                        \
1114       if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) {     \
1115            EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC);        \
1116            goto label;                                          \
1117         }                                                       \
1118       ELM_WIDGET_CHECK_OR_GOTO((item)->widget, label);          \
1119   } while (0)
1120
1121 /* to be used by INTERNAL classes on Elementary, so that the widgets
1122  * parsing script skips it */
1123 #define ELM_INTERNAL_SMART_SUBCLASS_NEW EVAS_SMART_SUBCLASS_NEW
1124
1125 /**
1126  * The drag and drop API.
1127  * Currently experimental, and will change when it does dynamic type
1128  * addition RSN.
1129  *
1130  * Here so applications can start to use it, if they ask elm nicely.
1131  *
1132  * And yes, elm_widget, should probably be elm_experimental...
1133  * Complaints about this code should go to /dev/null, or failing that nash.
1134  */
1135 EAPI Eina_Bool elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_Drop_Cb, void *);
1136 EAPI Eina_Bool elm_drop_target_del(Evas_Object *widget);
1137 EAPI Eina_Bool elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data, void (*dragdone) (void *data, Evas_Object *), void *donecbdata);
1138 EAPI Eina_Bool elm_selection_selection_has_owner(Evas_Object *obj);
1139
1140 #endif