"of information. This of course can be later explicitly "
"done by links maybe running local apps or even being "
"web URL's too that launch the web browser and point it "
- "to that URL.");
+ "to that URL. <item relsize=16x16 vsize=full href=emoticon/omg></item>");
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
elm_bubble_content_set(bb, av);
evas_object_show(av);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
- elm_anchorblock_text_set(av, "This is a short message");
+ elm_anchorblock_text_set(av, "This is a short message. <item relsize=16x16 vsize=full href=emoticon/haha></item>");
evas_object_smart_callback_add(av, "anchor,clicked",
my_anchorblock_anchor, av);
elm_bubble_content_set(bb, av);
"<a href=X><link>links in the text</></a>, so enter text<br>"
"in here to edit it. By the way, links are<br>"
"called <a href=anc-02>Anchors</a> so you will need<br>"
- "to refer to them this way.");
+ "to refer to them this way. <item relsize=16x16 vsize=full href=emoticon/guilty-smile></item>");
evas_object_size_hint_weight_set(av, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorview_anchor, av);
elm_win_resize_object_add(win, av);
EAPI Eina_Bool elm_label_line_wrap_get(const Evas_Object *obj);
EAPI void elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w);
EAPI Evas_Coord elm_label_wrap_width_get(const Evas_Object *obj);
-/* available styles:
+ /* available styles:
* default
* marker
*/
EAPI void elm_anchorview_hover_style_set(Evas_Object *obj, const char *style);
EAPI void elm_anchorview_hover_end(Evas_Object *obj);
EAPI void elm_anchorview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
+ EAPI void elm_anchorview_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data);
+ EAPI void elm_anchorview_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data);
+ EAPI void elm_anchorview_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data);
/* smart callbacks called:
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorview_Info
*/
EAPI void elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
EAPI void elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style);
EAPI void elm_anchorblock_hover_end(Evas_Object *obj);
+ EAPI void elm_anchorblock_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data);
+ EAPI void elm_anchorblock_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data);
+ EAPI void elm_anchorblock_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data);
/* smart callbacks called:
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorblock_Info
*/
* Elm_Entry_Anchorview_Info
*/
typedef struct _Widget_Data Widget_Data;
+typedef struct _Elm_Anchorblock_Item_Provider Elm_Anchorblock_Item_Provider;
struct _Widget_Data
{
Evas_Object *entry;
Evas_Object *hover_parent;
Evas_Object *pop, *hover;
+ Eina_List *item_providers;
const char *hover_style;
};
+struct _Elm_Anchorblock_Item_Provider
+{
+ Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item);
+ void *data;
+};
+
static const char *widtype = NULL;
static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Elm_Anchorblock_Item_Provider *ip;
if (!wd) return;
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
+ EINA_LIST_FREE(wd->item_providers, ip)
+ {
+ free(ip);
+ }
free(wd);
}
wd->hover_parent = NULL;
}
+static Evas_Object *
+_item_provider(void *data, Evas_Object *entry, const char *item)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Evas_Object *o;
+ Eina_List *l;
+ Elm_Anchorblock_Item_Provider *ip;
+
+ EINA_LIST_FOREACH(wd->item_providers, l, ip)
+ {
+ o = ip->func(ip->data, data, item);
+ if (o) return o;
+ }
+ return NULL;
+}
+
/**
* Add a new Anchorblock object
*
elm_widget_del_hook_set(obj, _del_hook);
wd->entry = elm_entry_add(parent);
+ elm_entry_item_provider_prepend(wd->entry, _item_provider, obj);
elm_widget_resize_object_set(obj, wd->entry);
elm_entry_editable_set(wd->entry, 0);
evas_object_size_hint_weight_set(wd->entry, 1.0, 1.0);
wd->hover = NULL;
wd->pop = NULL;
}
+
+/**
+ * This appends a custom item provider to the list for that anchorblock
+ *
+ * This appends the given callback. The list is walked from beginning to end
+ * with each function called given the item href string in the text. If the
+ * function returns an object handle other than NULL (it should create an
+ * and object to do this), then this object is used to replace that item. If
+ * not the next provider is called until one provides an item object, or the
+ * default provider in anchorblock does.
+ *
+ * @param obj The anchorblock object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorblock
+ */
+EAPI void
+elm_anchorblock_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (!func) return;
+ Elm_Anchorblock_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorblock_Item_Provider));
+ if (!ip) return;
+ ip->func = func;
+ ip->data = data;
+ wd->item_providers = eina_list_append(wd->item_providers, ip);
+}
+
+/**
+ * This prepends a custom item provider to the list for that anchorblock
+ *
+ * This prepends the given callback. See elm_anchorblock_item_provider_append() for
+ * more information
+ *
+ * @param obj The anchorblock object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorblock
+ */
+EAPI void
+elm_anchorblock_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (!func) return;
+ Elm_Anchorblock_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorblock_Item_Provider));
+ if (!ip) return;
+ ip->func = func;
+ ip->data = data;
+ wd->item_providers = eina_list_prepend(wd->item_providers, ip);
+}
+
+/**
+ * This removes a custom item provider to the list for that anchorblock
+ *
+ * This removes the given callback. See elm_anchorblock_item_provider_append() for
+ * more information
+ *
+ * @param obj The anchorblock object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorblock
+ */
+EAPI void
+elm_anchorblock_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorblock, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Eina_List *l;
+ Elm_Anchorblock_Item_Provider *ip;
+ if (!wd) return;
+ if (!func) return;
+ EINA_LIST_FOREACH(wd->item_providers, l, ip)
+ {
+ if ((ip->func == func) && (ip->data == data))
+ {
+ wd->item_providers = eina_list_remove_list(wd->item_providers, l);
+ free(ip);
+ return;
+ }
+ }
+}
* Elm_Entry_Anchorview_Info
*/
typedef struct _Widget_Data Widget_Data;
+typedef struct _Elm_Anchorview_Item_Provider Elm_Anchorview_Item_Provider;
struct _Widget_Data
{
Evas_Object *scroller, *entry;
Evas_Object *hover_parent;
Evas_Object *pop, *hover;
+ Eina_List *item_providers;
const char *hover_style;
};
+struct _Elm_Anchorview_Item_Provider
+{
+ Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item);
+ void *data;
+};
+
static const char *widtype = NULL;
static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Elm_Anchorview_Item_Provider *ip;
if (!wd) return;
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
+ EINA_LIST_FREE(wd->item_providers, ip)
+ {
+ free(ip);
+ }
free(wd);
}
wd->hover_parent = NULL;
}
+static Evas_Object *
+_item_provider(void *data, Evas_Object *entry, const char *item)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ Evas_Object *o;
+ Eina_List *l;
+ Elm_Anchorview_Item_Provider *ip;
+
+ EINA_LIST_FOREACH(wd->item_providers, l, ip)
+ {
+ o = ip->func(ip->data, data, item);
+ if (o) return o;
+ }
+ return NULL;
+}
+
/**
* Add a new Anchorview object
*
wd->scroller = elm_scroller_add(parent);
elm_widget_resize_object_set(obj, wd->scroller);
wd->entry = elm_entry_add(parent);
+ elm_entry_item_provider_prepend(wd->entry, _item_provider, obj);
elm_entry_editable_set(wd->entry, 0);
evas_object_size_hint_weight_set(wd->entry, 1.0, 1.0);
evas_object_size_hint_align_set(wd->entry, -1.0, -1.0);
if (!wd) return;
elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
}
+
+/**
+ * This appends a custom item provider to the list for that anchorview
+ *
+ * This appends the given callback. The list is walked from beginning to end
+ * with each function called given the item href string in the text. If the
+ * function returns an object handle other than NULL (it should create an
+ * and object to do this), then this object is used to replace that item. If
+ * not the next provider is called until one provides an item object, or the
+ * default provider in anchorview does.
+ *
+ * @param obj The anchorview object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorview
+ */
+EAPI void
+elm_anchorview_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (!func) return;
+ Elm_Anchorview_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorview_Item_Provider));
+ if (!ip) return;
+ ip->func = func;
+ ip->data = data;
+ wd->item_providers = eina_list_append(wd->item_providers, ip);
+}
+
+/**
+ * This prepends a custom item provider to the list for that anchorview
+ *
+ * This prepends the given callback. See elm_anchorview_item_provider_append() for
+ * more information
+ *
+ * @param obj The anchorview object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorview
+ */
+EAPI void
+elm_anchorview_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (!func) return;
+ Elm_Anchorview_Item_Provider *ip = calloc(1, sizeof(Elm_Anchorview_Item_Provider));
+ if (!ip) return;
+ ip->func = func;
+ ip->data = data;
+ wd->item_providers = eina_list_prepend(wd->item_providers, ip);
+}
+
+/**
+ * This removes a custom item provider to the list for that anchorview
+ *
+ * This removes the given callback. See elm_anchorview_item_provider_append() for
+ * more information
+ *
+ * @param obj The anchorview object
+ * @param func The function called to provide the item object
+ * @param data The data passed to @p func
+ *
+ * @ingroup Anchorview
+ */
+EAPI void
+elm_anchorview_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Eina_List *l;
+ Elm_Anchorview_Item_Provider *ip;
+ if (!wd) return;
+ if (!func) return;
+ EINA_LIST_FOREACH(wd->item_providers, l, ip)
+ {
+ if ((ip->func == func) && (ip->data == data))
+ {
+ wd->item_providers = eina_list_remove_list(wd->item_providers, l);
+ free(ip);
+ return;
+ }
+ }
+}
*
* You can also insert "items" in the entry with:
*
- * <item size=16x16 vsize=full href=emoticon/haha></item>
+ * \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
*
* for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
* vsize=ascent or vsize=full. the href=NAME sets the item name. Entry