* callback, where we move the button doing some size hint magic. To
* understand how that works better, refer to the @ref Box documentation.
* Also, the first time the function is called, we change the icon in the
- * middle button, using elm_button_icon_unset() first to keep the reference
+ * middle button, using elm_object_content_unset() first to keep the reference
* to the previous one, so we don't need to recreate it when we are done
* moving it.
* @skip static void
Evas_Object *o2 = elm_icon_add(win);
elm_icon_standard_set(o2, "home");
-elm_button_icon_set(o, o2);
+elm_object_content_set(o, o2);
evas_object_show(o2);
#include "widget_preview_tmpl_foot.c"
Evas_Object *o2 = elm_icon_add(win);
elm_icon_standard_set(o2, "home");
-elm_button_icon_set(o, o2);
+elm_object_content_set(o, o2);
evas_object_show(o2);
#include "widget_preview_tmpl_foot.c"
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon sized to button");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
elm_box_pack_end(bx, bt);
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon no scale");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
elm_box_pack_end(bx, bt);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Disabled Button");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
elm_box_pack_end(bx, bt);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_style_set(bt, "anchor");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
elm_box_pack_end(bx, bt);
bt = elm_button_add(win);
elm_object_access_info_set(bt, "This is some custom text describing this widget");
elm_object_style_set(bt, "anchor");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);
evas_object_show(icon);
Evas_Object *o = elm_button_add(obj);
- elm_button_icon_set(o, icon);
+ elm_object_content_set(o, icon);
evas_object_show(o);
elm_box_pack_end(bx, o);
}
snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
bt2 = elm_button_add(nf);
evas_object_size_hint_align_set(bt2, EVAS_HINT_FILL, EVAS_HINT_FILL);
snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
it = elm_naviframe_item_push(nf,
"Page 2",
bt = elm_button_add(win);
elm_object_text_set(bt, "ImageAnimation Effect");
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
evas_object_size_hint_max_set(ic, 50, 50);
bt = elm_button_add(win);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_text_set(bt, "Before Button - Blend Effect");
evas_object_move(bt, 25, 125);
evas_object_resize(bt, 250, 50);
evas_object_size_hint_max_set(ic, 50, 50);
bt2 = elm_button_add(win);
- elm_button_icon_set(bt2, ic);
+ elm_object_content_set(bt2, ic);
elm_object_text_set(bt2, "After Button - Blend Effect");
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);
evas_object_size_hint_max_set(ic, 50, 50);
bt = elm_button_add(win);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_text_set(bt, "Before Button - Fade Effect");
evas_object_move(bt, 25, 125);
evas_object_resize(bt, 250, 50);
evas_object_size_hint_max_set(ic, 50, 50);
bt2 = elm_button_add(win);
- elm_button_icon_set(bt2, ic);
+ elm_object_content_set(bt2, ic);
elm_object_text_set(bt2, "After Button - Fade Effect");
evas_object_move(bt2, 25, 125);
evas_object_resize(bt2, 250, 50);
if (p->label)
elm_object_text_set(obj, p->label);
if (p->icon)
- elm_button_icon_set(obj, p->icon);
+ elm_object_content_set(obj, p->icon);
}
static Eina_Bool
{
Evas_Object *icon = external_common_param_icon_get(obj, param);
if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
- elm_button_icon_set(obj, icon);
+ elm_object_content_set(obj, icon);
return EINA_TRUE;
}
}
_btn_cursors_release_cb(void *data, Evas_Object *btn __UNUSED__, void *ev __UNUSED__)
{
App_Data *app = data;
- elm_button_icon_set(app->mid, app->icon_still);
+ elm_object_content_set(app->mid, app->icon_still);
app->icon_still = NULL;
}
if (!app->icon_still)
{
Evas_Object *icon;
- app->icon_still = elm_button_icon_unset(app->mid);
+ app->icon_still = elm_object_content_unset(app->mid);
icon = elm_icon_add(app->mid);
elm_icon_standard_set(icon, "chat");
- elm_button_icon_set(app->mid, icon);
+ elm_object_content_set(app->mid, icon);
}
evas_object_size_hint_align_get(app->mid, &ax, &ay);
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_up");
- elm_button_icon_set(btn, icon);
+ elm_object_content_set(btn, icon);
data.cursors.up = btn;
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_left");
- elm_button_icon_set(btn, icon);
+ elm_object_content_set(btn, icon);
data.cursors.left = btn;
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "close");
- elm_button_icon_set(btn, icon);
+ elm_object_content_set(btn, icon);
data.mid = btn;
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_right");
- elm_button_icon_set(btn, icon);
+ elm_object_content_set(btn, icon);
data.cursors.right = btn;
icon = elm_icon_add(win);
elm_icon_standard_set(icon, "arrow_down");
- elm_button_icon_set(btn, icon);
+ elm_object_content_set(btn, icon);
data.cursors.down = btn;
icon = elm_layout_add(win);
elm_layout_theme_set(icon, "entry", "emoticon/haha", "default");
- elm_button_icon_set(o, icon);
+ elm_object_content_set(o, icon);
evas_object_smart_callback_add(o, "clicked", _image_insert_cb, &app);
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_07.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
- elm_button_icon_set(obj, icon);
+ elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);
evas_object_show(obj);
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_07.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
- elm_button_icon_set(obj, icon);
+ elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);
evas_object_show(obj);
icon = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_08.png", PACKAGE_DATA_DIR);
elm_icon_file_set(icon, buf, NULL);
- elm_button_icon_set(obj, icon);
+ elm_object_content_set(obj, icon);
evas_object_move(obj, 160, 60);
evas_object_resize(obj, 250, 100);
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "arrow_up");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_prev_cb, ad);
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "arrow_down");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_next_cb, ad);
ic = elm_icon_add(ad->win);
elm_icon_standard_set(ic, "close");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _search_close_cb, ad);
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "arrow_left");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_back_cb, ad);
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "refresh");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_refresh_cb, ad);
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "arrow_right");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _nav_fwd_cb, ad);
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
evas_object_smart_callback_add(btn, "clicked", _add_tab_cb, ad);
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "close");
- elm_button_icon_set(btn, ic);
+ elm_object_content_set(btn, ic);
pager = elm_pager_add(win);
evas_object_size_hint_weight_set(pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
* @param obj The button object
* @param icon The icon object for the button
*/
- EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI void elm_button_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
/**
* Get the icon used for the button
*
*
* @see elm_button_icon_unset()
*/
- EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI Evas_Object *elm_button_icon_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Remove the icon set without deleting it and return the object
*
* @param obj The button object
* @return The icon object that was being used
*/
- EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI Evas_Object *elm_button_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Turn on/off the autorepeat event generated when the button is kept pressed
*
* deleted, if you want to keep that old content object, use the
* elm_hoversel_icon_unset() function.
*
- * @see elm_button_icon_set()
+ * @see elm_object_content_set() for the button widget
*/
EAPI void elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon) EINA_ARG_NONNULL(1);
/**
* @return The icon object
*
* Get the icon of the button that is always visible (before it is clicked
- * and expanded). Also see elm_button_icon_get().
+ * and expanded). Also see elm_object_content_get() for the button widget.
*
* @see elm_hoversel_icon_set()
*/
* (before it is clicked and expanded).
*
* @see elm_hoversel_icon_set()
- * @see elm_button_icon_unset()
+ * @see elm_object_content_unset() for the button widget
*/
EAPI Evas_Object *elm_hoversel_icon_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Up"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Home"));
evas_object_size_hint_align_set(bt, 0.0, 0.0);
evas_object_del(icon);
return;
}
- elm_button_icon_set(wd->btn, icon);
+ elm_object_content_set(wd->btn, icon);
}
EAPI Evas_Object *
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
- return elm_button_icon_get(wd->btn);
+ return elm_object_content_get(wd->btn);
}
EAPI Evas_Object *
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
- return elm_button_icon_unset(wd->btn);
+ return elm_object_content_unset(wd->btn);
}
elm_icon_file_set(ic, item->icon_file, item->icon_group);
else if (item->icon_type == ELM_ICON_STANDARD)
elm_icon_standard_set(ic, item->icon_file);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_show(ic);
}
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- elm_button_icon_set(wd->btn, icon);
+ elm_object_content_set(wd->btn, icon);
}
EAPI Evas_Object *
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->btn)) return NULL;
- return elm_button_icon_get(wd->btn);
+ return elm_object_content_get(wd->btn);
}
EAPI Evas_Object *
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (!wd->btn)) return NULL;
- return elm_button_icon_unset(wd->btn);
+ return elm_object_content_unset(wd->btn);
}
EAPI void
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(parent);
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
- elm_button_icon_set(bt, ic);
+ elm_object_content_set(bt, ic);
evas_object_size_hint_align_set(bt, 0.0, 0.0);
elm_object_style_set(bt, "anchor");
evas_object_smart_callback_add(bt, "clicked", func, obj);
static void _del_pre_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _disable_hook(Evas_Object *obj);
+static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
+static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
+static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
}
static void
+_content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->icon == content) return;
+ if (wd->icon) evas_object_del(wd->icon);
+ wd->icon = content;
+ if (content)
+ {
+ elm_widget_sub_object_add(obj, content);
+ evas_object_event_callback_add(content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_swallow(wd->btn, "elm.swallow.content", content);
+ edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
+ edje_object_message_signal_process(wd->btn);
+ }
+ _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->icon;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (!wd->icon) return NULL;
+ Evas_Object *icon = wd->icon;
+ elm_widget_sub_object_del(obj, wd->icon);
+ edje_object_part_unswallow(wd->btn, wd->icon);
+ wd->icon = NULL;
+ return icon;
+}
+
+static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_text_set_hook_set(obj, _elm_button_label_set);
elm_widget_text_get_hook_set(obj, _elm_button_label_get);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->btn = edje_object_add(e);
_elm_theme_object_set(obj, wd->btn, "button", "base", "default");
return _elm_button_label_get(obj, NULL);
}
+
EAPI void
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->icon == icon) return;
- if (wd->icon) evas_object_del(wd->icon);
- wd->icon = icon;
- if (icon)
- {
- elm_widget_sub_object_add(obj, icon);
- evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _changed_size_hints, obj);
- edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
- edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
- edje_object_message_signal_process(wd->btn);
- }
- _sizing_eval(obj);
+ _content_set_hook(obj, NULL, icon);
}
EAPI Evas_Object *
elm_button_icon_get(const Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return wd->icon;
+ return _content_get_hook(obj, NULL);
}
EAPI Evas_Object *
elm_button_icon_unset(Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- if (!wd->icon) return NULL;
- Evas_Object *icon = wd->icon;
- elm_widget_sub_object_del(obj, wd->icon);
- edje_object_part_unswallow(wd->btn, wd->icon);
- wd->icon = NULL;
- return icon;
+ return _content_unset_hook(obj, NULL);
}
EAPI void