From 3c776888417c3fe4a6b98aee4f6a0db5f7500804 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Wed, 3 Aug 2011 09:34:00 +0000 Subject: [PATCH] elementary/common - exported Elm_Object_Item type and a few common item APIs. SVN revision: 62047 --- src/lib/Elementary.h.in | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_main.c | 35 ++++++++++++++++++++++ src/lib/elm_widget.c | 47 +++++++++++++++++++++++++++++ src/lib/elm_widget.h | 18 +++++++++++ 4 files changed, 180 insertions(+) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 67e9226..000e641 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -328,6 +328,12 @@ extern "C" { ELM_WRAP_LAST } Elm_Wrap_Type; + /** + * @typedef Elm_Object_Item + * An Elementary Object item handle. + * @ingroup General + */ + typedef struct _Elm_Widget_Item Elm_Object_Item; /** * Called back when a widget's tooltip is activated and needs content. @@ -756,6 +762,80 @@ extern "C" { #define elm_object_content_unset(obj) elm_object_content_part_unset((obj), NULL) /** + * Set a content of an object item + * + * @param it The Elementary object item + * @param item The content id to unset (NULL for the default content) + * @param content The new content of the object item + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI void elm_object_item_content_part_set(Elm_Object_Item *it, const char *item, Evas_Object *content); + +#define elm_object_item_content_set(it, content) elm_object_item_content_part_set((it), NULL, (content)) + + /** + * Get a content of an object item + * + * @param it The Elementary object item + * @param item The content id to unset (NULL for the default content) + * @return content of the object item or NULL for any error + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_item_content_part_get(const Elm_Object_Item *it, const char *item); + +#define elm_object_item_content_get(it, content) elm_object_item_content_part_get((it), NULL, (content)) + + /** + * Unset a content of an object item + * + * @param it The Elementary object item + * @param item The content id to unset (NULL for the default content) + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_item_content_part_unset(Elm_Object_Item *it, const char *item); + +#define elm_object_item_content_unset(it, content) elm_object_item_content_part_unset((it), (content)) + + /** + * Set a label of an objec itemt + * + * @param obj The Elementary object item + * @param item The label id to set (NULL for the default label) + * @param label The new text of the label + * + * @note Elementary object items may have many labels + * + * @ingroup General + */ + EAPI void elm_object_item_text_part_set(Elm_Object_Item *it, const char *item, const char *label); + +#define elm_object_item_text_set(it, label) elm_object_item_text_part_set((it), NULL, (label)) + + /** + * Get a label of an object + * + * @param obj The Elementary object item + * @param item The label id to get (NULL for the default label) + * @return text of the label or NULL for any error + * + * @note Elementary object items may have many labels + * + * @ingroup General + */ + EAPI const char *elm_object_item_text_part_get(const Elm_Object_Item *it, const char *item); + +#define elm_object_item_text_get(it) elm_object_item_part_text_get((it), NULL) + + /** * @} */ diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 9acd9bc..712879e 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -3437,3 +3437,38 @@ elm_longpress_timeout_get(void) { return _elm_config->longpress_timeout; } + +EAPI void +elm_object_item_content_part_set(Elm_Object_Item *it, + const char *item, + Evas_Object *content) +{ + elm_widget_item_content_part_set(it, item, content); +} + +EAPI Evas_Object * +elm_object_item_content_part_get(const Elm_Object_Item *it, + const char *item) +{ + return elm_widget_item_content_part_get(it, item); +} + +EAPI Evas_Object * +elm_object_item_content_part_unset(Elm_Object_Item *it, const char *item) +{ + return elm_widget_item_content_part_unset(it, item); +} + +EAPI void +elm_object_item_text_part_set(Elm_Object_Item *it, + const char *item, + const char *label) +{ + elm_widget_item_text_part_set(it, item, label); +} + +EAPI const char * +elm_object_item_text_part_get(const Elm_Object_Item *it, const char *item) +{ + return elm_widget_item_text_part_get(it, item); +} diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index cf9d8e3..ab91968 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -2921,6 +2921,53 @@ _smart_reconfigure(Smart_Data *sd) } } +EAPI void +elm_widget_item_content_part_set(Elm_Widget_Item *it, + const char *item, + Evas_Object *content) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(it); + if (!it->on_content_set_func) return; + it->on_content_set_func(it, item, content); +} + +EAPI Evas_Object * +elm_widget_item_content_part_get(const Elm_Widget_Item *it, + const char *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(it, NULL); + if (!it->on_content_get_func) return NULL; + return it->on_content_get_func(it, item); +} + +EAPI Evas_Object * +elm_widget_item_content_part_unset(Elm_Widget_Item *it, + const char *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(it, NULL); + if (!it->on_content_unset_func) return NULL; + return it->on_content_unset_func(it, item); +} + +EAPI void +elm_widget_item_text_part_set(Elm_Widget_Item *it, + const char *item, + const char *label) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(it); + if (!it->on_text_set_func) return; + it->on_text_set_func(it, item, label); +} + +EAPI const char * +elm_widget_item_text_part_get(const Elm_Widget_Item *it, + const char *item) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(it, NULL); + if (!it->on_text_get_func) return NULL; + return it->on_text_get_func(it, item); +} + static void _smart_add(Evas_Object *obj) { diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index 32d85e1..e26c52a 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -202,6 +202,18 @@ struct _Elm_Widget_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 */ + void (*on_content_set_func)(Elm_Widget_Item *it, + const char *item, + Evas_Object *content); + Evas_Object *(*on_content_get_func)(const Elm_Widget_Item *it, + const char *item); + Evas_Object *(*on_content_unset_func)(Elm_Widget_Item *it, + const char *item); + void (*on_text_set_func)(Elm_Widget_Item *it, + const char *item, + const char *label); + const char *(*on_text_get_func)(const Elm_Widget_Item *it, + const char *item); /* widget variations should have data from here and on */ /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */ }; @@ -344,6 +356,12 @@ 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_Object_Item *it, const char *item, Evas_Object *content); +EAPI Evas_Object *elm_widget_item_content_part_get(const Elm_Object_Item *it, const char *item); +EAPI Evas_Object *elm_widget_item_content_part_unset(Elm_Object_Item *it, const char *item); +EAPI void elm_widget_item_text_part_set(Elm_Object_Item *it, const char *item, const char *label); +EAPI const char *elm_widget_item_text_part_get(const Elm_Object_Item *it, const char *item); + /* debug function. don't use it unless you are tracking parenting issues */ EAPI void elm_widget_tree_dump(const Evas_Object *top); -- 2.7.4