Merge "[elc_navigationbar]: prevent defect fix 20519, removed unnecessary test as...
[framework/uifw/elementary.git] / src / lib / elm_widget.h
index 98a17f5..3e5e8b9 100644 (file)
@@ -5,33 +5,33 @@
  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK IT
  * AT RUNTIME
- * 
+ *
  * How to make your own widget? like this:
- * 
+ *
  * #include <Elementary.h>
  * #include "elm_priv.h"
- * 
+ *
  * typedef struct _Widget_Data Widget_Data;
- *    
+ *
  * struct _Widget_Data
  * {
  *   Evas_Object *sub;
  *   // add any other widget data here too
  * };
- * 
+ *
  * static const char *widtype = NULL;
  * static void _del_hook(Evas_Object *obj);
  * static void _theme_hook(Evas_Object *obj);
  * static void _disable_hook(Evas_Object *obj);
  * static void _sizing_eval(Evas_Object *obj);
  * static void _on_focus_hook(void *data, Evas_Object *obj);
- * 
+ *
  * static const char SIG_CLICKED[] = "clicked";
  * static const Evas_Smart_Cb_Description _signals[] = {
  *   {SIG_CLICKED, ""},
  *   {NULL, NULL}
  * };
- * 
+ *
  * static void
  * _del_hook(Evas_Object *obj)
  * {
@@ -40,7 +40,7 @@
  *    // delete hook - on delete of object delete object struct etc.
  *    free(wd);
  * }
- * 
+ *
  * static void
  * _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
  * {
  *         evas_object_focus_set(wd->sub, EINA_FALSE);
  *      }
  * }
- * 
+ *
  * static void
  * _theme_hook(Evas_Object *obj)
  * {
  *    Widget_Data *wd = elm_widget_data_get(obj);
  *    if (!wd) return;
  *    // handle change in theme/scale etc.
- *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base", 
+ *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base",
  *                                elm_widget_style_get(obj));
  * }
- * 
+ *
  * static void
  * _disable_hook(Evas_Object *obj)
  * {
@@ -81,7 +81,7 @@
  *    else
  *      edje_object_signal_emit(wd->sub, "elm,state,enabled", "elm");
  * }
- * 
+ *
  * static void
  * _sizing_eval(Evas_Object *obj)
  * {
@@ -94,7 +94,7 @@
  *    evas_object_size_hint_min_set(obj, minw, minh);
  *    evas_object_size_hint_max_set(obj, maxw, maxh);
  * }
- * 
+ *
  * // actual api to create your widget. add more to manipulate it as needed
  * // mark your calls with EAPI to make them "external api" calls.
  * EAPI Evas_Object *
  *    Evas_Object *obj;
  *    Evas *e;
  *    Widget_Data *wd;
- * 
+ *
  *    // ALWAYS call this - this checks that your widget matches that of
  *    // elementary and that the api hasn't broken. if it has this returns
  *    // false and you need to handle this error gracefully
  *    if (!elm_widget_api_check(ELM_INTERNAL_API_VERSION)) return NULL;
- * 
- *    // basic - allocate data for widget and fill it
- *    wd = ELM_NEW(Widget_Data);
- *    e = evas_object_evas_get(parent);
- *    if (!e) return NULL;
- *    obj = elm_widget_add(e);
+ *
+ *    // standard widget setup and allocate wd, create obj given parent etc.
+ *    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
+ *
  *    // give it a type name and set up a mywidget type string if needed
  *    ELM_SET_WIDTYPE(widtype, "mywidget");
  *    elm_widget_type_set(obj, "mywidget");
  *    elm_widget_disable_hook_set(obj, _disable_hook);
  *    // this widget can focus (true means yes it can, false means it can't)
  *    elm_widget_can_focus_set(obj, EINA_TRUE);
