* Finally, we have an area in this layout theme, in the bottom part of it,
* reserved for adding an specific widget. Differently from the 2 parts
* described until now, this one can only receive one widget with the call
- * elm_layout_content_set(). If there was already an item on this specific part,
- * it will be deleted (one can use elm_layout_content_unset() in order to remove
+ * elm_object_content_part_set() for the layout. If there was already an item on this specific part,
+ * it will be deleted (one can use elm_object_content_part_unset() in order to remove
* it without deleting). An example of removing it without deleting, but
* manually deleting this widget just after that, can be seen on the callback
* for this button. Actually, the callback defined for this button will clean
* Also notice that, for this last added button, we don't have to call
* evas_object_show() on it. This is a particularity of the theme for layouts,
* that will have total control over the properties like size, position,
- * visibility and clipping of a widget added with elm_layout_content_set().
+ * visibility and clipping of a widget added with elm_object_content_part_set().
* Again, read the Edje documentation to understand this better.
*
* Now we just put the code for the different callbacks specified for each kind
evas_object_size_hint_min_set(icon, 200, 140);
evas_object_show(icon);
-elm_layout_content_set(layout, "elm.swallow.content", icon);
+elm_object_content_part_set(layout, "elm.swallow.content", icon);
elm_object_text_part_set(layout, "elm.text.title", "Layout");
#include "widget_preview_tmpl_foot.c"
re = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_show(re);
- elm_layout_content_set(ly, "ColorPreview", re);
+ elm_object_content_part_set(ly, "ColorPreview", re);
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, 1.0, 0);
elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_entry_entry_set(en, "This is a single line");
elm_entry_single_line_set(en, 1);
- elm_layout_content_set(ly, "element1", en);
+ elm_object_content_part_set(ly, "element1", en);
evas_object_show(en);
en = elm_entry_add(win);
"use it more flexibly.");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_layout_content_set(ly, "element2", en);
+ elm_object_content_part_set(ly, "element2", en);
evas_object_show(en);
en = elm_entry_add(win);
"good testing to see if entry widgets work as advertised."
);
evas_object_smart_callback_add(en, "anchor,clicked", scrolled_anchor_test, en);
- elm_layout_content_set(ly, "element3", en);
+ elm_object_content_part_set(ly, "element3", en);
evas_object_show(en);
evas_object_show(win);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
- elm_layout_content_set(ly, "element1", bt);
+ elm_object_content_part_set(ly, "element1", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
- elm_layout_content_set(ly, "element2", bt);
+ elm_object_content_part_set(ly, "element2", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
- elm_layout_content_set(ly, "element3", bt);
+ elm_object_content_part_set(ly, "element3", bt);
evas_object_show(bt);
evas_object_show(fl);
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
- elm_layout_content_set(ly, "element1", bx2);
+ elm_object_content_part_set(ly, "element1", bx2);
my_show(bx2);
for (i = 3; i; i--)
evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx2, 0.0, 0.0);
- elm_layout_content_set(ly, "element2", bx2);
+ elm_object_content_part_set(ly, "element2", bx2);
my_show(bx2);
{
bt1 = bt = elm_button_add(ly);
elm_object_text_set(bt, "Button 1");
- elm_layout_content_set(ly, "element1", bt);
+ elm_object_content_part_set(ly, "element1", bt);
en = elm_entry_add(ly);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_entry_entry_set(en, "Scrolled Entry that should get focus");
elm_entry_single_line_set(en, 1);
- elm_layout_content_set(ly, "element2", en);
+ elm_object_content_part_set(ly, "element2", en);
bt = elm_button_add(ly);
elm_object_text_set(bt, "Button 2");
- elm_layout_content_set(ly, "element3", bt);
+ elm_object_content_part_set(ly, "element3", bt);
bt = elm_button_add(PARENT);
elm_object_text_set(bt, "Give focus to layout");
Evas_Object *postit = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/postit_ent.edj", elm_app_data_dir_get());
elm_layout_file_set(postit, buf, "main");
- elm_layout_content_set(postit, "ent", en);
+ elm_object_content_part_set(postit, "ent", en);
photo_array[ind++] = photo_object_add(win, postit, NULL, 50, 50, 382, 400, 355);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
- elm_layout_content_set(ly, "element1", bt);
+ elm_object_content_part_set(ly, "element1", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
- elm_layout_content_set(ly, "element2", bt);
+ elm_object_content_part_set(ly, "element2", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
- elm_layout_content_set(ly, "element3", bt);
+ elm_object_content_part_set(ly, "element3", bt);
evas_object_show(bt);
mb = elm_mapbuf_add(win);
slx = (int)(long)evas_object_data_get(data, "slx");
sly = (int)(long)evas_object_data_get(data, "sly");
snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
- elm_layout_content_unset(ly, buf);
+ elm_object_content_part_unset(ly, buf);
edje_object_signal_emit(elm_layout_edje_get(ly2), "drag", "app");
return EINA_FALSE;
}
slx = (int)(long)evas_object_data_get(obj, "slx");
sly = (int)(long)evas_object_data_get(obj, "sly");
snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
- elm_layout_content_set(ly, buf, ly2);
+ elm_object_content_part_set(ly, buf, ly2);
list = (Eina_List *)evas_object_data_get
(elm_object_top_widget_get(obj), "mbs");
EINA_LIST_FOREACH(list, l, mb)
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ic, 0.5, 0.5);
- elm_layout_content_set(ly2, "slot", ic);
+ elm_object_content_part_set(ly2, "slot", ic);
evas_object_show(ic);
evas_object_event_callback_add(ic, EVAS_CALLBACK_DEL, l3_ic_del_cb, ic);
evas_object_data_set(ic, "sly", (void *)(long)(j));
snprintf(buf, sizeof(buf), "slot.%i.%i", i, j);
- elm_layout_content_set(ly, buf, ly2);
+ elm_object_content_part_set(ly, buf, ly2);
evas_object_show(ly2);
n++; if (n > 23) n = 0;
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
- elm_layout_content_set(ly, "element1", bt);
+ elm_object_content_part_set(ly, "element1", bt);
evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
- elm_layout_content_set(ly, "element2", bt);
+ elm_object_content_part_set(ly, "element2", bt);
evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
- elm_layout_content_set(ly, "element3", bt);
+ elm_object_content_part_set(ly, "element3", bt);
evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Flip to 1");
evas_object_smart_callback_add(bt, "clicked", my_pager_4, &info);
- elm_layout_content_set(ly2, "element1", bt);
+ elm_object_content_part_set(ly2, "element1", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Popme");
evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
evas_object_show(bt);
- elm_layout_content_set(ly2, "element2", bt);
+ elm_object_content_part_set(ly2, "element2", bt);
- elm_layout_content_set(ly, "swallow", ly2);
+ elm_object_content_part_set(ly, "swallow", ly2);
evas_object_show(ly);
elm_pager_content_push(pg, ly);
elm_segment_control_item_add(segment4, NULL, "Disabled");
elm_object_disabled_set(segment4, EINA_TRUE);
- elm_layout_content_set(in_layout, "segment1", segment1);
- elm_layout_content_set(in_layout, "segment2", segment2);
- elm_layout_content_set(in_layout, "segment3", segment3);
- elm_layout_content_set(in_layout, "segment4", segment4);
+ elm_object_content_part_set(in_layout, "segment1", segment1);
+ elm_object_content_part_set(in_layout, "segment2", segment2);
+ elm_object_content_part_set(in_layout, "segment3", segment3);
+ elm_object_content_part_set(in_layout, "segment4", segment4);
evas_object_show(in_layout);
elm_layout_table_clear(layout, TABLE, EINA_TRUE);
elm_layout_box_remove_all(layout, BOX, EINA_TRUE);
- item = elm_layout_content_unset(layout, SWALLOW);
+ item = elm_object_content_part_unset(layout, SWALLOW);
evas_object_del(item);
}
bt2 = elm_button_add(win);
elm_object_text_set(bt2, "Delete All");
- elm_layout_content_set(layout, SWALLOW, bt2);
+ elm_object_content_part_set(layout, SWALLOW, bt2);
evas_object_smart_callback_add(bt2, "clicked", _swallow_btn_cb, layout);
evas_object_size_hint_min_set(bg, 160, 160);
_signal_cb(void *data, Evas_Object *o, const char *emission, const char *source __UNUSED__)
{
struct _App *app = data;
- Evas_Object *icon = elm_layout_content_get(o, "elm.swallow.content");
+ Evas_Object *icon = elm_object_content_part_get(o, "elm.swallow.content");
printf("signal received\n");
icon = elm_icon_add(win);
elm_icon_standard_set(icon, images[app.current]);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_layout_content_set(layout, "elm.swallow.content", icon);
+ elm_object_content_part_set(layout, "elm.swallow.content", icon);
elm_object_signal_callback_add(layout, "elm,action,back", "", _signal_cb, &app);
elm_object_signal_callback_add(layout, "elm,action,next", "", _signal_cb, &app);
elm_object_text_set(btn, "Enlarge me!");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_layout_content_set(layout, SWALLOW, btn);
+ elm_object_content_part_set(layout, SWALLOW, btn);
evas_object_smart_callback_add(btn, "clicked", _swallow_btn_cb, layout);
evas_object_size_hint_min_set(bg, 160, 160);
* column or row span if necessary.
*
* Again, we could have this design by adding a @ref Table widget to the @c
- * SWALLOW part using elm_layout_content_set(). The same difference happens
+ * SWALLOW part using elm_object_content_part_set(). The same difference happens
* here when choosing to use the Layout Table (a @c TABLE part) instead of
* the @ref Table plus @c SWALLOW part. It's just a matter of convenience.
*
*
* Once the content object is set, a previously set one will be deleted.
* If you want to keep that old content object, use the
- * elm_layout_content_unset() function.
+ * elm_object_content_part_unset() function.
*
* @note In an Edje theme, the part used as a content container is called @c
* SWALLOW. This is why the parameter name is called @p swallow, but it is
* elm_layout_box_append().
*
* @see elm_layout_box_append()
- * @see elm_layout_content_get()
- * @see elm_layout_content_unset()
+ * @see elm_object_content_part_get()
+ * @see elm_object_content_part_unset()
* @see @ref secBox
*
* @ingroup Layout
*/
- EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content) EINA_ARG_NONNULL(1);
/**
* Get the child object in the given content part.
*
*
* @return The swallowed object or NULL if none or an error occurred
*
- * @see elm_layout_content_set()
+ * @see elm_object_content_part_set()
*
* @ingroup Layout
*/
- EAPI Evas_Object *elm_layout_content_get(const Evas_Object *obj, const char *swallow) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI Evas_Object *elm_layout_content_get(const Evas_Object *obj, const char *swallow) EINA_ARG_NONNULL(1);
/**
* Unset the layout content.
*
*
* Unparent and return the content object which was set for this part.
*
- * @see elm_layout_content_set()
+ * @see elm_object_content_part_set()
*
* @ingroup Layout
*/
- EAPI Evas_Object *elm_layout_content_unset(Evas_Object *obj, const char *swallow) EINA_ARG_NONNULL(1);
+ EINA_DEPRECATED EAPI Evas_Object *elm_layout_content_unset(Evas_Object *obj, const char *swallow) EINA_ARG_NONNULL(1);
/**
* Set the text of the given part
*
*
* The object will be removed from the box part and its lifetime will
* not be handled by the layout anymore. This is equivalent to
- * elm_layout_content_unset() for box.
+ * elm_object_content_part_unset() for box.
*
* @see elm_layout_box_append()
* @see elm_layout_box_remove_all()
*
* The object will be unpacked from the table part and its lifetime
* will not be handled by the layout anymore. This is equivalent to
- * elm_layout_content_unset() for table.
+ * elm_object_content_part_unset() for table.
*
* @see elm_layout_table_pack()
* @see elm_layout_table_clear()
*
* This returns the edje object. It is not expected to be used to then
* swallow objects via edje_object_part_swallow() for example. Use
- * elm_layout_content_set() instead so child object handling and sizing is
+ * elm_object_content_part_set() instead so child object handling and sizing is
* done properly.
*
* @note This function should only be used if you really need to call some
* @see elm_object_signal_callback_add()
* @see elm_object_signal_emit()
* @see elm_object_text_part_set()
- * @see elm_layout_content_set()
+ * @see elm_object_content_part_set()
* @see elm_layout_box_append()
* @see elm_layout_table_pack()
* @see elm_layout_data_get()
#define elm_layout_icon_set(_ly, _obj) \
do { \
const char *sig; \
- elm_layout_content_set((_ly), "elm.swallow.icon", (_obj)); \
+ elm_object_content_part_set((_ly), "elm.swallow.icon", (_obj)); \
if ((_obj)) sig = "elm,state,icon,visible"; \
else sig = "elm,state,icon,hidden"; \
elm_object_signal_emit((_ly), sig, "elm"); \
* @ingroup Layout
*/
#define elm_layout_icon_get(_ly) \
- elm_layout_content_get((_ly), "elm.swallow.icon")
+ elm_object_content_part_get((_ly), "elm.swallow.icon")
/**
* @def elm_layout_end_set
#define elm_layout_end_set(_ly, _obj) \
do { \
const char *sig; \
- elm_layout_content_set((_ly), "elm.swallow.end", (_obj)); \
+ elm_object_content_part_set((_ly), "elm.swallow.end", (_obj)); \
if ((_obj)) sig = "elm,state,end,visible"; \
else sig = "elm,state,end,hidden"; \
elm_object_signal_emit((_ly), sig, "elm"); \
* @ingroup Layout
*/
#define elm_layout_end_get(_ly) \
- elm_layout_content_get((_ly), "elm.swallow.end")
+ elm_object_content_part_get((_ly), "elm.swallow.end")
/**
* @def elm_layout_label_set
return edje_object_part_text_get(wd->lay, part);
}
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Subinfo *si;
+ const Eina_List *l;
+ if (!wd) return;
+ EINA_LIST_FOREACH(wd->subs, l, si)
+ {
+ if ((si->type == SWALLOW) && (!strcmp(part, si->part)))
+ {
+ if (content == si->obj) return;
+ evas_object_del(si->obj);
+ break;
+ }
+ }
+ if (content)
+ {
+ elm_widget_sub_object_add(obj, content);
+ evas_object_event_callback_add(content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, wd);
+ if (!edje_object_part_swallow(wd->lay, part, content))
+ WRN("could not swallow %p into part '%s'", content, part);
+ si = ELM_NEW(Subinfo);
+ si->type = SWALLOW;
+ si->part = eina_stringshare_add(part);
+ si->obj = content;
+ wd->subs = eina_list_append(wd->subs, si);
+ }
+ _request_sizing_eval(wd);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ const Eina_List *l;
+ Subinfo *si;
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+
+ EINA_LIST_FOREACH(wd->subs, l, si)
+ {
+ if ((si->type == SWALLOW) && !strcmp(part, si->part))
+ return si->obj;
+ }
+ return NULL;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Subinfo *si;
+ const Eina_List *l;
+ if (!wd) return NULL;
+ EINA_LIST_FOREACH(wd->subs, l, si)
+ {
+ if ((si->type == SWALLOW) && (!strcmp(part, si->part)))
+ {
+ Evas_Object *content;
+ if (!si->obj) return NULL;
+ content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
+ elm_widget_sub_object_del(obj, content);
+ edje_object_part_unswallow(wd->lay, content);
+ return content;
+ }
+ }
+ return NULL;
+}
+
EAPI Evas_Object *
elm_layout_add(Evas_Object *parent)
{
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_text_set_hook_set(obj, _elm_layout_label_set);
elm_widget_text_get_hook_set(obj, _elm_layout_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->obj = obj;
wd->lay = edje_object_add(e);
EAPI void
elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- Subinfo *si;
- const Eina_List *l;
- if (!wd) return;
- EINA_LIST_FOREACH(wd->subs, l, si)
- {
- if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
- {
- if (content == si->obj) return;
- evas_object_del(si->obj);
- break;
- }
- }
- if (content)
- {
- elm_widget_sub_object_add(obj, content);
- evas_object_event_callback_add(content,
- EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _changed_size_hints, wd);
- if (!edje_object_part_swallow(wd->lay, swallow, content))
- WRN("could not swallow %p into part '%s'", content, swallow);
- si = ELM_NEW(Subinfo);
- si->type = SWALLOW;
- si->part = eina_stringshare_add(swallow);
- si->obj = content;
- wd->subs = eina_list_append(wd->subs, si);
- }
- _request_sizing_eval(wd);
+ _content_set_hook(obj, swallow, content);
}
+
EAPI Evas_Object *
elm_layout_content_get(const Evas_Object *obj, const char *swallow)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- const Eina_List *l;
- Subinfo *si;
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
-
- EINA_LIST_FOREACH(wd->subs, l, si)
- {
- if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
- return si->obj;
- }
- return NULL;
+ return _content_get_hook(obj, swallow);
}
EAPI Evas_Object *
elm_layout_content_unset(Evas_Object *obj, const char *swallow)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Subinfo *si;
- const Eina_List *l;
- if (!wd) return NULL;
- EINA_LIST_FOREACH(wd->subs, l, si)
- {
- if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
- {
- Evas_Object *content;
- if (!si->obj) return NULL;
- content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
- elm_widget_sub_object_del(obj, content);
- edje_object_part_unswallow(wd->lay, content);
- return content;
- }
- }
- return NULL;
+ return _content_unset_hook(obj, swallow);
}
EAPI void
group->obj = elm_layout_add(group->wd->obj);
elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
- if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
+ if (icon) elm_object_content_part_set(group->obj, "elm.icon", icon);
evas_object_smart_member_add(group->obj, group->wd->pan_smart);
elm_widget_sub_object_add(group->wd->obj, group->obj);