diff --git a/legacy/elementary/src/bin/test_drag.c b/legacy/elementary/src/bin/test_drag.c index 8f6442f3d8..c7328bd8fc 100644 --- a/legacy/elementary/src/bin/test_drag.c +++ b/legacy/elementary/src/bin/test_drag.c @@ -1,11 +1,14 @@ -#include - -#include #include -#include "elm_priv.h" /* nash: I have NFI what this does: Just copying the other tests */ #ifndef ELM_LIB_QUICKLAUNCH +// FIXME: nash - depends on Ecore_X.h - shouldnt. should be agnostic of display +// system here and elm provide any dnd stuff needed, wrapped as needed +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#ifdef HAVE_ELEMENTARY_X +# include #define IM "/home/nash/work/samsung/autopaste/images/" static const char *images[] = { @@ -37,7 +40,7 @@ test_drag_source(void *data, Evas_Object *obj, void *eventinfo){ evas_object_show(bx); ctrls = elm_box_add(win); - elm_box_horizontal_set(ctrls, true); + elm_box_horizontal_set(ctrls, EINA_TRUE); evas_object_size_hint_weight_set(ctrls, EVAS_HINT_EXPAND, 0); evas_object_size_hint_align_set(ctrls, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_box_pack_end(bx, ctrls); @@ -72,13 +75,13 @@ test_drag_source(void *data, Evas_Object *obj, void *eventinfo){ static Eina_Bool _dnd_enter(void *data, int etype, void *ev){ printf("enter\n"); - return true; + return EINA_TRUE; } static Eina_Bool _dnd_leave(void *data, int etype, void *ev){ printf("leave\n"); - return true; + return EINA_TRUE; } static Eina_Bool _dnd_position(void *data, int etype, void *ev){ @@ -96,14 +99,14 @@ _dnd_position(void *data, int etype, void *ev){ rect.y = pos->position.y - 5; rect.width = 10; rect.height = 10; - ecore_x_dnd_send_status(true, false, rect, pos->action); + ecore_x_dnd_send_status(EINA_TRUE, EINA_FALSE, rect, pos->action); - return true; + return EINA_TRUE; } static Eina_Bool _dnd_status(void *data, int etype, void *ev){ printf("status\n"); - return true; + return EINA_TRUE; } @@ -120,16 +123,16 @@ _dnd_drop(void *data, int etype, void *ev){ /* FIXME: elm_selection_get is in elm_priv.h and does not build with -fvisibility=hidden */ // rv = elm_selection_get(ELM_SEL_XDND, ELM_SEL_MARKUP, en); -// if (rv != true){ +// if (rv != EINA_TRUE){ // printf("Selection set fail\n"); // } - return true; + return EINA_TRUE; } static Eina_Bool _dnd_finish(void *data, int etype, void *ev){ printf("finish\n"); - return true; + return EINA_TRUE; } void test_drag_dest(void *data, Evas_Object *obj, void *event){ @@ -174,7 +177,7 @@ test_drag_dest(void *data, Evas_Object *obj, void *event){ ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); xwin = (Ecore_X_Window)ecore_evas_window_get(ee); - ecore_x_dnd_aware_set(xwin, true); + ecore_x_dnd_aware_set(xwin, EINA_TRUE); evas_object_show(win); } @@ -183,6 +186,19 @@ void test_drag_genlist(void *data, Evas_Object *obj, void *event){ printf("No genlist yet\n"); } - +#else +void +test_drag_source(void *data, Evas_Object *obj, void *eventinfo) +{ +} +void +test_drag_dest(void *data, Evas_Object *obj, void *event) +{ +} +void +test_drag_genlist(void *data, Evas_Object *obj, void *event) +{ +} +#endif #endif diff --git a/legacy/elementary/src/edje_externals/Makefile.am b/legacy/elementary/src/edje_externals/Makefile.am index da3f967370..e60e7426d9 100644 --- a/legacy/elementary/src/edje_externals/Makefile.am +++ b/legacy/elementary/src/edje_externals/Makefile.am @@ -1,6 +1,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ +-DELM_INTERAL_API_MDFGELQ=1 \ -I. \ -I$(top_builddir) \ -I$(top_srcdir) \ diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am index e209dc9fb7..046490ebfa 100644 --- a/legacy/elementary/src/lib/Makefile.am +++ b/legacy/elementary/src/lib/Makefile.am @@ -2,6 +2,7 @@ AUTOMAKE_OPTIONS = 1.4 foreign MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ +-DELM_INTERAL_API_MDFGELQ=1 \ -I. \ -I$(top_builddir) \ -I$(top_srcdir) \ @@ -25,11 +26,12 @@ endif lib_LTLIBRARIES = libelementary.la -includes_HEADERS = Elementary.h +includes_HEADERS = Elementary.h elm_widget.h includesdir = $(includedir)/elementary-@VMAJ@ libelementary_la_SOURCES = \ elm_priv.h \ +\ elm_main.c \ elm_theme.c \ elm_module.c \ diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index cd07403ba7..f26c3f624f 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -473,7 +473,7 @@ _item_realize(Elm_Gengrid_Item *item) const Eina_List *l; const char *key; - item->labels = _elm_stringlist_get(edje_object_data_get(item->base.view, + item->labels = elm_widget_stringlist_get(edje_object_data_get(item->base.view, "labels")); EINA_LIST_FOREACH(item->labels, l, key) { @@ -492,7 +492,7 @@ _item_realize(Elm_Gengrid_Item *item) const Eina_List *l; const char *key; - item->icons = _elm_stringlist_get(edje_object_data_get(item->base.view, + item->icons = elm_widget_stringlist_get(edje_object_data_get(item->base.view, "icons")); EINA_LIST_FOREACH(item->icons, l, key) { @@ -514,7 +514,7 @@ _item_realize(Elm_Gengrid_Item *item) const Eina_List *l; const char *key; - item->states = _elm_stringlist_get(edje_object_data_get(item->base.view, + item->states = elm_widget_stringlist_get(edje_object_data_get(item->base.view, "states")); EINA_LIST_FOREACH(item->states, l, key) { @@ -569,11 +569,11 @@ _item_unrealize(Elm_Gengrid_Item *item) item->base.view = NULL; evas_object_del(item->spacer); item->spacer = NULL; - _elm_stringlist_free(item->labels); + elm_widget_stringlist_free(item->labels); item->labels = NULL; - _elm_stringlist_free(item->icons); + elm_widget_stringlist_free(item->icons); item->icons = NULL; - _elm_stringlist_free(item->states); + elm_widget_stringlist_free(item->states); EINA_LIST_FREE(item->icon_objs, icon) evas_object_del(icon); diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index 8164fd3f0a..fca79c4847 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -900,7 +900,7 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc) const Eina_List *l; const char *key; - it->labels = _elm_stringlist_get(edje_object_data_get(it->base.view, "labels")); + it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "labels")); EINA_LIST_FOREACH(it->labels, l, key) { char *s = it->itc->func.label_get(it->base.data, it->base.widget, l->data); @@ -917,7 +917,7 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc) const Eina_List *l; const char *key; - it->icons = _elm_stringlist_get(edje_object_data_get(it->base.view, "icons")); + it->icons = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "icons")); EINA_LIST_FOREACH(it->icons, l, key) { Evas_Object *ic = it->itc->func.icon_get(it->base.data, it->base.widget, l->data); @@ -936,7 +936,7 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc) const Eina_List *l; const char *key; - it->states = _elm_stringlist_get(edje_object_data_get(it->base.view, "states")); + it->states = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "states")); EINA_LIST_FOREACH(it->states, l, key) { Eina_Bool on = it->itc->func.state_get(it->base.data, it->base.widget, l->data); @@ -988,11 +988,11 @@ _item_unrealize(Elm_Genlist_Item *it) it->base.view = NULL; evas_object_del(it->spacer); it->spacer = NULL; - _elm_stringlist_free(it->labels); + elm_widget_stringlist_free(it->labels); it->labels = NULL; - _elm_stringlist_free(it->icons); + elm_widget_stringlist_free(it->icons); it->icons = NULL; - _elm_stringlist_free(it->states); + elm_widget_stringlist_free(it->states); EINA_LIST_FREE(it->icon_objs, icon) evas_object_del(icon); diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c index bf070b83cb..673176d0c4 100644 --- a/legacy/elementary/src/lib/elm_main.c +++ b/legacy/elementary/src/lib/elm_main.c @@ -315,26 +315,6 @@ _elm_rescale(void) _elm_win_rescale(); } -static Eina_List *widtypes = NULL; - -void -_elm_widtype_register(const char **ptr) -{ - widtypes = eina_list_append(widtypes, (void *)ptr); -} - -static void -_elm_widtype_clear(void) -{ - const char **ptr; - - EINA_LIST_FREE(widtypes, ptr) - { - eina_stringshare_del(*ptr); - *ptr = NULL; - } -} - /** * @defgroup General General */ @@ -611,7 +591,7 @@ elm_quicklaunch_shutdown(void) _elm_log_dom = -1; } - _elm_widtype_clear(); + _elm_widget_type_clear(); eina_shutdown(); } diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index bed9bea7ca..23a8ab5290 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -18,44 +18,75 @@ #include "els_box.h" #include "els_icon.h" +#include "elm_widget.h" #define CRITICAL(...) EINA_LOG_DOM_CRIT(_elm_log_dom, __VA_ARGS__) -#define ERR(...) EINA_LOG_DOM_ERR(_elm_log_dom, __VA_ARGS__) -#define WRN(...) EINA_LOG_DOM_WARN(_elm_log_dom, __VA_ARGS__) -#define INF(...) EINA_LOG_DOM_INFO(_elm_log_dom, __VA_ARGS__) -#define DBG(...) EINA_LOG_DOM_DBG(_elm_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR (_elm_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_elm_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_elm_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG (_elm_log_dom, __VA_ARGS__) -// FIXME: totally disorganised. clean this up! -// -// Why EAPI in a private header ? -// EAPI is temporaty - that widget api will change, but makign it EAPI right now to indicate its bound for externalness +typedef struct _Elm_Config Elm_Config; +typedef struct _Elm_Module Elm_Module; +typedef struct _Elm_Drop_Data Elm_Drop_Data; + +// FIXME: nash - type name wrong (caps) +typedef Eina_Bool (*elm_drop_cb) (void *d, Evas_Object *o, Elm_Drop_Data *data); struct _Elm_Theme { - Eina_List *overlay; - Eina_List *themes; - Eina_List *extension; - Eina_Hash *cache; + Eina_List *overlay; + Eina_List *themes; + Eina_List *extension; + Eina_Hash *cache; const char *theme; - int ref; + int ref; }; typedef enum _Elm_Engine { ELM_SOFTWARE_X11, - ELM_SOFTWARE_FB, - ELM_SOFTWARE_DIRECTFB, - ELM_SOFTWARE_16_X11, - ELM_XRENDER_X11, - ELM_OPENGL_X11, - ELM_SOFTWARE_WIN32, - ELM_SOFTWARE_16_WINCE, - ELM_SOFTWARE_SDL, - ELM_SOFTWARE_16_SDL, - ELM_OPENGL_SDL + ELM_SOFTWARE_FB, + ELM_SOFTWARE_DIRECTFB, + ELM_SOFTWARE_16_X11, + ELM_XRENDER_X11, + ELM_OPENGL_X11, + ELM_SOFTWARE_WIN32, + ELM_SOFTWARE_16_WINCE, + ELM_SOFTWARE_SDL, + ELM_SOFTWARE_16_SDL, + ELM_OPENGL_SDL } Elm_Engine; -typedef struct _Elm_Config Elm_Config; +// FIXME: nash - make typedef like above with caps etc. named right +enum _elm_sel_type +{ + ELM_SEL_PRIMARY, + ELM_SEL_SECONDARY, + ELM_SEL_CLIPBOARD, + ELM_SEL_XDND, + + ELM_SEL_MAX, +}; + +// FIXME: nash - same as above +enum _elm_sel_format +{ + /** Plain unformated text: Used for things that don't want rich markup */ + ELM_SEL_FORMAT_TEXT = 0x01, + /** Edje textblock markup, including inline images */ + ELM_SEL_FORMAT_MARKUP = 0x02, + /** Images */ + ELM_SEL_FORMAT_IMAGE = 0x04, +}; + +struct _Elm_Drop_Data +{ + int x, y; + enum _elm_sel_format format; + void *data; + int len; +}; /* increment this whenever we change config enough that you need new * defaults for elm to work. @@ -69,362 +100,92 @@ typedef struct _Elm_Config Elm_Config; struct _Elm_Config { - int config_version; - int engine; - int thumbscroll_enable; - int thumbscroll_threshhold; - double thumbscroll_momentum_threshhold; - double thumbscroll_friction; - double thumbscroll_bounce_friction; - double page_scroll_friction; - double bring_in_scroll_friction; - double zoom_friction; - int thumbscroll_bounce_enable; - double scale; - int bgpixmap; - int compositing; - Eina_List *font_dirs; - int font_hinting; - int image_cache; - int font_cache; - int finger_size; - double fps; - const char *theme; - const char *modules; - double tooltip_delay; + int config_version; + int engine; + int thumbscroll_enable; + int thumbscroll_threshhold; + double thumbscroll_momentum_threshhold; + double thumbscroll_friction; + double thumbscroll_bounce_friction; + double page_scroll_friction; + double bring_in_scroll_friction; + double zoom_friction; + int thumbscroll_bounce_enable; + double scale; + int bgpixmap; + int compositing; + Eina_List *font_dirs; + int font_hinting; + int image_cache; + int font_cache; + int finger_size; + double fps; + const char *theme; + const char *modules; + double tooltip_delay; }; -typedef struct _Elm_Module Elm_Module; - struct _Elm_Module { - int version; - const char *name; - const char *as; - const char *so_path; - const char *data_dir; - const char *bin_dir; - void *handle; - void *data; - void *api; - int (*init_func) (Elm_Module *m); - int (*shutdown_func) (Elm_Module *m); - int references; + int version; + const char *name; + const char *as; + const char *so_path; + const char *data_dir; + const char *bin_dir; + void *handle; + void *data; + void *api; + int (*init_func) (Elm_Module *m); + int (*shutdown_func) (Elm_Module *m); + int references; }; +void _elm_win_shutdown(void); +void _elm_win_rescale(void); -enum _elm_sel_type { - ELM_SEL_PRIMARY, - ELM_SEL_SECONDARY, - ELM_SEL_CLIPBOARD, - ELM_SEL_XDND, +int _elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, const char *group, const char *style); +int _elm_theme_object_icon_set(Evas_Object *parent, Evas_Object *o, const char *group, const char *style); +int _elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *group, const char *style); +int _elm_theme_icon_set(Elm_Theme *th, Evas_Object *o, const char *group, const char *style); +int _elm_theme_parse(Elm_Theme *th, const char *theme); +void _elm_theme_shutdown(void); - ELM_SEL_MAX, -}; +void _elm_module_init(void); +void _elm_module_shutdown(void); +void _elm_module_parse(const char *s); +Elm_Module *_elm_module_find_as(const char *as); +Elm_Module *_elm_module_add(const char *name, const char *as); +void _elm_module_del(Elm_Module *m); +const void *_elm_module_symbol_get(Elm_Module *m, const char *name); -enum _elm_sel_format { - /** Plain unformated text: Used for things that don't want rich markup */ - ELM_SEL_FORMAT_TEXT = 0x01, - /** Edje textblock markup, including inline images */ - ELM_SEL_FORMAT_MARKUP = 0x02, - /** Images */ - ELM_SEL_FORMAT_IMAGE = 0x04, -}; +void _elm_widget_type_clear(void); +void _elm_unneed_ethumb(void); +void _elm_rescale(void); -#define ELM_NEW(t) calloc(1, sizeof(t)) +void _elm_config_init(void); +void _elm_config_sub_init(void); +void _elm_config_shutdown(void); -void _elm_win_shutdown(void); -void _elm_win_rescale(void); +void elm_tooltip_theme(Elm_Tooltip *tt); +void elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb); -int _elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, const char *group, const char *style); -int _elm_theme_object_icon_set(Evas_Object *parent, Evas_Object *o, const char *group, const char *style); -int _elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *group, const char *style); -int _elm_theme_icon_set(Elm_Theme *th, Evas_Object *o, const char *group, const char *style); -int _elm_theme_parse(Elm_Theme *th, const char *theme); -void _elm_theme_shutdown(void); +Eina_Bool elm_selection_set(enum _elm_sel_type selection, Evas_Object *widget, enum _elm_sel_format format, const char *buf); +Eina_Bool elm_selection_clear(enum _elm_sel_type selection, Evas_Object *widget); +Eina_Bool elm_selection_get(enum _elm_sel_type selection, enum _elm_sel_format format, Evas_Object *widget); +Eina_Bool elm_drop_target_add(Evas_Object *widget, enum _elm_sel_type, elm_drop_cb, void *); +Eina_Bool elm_drop_target_del(Evas_Object *widget); +Eina_Bool elm_drag_start(Evas_Object *, enum _elm_sel_format, const char *, void (*)(void *,Evas_Object*),void*); -void _elm_module_init(void); -void _elm_module_shutdown(void); -void _elm_module_parse(const char *s); -Elm_Module *_elm_module_find_as(const char *as); -Elm_Module *_elm_module_add(const char *name, const char *as); -void _elm_module_del(Elm_Module *m); -const void *_elm_module_symbol_get(Elm_Module *m, const char *name); - -/* FIXME: should this be public? for now - private (but public symbols) */ -EAPI Evas_Object *elm_widget_add(Evas *evas); -EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -EAPI void elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -EAPI void elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -EAPI void elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); -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))); -EAPI void elm_widget_theme(Evas_Object *obj); -EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data); -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_data_set(Evas_Object *obj, void *data); -EAPI void *elm_widget_data_get(const Evas_Object *obj); -EAPI void elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); -EAPI void elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); -EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj); -EAPI void elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj); -EAPI void elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source); -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); -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)); -EAPI void elm_widget_can_focus_set(Evas_Object *obj, int can_focus); -EAPI int elm_widget_can_focus_get(const Evas_Object *obj); -EAPI int elm_widget_focus_get(const Evas_Object *obj); -EAPI Evas_Object *elm_widget_focused_object_get(const Evas_Object *obj); -EAPI Evas_Object *elm_widget_top_get(const Evas_Object *obj); -EAPI int elm_widget_focus_jump(Evas_Object *obj, int forward); -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); -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_show_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); -EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj); -EAPI int elm_widget_scroll_hold_get(const Evas_Object *obj); -EAPI void elm_widget_scroll_freeze_push(Evas_Object *obj); -EAPI void elm_widget_scroll_freeze_pop(Evas_Object *obj); -EAPI int elm_widget_scroll_freeze_get(const Evas_Object *obj); -EAPI void elm_widget_scale_set(Evas_Object *obj, double scale); -EAPI double elm_widget_scale_get(const Evas_Object *obj); -EAPI void elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th); -EAPI Elm_Theme *elm_widget_theme_get(const Evas_Object *obj); -EAPI void elm_widget_style_set(Evas_Object *obj, const char *style); -EAPI const char *elm_widget_style_get(const Evas_Object *obj); -EAPI void elm_widget_type_set(Evas_Object *obj, const char *type); -EAPI const char *elm_widget_type_get(const Evas_Object *obj); -EAPI void elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock); -EAPI void elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock); -EAPI Eina_Bool elm_widget_drag_lock_x_get(const Evas_Object *obj); -EAPI Eina_Bool elm_widget_drag_lock_y_get(const Evas_Object *obj); -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_is(const Evas_Object *obj); -EAPI Evas_Object *elm_widget_parent_widget_get(const Evas_Object *obj); +Eina_Bool _elm_dangerous_call_check(const char *call); -typedef struct _Elm_Tooltip Elm_Tooltip; -void elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt); -void elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt); -void elm_tooltip_theme(Elm_Tooltip *tt); -EAPI void elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb); - - -EAPI Eina_List *_elm_stringlist_get(const char *str); -EAPI void _elm_stringlist_free(Eina_List *list); - -Eina_Bool _elm_widget_type_check(const Evas_Object *obj, const char *type); - -typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */ -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 */ - /* widget variations should have data from here and on */ - /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */ -}; - -Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size); -void _elm_widget_item_del(Elm_Widget_Item *item); -void _elm_widget_item_pre_notify_del(Elm_Widget_Item *item); -void _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb); -void _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data); -void *_elm_widget_item_data_get(const Elm_Widget_Item *item); -void _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text); -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); -void _elm_widget_item_tooltip_unset(Elm_Widget_Item *item); -void _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style); -const char *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item); - - -/** - * Convenience macro to create new widget item, doing casts for you. - * @see _elm_widget_item_new() - * @param parent a valid elm_widget variant. - * @param type the C type that extends Elm_Widget_Item - */ -#define elm_widget_item_new(parent, type) \ - (type *)_elm_widget_item_new((parent), sizeof(type)) -/** - * Convenience macro to delete widget item, doing casts for you. - * @see _elm_widget_item_del() - * @param item a valid item. - */ -#define elm_widget_item_del(item) \ - _elm_widget_item_del((Elm_Widget_Item *)item) -/** - * Convenience macro to notify deletion of widget item, doing casts for you. - * @see _elm_widget_item_pre_notify_del() - */ -#define elm_widget_item_pre_notify_del(item) \ - _elm_widget_item_pre_notify_del((Elm_Widget_Item *)item) -/** - * Convenience macro to set deletion callback of widget item, doing casts for you. - * @see _elm_widget_item_del_cb_set() - */ -#define elm_widget_item_del_cb_set(item, del_cb) \ - _elm_widget_item_del_cb_set((Elm_Widget_Item *)item, del_cb) - -/** - * Set item's data - * @see _elm_widget_item_data_set() - */ -#define elm_widget_item_data_set(item, data) \ - _elm_widget_item_data_set((Elm_Widget_Item *)item, data) -/** - * Get item's data - * @see _elm_widget_item_data_get() - */ -#define elm_widget_item_data_get(item) \ - _elm_widget_item_data_get((const Elm_Widget_Item *)item) - -/** - * Convenience function to set widget item tooltip as a text string. - * @see _elm_widget_item_tooltip_text_set() - */ -#define elm_widget_item_tooltip_text_set(item, text) \ - _elm_widget_item_tooltip_text_set((Elm_Widget_Item *)item, text) -/** - * Convenience function to set widget item tooltip. - * @see _elm_widget_item_tooltip_content_cb_set() - */ -#define elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb) \ - _elm_widget_item_tooltip_content_cb_set((Elm_Widget_Item *)item, \ - func, data, del_cb) -/** - * Convenience function to unset widget item tooltip. - * @see _elm_widget_item_tooltip_unset() - */ -#define elm_widget_item_tooltip_unset(item) \ - _elm_widget_item_tooltip_unset((Elm_Widget_Item *)item) -/** - * Convenience function to change item's tooltip style. - * @see _elm_widget_item_tooltip_style_set() - */ -#define elm_widget_item_tooltip_style_set(item, style) \ - _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style) -/** - * Convenience function to query item's tooltip style. - * @see _elm_widget_item_tooltip_style_get() - */ -#define elm_widget_item_tooltip_style_get(item) \ - _elm_widget_item_tooltip_style_get((const Elm_Widget_Item *)item) - - -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); - -/** - * Cast and ensure the given pointer is an Elm_Widget_Item or return NULL. - */ -#define ELM_WIDGET_ITEM(item) \ - ((item && EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) ? \ - ((Elm_Widget_Item *)(item)) : NULL) - -#define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \ - do \ - { \ - if (!item) \ - { \ - CRITICAL("Elm_Widget_Item " # item " is NULL!"); \ - return __VA_ARGS__; \ - } \ - if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) \ - { \ - EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \ - return __VA_ARGS__; \ - } \ - } \ - while (0) - -#define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label) \ - do \ - { \ - if (!item) \ - { \ - CRITICAL("Elm_Widget_Item " # item " is NULL!"); \ - goto label; \ - } \ - if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) \ - { \ - EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \ - goto label; \ - } \ - } \ - while (0) - - -void _elm_unneed_ethumb(void); - -void _elm_rescale(void); - -void _elm_config_init(void); -void _elm_config_sub_init(void); -void _elm_config_shutdown(void); - -/* FIXME: nash formatiing */ -typedef struct Elm_Drop_Data { - int x,y; - - enum _elm_sel_format format; - void *data; - int len; -} Elm_Drop_Data; - -typedef Eina_Bool (*elm_drop_cb)(void *, Evas_Object *, Elm_Drop_Data *data); - -Eina_Bool elm_selection_set(enum _elm_sel_type selection, Evas_Object *widget, enum _elm_sel_format format, const char *buf); -Eina_Bool elm_selection_clear(enum _elm_sel_type selection, Evas_Object *widget); -Eina_Bool elm_selection_get(enum _elm_sel_type selection, enum _elm_sel_format format, Evas_Object *widget); -/* FIXME: Need a typedef for the callback */ -Eina_Bool elm_drop_target_add(Evas_Object *widget, - enum _elm_sel_type, elm_drop_cb, void *); -Eina_Bool elm_drop_target_del(Evas_Object *widget); -Eina_Bool elm_drag_start(Evas_Object *, enum _elm_sel_format, - const char *, - void (*)(void *,Evas_Object*),void*); - -Eina_Bool _elm_dangerous_call_check(const char *call); - -void _elm_widtype_register(const char **ptr); - - -#define ELM_SET_WIDTYPE(widtype, type) \ - do { \ - if (!widtype) { \ - widtype = eina_stringshare_add(type); \ - _elm_widtype_register(&widtype); \ - } \ - } while (0) - -//#define ELM_CHECK_WIDTYPE(obj, widtype) if (elm_widget_type_get(obj) != widtype) return -#define ELM_CHECK_WIDTYPE(obj, widtype) if (!_elm_widget_type_check((obj), (widtype))) return - -extern char *_elm_appname; -extern Elm_Config *_elm_config; -extern const char *_elm_data_dir; -extern const char *_elm_lib_dir; -extern int _elm_log_dom; - -extern Eina_List *_elm_win_list; +extern char *_elm_appname; +extern Elm_Config *_elm_config; +extern const char *_elm_data_dir; +extern const char *_elm_lib_dir; +extern int _elm_log_dom; +extern Eina_List *_elm_win_list; #endif diff --git a/legacy/elementary/src/lib/elm_slideshow.c b/legacy/elementary/src/lib/elm_slideshow.c index 6bfaadca95..c53e2f207e 100644 --- a/legacy/elementary/src/lib/elm_slideshow.c +++ b/legacy/elementary/src/lib/elm_slideshow.c @@ -64,7 +64,7 @@ _del_hook(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; elm_slideshow_clear(obj); - _elm_stringlist_free(wd->transitions); + elm_widget_stringlist_free(wd->transitions); if (wd->timer) ecore_timer_del(wd->timer); EINA_LIST_FREE(wd->layout.list, layout) eina_stringshare_del(layout); @@ -255,11 +255,11 @@ elm_slideshow_add(Evas_Object *parent) elm_widget_resize_object_set(obj, wd->slideshow); evas_object_show(wd->slideshow); - wd->transitions = _elm_stringlist_get(edje_object_data_get(wd->slideshow, "transitions")); + wd->transitions = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "transitions")); if (eina_list_count(wd->transitions) > 0) wd->transition = eina_stringshare_add(eina_list_data_get(wd->transitions)); - wd->layout.list = _elm_stringlist_get(edje_object_data_get(wd->slideshow, "layouts")); + wd->layout.list = elm_widget_stringlist_get(edje_object_data_get(wd->slideshow, "layouts")); if (eina_list_count(wd->layout.list) > 0) wd->layout.current = eina_list_data_get(wd->layout.list); diff --git a/legacy/elementary/src/lib/elm_widget.c b/legacy/elementary/src/lib/elm_widget.c index 97edadea76..ab06662eaa 100644 --- a/legacy/elementary/src/lib/elm_widget.c +++ b/legacy/elementary/src/lib/elm_widget.c @@ -78,15 +78,23 @@ static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip); static void _smart_clip_unset(Evas_Object *obj); static void _smart_calculate(Evas_Object *obj); static void _smart_init(void); -static inline Eina_Bool _elm_widget_is(const Evas_Object *obj); static void _if_focused_revert(Evas_Object *obj); /* local subsystem globals */ static Evas_Smart *_e_smart = NULL; +static Eina_List *widtypes = NULL; static unsigned int focus_order = 0; +// internal funcs +static inline Eina_Bool +_elm_widget_is(const Evas_Object *obj) +{ + const char *type = evas_object_type_get(obj); + return type == SMART_NAME; +} + static void _sub_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { @@ -116,6 +124,82 @@ _sub_obj_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, elm_widget_focus_steal(o); } +static void +_propagate_x_drag_lock(Evas_Object *obj, int dir) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + if (sd->parent_obj) + { + Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj); + if (sd2) + { + sd2->child_drag_x_locked += dir; + _propagate_x_drag_lock(sd->parent_obj, dir); + } + } +} + +static void +_propagate_y_drag_lock(Evas_Object *obj, int dir) +{ + Smart_Data *sd = evas_object_smart_data_get(obj); + if (sd->parent_obj) + { + Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj); + if (sd2) + { + sd2->child_drag_y_locked += dir; + _propagate_y_drag_lock(sd->parent_obj, dir); + } + } +} + +static void +_parent_focus(Evas_Object *obj) +{ + API_ENTRY return; + Evas_Object *o = elm_widget_parent_get(obj); + + if (sd->focused) return; + if (o) _parent_focus(o); + focus_order++; + sd->focus_order = focus_order; + sd->focused = 1; + if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj); + if (sd->focus_func) sd->focus_func(obj); +} + +// exposed util funcs to elm +void +_elm_widget_type_clear(void) +{ + const char **ptr; + + EINA_LIST_FREE(widtypes, ptr) + { + eina_stringshare_del(*ptr); + *ptr = NULL; + } +} + +// exposed api for making widgets +EAPI void +elm_widget_type_register(const char **ptr) +{ + widtypes = eina_list_append(widtypes, (void *)ptr); +} + +EAPI Eina_Bool +elm_widget_api_check(int ver) +{ + if (ver != ELM_INTERNAL_API_VERSION) + { + CRITICAL("Elementary widget api versions do not match"); + return EINA_FALSE; + } + return EINA_TRUE; +} + EAPI Evas_Object * elm_widget_add(Evas *evas) { @@ -201,12 +285,10 @@ elm_widget_theme(Evas_Object *obj) Elm_Tooltip *tt; API_ENTRY return; - EINA_LIST_FOREACH(sd->subobjs, l, child) - elm_widget_theme(child); + EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child); if (sd->resize_obj) elm_widget_theme(sd->resize_obj); if (sd->hover_obj) elm_widget_theme(sd->hover_obj); - EINA_LIST_FOREACH(sd->tooltips, l, tt) - elm_tooltip_theme(tt); + EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt); if (sd->theme_func) sd->theme_func(obj); } @@ -266,7 +348,7 @@ elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) if (sd2) { if (sd2->parent_obj) - elm_widget_sub_object_del(sd2->parent_obj, sobj); + elm_widget_sub_object_del(sd2->parent_obj, sobj); sd2->parent_obj = obj; } } @@ -309,7 +391,8 @@ elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj) Smart_Data *sd2 = evas_object_smart_data_get(sobj); if (sd2) sd2->parent_obj = NULL; } - evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd); + evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, + _sub_obj_del, sd); evas_object_smart_callback_call(obj, "sub-object-del", sobj); } @@ -326,9 +409,9 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) if (sd2) sd2->parent_obj = NULL; } evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL, - _sub_obj_del, sd); + _sub_obj_del, sd); evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN, - _sub_obj_mouse_down, sd); + _sub_obj_mouse_down, sd); evas_object_smart_member_del(sd->resize_obj); } sd->resize_obj = sobj; @@ -341,7 +424,8 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) } evas_object_clip_set(sobj, evas_object_clip_get(obj)); evas_object_smart_member_add(sobj, obj); - evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd); + evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, + _sub_obj_del, sd); evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN, _sub_obj_mouse_down, sd); _smart_reconfigure(sd); @@ -362,7 +446,8 @@ elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj) sd->hover_obj = sobj; if (sd->hover_obj) { - evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd); + evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, + _sub_obj_del, sd); _smart_reconfigure(sd); } } @@ -421,9 +506,9 @@ elm_widget_top_get(const Evas_Object *obj) if ((sd) && _elm_widget_is(obj)) { if ((sd->type) && (!strcmp(sd->type, "win"))) - return (Evas_Object *)obj; + return (Evas_Object *)obj; if (sd->parent_obj) - return elm_widget_top_get(sd->parent_obj); + return elm_widget_top_get(sd->parent_obj); } par = evas_object_smart_parent_get(obj); if (!par) return (Evas_Object *)obj; @@ -451,8 +536,7 @@ elm_widget_parent_widget_get(const Evas_Object *obj) else { parent = evas_object_data_get(obj, "elm-parent"); - if (!parent) - parent = evas_object_smart_data_get(obj); + if (!parent) parent = evas_object_smart_data_get(obj); } while (parent) @@ -460,10 +544,8 @@ elm_widget_parent_widget_get(const Evas_Object *obj) Evas_Object *elm_parent; if (_elm_widget_is(parent)) break; elm_parent = evas_object_data_get(parent, "elm-parent"); - if (elm_parent) - parent = elm_parent; - else - parent = evas_object_smart_parent_get(parent); + if (elm_parent) parent = elm_parent; + else parent = evas_object_smart_parent_get(parent); } return parent; } @@ -493,7 +575,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) { int focus_next; int noloop = 0; - + focus_next = 0; if (!sd->focused) { @@ -512,7 +594,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) /* the previous focused item was unfocused - so focus * the next one (that can be focused) */ if (elm_widget_focus_jump(sd->resize_obj, forward)) - return 1; + return 1; else noloop = 1; } else @@ -521,7 +603,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) { /* jump to the next focused item or focus this item */ if (elm_widget_focus_jump(sd->resize_obj, forward)) - return 1; + return 1; /* it returned 0 - it got to the last item and is past it */ focus_next = 1; } @@ -541,7 +623,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) /* the previous focused item was unfocused - so focus * the next one (that can be focused) */ if (elm_widget_focus_jump(child, forward)) - return 1; + return 1; else break; } else @@ -550,7 +632,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) { /* jump to the next focused item or focus this item */ if (elm_widget_focus_jump(child, forward)) - return 1; + return 1; /* it returned 0 - it got to the last item and is past it */ focus_next = 1; } @@ -574,7 +656,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) /* the previous focused item was unfocused - so focus * the next one (that can be focused) */ if (elm_widget_focus_jump(child, forward)) - return 1; + return 1; else break; } else @@ -583,7 +665,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) { /* jump to the next focused item or focus this item */ if (elm_widget_focus_jump(child, forward)) - return 1; + return 1; /* it returned 0 - it got to the last item and is past it */ focus_next = 1; } @@ -600,7 +682,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) /* the previous focused item was unfocused - so focus * the next one (that can be focused) */ if (elm_widget_focus_jump(sd->resize_obj, forward)) - return 1; + return 1; } else { @@ -608,7 +690,7 @@ elm_widget_focus_jump(Evas_Object *obj, int forward) { /* jump to the next focused item or focus this item */ if (elm_widget_focus_jump(sd->resize_obj, forward)) - return 1; + return 1; /* it returned 0 - it got to the last item and is past it */ focus_next = 1; } @@ -729,7 +811,7 @@ elm_widget_focused_object_clear(Evas_Object *obj) API_ENTRY return; if (!sd->focused) return; if (elm_widget_focus_get(sd->resize_obj)) - elm_widget_focused_object_clear(sd->resize_obj); + elm_widget_focused_object_clear(sd->resize_obj); else { const Eina_List *l; @@ -748,21 +830,6 @@ elm_widget_focused_object_clear(Evas_Object *obj) if (sd->focus_func) sd->focus_func(obj); } -static void -_elm_widget_parent_focus(Evas_Object *obj) -{ - API_ENTRY return; - Evas_Object *o = elm_widget_parent_get(obj); - - if (sd->focused) return; - if (o) _elm_widget_parent_focus(o); - focus_order++; - sd->focus_order = focus_order; - sd->focused = 1; - if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj); - if (sd->focus_func) sd->focus_func(obj); -} - EAPI void elm_widget_focus_steal(Evas_Object *obj) { @@ -804,7 +871,7 @@ elm_widget_focus_steal(Evas_Object *obj) } } } - _elm_widget_parent_focus(obj); + _parent_focus(obj); return; } @@ -864,7 +931,7 @@ elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Co sd->rw = w; sd->rh = h; if (sd->on_show_region_func) - sd->on_show_region_func(sd->on_show_region_data, obj); + sd->on_show_region_func(sd->on_show_region_data, obj); } EAPI void @@ -883,7 +950,7 @@ elm_widget_scroll_hold_push(Evas_Object *obj) API_ENTRY return; sd->scroll_hold++; if (sd->scroll_hold == 1) - evas_object_smart_callback_call(obj, "scroll-hold-on", obj); + evas_object_smart_callback_call(obj, "scroll-hold-on", obj); if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj); // FIXME: on delete/reparent hold pop } @@ -895,7 +962,7 @@ elm_widget_scroll_hold_pop(Evas_Object *obj) sd->scroll_hold--; if (sd->scroll_hold < 0) sd->scroll_hold = 0; if (sd->scroll_hold == 0) - evas_object_smart_callback_call(obj, "scroll-hold-off", obj); + evas_object_smart_callback_call(obj, "scroll-hold-off", obj); if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj); } @@ -912,7 +979,7 @@ elm_widget_scroll_freeze_push(Evas_Object *obj) API_ENTRY return; sd->scroll_freeze++; if (sd->scroll_freeze == 1) - evas_object_smart_callback_call(obj, "scroll-freeze-on", obj); + evas_object_smart_callback_call(obj, "scroll-freeze-on", obj); if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj); // FIXME: on delete/reparent freeze pop } @@ -924,7 +991,7 @@ elm_widget_scroll_freeze_pop(Evas_Object *obj) sd->scroll_freeze--; if (sd->scroll_freeze < 0) sd->scroll_freeze = 0; if (sd->scroll_freeze == 0) - evas_object_smart_callback_call(obj, "scroll-freeze-off", obj); + evas_object_smart_callback_call(obj, "scroll-freeze-off", obj); if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj); } @@ -955,9 +1022,9 @@ elm_widget_scale_get(const Evas_Object *obj) if (sd->scale == 0.0) { if (sd->parent_obj) - return elm_widget_scale_get(sd->parent_obj); + return elm_widget_scale_get(sd->parent_obj); else - return 1.0; + return 1.0; } return sd->scale; } @@ -982,9 +1049,9 @@ elm_widget_theme_get(const Evas_Object *obj) if (!sd->theme) { if (sd->parent_obj) - return elm_widget_theme_get(sd->parent_obj); + return elm_widget_theme_get(sd->parent_obj); else - return NULL; + return NULL; } return sd->theme; } @@ -993,9 +1060,9 @@ EAPI void elm_widget_style_set(Evas_Object *obj, const char *style) { API_ENTRY return; - + if (eina_stringshare_replace(&sd->style, style)) - elm_widget_theme(obj); + elm_widget_theme(obj); } EAPI const char * @@ -1021,57 +1088,20 @@ elm_widget_type_get(const Evas_Object *obj) return ""; } -void +EAPI void elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt) { API_ENTRY return; sd->tooltips = eina_list_append(sd->tooltips, tt); } -void +EAPI void elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt) { API_ENTRY return; sd->tooltips = eina_list_remove(sd->tooltips, tt); } - - - - - - - -static void -_propagate_x_drag_lock(Evas_Object *obj, int dir) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (sd->parent_obj) - { - Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj); - if (sd2) - { - sd2->child_drag_x_locked += dir; - _propagate_x_drag_lock(sd->parent_obj, dir); - } - } -} - -static void -_propagate_y_drag_lock(Evas_Object *obj, int dir) -{ - Smart_Data *sd = evas_object_smart_data_get(obj); - if (sd->parent_obj) - { - Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj); - if (sd2) - { - sd2->child_drag_y_locked += dir; - _propagate_y_drag_lock(sd->parent_obj, dir); - } - } -} - EAPI void elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock) { @@ -1120,17 +1150,380 @@ elm_widget_drag_child_locked_y_get(const Evas_Object *obj) return sd->child_drag_y_locked; } +EAPI int +elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle) +{ + return _elm_theme_object_set(obj, edj, wname, welement, wstyle); +} +EAPI Eina_Bool +elm_widget_type_check(const Evas_Object *obj, const char *type) +{ + const char *provided, *expected = "(unknown)"; + static int abort_on_warn = -1; + provided = elm_widget_type_get(obj); + if (EINA_LIKELY(provided == type)) return EINA_TRUE; + if (type) expected = type; + if ((!provided) || (provided[0] == 0)) + { + provided = evas_object_type_get(obj); + if ((!provided) || (provided[0] == 0)) + provided = "(unknown)"; + } + ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected); + if (abort_on_warn == -1) + { + if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1; + else abort_on_warn = 0; + } + if (abort_on_warn == 1) abort(); + return EINA_FALSE; +} +EAPI Eina_List * +elm_widget_stringlist_get(const char *str) +{ + Eina_List *list = NULL; + const char *s, *b; + if (!str) return NULL; + for (b = s = str; 1; s++) + { + if ((*s == ' ') || (*s == 0)) + { + char *t = malloc(s - b + 1); + if (t) + { + strncpy(t, b, s - b); + t[s - b] = 0; + list = eina_list_append(list, eina_stringshare_add(t)); + free(t); + } + b = s + 1; + } + if (*s == 0) break; + } + return list; +} +EAPI void +elm_widget_stringlist_free(Eina_List *list) +{ + const char *s; + EINA_LIST_FREE(list, s) eina_stringshare_del(s); +} +/** + * Allocate a new Elm_Widget_Item-derived structure. + * + * The goal of this structure is to provide common ground for actions + * that a widget item have, such as the owner widget, callback to + * notify deletion, data pointer and maybe more. + * + * @param widget the owner widget that holds this item, must be an elm_widget! + * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will + * be used to allocate memory. + * + * @return allocated memory that is already zeroed out, or NULL on errors. + * + * @see elm_widget_item_new() convenience macro. + * @see elm_widget_item_del() to release memory. + */ +EAPI Elm_Widget_Item * +_elm_widget_item_new(Evas_Object *widget, size_t alloc_size) +{ + Elm_Widget_Item *item; + EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL); + EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL); + item = calloc(1, alloc_size); + EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL); + EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC); + item->widget = widget; + return item; +} +/** + * Releases widget item memory, calling back del_cb() if it exists. + * + * If there is a Elm_Widget_Item::del_cb, then it will be called prior + * to memory release. Note that elm_widget_item_pre_notify_del() calls + * this function and then unset it, thus being useful for 2 step + * cleanup whenever the del_cb may use any of the data that must be + * deleted from item. + * + * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it + * is presented! + * + * @param item a valid #Elm_Widget_Item to be deleted. + * @see elm_widget_item_del() convenience macro. + */ +EAPI void +_elm_widget_item_del(Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if (item->del_cb) + item->del_cb((void *)item->data, item->widget, item); -/* local subsystem functions */ + if (item->view) + evas_object_del(item->view); + + EINA_MAGIC_SET(item, EINA_MAGIC_NONE); + free(item); +} + +/** + * Notify object will be deleted without actually deleting it. + * + * This function will callback Elm_Widget_Item::del_cb if it is set + * and then unset it so it is not called twice (ie: from + * elm_widget_item_del()). + * + * @param item a valid #Elm_Widget_Item to be notified + * @see elm_widget_item_pre_notify_del() convenience macro. + */ +EAPI void +_elm_widget_item_pre_notify_del(Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if (!item->del_cb) return; + item->del_cb((void *)item->data, item->widget, item); + item->del_cb = NULL; +} + +/** + * Set the function to notify when item is being deleted. + * + * This function will complain if there was a callback set already, + * however it will set the new one. + * + * The callback will be called from elm_widget_item_pre_notify_del() + * or elm_widget_item_del() will be called with: + * - data: the Elm_Widget_Item::data value. + * - obj: the Elm_Widget_Item::widget evas object. + * - event_info: the item being deleted. + * + * @param item a valid #Elm_Widget_Item to be notified + * @see elm_widget_item_del_cb_set() convenience macro. + */ +EAPI void +_elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + + if ((item->del_cb) && (item->del_cb != del_cb)) + WRN("You're replacing a previously set del_cb %p of item %p with %p", + item->del_cb, item, del_cb); + + item->del_cb = del_cb; +} + +/** + * Set user-data in this item. + * + * User data may be used to identify this item or just store any + * application data. It is automatically given as the first parameter + * of the deletion notify callback. + * + * @param item a valid #Elm_Widget_Item to store data in. + * @param data user data to store. + * @see elm_widget_item_del_cb_set() convenience macro. + */ +EAPI void +_elm_widget_item_data_set(Elm_Widget_Item *item, const void *data) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if ((item->data) && (item->data != data)) + DBG("Replacing item %p data %p with %p", item, item->data, data); + item->data = data; +} + +/** + * Retrieves user-data of this item. + * + * @param item a valid #Elm_Widget_Item to get data from. + * @see elm_widget_item_data_set() + */ +EAPI void * +_elm_widget_item_data_get(const Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); + return (void *)item->data; +} + +typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip; + +struct _Elm_Widget_Item_Tooltip +{ + Elm_Widget_Item *item; + Elm_Tooltip_Item_Content_Cb func; + Evas_Smart_Cb del_cb; + const void *data; +}; + +static Evas_Object * +_elm_widget_item_tooltip_label_create(void *data, Evas_Object *obj, void *item __UNUSED__) +{ + Evas_Object *label = elm_label_add(obj); + if (!label) + return NULL; + elm_object_style_set(label, "tooltip"); + elm_label_label_set(label, data); + return label; +} + +static void +_elm_widget_item_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + eina_stringshare_del(data); +} + +/** + * Set the text to be shown in the widget item. + * + * @param item Target item + * @param text The text to set in the content + * + * Setup the text as tooltip to object. The item can have only one tooltip, + * so any previous tooltip data is removed. + * + * @internal + */ +EAPI void +_elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text) +{ + EINA_SAFETY_ON_NULL_RETURN(item); + EINA_SAFETY_ON_NULL_RETURN(text); + + text = eina_stringshare_add(text); + _elm_widget_item_tooltip_content_cb_set + (item, _elm_widget_item_tooltip_label_create, text, + _elm_widget_item_tooltip_label_del_cb); +} + +static Evas_Object * +_elm_widget_item_tooltip_create(void *data, Evas_Object *obj) +{ + Elm_Widget_Item_Tooltip *wit = data; + return wit->func((void *)wit->data, obj, wit->item); +} + +static void +_elm_widget_item_tooltip_del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) +{ + Elm_Widget_Item_Tooltip *wit = data; + if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item); + free(wit); +} + +/** + * Set the content to be shown in the tooltip item + * + * Setup the tooltip to item. The item can have only one tooltip, + * so any previous tooltip data is removed. @p func(with @p data) will + * be called every time that need show the tooltip and it should + * return a valid Evas_Object. This object is then managed fully by + * tooltip system and is deleted when the tooltip is gone. + * + * @param item the widget item being attached a tooltip. + * @param func the function used to create the tooltip contents. + * @param data what to provide to @a func as callback data/context. + * @param del_cb called when data is not needed anymore, either when + * another callback replaces @func, the tooltip is unset with + * elm_widget_item_tooltip_unset() or the owner @a item + * dies. This callback receives as the first parameter the + * given @a data, and @c event_info is the item. + * + * @internal + */ +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) +{ + Elm_Widget_Item_Tooltip *wit; + + ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error); + + if (!func) + { + _elm_widget_item_tooltip_unset(item); + return; + } + + wit = ELM_NEW(Elm_Widget_Item_Tooltip); + if (!wit) goto error; + wit->item = item; + wit->func = func; + wit->data = data; + wit->del_cb = del_cb; + + elm_object_sub_tooltip_content_cb_set + (item->view, item->widget, _elm_widget_item_tooltip_create, wit, + _elm_widget_item_tooltip_del_cb); + + return; + + error: + if (del_cb) del_cb((void *)data, item->widget, item); +} + +/** + * Unset tooltip from item + * + * @param item widget item to remove previously set tooltip. + * + * Remove tooltip from item. The callback provided as del_cb to + * elm_widget_item_tooltip_content_cb_set() will be called to notify + * it is not used anymore. + * + * @see elm_widget_item_tooltip_content_cb_set() + * + * @internal + */ +EAPI void +_elm_widget_item_tooltip_unset(Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + elm_object_tooltip_unset(item->view); +} + +/** + * Sets a different style for this item tooltip. + * + * @note before you set a style you should define a tooltip with + * elm_widget_item_tooltip_content_cb_set() or + * elm_widget_item_tooltip_text_set() + * + * @param item widget item with tooltip already set. + * @param style the theme style to use (default, transparent, ...) + * + * @internal + */ +EAPI void +_elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + elm_object_tooltip_style_set(item->view, style); +} + +/** + * Get the style for this item tooltip. + * + * @param item widget item with tooltip already set. + * @return style the theme style in use, defaults to "default". If the + * object does not have a tooltip set, then NULL is returned. + * + * @internal + */ +EAPI const char * +_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); + return elm_object_tooltip_style_get(item->view); +} + +// smart object funcs static void _smart_reconfigure(Smart_Data *sd) { @@ -1154,10 +1547,7 @@ _smart_add(Evas_Object *obj) sd = calloc(1, sizeof(Smart_Data)); if (!sd) return; sd->obj = obj; - sd->x = 0; - sd->y = 0; - sd->w = 0; - sd->h = 0; + sd->x = sd->y = sd->w = sd->h = 0; sd->can_focus = 1; evas_object_smart_data_set(obj, sd); } @@ -1276,7 +1666,7 @@ _smart_show(Evas_Object *obj) { if (evas_object_data_get(o, "_elm_leaveme")) continue; evas_object_show(o); - } + } } static void @@ -1346,7 +1736,6 @@ _smart_calculate(Evas_Object *obj) } /* never need to touch this */ - static void _smart_init(void) { @@ -1355,399 +1744,24 @@ _smart_init(void) static const Evas_Smart_Class sc = { SMART_NAME, - EVAS_SMART_CLASS_VERSION, - _smart_add, - _smart_del, - _smart_move, - _smart_resize, - _smart_show, - _smart_hide, - _smart_color_set, - _smart_clip_set, - _smart_clip_unset, - _smart_calculate, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + EVAS_SMART_CLASS_VERSION, + _smart_add, + _smart_del, + _smart_move, + _smart_resize, + _smart_show, + _smart_hide, + _smart_color_set, + _smart_clip_set, + _smart_clip_unset, + _smart_calculate, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL }; _e_smart = evas_smart_class_new(&sc); } } - -/* utilities */ - -Eina_List * -_elm_stringlist_get(const char *str) -{ - Eina_List *list = NULL; - const char *s, *b; - if (!str) return NULL; - for (b = s = str; 1; s++) - { - if ((*s == ' ') || (*s == 0)) - { - char *t = malloc(s - b + 1); - if (t) - { - strncpy(t, b, s - b); - t[s - b] = 0; - list = eina_list_append(list, eina_stringshare_add(t)); - free(t); - } - b = s + 1; - } - if (*s == 0) break; - } - return list; -} - -void -_elm_stringlist_free(Eina_List *list) -{ - const char *s; - EINA_LIST_FREE(list, s) eina_stringshare_del(s); -} - -Eina_Bool -_elm_widget_type_check(const Evas_Object *obj, const char *type) -{ - const char *provided, *expected = "(unknown)"; - static int abort_on_warn = -1; - provided = elm_widget_type_get(obj); - if (EINA_LIKELY(provided == type)) return EINA_TRUE; - if (type) expected = type; - if ((!provided) || (provided[0] == 0)) - { - provided = evas_object_type_get(obj); - if ((!provided) || (provided[0] == 0)) - provided = "(unknown)"; - } - ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected); - if (abort_on_warn == -1) - { - if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1; - else abort_on_warn = 0; - } - if (abort_on_warn == 1) abort(); - return EINA_FALSE; -} - -static inline Eina_Bool -_elm_widget_is(const Evas_Object *obj) -{ - const char *type = evas_object_type_get(obj); - return type == SMART_NAME; -} - -/** - * Allocate a new Elm_Widget_Item-derived structure. - * - * The goal of this structure is to provide common ground for actions - * that a widget item have, such as the owner widget, callback to - * notify deletion, data pointer and maybe more. - * - * @param widget the owner widget that holds this item, must be an elm_widget! - * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will - * be used to allocate memory. - * - * @return allocated memory that is already zeroed out, or NULL on errors. - * - * @see elm_widget_item_new() convenience macro. - * @see elm_widget_item_del() to release memory. - */ -Elm_Widget_Item * -_elm_widget_item_new(Evas_Object *widget, size_t alloc_size) -{ - Elm_Widget_Item *item; - - EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL); - EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL); - - item = calloc(1, alloc_size); - EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL); - - EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC); - item->widget = widget; - return item; -} - -/** - * Releases widget item memory, calling back del_cb() if it exists. - * - * If there is a Elm_Widget_Item::del_cb, then it will be called prior - * to memory release. Note that elm_widget_item_pre_notify_del() calls - * this function and then unset it, thus being useful for 2 step - * cleanup whenever the del_cb may use any of the data that must be - * deleted from item. - * - * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it - * is presented! - * - * @param item a valid #Elm_Widget_Item to be deleted. - * @see elm_widget_item_del() convenience macro. - */ -void -_elm_widget_item_del(Elm_Widget_Item *item) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - - if (item->del_cb) - item->del_cb((void *)item->data, item->widget, item); - - if (item->view) - evas_object_del(item->view); - - EINA_MAGIC_SET(item, EINA_MAGIC_NONE); - free(item); -} - -/** - * Notify object will be deleted without actually deleting it. - * - * This function will callback Elm_Widget_Item::del_cb if it is set - * and then unset it so it is not called twice (ie: from - * elm_widget_item_del()). - * - * @param item a valid #Elm_Widget_Item to be notified - * @see elm_widget_item_pre_notify_del() convenience macro. - */ -void -_elm_widget_item_pre_notify_del(Elm_Widget_Item *item) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - if (!item->del_cb) return; - item->del_cb((void *)item->data, item->widget, item); - item->del_cb = NULL; -} - -/** - * Set the function to notify when item is being deleted. - * - * This function will complain if there was a callback set already, - * however it will set the new one. - * - * The callback will be called from elm_widget_item_pre_notify_del() - * or elm_widget_item_del() will be called with: - * - data: the Elm_Widget_Item::data value. - * - obj: the Elm_Widget_Item::widget evas object. - * - event_info: the item being deleted. - * - * @param item a valid #Elm_Widget_Item to be notified - * @see elm_widget_item_del_cb_set() convenience macro. - */ -void -_elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - - if ((item->del_cb) && (item->del_cb != del_cb)) - WRN("You're replacing a previously set del_cb %p of item %p with %p", - item->del_cb, item, del_cb); - - item->del_cb = del_cb; -} - -/** - * Set user-data in this item. - * - * User data may be used to identify this item or just store any - * application data. It is automatically given as the first parameter - * of the deletion notify callback. - * - * @param item a valid #Elm_Widget_Item to store data in. - * @param data user data to store. - * @see elm_widget_item_del_cb_set() convenience macro. - */ -void -_elm_widget_item_data_set(Elm_Widget_Item *item, const void *data) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - if ((item->data) && (item->data != data)) - DBG("Replacing item %p data %p with %p", item, item->data, data); - item->data = data; -} - -/** - * Retrieves user-data of this item. - * - * @param item a valid #Elm_Widget_Item to get data from. - * @see elm_widget_item_data_set() - */ -void * -_elm_widget_item_data_get(const Elm_Widget_Item *item) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); - return (void *)item->data; -} - -typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip; -struct _Elm_Widget_Item_Tooltip -{ - Elm_Widget_Item *item; - Elm_Tooltip_Item_Content_Cb func; - Evas_Smart_Cb del_cb; - const void *data; -}; - -static Evas_Object * -_elm_widget_item_tooltip_label_create(void *data, Evas_Object *obj, void *item __UNUSED__) -{ - Evas_Object *label = elm_label_add(obj); - if (!label) - return NULL; - elm_object_style_set(label, "tooltip"); - elm_label_label_set(label, data); - return label; -} - -static void -_elm_widget_item_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - eina_stringshare_del(data); -} - -/** - * Set the text to be shown in the widget item. - * - * @param item Target item - * @param text The text to set in the content - * - * Setup the text as tooltip to object. The item can have only one tooltip, - * so any previous tooltip data is removed. - * - * @internal - */ -void -_elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text) -{ - EINA_SAFETY_ON_NULL_RETURN(item); - EINA_SAFETY_ON_NULL_RETURN(text); - - text = eina_stringshare_add(text); - _elm_widget_item_tooltip_content_cb_set - (item, _elm_widget_item_tooltip_label_create, text, - _elm_widget_item_tooltip_label_del_cb); -} - -static Evas_Object * -_elm_widget_item_tooltip_create(void *data, Evas_Object *obj) -{ - Elm_Widget_Item_Tooltip *wit = data; - return wit->func((void *)wit->data, obj, wit->item); -} - -static void -_elm_widget_item_tooltip_del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) -{ - Elm_Widget_Item_Tooltip *wit = data; - if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item); - free(wit); -} - -/** - * Set the content to be shown in the tooltip item - * - * Setup the tooltip to item. The item can have only one tooltip, - * so any previous tooltip data is removed. @p func(with @p data) will - * be called every time that need show the tooltip and it should - * return a valid Evas_Object. This object is then managed fully by - * tooltip system and is deleted when the tooltip is gone. - * - * @param item the widget item being attached a tooltip. - * @param func the function used to create the tooltip contents. - * @param data what to provide to @a func as callback data/context. - * @param del_cb called when data is not needed anymore, either when - * another callback replaces @func, the tooltip is unset with - * elm_widget_item_tooltip_unset() or the owner @a item - * dies. This callback receives as the first parameter the - * given @a data, and @c event_info is the item. - * - * @internal - */ -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) -{ - Elm_Widget_Item_Tooltip *wit; - - ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error); - - if (!func) - { - _elm_widget_item_tooltip_unset(item); - return; - } - - wit = ELM_NEW(Elm_Widget_Item_Tooltip); - if (!wit) goto error; - wit->item = item; - wit->func = func; - wit->data = data; - wit->del_cb = del_cb; - - elm_object_sub_tooltip_content_cb_set - (item->view, item->widget, _elm_widget_item_tooltip_create, wit, - _elm_widget_item_tooltip_del_cb); - - return; - - error: - if (del_cb) del_cb((void *)data, item->widget, item); -} - -/** - * Unset tooltip from item - * - * @param item widget item to remove previously set tooltip. - * - * Remove tooltip from item. The callback provided as del_cb to - * elm_widget_item_tooltip_content_cb_set() will be called to notify - * it is not used anymore. - * - * @see elm_widget_item_tooltip_content_cb_set() - * - * @internal - */ -void -_elm_widget_item_tooltip_unset(Elm_Widget_Item *item) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - elm_object_tooltip_unset(item->view); -} - -/** - * Sets a different style for this item tooltip. - * - * @note before you set a style you should define a tooltip with - * elm_widget_item_tooltip_content_cb_set() or - * elm_widget_item_tooltip_text_set() - * - * @param item widget item with tooltip already set. - * @param style the theme style to use (default, transparent, ...) - * - * @internal - */ -void -_elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); - elm_object_tooltip_style_set(item->view, style); -} - -/** - * Get the style for this item tooltip. - * - * @param item widget item with tooltip already set. - * @return style the theme style in use, defaults to "default". If the - * object does not have a tooltip set, then NULL is returned. - * - * @internal - */ -const char * -_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item) -{ - ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); - return elm_object_tooltip_style_get(item->view); -} diff --git a/legacy/elementary/src/lib/elm_widget.h b/legacy/elementary/src/lib/elm_widget.h new file mode 100644 index 0000000000..fb3266f36a --- /dev/null +++ b/legacy/elementary/src/lib/elm_widget.h @@ -0,0 +1,406 @@ +#ifndef ELM_WIDGET_H +#define ELM_WIDGET_H + +/* DO NOT USE THIUS HEADER UNLESS YOU ARE PREPARED FOR BESAKING OF YOUR + * 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 + * #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) + * { + * Widget_Data *wd = elm_widget_data_get(obj); + * if (!wd) return; + * // delete hook - on delete of object delete object struct etc. + * free(wd); + * } + * + * static void + * _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) + * { + * Widget_Data *wd = elm_widget_data_get(obj); + * if (!wd) return; + * // handle focus going in and out - optional, but if you want to, set + * // this hook and handle it (eg emit a signal to an edje obj) + * if (elm_widget_focus_get(obj)) + * { + * edje_object_signal_emit(wd->sub, "elm,action,focus", "elm"); + * evas_object_focus_set(wd->sub, 1); + * } + * else + * { + * edje_object_signal_emit(wd->sub, "elm,action,unfocus", "elm"); + * evas_object_focus_set(wd->sub, 0); + * } + * } + * + * static void + * _theme_hook(Evas_Object *obj) + * { + * Widget_Data *wd = elm_widget_data_get(obj); + * if (!wd) return; + * // handle change in theme/scale etc. etc. + * // XXX: export _elm_theme_object_set + * _elm_theme_object_set(obj, wd->sub, "mywidget", "base", + * elm_widget_style_get(obj)); + * } + * + * static void + * _disable_hook(Evas_Object *obj) + * { + * Widget_Data *wd = elm_widget_data_get(obj); + * if (!wd) return; + * // optional, gbut handle if the widget gets disabled or not + * if (elm_widget_disabled_get(obj)) + * edje_object_signal_emit(wd->sub, "elm,state,disabled", "elm"); + * else + * edje_object_signal_emit(wd->sub, "elm,state,enabled", "elm"); + * } + * + * static void + * _sizing_eval(Evas_Object *obj) + * { + * Widget_Data *wd = elm_widget_data_get(obj); + * Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; + * // + * if (!wd) return; + * elm_coords_finger_size_adjust(1, &minw, 1, &minh); + * edje_object_size_min_restricted_calc(wd->sub, &minw, &minh, minw, minh); + * elm_coords_finger_size_adjust(1, &minw, 1, &minh); + * 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 * + * elm_mywidget_add(Evas_Object *parent) + * { + * 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); + * obj = elm_widget_add(e); + * // give it a type name and set yp a mywidget type string if needed + * ELM_SET_WIDTYPE(widtype, "mywidget"); + * elm_widget_type_set(obj, "mywidget"); + * // tell the parent widget that we are a sub object + * elm_widget_sub_object_add(parent, obj); + * // setup hooks we need (some are optional) + * elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL); + * elm_widget_data_set(obj, wd); + * elm_widget_del_hook_set(obj, _del_hook); + * elm_widget_theme_hook_set(obj, _theme_hook); + * 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 ad d1 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: + * // "elm/WIDGETNAME/ELEMENT/STYLE" + * // so here it will be: + * // "elm/mywidget/base/default" + * // changing style changes style name from default (all widgets start + * // with the default style) and element is for your widget internal + * // structure as you see fit + * elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base", "default"); + * // listen to a signal from the edje object to produce widget smart + * // callback (like click) + * edje_object_signal_callback_add(wd->sub, "elm,action,click", "", + * _signal_clicked, obj); + * // set this sub object as the "resize object". widgets get 1 resize + * // object that is zresized 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) + * { + * // check if type is correct - check will return if it fails + * ELM_CHECK_WIDTYPE(obj, widtype); + * // get widget data - tyope is correct and sany by this point, so this + * // should never fail + * Widget_Data *wd = elm_widget_data_get(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. rememebr this api is not stable and may change. it's + * // internal + * + */ + +#ifndef ELM_INTERAL_API_MDFGELQ +# 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." +#endif +#define ELM_INTERNAL_API_VERSION 7000 + +typedef struct _Elm_Tooltip Elm_Tooltip; +typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */ + +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 */ + /* widget variations should have data from here and on */ + /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */ +}; + +#define ELM_NEW(t) calloc(1, sizeof(t)) + +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)); +EAPI void elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +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))); +EAPI void elm_widget_theme(Evas_Object *obj); +EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data); +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_data_set(Evas_Object *obj, void *data); +EAPI void *elm_widget_data_get(const Evas_Object *obj); +EAPI void elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); +EAPI void elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); +EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj); +EAPI void elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj); +EAPI void elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source); +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); +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)); +EAPI void elm_widget_can_focus_set(Evas_Object *obj, int can_focus); +EAPI int elm_widget_can_focus_get(const Evas_Object *obj); +EAPI int elm_widget_focus_get(const Evas_Object *obj); +EAPI Evas_Object *elm_widget_focused_object_get(const Evas_Object *obj); +EAPI Evas_Object *elm_widget_top_get(const Evas_Object *obj); +EAPI Eina_Bool elm_widget_is(const Evas_Object *obj); +EAPI Evas_Object *elm_widget_parent_widget_get(const Evas_Object *obj); +EAPI int elm_widget_focus_jump(Evas_Object *obj, int forward); +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); +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_show_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); +EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj); +EAPI int elm_widget_scroll_hold_get(const Evas_Object *obj); +EAPI void elm_widget_scroll_freeze_push(Evas_Object *obj); +EAPI void elm_widget_scroll_freeze_pop(Evas_Object *obj); +EAPI int elm_widget_scroll_freeze_get(const Evas_Object *obj); +EAPI void elm_widget_scale_set(Evas_Object *obj, double scale); +EAPI double elm_widget_scale_get(const Evas_Object *obj); +EAPI void elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th); +EAPI Elm_Theme *elm_widget_theme_get(const Evas_Object *obj); +EAPI void elm_widget_style_set(Evas_Object *obj, const char *style); +EAPI const char *elm_widget_style_get(const Evas_Object *obj); +EAPI void elm_widget_type_set(Evas_Object *obj, const char *type); +EAPI const char *elm_widget_type_get(const Evas_Object *obj); +EAPI void elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt); +EAPI void elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt); +EAPI void elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock); +EAPI void elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock); +EAPI Eina_Bool elm_widget_drag_lock_x_get(const Evas_Object *obj); +EAPI Eina_Bool elm_widget_drag_lock_y_get(const Evas_Object *obj); +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 int 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 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 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); +EAPI void _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb); +EAPI void _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data); +EAPI void *_elm_widget_item_data_get(const Elm_Widget_Item *item); +EAPI void _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text); +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); +EAPI void _elm_widget_item_tooltip_unset(Elm_Widget_Item *item); +EAPI void _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style); +EAPI const char *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item); + +/** + * Convenience macro to create new widget item, doing casts for you. + * @see _elm_widget_item_new() + * @param parent a valid elm_widget variant. + * @param type the C type that extends Elm_Widget_Item + */ +#define elm_widget_item_new(parent, type) \ + (type *)_elm_widget_item_new((parent), sizeof(type)) +/** + * Convenience macro to delete widget item, doing casts for you. + * @see _elm_widget_item_del() + * @param item a valid item. + */ +#define elm_widget_item_del(item) \ + _elm_widget_item_del((Elm_Widget_Item *)item) +/** + * Convenience macro to notify deletion of widget item, doing casts for you. + * @see _elm_widget_item_pre_notify_del() + */ +#define elm_widget_item_pre_notify_del(item) \ + _elm_widget_item_pre_notify_del((Elm_Widget_Item *)item) +/** + * Convenience macro to set deletion callback of widget item, doing casts for you. + * @see _elm_widget_item_del_cb_set() + */ +#define elm_widget_item_del_cb_set(item, del_cb) \ + _elm_widget_item_del_cb_set((Elm_Widget_Item *)item, del_cb) + +/** + * Set item's data + * @see _elm_widget_item_data_set() + */ +#define elm_widget_item_data_set(item, data) \ + _elm_widget_item_data_set((Elm_Widget_Item *)item, data) +/** + * Get item's data + * @see _elm_widget_item_data_get() + */ +#define elm_widget_item_data_get(item) \ + _elm_widget_item_data_get((const Elm_Widget_Item *)item) + +/** + * Convenience function to set widget item tooltip as a text string. + * @see _elm_widget_item_tooltip_text_set() + */ +#define elm_widget_item_tooltip_text_set(item, text) \ + _elm_widget_item_tooltip_text_set((Elm_Widget_Item *)item, text) +/** + * Convenience function to set widget item tooltip. + * @see _elm_widget_item_tooltip_content_cb_set() + */ +#define elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb) \ + _elm_widget_item_tooltip_content_cb_set((Elm_Widget_Item *)item, \ + func, data, del_cb) +/** + * Convenience function to unset widget item tooltip. + * @see _elm_widget_item_tooltip_unset() + */ +#define elm_widget_item_tooltip_unset(item) \ + _elm_widget_item_tooltip_unset((Elm_Widget_Item *)item) +/** + * Convenience function to change item's tooltip style. + * @see _elm_widget_item_tooltip_style_set() + */ +#define elm_widget_item_tooltip_style_set(item, style) \ + _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style) +/** + * Convenience function to query item's tooltip style. + * @see _elm_widget_item_tooltip_style_get() + */ +#define elm_widget_item_tooltip_style_get(item) \ + _elm_widget_item_tooltip_style_get((const Elm_Widget_Item *)item) + +/** + * Cast and ensure the given pointer is an Elm_Widget_Item or return NULL. + */ +#define ELM_WIDGET_ITEM(item) \ + ((item && EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) ? \ + ((Elm_Widget_Item *)(item)) : NULL) + +#define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \ + do { \ + if (!item) { \ + CRITICAL("Elm_Widget_Item " # item " is NULL!"); \ + return __VA_ARGS__; \ + } \ + if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \ + EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label) \ + do { \ + if (!item) { \ + CRITICAL("Elm_Widget_Item " # item " is NULL!"); \ + goto label; \ + } \ + if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \ + EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \ + goto label; \ + } \ + } while (0) + +#define ELM_SET_WIDTYPE(widtype, type) \ + do { \ + if (!widtype) { \ + widtype = eina_stringshare_add(type); \ + elm_widget_type_register(&widtype); \ + } \ + } while (0) + +#define ELM_CHECK_WIDTYPE(obj, widtype) \ + if (!elm_widget_type_check((obj), (widtype))) return + +#endif diff --git a/legacy/elementary/src/lib/els_tooltip.c b/legacy/elementary/src/lib/els_tooltip.c index e3428b35aa..0fc886c63e 100644 --- a/legacy/elementary/src/lib/els_tooltip.c +++ b/legacy/elementary/src/lib/els_tooltip.c @@ -469,6 +469,112 @@ elm_tooltip_theme(Elm_Tooltip *tt) _elm_tooltip_reconfigure_job_start(tt); } + +/** + * Set the content to be shown in the tooltip object for specific event area. + * + * Setup the tooltip to object. The object @a eventarea can have only + * one tooltip, so any previous tooltip data is removed. @p func(with + * @p data) will be called every time that need show the tooltip and + * it should return a valid Evas_Object. This object is then managed + * fully by tooltip system and is deleted when the tooltip is gone. + * + * This is an internal function that is used by objects with sub-items + * that want to provide different tooltips for each of them. The @a + * owner object should be an elm_widget and will be used to track + * theme changes and to feed @a func and @a del_cb. The @a eventarea + * may be any object and is the one that should be used later on with + * elm_object_tooltip apis, such as elm_object_tooltip_hide(), + * elm_object_tooltip_show() or elm_object_tooltip_unset(). + * + * @param eventarea the object being attached a tooltip. + * @param owner the elm_widget that owns this object, will be used to + * track theme changes and to be used in @a func or @a del_cb. + * @param func the function used to create the tooltip contents. The + * @a Evas_Object parameters will receive @a owner as value. + * @param data what to provide to @a func as callback data/context. + * @param del_cb called when data is not needed anymore, either when + * another callback replaces @func, the tooltip is unset with + * elm_object_tooltip_unset() or the owner object @a obj + * dies. This callback receives as the first parameter the + * given @a data, and @c event_info is NULL. + * + * @internal + * @ingroup Tooltips + */ +void +elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) +{ + Elm_Tooltip *tt = NULL; + Eina_Bool just_created; + + EINA_SAFETY_ON_NULL_GOTO(owner, error); + EINA_SAFETY_ON_NULL_GOTO(eventarea, error); + + if (!func) + { + elm_object_tooltip_unset(eventarea); + return; + } + + tt = evas_object_data_get(eventarea, _tooltip_key); + if (tt) + { + if (tt->owner != owner) + { + evas_object_event_callback_del_full + (tt->owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); + elm_widget_tooltip_del(tt->owner, tt); + + evas_object_event_callback_add + (owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); + elm_widget_tooltip_add(tt->owner, tt); + } + + if ((tt->func == func) && (tt->data == data) && + (tt->del_cb == del_cb)) + return; + _elm_tooltip_data_clean(tt); + just_created = EINA_FALSE; + } + else + { + tt = ELM_NEW(Elm_Tooltip); + if (!tt) goto error; + + tt->owner = owner; + tt->eventarea = eventarea; + tt->evas = evas_object_evas_get(eventarea); + evas_object_data_set(eventarea, _tooltip_key, tt); + + just_created = EINA_TRUE; + + evas_object_event_callback_add + (eventarea, EVAS_CALLBACK_MOUSE_IN, + _elm_tooltip_obj_mouse_in_cb, tt); + evas_object_event_callback_add + (eventarea, EVAS_CALLBACK_MOUSE_OUT, + _elm_tooltip_obj_mouse_out_cb, tt); + evas_object_event_callback_add + (eventarea, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); + + evas_object_event_callback_add + (owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); + elm_widget_tooltip_add(tt->owner, tt); + } + + tt->func = func; + tt->data = data; + tt->del_cb = del_cb; + + if (!just_created) _elm_tooltip_reconfigure_job_start(tt); + return; + + error: + if (tt) _elm_tooltip_hide(tt); + if (del_cb) del_cb((void *)data, owner, NULL); +} + /** * Force show tooltip of object * @@ -555,111 +661,6 @@ elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb); } -/** - * Set the content to be shown in the tooltip object for specific event area. - * - * Setup the tooltip to object. The object @a eventarea can have only - * one tooltip, so any previous tooltip data is removed. @p func(with - * @p data) will be called every time that need show the tooltip and - * it should return a valid Evas_Object. This object is then managed - * fully by tooltip system and is deleted when the tooltip is gone. - * - * This is an internal function that is used by objects with sub-items - * that want to provide different tooltips for each of them. The @a - * owner object should be an elm_widget and will be used to track - * theme changes and to feed @a func and @a del_cb. The @a eventarea - * may be any object and is the one that should be used later on with - * elm_object_tooltip apis, such as elm_object_tooltip_hide(), - * elm_object_tooltip_show() or elm_object_tooltip_unset(). - * - * @param eventarea the object being attached a tooltip. - * @param owner the elm_widget that owns this object, will be used to - * track theme changes and to be used in @a func or @a del_cb. - * @param func the function used to create the tooltip contents. The - * @a Evas_Object parameters will receive @a owner as value. - * @param data what to provide to @a func as callback data/context. - * @param del_cb called when data is not needed anymore, either when - * another callback replaces @func, the tooltip is unset with - * elm_object_tooltip_unset() or the owner object @a obj - * dies. This callback receives as the first parameter the - * given @a data, and @c event_info is NULL. - * - * @internal - * @ingroup Tooltips - */ -EAPI void -elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) -{ - Elm_Tooltip *tt = NULL; - Eina_Bool just_created; - - EINA_SAFETY_ON_NULL_GOTO(owner, error); - EINA_SAFETY_ON_NULL_GOTO(eventarea, error); - - if (!func) - { - elm_object_tooltip_unset(eventarea); - return; - } - - tt = evas_object_data_get(eventarea, _tooltip_key); - if (tt) - { - if (tt->owner != owner) - { - evas_object_event_callback_del_full - (tt->owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); - elm_widget_tooltip_del(tt->owner, tt); - - evas_object_event_callback_add - (owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); - elm_widget_tooltip_add(tt->owner, tt); - } - - if ((tt->func == func) && (tt->data == data) && - (tt->del_cb == del_cb)) - return; - _elm_tooltip_data_clean(tt); - just_created = EINA_FALSE; - } - else - { - tt = ELM_NEW(Elm_Tooltip); - if (!tt) goto error; - - tt->owner = owner; - tt->eventarea = eventarea; - tt->evas = evas_object_evas_get(eventarea); - evas_object_data_set(eventarea, _tooltip_key, tt); - - just_created = EINA_TRUE; - - evas_object_event_callback_add - (eventarea, EVAS_CALLBACK_MOUSE_IN, - _elm_tooltip_obj_mouse_in_cb, tt); - evas_object_event_callback_add - (eventarea, EVAS_CALLBACK_MOUSE_OUT, - _elm_tooltip_obj_mouse_out_cb, tt); - evas_object_event_callback_add - (eventarea, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); - - evas_object_event_callback_add - (owner, EVAS_CALLBACK_DEL, _elm_tooltip_obj_del_cb, tt); - elm_widget_tooltip_add(tt->owner, tt); - } - - tt->func = func; - tt->data = data; - tt->del_cb = del_cb; - - if (!just_created) _elm_tooltip_reconfigure_job_start(tt); - return; - - error: - if (tt) _elm_tooltip_hide(tt); - if (del_cb) del_cb((void *)data, owner, NULL); -} - /** * Unset tooltip from object *