- * 
+ *
  *    // for this widget we will add 1 sub object that is an edje object
  *    wd->sub = edje_object_add(e);
  *    // set the theme. this follows a scheme for group name like this:
  *    // set this sub object as the "resize object". widgets get 1 resize
  *    // object that is resized along with the object wrapper.
  *    elm_widget_resize_object_set(obj, wd->sub);
- * 
+ *
  *    // evaluate sizing of the widget (minimum size calc etc.). optional but
  *    // not a bad idea to do here. it will get queued for later anyway
  *    _sizing_eval(obj);
- * 
+ *
  *    // register the smart callback descriptions so we can have some runtime
  *    // info as to what the smart callback strings mean
  *    evas_object_smart_callbacks_descriptions_set(obj, _signals);
  *    return obj;
  * }
- * 
+ *
  * // example - do "whatever" to the widget (here just emit a signal)
  * EAPI void
  * elm_mywidget_whatever(Evas_Object *obj)
  *    // do whatever you like
  *    edje_object_signal_emit(wd->sub, "elm,state,action,whatever", "elm");
  * }
- * 
+ *
  * // you can add more - you need to see elementary's code to know how to
  * // handle all cases. remember this api is not stable and may change. it's
  * // internal
- * 
+ *
  */
 
-#ifndef ELM_INTERAL_API_MDFGELQ
+#ifndef ELM_INTERNAL_API_ARGESFSDFEFC
 # warning "You are using an internal elementary API. This API is not stable"
 # warning "and is subject to change. You use this at your own risk."
 # warning "Remember to call elm_widget_api_check(ELM_INTERNAL_API_VERSION);"
 # warning "in your widgets before you call any other elm_widget calls to do"
-# warning "a correct runtime version check."
+# warning "a correct runtime version check. Also remember - you don't NEED"
+# warning "to make an Elementary widget is almost ALL cases. You can easily"
+# warning "make a smart object with Evas's API and do everything you need"
+# warning "there. You only need a widget if you want to seamlessly be part"
+# warning "of the focus tree and want to transparently become a container"
+# warning "for any number of child Elementary widgets"
+//# error "ERROR. Compile aborted." // Note : Do not merge this from upstream.
 #endif
 #define ELM_INTERNAL_API_VERSION 7000
 
@@ -188,22 +192,46 @@ typedef struct _Elm_Tooltip Elm_Tooltip;
 typedef struct _Elm_Cursor Elm_Cursor;
 typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */
 
+typedef void (*Elm_Widget_On_Text_Set_Cb)(void *data, const char *part, const char *text);
+typedef void (*Elm_Widget_On_Content_Set_Cb)(void *data, const char *part, Evas_Object *content);
+typedef const char *(*Elm_Widget_On_Text_Get_Cb)(const void *data, const char *part);
+typedef Evas_Object *(*Elm_Widget_On_Content_Get_Cb)(const void *data, const char *part);
+typedef Evas_Object *(*Elm_Widget_On_Content_Unset_Cb)(const void *data, const char *part);
+typedef void (*Elm_Widget_On_Signal_Emit_Cb)(void *data, const char *emission, const char *source);
+
 struct _Elm_Widget_Item
 {
    /* ef1 ~~ efl, el3 ~~ elm */
 #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301
    EINA_MAGIC;
-   
+
    Evas_Object   *widget; /**< the owner widget that owns this item */
    Evas_Object   *view; /**< the base view object */
    const void    *data; /**< item specific data */
    Evas_Smart_Cb  del_cb; /**< used to notify the item is being deleted */
+   Elm_Widget_On_Content_Set_Cb on_content_set_func;
+   Elm_Widget_On_Content_Get_Cb on_content_get_func;
+   Elm_Widget_On_Content_Unset_Cb on_content_unset_func;
+   Elm_Widget_On_Text_Set_Cb on_text_set_func;
+   Elm_Widget_On_Text_Get_Cb on_text_get_func;
+   Elm_Widget_On_Signal_Emit_Cb on_signal_emit_func;
    /* widget variations should have data from here and on */
    /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */
 };
 
