1 #include <Elementary.h>
5 * @defgroup Layout Layout
7 * This takes a standard Edje design file and wraps it very thinly
8 * in a widget and handles swallowing widgets into swallow regions
9 * in the Edje object, allowing Edje to be used as a design and
13 typedef struct _Widget_Data Widget_Data;
14 typedef struct _Subinfo Subinfo;
15 typedef struct _Part_Cursor Part_Cursor;
22 Eina_List *parts_cursors;
23 Eina_Bool needs_size_calc:1;
24 const char *clas, *group, *style;
42 const Evas_Object *reference;
46 unsigned short col, row, colspan, rowspan;
60 Eina_Bool engine_only:1;
63 static const char *widtype = NULL;
64 static void _del_hook(Evas_Object *obj);
65 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
66 static void _theme_hook(Evas_Object *obj);
67 static void _sizing_eval(Widget_Data *wd);
68 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
69 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
70 static void _part_cursor_free(Part_Cursor *pc);
73 _del_hook(Evas_Object *obj)
75 Widget_Data *wd = elm_widget_data_get(obj);
80 EINA_LIST_FREE(wd->subs, si)
82 eina_stringshare_del(si->part);
84 eina_stringshare_del(si->p.text.text);
87 EINA_LIST_FREE(wd->parts_cursors, pc) _part_cursor_free(pc);
92 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
94 Widget_Data *wd = elm_widget_data_get(obj);
96 edje_object_mirrored_set(wd->lay, rtl);
100 _theme_hook(Evas_Object *obj)
102 Widget_Data *wd = elm_widget_data_get(obj);
104 _elm_widget_mirrored_reload(obj);
105 _mirrored_set(obj, elm_widget_mirrored_get(obj));
106 _elm_theme_object_set(obj, wd->lay, wd->clas, wd->group, wd->style);
107 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
113 _changed_hook(Evas_Object *obj)
115 Widget_Data *wd = elm_widget_data_get(obj);
117 if (wd->needs_size_calc)
120 wd->needs_size_calc = 0;
125 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
127 Widget_Data *wd = elm_widget_data_get(obj);
128 edje_object_signal_emit(wd->lay, emission, source);
132 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
134 Widget_Data *wd = elm_widget_data_get(obj);
135 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
139 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
141 Widget_Data *wd = elm_widget_data_get(obj);
142 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
148 _elm_layout_list_data_get(const Eina_List *list)
150 Subinfo *si = eina_list_data_get(list);
155 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
157 Widget_Data *wd = elm_widget_data_get(obj);
158 const Eina_List *items;
159 void *(*list_data_get) (const Eina_List *list);
161 if ((!wd) || (!wd->subs))
164 /* Focus chain (This block is diferent of elm_win cycle)*/
165 if ((items = elm_widget_focus_custom_chain_get(obj)))
166 list_data_get = eina_list_data_get;
170 list_data_get = _elm_layout_list_data_get;
172 if (!items) return EINA_FALSE;
175 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
180 _sizing_eval(Widget_Data *wd)
182 Evas_Coord minw = -1, minh = -1;
183 edje_object_size_min_calc(wd->lay, &minw, &minh);
184 evas_object_size_hint_min_set(wd->obj, minw, minh);
185 evas_object_size_hint_max_set(wd->obj, -1, -1);
189 _request_sizing_eval(Widget_Data *wd)
191 if (wd->needs_size_calc) return;
192 wd->needs_size_calc = 1;
193 evas_object_smart_changed(wd->obj);
197 _part_cursor_free(Part_Cursor *pc)
199 eina_stringshare_del(pc->part);
200 eina_stringshare_del(pc->style);
201 eina_stringshare_del(pc->cursor);
206 _part_cursor_part_apply(const Part_Cursor *pc)
208 elm_object_cursor_set(pc->obj, pc->cursor);
209 elm_object_cursor_style_set(pc->obj, pc->style);
210 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
214 _parts_cursors_find(Widget_Data *wd, const char *part)
218 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
220 if (!strcmp(pc->part, part))
227 _parts_cursors_apply(Widget_Data *wd)
229 const char *file, *group;
233 edje_object_file_get(wd->lay, &file, &group);
235 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
237 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
243 WRN("no part '%s' in group '%s' of file '%s'. "
244 "Cannot set cursor '%s'",
245 pc->part, group, file, pc->cursor);
248 else if (evas_object_pass_events_get(obj))
251 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
252 "Cannot set cursor '%s'",
253 pc->part, group, file, pc->cursor);
258 _part_cursor_part_apply(pc);
263 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
265 _request_sizing_eval(data);
269 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
271 Widget_Data *wd = elm_widget_data_get(obj);
272 Evas_Object *sub = event_info;
276 EINA_LIST_FOREACH(wd->subs, l, si)
280 evas_object_event_callback_del_full(sub,
281 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
284 wd->subs = eina_list_remove_list(wd->subs, l);
285 eina_stringshare_del(si->part);
293 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
295 _request_sizing_eval(data);
299 _parts_text_fix(Widget_Data *wd)
304 EINA_LIST_FOREACH(wd->subs, l, si)
306 if (si->type == TEXT)
307 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
312 _elm_layout_label_set(Evas_Object *obj, const char *part, const char *text)
314 Widget_Data *wd = elm_widget_data_get(obj);
317 ELM_CHECK_WIDTYPE(obj, widtype);
318 if (!part) part = "elm.text";
320 EINA_LIST_FOREACH(wd->subs, l, si)
322 if ((si->type == TEXT) && (!strcmp(part, si->part)))
326 eina_stringshare_del(si->part);
327 eina_stringshare_del(si->p.text.text);
329 edje_object_part_text_set(wd->lay, part, NULL);
330 wd->subs = eina_list_remove_list(wd->subs, l);
341 si = ELM_NEW(Subinfo);
344 si->part = eina_stringshare_add(part);
345 wd->subs = eina_list_append(wd->subs, si);
348 eina_stringshare_replace(&si->p.text.text, text);
349 edje_object_part_text_set(wd->lay, part, text);
350 _request_sizing_eval(wd);
354 _elm_layout_label_get(const Evas_Object *obj, const char *part)
356 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
357 Widget_Data *wd = elm_widget_data_get(obj);
358 if (!part) part = "elm.text";
359 return edje_object_part_text_get(wd->lay, part);
363 * Add a new layout to the parent
365 * @param parent The parent object
366 * @return The new object or NULL if it cannot be created
371 elm_layout_add(Evas_Object *parent)
377 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
379 ELM_SET_WIDTYPE(widtype, "layout");
380 elm_widget_type_set(obj, "layout");
381 elm_widget_sub_object_add(parent, obj);
382 elm_widget_data_set(obj, wd);
383 elm_widget_del_hook_set(obj, _del_hook);
384 elm_widget_theme_hook_set(obj, _theme_hook);
385 elm_widget_changed_hook_set(obj, _changed_hook);
386 elm_widget_can_focus_set(obj, EINA_FALSE);
387 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
388 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
389 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
390 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
391 elm_widget_text_set_hook_set(obj, _elm_layout_label_set);
392 elm_widget_text_get_hook_set(obj, _elm_layout_label_get);
395 wd->lay = edje_object_add(e);
396 elm_widget_resize_object_set(obj, wd->lay);
397 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
398 _signal_size_eval, wd);
400 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
402 _mirrored_set(obj, elm_widget_mirrored_get(obj));
403 _request_sizing_eval(wd);
408 * Set the file that will be used as layout
410 * @param obj The layout object
411 * @param file The path to file (edj) that will be used as layout
412 * @param group The group that the layout belongs in edje file
414 * @return (1 = success, 0 = error)
419 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
421 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
422 Widget_Data *wd = elm_widget_data_get(obj);
423 if (!wd) return EINA_FALSE;
424 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
428 _request_sizing_eval(wd);
429 _parts_cursors_apply(wd);
431 else DBG("failed to set edje file '%s', group '%s': %s",
433 edje_load_error_str(edje_object_load_error_get(wd->lay)));
438 * Set the edje group from the elementary theme that will be used as layout
440 * @param obj The layout object
441 * @param clas the clas of the group
442 * @param group the group
443 * @param style the style to used
445 * @return (1 = success, 0 = error)
450 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
452 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
453 Widget_Data *wd = elm_widget_data_get(obj);
454 if (!wd) return EINA_FALSE;
455 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
462 _request_sizing_eval(wd);
463 _parts_cursors_apply(wd);
469 * Set the layout content
471 * Once the content object is set, a previously set one will be deleted.
472 * If you want to keep that old content object, use the
473 * elm_layout_content_unset() function.
475 * @param obj The layout object
476 * @param swallow The swallow group name in the edje file
477 * @param content The content will be filled in this layout object
482 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
484 ELM_CHECK_WIDTYPE(obj, widtype);
485 Widget_Data *wd = elm_widget_data_get(obj);
489 EINA_LIST_FOREACH(wd->subs, l, si)
491 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
493 if (content == si->obj) return;
494 evas_object_del(si->obj);
500 elm_widget_sub_object_add(obj, content);
501 evas_object_event_callback_add(content,
502 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
503 _changed_size_hints, wd);
504 if (!edje_object_part_swallow(wd->lay, swallow, content))
505 WRN("could not swallow %p into part '%s'", content, swallow);
506 si = ELM_NEW(Subinfo);
508 si->part = eina_stringshare_add(swallow);
510 wd->subs = eina_list_append(wd->subs, si);
512 _request_sizing_eval(wd);
516 * Get the swallowed object in the given part
518 * @param obj The layout object
519 * @param swallow The SWALLOW part to get its content
521 * @return The swallowed object or NULL if none or an error occurred
526 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
528 Widget_Data *wd = elm_widget_data_get(obj);
531 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
533 EINA_LIST_FOREACH(wd->subs, l, si)
535 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
542 * Unset the layout content
544 * Unparent and return the content object which was set for this widget
546 * @param obj The layout object
547 * @param swallow The swallow group name in the edje file
548 * @return The content that was being used
553 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
555 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
556 Widget_Data *wd = elm_widget_data_get(obj);
559 if (!wd) return NULL;
560 EINA_LIST_FOREACH(wd->subs, l, si)
562 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
564 Evas_Object *content;
565 if (!si->obj) return NULL;
566 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
567 elm_widget_sub_object_del(obj, content);
568 edje_object_part_unswallow(wd->lay, content);
576 * Set the text of the given part
578 * @param obj The layout object
579 * @param part The TEXT part where to set the text
580 * @param text The text to set
583 * @deprecate use elm_object_text_* instead.
586 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
588 _elm_layout_label_set(obj, part, text);
592 * Get the text set in the given part
594 * @param obj The layout object
595 * @param part The TEXT part to retrieve the text off
597 * @return The text set in @p part
600 * @deprecate use elm_object_text_* instead.
603 elm_layout_text_get(const Evas_Object *obj, const char *part)
605 return _elm_layout_label_get(obj, part);
609 * Append child to layout box part.
611 * Once the object is appended, its lifetime will be bound to the
612 * layout, whenever the layout dies the child will be deleted
613 * automatically. One should use elm_layout_box_remove() to make this
614 * layout forget about the object.
616 * @param obj the layout object
617 * @param part the box part to append.
618 * @param child the child object to append to box.
623 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
625 ELM_CHECK_WIDTYPE(obj, widtype);
626 Widget_Data *wd = elm_widget_data_get(obj);
630 if (!edje_object_part_box_append(wd->lay, part, child))
631 WRN("child %p could not be appended to box part '%s'", child, part);
632 elm_widget_sub_object_add(obj, child);
633 evas_object_event_callback_add
634 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
636 si = ELM_NEW(Subinfo);
637 si->type = BOX_APPEND;
638 si->part = eina_stringshare_add(part);
640 wd->subs = eina_list_append(wd->subs, si);
641 _request_sizing_eval(wd);
645 * Prepend child to layout box part.
647 * Once the object is prepended, its lifetime will be bound to the
648 * layout, whenever the layout dies the child will be deleted
649 * automatically. One should use elm_layout_box_remove() to make this
650 * layout forget about the object.
652 * @param obj the layout object
653 * @param part the box part to prepend.
654 * @param child the child object to prepend to box.
659 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
661 ELM_CHECK_WIDTYPE(obj, widtype);
662 Widget_Data *wd = elm_widget_data_get(obj);
666 if (!edje_object_part_box_prepend(wd->lay, part, child))
667 WRN("child %p could not be prepended to box part '%s'", child, part);
668 elm_widget_sub_object_add(obj, child);
669 evas_object_event_callback_add
670 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
672 si = ELM_NEW(Subinfo);
673 si->type = BOX_PREPEND;
674 si->part = eina_stringshare_add(part);
676 wd->subs = eina_list_prepend(wd->subs, si);
677 _request_sizing_eval(wd);
681 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
684 si->p.box.reference = NULL;
688 * Insert child to layout box part before a reference object.
690 * Once the object is inserted, its lifetime will be bound to the
691 * layout, whenever the layout dies the child will be deleted
692 * automatically. One should use elm_layout_box_remove() to make this
693 * layout forget about the object.
695 * @param obj the layout object
696 * @param part the box part to insert.
697 * @param child the child object to insert into box.
698 * @param reference another reference object to insert before in box.
703 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
705 ELM_CHECK_WIDTYPE(obj, widtype);
706 Widget_Data *wd = elm_widget_data_get(obj);
710 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
711 WRN("child %p could not be inserted before %p inf box part '%s'",
712 child, reference, part);
714 si = ELM_NEW(Subinfo);
715 si->type = BOX_INSERT_BEFORE;
716 si->part = eina_stringshare_add(part);
718 si->p.box.reference = reference;
720 elm_widget_sub_object_add(obj, child);
721 evas_object_event_callback_add
722 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
723 evas_object_event_callback_add
724 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
726 wd->subs = eina_list_append(wd->subs, si);
727 _request_sizing_eval(wd);
731 * Insert child to layout box part at a given position.
733 * Once the object is inserted, its lifetime will be bound to the
734 * layout, whenever the layout dies the child will be deleted
735 * automatically. One should use elm_layout_box_remove() to make this
736 * layout forget about the object.
738 * @param obj the layout object
739 * @param part the box part to insert.
740 * @param child the child object to insert into box.
741 * @param pos the numeric position >=0 to insert the child.
746 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
748 ELM_CHECK_WIDTYPE(obj, widtype);
749 Widget_Data *wd = elm_widget_data_get(obj);
753 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
754 WRN("child %p could not be inserted at %u to box part '%s'",
757 elm_widget_sub_object_add(obj, child);
758 evas_object_event_callback_add
759 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
761 si = ELM_NEW(Subinfo);
762 si->type = BOX_INSERT_AT;
763 si->part = eina_stringshare_add(part);
766 wd->subs = eina_list_append(wd->subs, si);
767 _request_sizing_eval(wd);
771 _sub_box_remove(Widget_Data *wd, Subinfo *si)
775 if (si->type == BOX_INSERT_BEFORE)
776 evas_object_event_callback_del_full
777 ((Evas_Object *)si->p.box.reference,
778 EVAS_CALLBACK_DEL, _box_reference_del, si);
780 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
781 edje_object_part_box_remove(wd->lay, si->part, child);
782 elm_widget_sub_object_del(wd->obj, child);
787 _sub_table_remove(Widget_Data *wd, Subinfo *si)
791 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
792 edje_object_part_table_unpack(wd->lay, si->part, child);
793 elm_widget_sub_object_del(wd->obj, child);
798 _sub_box_is(const Subinfo *si)
804 case BOX_INSERT_BEFORE:
813 * Remove a child of the given part box.
815 * The object will be removed from the box part and its lifetime will
816 * not be handled by the layout anymore. This is equivalent to
817 * elm_layout_content_unset() for box.
819 * @param obj The layout object
820 * @param part The box part name to remove child.
821 * @param child The object to remove from box.
822 * @return The object that was being used, or NULL if not found.
827 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
829 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
830 Widget_Data *wd = elm_widget_data_get(obj);
834 if (!wd) return NULL;
836 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
837 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
838 EINA_LIST_FOREACH(wd->subs, l, si)
840 if (!_sub_box_is(si)) continue;
841 if ((si->obj == child) && (!strcmp(si->part, part)))
842 return _sub_box_remove(wd, si);
848 * Remove all child of the given part box.
850 * The objects will be removed from the box part and their lifetime will
851 * not be handled by the layout anymore. This is equivalent to
852 * elm_layout_content_unset() for all box children.
854 * @param obj The layout object
855 * @param part The box part name to remove child.
856 * @param clear If EINA_TRUE, then all objects will be deleted as
857 * well, otherwise they will just be removed and will be
858 * dangling on the canvas.
863 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
865 ELM_CHECK_WIDTYPE(obj, widtype);
866 Widget_Data *wd = elm_widget_data_get(obj);
871 EINA_SAFETY_ON_NULL_RETURN(part);
873 lst = eina_list_clone(wd->subs);
874 EINA_LIST_FREE(lst, si)
876 if (!_sub_box_is(si)) continue;
877 if (!strcmp(si->part, part))
879 Evas_Object *child = _sub_box_remove(wd, si);
880 if ((clear) && (child)) evas_object_del(child);
883 /* eventually something may not be added with layout, del them as well */
884 edje_object_part_box_remove_all(wd->lay, part, clear);
888 * Insert child to layout table part.
890 * Once the object is inserted, its lifetime will be bound to the
891 * layout, whenever the layout dies the child will be deleted
892 * automatically. One should use elm_layout_box_remove() to make this
893 * layout forget about the object.
895 * @param obj the layout object
896 * @param part the box part to pack child.
897 * @param child the child object to pack into table.
898 * @param reference another reference object to insert before in box.
903 elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan)
905 ELM_CHECK_WIDTYPE(obj, widtype);
906 Widget_Data *wd = elm_widget_data_get(obj);
910 if (!edje_object_part_table_pack
911 (wd->lay, part, child, col, row, colspan, rowspan))
912 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
913 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
915 elm_widget_sub_object_add(obj, child);
916 evas_object_event_callback_add
917 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
919 si = ELM_NEW(Subinfo);
920 si->type = TABLE_PACK;
921 si->part = eina_stringshare_add(part);
923 si->p.table.col = col;
924 si->p.table.row = row;
925 si->p.table.colspan = colspan;
926 si->p.table.rowspan = rowspan;
927 wd->subs = eina_list_append(wd->subs, si);
928 _request_sizing_eval(wd);
932 * Unpack (remove) a child of the given part table.
934 * The object will be unpacked from the table part and its lifetime
935 * will not be handled by the layout anymore. This is equivalent to
936 * elm_layout_content_unset() for table.
938 * @param obj The layout object
939 * @param part The table part name to remove child.
940 * @param child The object to remove from table.
941 * @return The object that was being used, or NULL if not found.
946 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
948 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
949 Widget_Data *wd = elm_widget_data_get(obj);
953 if (!wd) return NULL;
955 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
956 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
957 EINA_LIST_FOREACH(wd->subs, l, si)
959 if (si->type != TABLE_PACK) continue;
960 if ((si->obj == child) && (!strcmp(si->part, part)))
961 return _sub_table_remove(wd, si);
967 * Remove all child of the given part table.
969 * The objects will be removed from the table part and their lifetime will
970 * not be handled by the layout anymore. This is equivalent to
971 * elm_layout_content_unset() for all table children.
973 * @param obj The layout object
974 * @param part The table part name to remove child.
975 * @param clear If EINA_TRUE, then all objects will be deleted as
976 * well, otherwise they will just be removed and will be
977 * dangling on the canvas.
982 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
984 ELM_CHECK_WIDTYPE(obj, widtype);
985 Widget_Data *wd = elm_widget_data_get(obj);
990 EINA_SAFETY_ON_NULL_RETURN(part);
992 lst = eina_list_clone(wd->subs);
993 EINA_LIST_FREE(lst, si)
995 if (si->type != TABLE_PACK) continue;
996 if (!strcmp(si->part, part))
998 Evas_Object *child = _sub_table_remove(wd, si);
999 if ((clear) && (child)) evas_object_del(child);
1002 /* eventually something may not be added with layout, del them as well */
1003 edje_object_part_table_clear(wd->lay, part, clear);
1007 * Get the edje layout
1009 * @param obj The layout object
1011 * This returns the edje object. It is not expected to be used to then swallow
1012 * objects via edje_object_part_swallow() for example. Use
1013 * elm_layout_content_set() instead so child object handling and sizing is
1014 * done properly. This is more intended for setting text, emitting signals,
1015 * hooking to signal callbacks etc.
1017 * @return A Evas_Object with the edje layout settings loaded
1018 * with function elm_layout_file_set
1023 elm_layout_edje_get(const Evas_Object *obj)
1025 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1026 Widget_Data *wd = elm_widget_data_get(obj);
1027 if (!wd) return NULL;
1032 * Get the edje data of the given layout
1034 * @param obj The layout object
1035 * @param key The data key
1037 * @return The edje data string
1039 * This function fetches data specified at the object level.
1040 * This function return NULL if data is not found.
1042 * In EDC this comes from a data block within the group block that @a
1043 * obj was loaded from. E.g.
1050 * item: "key1" "value1";
1051 * item: "key2" "value2";
1060 elm_layout_data_get(const Evas_Object *obj, const char *key)
1062 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1063 Widget_Data *wd = elm_widget_data_get(obj);
1064 return edje_object_data_get(wd->lay, key);
1070 * Manually forms a sizing re-evaluation when contents changed state so that
1071 * minimum size might have changed and needs re-evaluation. Also note that
1072 * a standard signal of "size,eval" "elm" emitted by the edje object will
1073 * cause this to happen too
1075 * @param obj The layout object
1080 elm_layout_sizing_eval(Evas_Object *obj)
1082 ELM_CHECK_WIDTYPE(obj, widtype);
1083 Widget_Data *wd = elm_widget_data_get(obj);
1084 EINA_SAFETY_ON_NULL_RETURN(wd);
1085 _request_sizing_eval(wd);
1089 * Sets a specific cursor for an edje part.
1091 * @param obj The layout object.
1092 * @param part_name a part from loaded edje group.
1093 * @param cursor cursor name to use, see Elementary_Cursor.h
1095 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1096 * part not exists or it has "mouse_events: 0".
1101 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1103 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1104 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1105 Widget_Data *wd = elm_widget_data_get(obj);
1106 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1107 Evas_Object *part_obj;
1110 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1113 const char *group, *file;
1114 edje_object_file_get(wd->lay, &file, &group);
1115 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1116 part_name, group, file, cursor);
1119 if (evas_object_pass_events_get(part_obj))
1121 const char *group, *file;
1122 edje_object_file_get(wd->lay, &file, &group);
1123 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1124 "Cannot set cursor '%s'",
1125 part_name, group, file, cursor);
1129 pc = _parts_cursors_find(wd, part_name);
1130 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1133 pc = calloc(1, sizeof(*pc));
1134 pc->part = eina_stringshare_add(part_name);
1135 pc->cursor = eina_stringshare_add(cursor);
1139 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1144 * Get the cursor to be shown when mouse is over an edje part
1146 * @param obj The layout object.
1147 * @param part_name a part from loaded edje group.
1148 * @return the cursor name.
1153 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1156 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1157 Widget_Data *wd = elm_widget_data_get(obj);
1158 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1159 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1160 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1161 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1162 return elm_object_cursor_get(pc->obj);
1166 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1168 * @param obj The layout object.
1169 * @param part_name a part from loaded edje group, that had a cursor set
1170 * with elm_layout_part_cursor_set().
1175 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1177 ELM_CHECK_WIDTYPE(obj, widtype);
1178 EINA_SAFETY_ON_NULL_RETURN(part_name);
1179 Widget_Data *wd = elm_widget_data_get(obj);
1180 EINA_SAFETY_ON_NULL_RETURN(wd);
1184 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1186 if (!strcmp(part_name, pc->part))
1188 if (pc->obj) elm_object_cursor_unset(pc->obj);
1189 _part_cursor_free(pc);
1190 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1197 * Sets a specific cursor style for an edje part.
1199 * @param obj The layout object.
1200 * @param part_name a part from loaded edje group.
1201 * @param style the theme style to use (default, transparent, ...)
1203 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1204 * part not exists or it did not had a cursor set.
1209 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1211 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1212 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1213 Widget_Data *wd = elm_widget_data_get(obj);
1214 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1215 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1216 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1217 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1219 eina_stringshare_replace(&pc->style, style);
1220 elm_object_cursor_style_set(pc->obj, pc->style);
1225 * Gets a specific cursor style for an edje part.
1227 * @param obj The layout object.
1228 * @param part_name a part from loaded edje group.
1230 * @return the theme style in use, defaults to "default". If the
1231 * object does not have a cursor set, then NULL is returned.
1236 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1238 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1239 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1240 Widget_Data *wd = elm_widget_data_get(obj);
1241 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1242 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1243 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1244 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1245 return elm_object_cursor_style_get(pc->obj);
1249 * Sets if the cursor set should be searched on the theme or should use
1250 * the provided by the engine, only.
1252 * @note before you set if should look on theme you should define a
1253 * cursor with elm_layout_part_cursor_set(). By default it will only
1254 * look for cursors provided by the engine.
1256 * @param obj The layout object.
1257 * @param part_name a part from loaded edje group.
1258 * @param engine_only if cursors should be just provided by the engine
1259 * or should also search on widget's theme as well
1261 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1262 * part not exists or it did not had a cursor set.
1267 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1269 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1270 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1271 Widget_Data *wd = elm_widget_data_get(obj);
1272 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1273 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1274 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1275 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1277 pc->engine_only = !!engine_only;
1278 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1283 * Gets a specific cursor engine_only for an edje part.
1285 * @param obj The layout object.
1286 * @param part_name a part from loaded edje group.
1288 * @return whenever the cursor is just provided by engine or also from theme.
1293 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1295 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1296 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1297 Widget_Data *wd = elm_widget_data_get(obj);
1298 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1299 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1300 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1301 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1302 return elm_object_cursor_engine_only_get(pc->obj);