+struct _Elm_Object_Item
+{
+   Elm_Widget_Item it;
+};
+
 #define ELM_NEW(t) calloc(1, sizeof(t))
 
+#define ELM_CAST(p) ((void *)(p))
+
+#define ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ...)                               \
+   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *) (it), __VA_ARGS__);  \
+   ELM_CHECK_WIDTYPE(it->it.widget, widtype) __VA_ARGS__;
+
 EAPI Eina_Bool        elm_widget_api_check(int ver);
 EAPI Evas_Object     *elm_widget_add(Evas *evas);
 EAPI void             elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
@@ -215,8 +243,8 @@ EAPI void             elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (
 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));
 EAPI void             elm_widget_changed_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
 EAPI void             elm_widget_signal_emit_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source));
-EAPI void             elm_widget_signal_callback_add_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data));
-EAPI void             elm_widget_signal_callback_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data));
+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));
+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));
 EAPI void             elm_widget_theme(Evas_Object *obj);
 EAPI void             elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
 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));
@@ -224,6 +252,16 @@ EAPI void             elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func
 EAPI void             elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
 EAPI void             elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
 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));
+EAPI void             elm_widget_text_set_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Set_Cb func);
+#define elm_widget_text_set_hook_set(obj, func) elm_widget_text_set_hook_set(obj, (Elm_Widget_On_Text_Set_Cb)(func))
+EAPI void             elm_widget_text_get_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Get_Cb func);
+#define elm_widget_text_get_hook_set(obj, func) elm_widget_text_get_hook_set(obj, (Elm_Widget_On_Text_Get_Cb)(func))
+EAPI void             elm_widget_content_set_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Set_Cb func);
+#define elm_widget_content_set_hook_set(obj, func) elm_widget_content_set_hook_set(obj, (Elm_Widget_On_Content_Set_Cb)(func))
+EAPI void             elm_widget_content_get_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Get_Cb func);
+#define elm_widget_content_get_hook_set(obj, func) elm_widget_content_get_hook_set(obj, (Elm_Widget_On_Content_Get_Cb)(func))
+EAPI void             elm_widget_content_unset_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Unset_Cb func);
+#define elm_widget_content_unset_hook_set(obj, func) elm_widget_content_unset_hook_set(obj, (Elm_Widget_On_Content_Unset_Cb)(func))
 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));
 EAPI void             elm_widget_data_set(Evas_Object *obj, void *data);
 EAPI void            *elm_widget_data_get(const Evas_Object *obj);
@@ -237,6 +275,8 @@ EAPI void            *elm_widget_signal_callback_del(Evas_Object *obj, const cha
 EAPI void             elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
 EAPI Eina_Bool        elm_widget_can_focus_get(const Evas_Object *obj);
 EAPI Eina_Bool        elm_widget_child_can_focus_get(const Evas_Object *obj);
+EAPI void             elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
+EAPI Eina_Bool        elm_widget_tree_unfocusable_get(const Evas_Object *obj);
 EAPI void             elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
 EAPI Eina_Bool        elm_widget_highlight_ignore_get(const Evas_Object *obj);
 EAPI void             elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
@@ -262,11 +302,27 @@ EAPI void             elm_widget_focus_set(Evas_Object *obj, int first);
 EAPI void             elm_widget_focused_object_clear(Evas_Object *obj);
 EAPI Evas_Object     *elm_widget_parent_get(const Evas_Object *obj);
 EAPI void             elm_widget_focus_steal(Evas_Object *obj);
+
+/**
+ * @internal
+ *
+ * Restore the focus state of the sub-tree.
+ *
+ * This API will restore the focus state of the sub-tree to the lastest
+ * state. If a sub-tree is unfocused and wants to get back to the lastest
+ * focus state, this API will be helpful.
+ *
+ * @param obj The widget root of sub-tree
+ *
+ * @ingroup Widget
+ */
+EAPI void             elm_widget_focus_restore(Evas_Object *obj);
+
 EAPI void             elm_widget_activate(Evas_Object *obj);
 EAPI void             elm_widget_change(Evas_Object *obj);
-EAPI void             elm_widget_disabled_set(Evas_Object *obj, int disabled);
-EAPI int              elm_widget_disabled_get(const Evas_Object *obj);
-EAPI void             elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
+EAPI void             elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabled);
+EAPI Eina_Bool        elm_widget_disabled_get(const Evas_Object *obj);
+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);
 EAPI void             elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
 EAPI void             elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
 EAPI void             elm_widget_scroll_hold_push(Evas_Object *obj);
@@ -299,10 +355,19 @@ EAPI int              elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
 EAPI int              elm_widget_drag_child_locked_y_get(const Evas_Object *obj);
 EAPI Eina_Bool        elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle);
 EAPI void             elm_widget_type_register(const char **ptr);
+EAPI void             elm_widget_type_unregister(const char **ptr);
 EAPI Eina_Bool        elm_widget_type_check(const Evas_Object *obj, const char *type);
 EAPI Eina_List       *elm_widget_stringlist_get(const char *str);
 EAPI void             elm_widget_stringlist_free(Eina_List *list);
-
+EAPI void             elm_widget_focus_hide_handle(Evas_Object *obj);
+EAPI void             elm_widget_focus_mouse_down_handle(Evas_Object *obj);
+EAPI void             elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj);
+EAPI void             elm_widget_focus_disabled_handle(Evas_Object *obj);
+EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label);
+EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *part);
+EAPI void             elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
+EAPI Evas_Object     *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
+EAPI Evas_Object     *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
 EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
 EAPI void             _elm_widget_item_del(Elm_Widget_Item *item);
 EAPI void             _elm_widget_item_pre_notify_del(Elm_Widget_Item *item);
@@ -321,6 +386,18 @@ EAPI void             _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, c
 EAPI const char      *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item);
 EAPI void             _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only);
 EAPI Eina_Bool        _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item);
+EAPI void             _elm_widget_item_content_part_set(Elm_Widget_Item *item, const char *part, Evas_Object *content);
+EAPI Evas_Object     *_elm_widget_item_content_part_get(const Elm_Widget_Item *item, const char *part);
+EAPI Evas_Object     *_elm_widget_item_content_part_unset(Elm_Widget_Item *item, const char *part);
+EAPI void             _elm_widget_item_text_part_set(Elm_Widget_Item *item, const char *part, const char *label);
+EAPI const char      *_elm_widget_item_text_part_get(const Elm_Widget_Item *item, const char *part);
+EAPI void             _elm_widget_item_signal_emit(Elm_Widget_Item *item, const char *emission, const char *source);
+EAPI void             _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Set_Cb func);
+EAPI void             _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Get_Cb func);
+EAPI void             _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Unset_Cb func);
+EAPI void             _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Set_Cb func);
+EAPI void             _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Get_Cb func);
+EAPI void             _elm_widget_item_signal_emit_hook_set(Elm_Widget_Item *it, Elm_Widget_On_Signal_Emit_Cb func);
 
 /* debug function. don't use it unless you are tracking parenting issues */
 EAPI void             elm_widget_tree_dump(const Evas_Object *top);
@@ -440,6 +517,78 @@ EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out
  */
 #define elm_widget_item_cursor_engine_only_get(item) \
   _elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item)
+/**
+ * Convenience function to query item's content part set.
+ * @see _elm_widget_item_content_part_set()
+ */
+#define elm_widget_item_content_part_set(item, part, content) \
+  _elm_widget_item_content_part_set((Elm_Widget_Item *)item, part, content)
+/**
+ * Convenience function to query item's content part get.
+ * @see _elm_widget_item_content_part_get()
+ */
+#define elm_widget_item_content_part_get(item, part) \
+  _elm_widget_item_content_part_get((const Elm_Widget_Item *)item, part)
+/**
+ * Convenience function to query item's content part unset.
+ * @see _elm_widget_item_content_part_unset()
+ */
+#define elm_widget_item_content_part_unset(item, part) \
+  _elm_widget_item_content_part_unset((Elm_Widget_Item *)item, part)
+/**
+ * Convenience function to query item's text part set.
+ * @see _elm_widget_item_text_part_set()
+ */
+#define elm_widget_item_text_part_set(item, part, label) \
+  _elm_widget_item_text_part_set((Elm_Widget_Item *)item, part, label)
+/**
+ * Convenience function to query item's text part get.
+ * @see _elm_widget_item_text_part_get()
+ */
+#define elm_widget_item_text_part_get(item, part) \
+  _elm_widget_item_text_part_get((const Elm_Widget_Item *)item, part)
+/**
+ * Convenience function to query item's signal emit.
+ * @see _elm_widget_item_signal_emit()
+ */
+#define elm_widget_item_signal_emit(item, emission, source) \
+  _elm_widget_item_signal_emit((Elm_Widget_Item *)item, emission, source)
+/**
+ * Convenience function to query item's content set hook.
+ * @see _elm_widget_item_content_set_hook_set()
+ */
+#define elm_widget_item_content_set_hook_set(item, func) \
+  _elm_widget_item_content_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Set_Cb)func)
+/**
+ * Convenience function to query item's content get hook.
+ * @see _elm_widget_item_content_get_hook_set()
+ */
+#define elm_widget_item_content_get_hook_set(item, func) \
+  _elm_widget_item_content_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Get_Cb)func)
+/**
+ * Convenience function to query item's content unset hook.
+ * @see _elm_widget_item_content_unset_hook_set()
+ */
+#define elm_widget_item_content_unset_hook_set(item, func) \
+  _elm_widget_item_content_unset_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Unset_Cb)func)
+/**
+ * Convenience function to query item's text set hook.
+ * @see _elm_widget_item_text_set_hook_set()
+ */
+#define elm_widget_item_text_set_hook_set(item, func) \
+  _elm_widget_item_text_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Set_Cb)func)
+/**
+ * Convenience function to query item's text get hook.
+ * @see _elm_widget_item_text_get_hook_set()
+ */
+#define elm_widget_item_text_get_hook_set(item, func) \
+  _elm_widget_item_text_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Get_Cb)func)
+/**
+ * Convenience function to query item's signal emit hook.
+ * @see _elm_widget_item_signal_emit_hook_set()
+ */
+#define elm_widget_item_signal_emit_hook_set(item, func) \
+  _elm_widget_item_signal_emit_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Signal_Emit_Cb)func)
 
 /**
  * Cast and ensure the given pointer is an Elm_Widget_Item or return NULL.
@@ -491,6 +640,13 @@ EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out
    ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label);         \
    if (!elm_widget_type_check((it->base.widget), (widtype))) goto label;
 
+#define ELM_WIDGET_STANDARD_SETUP(wdat, wdtype, par, evas, ob, ret) \
+   do { \
+      EINA_SAFETY_ON_NULL_RETURN_VAL((par), (ret)); \
+      evas = evas_object_evas_get(par); if (!(evas)) return (ret); \
+      wdat = ELM_NEW(wdtype); if (!(wdat)) return (ret); \
+      ob = elm_widget_add(evas); if (!(ob)) { free(wdat); return (ret); } \
+   } while (0)
 
 /**
  * The drag and drop API.
@@ -545,5 +701,4 @@ Eina_Bool            elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_
 Eina_Bool            elm_drop_target_del(Evas_Object *widget);
 Eina_Bool            elm_drag_start(Evas_Object *, Elm_Sel_Format, const char *, void (*)(void *,Evas_Object*),void*);
 
-
 #endif