1 #include <Elementary.h>
5 * @defgroup Layout Layout
8 * This takes a standard Edje design file and wraps it very thinly
9 * in a widget and handles swallowing widgets into swallow regions
10 * in the Edje object, allowing Edje to be used as a design and
14 typedef struct _Widget_Data Widget_Data;
15 typedef struct _Subinfo Subinfo;
16 typedef struct _Part_Cursor Part_Cursor;
23 Eina_List *parts_cursors;
24 Eina_Bool needs_size_calc:1;
25 const char *clas, *group, *style;
43 const Evas_Object *reference;
47 unsigned short col, row, colspan, rowspan;
61 Eina_Bool engine_only:1;
64 static const char *widtype = NULL;
65 static void _del_hook(Evas_Object *obj);
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 _theme_hook(Evas_Object *obj)
94 Widget_Data *wd = elm_widget_data_get(obj);
97 _elm_theme_object_set(obj, wd->lay, wd->clas, wd->group, wd->style);
98 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
104 _changed_hook(Evas_Object *obj)
106 Widget_Data *wd = elm_widget_data_get(obj);
108 if (wd->needs_size_calc)
111 wd->needs_size_calc = 0;
116 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
118 Widget_Data *wd = elm_widget_data_get(obj);
119 edje_object_signal_emit(wd->lay, emission, source);
123 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
125 Widget_Data *wd = elm_widget_data_get(obj);
126 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
130 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
132 Widget_Data *wd = elm_widget_data_get(obj);
133 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
139 _elm_layout_list_data_get(const Eina_List *list)
141 Subinfo *si = eina_list_data_get(list);
146 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
148 Widget_Data *wd = elm_widget_data_get(obj);
149 const Eina_List *items;
150 void *(*list_data_get) (const Eina_List *list);
152 if ((!wd) || (!wd->subs))
155 /* Focus chain (This block is diferent of elm_win cycle)*/
156 if ((items = elm_widget_focus_custom_chain_get(obj)))
157 list_data_get = eina_list_data_get;
161 list_data_get = _elm_layout_list_data_get;
163 if (!items) return EINA_FALSE;
166 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
171 _sizing_eval(Widget_Data *wd)
173 Evas_Coord minw = -1, minh = -1;
174 edje_object_size_min_calc(wd->lay, &minw, &minh);
175 evas_object_size_hint_min_set(wd->obj, minw, minh);
176 evas_object_size_hint_max_set(wd->obj, -1, -1);
180 _request_sizing_eval(Widget_Data *wd)
182 if (wd->needs_size_calc) return;
183 wd->needs_size_calc = 1;
184 evas_object_smart_changed(wd->obj);
188 _part_cursor_free(Part_Cursor *pc)
190 eina_stringshare_del(pc->part);
191 eina_stringshare_del(pc->style);
192 eina_stringshare_del(pc->cursor);
197 _part_cursor_part_apply(const Part_Cursor *pc)
199 elm_object_cursor_set(pc->obj, pc->cursor);
200 elm_object_cursor_style_set(pc->obj, pc->style);
201 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
205 _parts_cursors_find(Widget_Data *wd, const char *part)
209 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
211 if (!strcmp(pc->part, part))
218 _parts_cursors_apply(Widget_Data *wd)
220 const char *file, *group;
224 edje_object_file_get(wd->lay, &file, &group);
226 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
228 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
234 WRN("no part '%s' in group '%s' of file '%s'. "
235 "Cannot set cursor '%s'",
236 pc->part, group, file, pc->cursor);
239 else if (evas_object_pass_events_get(obj))
242 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
243 "Cannot set cursor '%s'",
244 pc->part, group, file, pc->cursor);
249 _part_cursor_part_apply(pc);
254 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
256 _request_sizing_eval(data);
260 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
262 Widget_Data *wd = elm_widget_data_get(obj);
263 Evas_Object *sub = event_info;
267 EINA_LIST_FOREACH(wd->subs, l, si)
271 evas_object_event_callback_del_full(sub,
272 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
275 wd->subs = eina_list_remove_list(wd->subs, l);
276 eina_stringshare_del(si->part);
284 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
286 _request_sizing_eval(data);
290 _parts_text_fix(Widget_Data *wd)
295 EINA_LIST_FOREACH(wd->subs, l, si)
297 if (si->type == TEXT)
298 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
303 * Add a new layout to the parent
305 * @param parent The parent object
306 * @return The new object or NULL if it cannot be created
311 elm_layout_add(Evas_Object *parent)
317 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
319 wd = ELM_NEW(Widget_Data);
320 e = evas_object_evas_get(parent);
322 wd->obj = obj = elm_widget_add(e);
323 ELM_SET_WIDTYPE(widtype, "layout");
324 elm_widget_type_set(obj, "layout");
325 elm_widget_sub_object_add(parent, obj);
326 elm_widget_data_set(obj, wd);
327 elm_widget_del_hook_set(obj, _del_hook);
328 elm_widget_theme_hook_set(obj, _theme_hook);
329 elm_widget_changed_hook_set(obj, _changed_hook);
330 elm_widget_can_focus_set(obj, EINA_FALSE);
331 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
332 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
333 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
334 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
336 wd->lay = edje_object_add(e);
337 elm_widget_resize_object_set(obj, wd->lay);
338 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
339 _signal_size_eval, wd);
341 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
343 _request_sizing_eval(wd);
348 * Set the file that will be used as layout
350 * @param obj The layout object
351 * @param file The path to file (edj) that will be used as layout
352 * @param group The group that the layout belongs in edje file
354 * @return (1 = success, 0 = error)
359 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
361 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
362 Widget_Data *wd = elm_widget_data_get(obj);
363 if (!wd) return EINA_FALSE;
364 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
368 _request_sizing_eval(wd);
369 _parts_cursors_apply(wd);
371 else DBG("failed to set edje file '%s', group '%s': %s",
373 edje_load_error_str(edje_object_load_error_get(wd->lay)));
378 * Set the edje group from the elementary theme that will be used as layout
380 * @param obj The layout object
381 * @param clas the clas of the group
382 * @param group the group
383 * @param style the style to used
385 * @return (1 = success, 0 = error)
390 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
392 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
393 Widget_Data *wd = elm_widget_data_get(obj);
394 if (!wd) return EINA_FALSE;
395 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
402 _request_sizing_eval(wd);
403 _parts_cursors_apply(wd);
409 * Set the layout content
411 * Once the content object is set, a previously set one will be deleted.
412 * If you want to keep that old content object, use the
413 * elm_layout_content_unset() function.
415 * @param obj The layout object
416 * @param swallow The swallow group name in the edje file
417 * @param content The content will be filled in this layout object
422 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
424 ELM_CHECK_WIDTYPE(obj, widtype);
425 Widget_Data *wd = elm_widget_data_get(obj);
429 EINA_LIST_FOREACH(wd->subs, l, si)
431 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
433 if (content == si->obj) return;
434 evas_object_del(si->obj);
440 elm_widget_sub_object_add(obj, content);
441 evas_object_event_callback_add(content,
442 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
443 _changed_size_hints, wd);
444 if (!edje_object_part_swallow(wd->lay, swallow, content))
445 WRN("could not swallow %p into part '%s'", content, swallow);
446 si = ELM_NEW(Subinfo);
448 si->part = eina_stringshare_add(swallow);
450 wd->subs = eina_list_append(wd->subs, si);
452 _request_sizing_eval(wd);
456 * Get the swallowed object in the given part
458 * @param obj The layout object
459 * @param swallow The SWALLOW part to get its content
461 * @return The swallowed object or NULL if none or an error occurred
465 EAPI const Evas_Object *
466 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
468 Widget_Data *wd = elm_widget_data_get(obj);
471 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
473 EINA_LIST_FOREACH(wd->subs, l, si)
475 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
482 * Unset the layout content
484 * Unparent and return the content object which was set for this widget
486 * @param obj The layout object
487 * @param swallow The swallow group name in the edje file
488 * @return The content that was being used
493 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
495 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
496 Widget_Data *wd = elm_widget_data_get(obj);
499 if (!wd) return NULL;
500 EINA_LIST_FOREACH(wd->subs, l, si)
502 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
504 Evas_Object *content;
505 if (!si->obj) return NULL;
506 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
507 elm_widget_sub_object_del(obj, content);
508 edje_object_part_unswallow(wd->lay, content);
516 * Set the text of the given part
518 * @param obj The layout object
519 * @param part The TEXT part where to set the text
520 * @param text The text to set
525 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
527 Widget_Data *wd = elm_widget_data_get(obj);
530 ELM_CHECK_WIDTYPE(obj, widtype);
532 EINA_LIST_FOREACH(wd->subs, l, si)
534 if ((si->type == TEXT) && (!strcmp(part, si->part)))
538 eina_stringshare_del(si->part);
539 eina_stringshare_del(si->p.text.text);
541 edje_object_part_text_set(wd->lay, part, NULL);
542 wd->subs = eina_list_remove_list(wd->subs, l);
553 si = ELM_NEW(Subinfo);
556 si->part = eina_stringshare_add(part);
557 wd->subs = eina_list_append(wd->subs, si);
560 eina_stringshare_replace(&si->p.text.text, text);
561 edje_object_part_text_set(wd->lay, part, text);
562 _request_sizing_eval(wd);
566 * Get the text set in the given part
568 * @param obj The layout object
569 * @param part The TEXT part to retrieve the text off
571 * @return The text set in @p part
576 elm_layout_text_get(const Evas_Object *obj, const char *part)
578 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
579 Widget_Data *wd = elm_widget_data_get(obj);
580 return edje_object_part_text_get(wd->lay, part);
584 * Append child to layout box part.
586 * Once the object is appended, its lifetime will be bound to the
587 * layout, whenever the layout dies the child will be deleted
588 * automatically. One should use elm_layout_box_remove() to make this
589 * layout forget about the object.
591 * @param obj the layout object
592 * @param part the box part to append.
593 * @param child the child object to append to box.
598 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
600 ELM_CHECK_WIDTYPE(obj, widtype);
601 Widget_Data *wd = elm_widget_data_get(obj);
605 if (!edje_object_part_box_append(wd->lay, part, child))
606 WRN("child %p could not be appended to box part '%s'", child, part);
607 elm_widget_sub_object_add(obj, child);
608 evas_object_event_callback_add
609 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
611 si = ELM_NEW(Subinfo);
612 si->type = BOX_APPEND;
613 si->part = eina_stringshare_add(part);
615 wd->subs = eina_list_append(wd->subs, si);
616 _request_sizing_eval(wd);
620 * Prepend child to layout box part.
622 * Once the object is prepended, its lifetime will be bound to the
623 * layout, whenever the layout dies the child will be deleted
624 * automatically. One should use elm_layout_box_remove() to make this
625 * layout forget about the object.
627 * @param obj the layout object
628 * @param part the box part to prepend.
629 * @param child the child object to prepend to box.
634 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
636 ELM_CHECK_WIDTYPE(obj, widtype);
637 Widget_Data *wd = elm_widget_data_get(obj);
641 if (!edje_object_part_box_prepend(wd->lay, part, child))
642 WRN("child %p could not be prepended to box part '%s'", child, part);
643 elm_widget_sub_object_add(obj, child);
644 evas_object_event_callback_add
645 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
647 si = ELM_NEW(Subinfo);
648 si->type = BOX_PREPEND;
649 si->part = eina_stringshare_add(part);
651 wd->subs = eina_list_prepend(wd->subs, si);
652 _request_sizing_eval(wd);
656 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
659 si->p.box.reference = NULL;
663 * Insert child to layout box part before a reference object.
665 * Once the object is inserted, its lifetime will be bound to the
666 * layout, whenever the layout dies the child will be deleted
667 * automatically. One should use elm_layout_box_remove() to make this
668 * layout forget about the object.
670 * @param obj the layout object
671 * @param part the box part to insert.
672 * @param child the child object to insert into box.
673 * @param reference another reference object to insert before in box.
678 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
680 ELM_CHECK_WIDTYPE(obj, widtype);
681 Widget_Data *wd = elm_widget_data_get(obj);
685 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
686 WRN("child %p could not be inserted before %p inf box part '%s'",
687 child, reference, part);
689 si = ELM_NEW(Subinfo);
690 si->type = BOX_INSERT_BEFORE;
691 si->part = eina_stringshare_add(part);
693 si->p.box.reference = reference;
695 elm_widget_sub_object_add(obj, child);
696 evas_object_event_callback_add
697 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
698 evas_object_event_callback_add
699 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
701 wd->subs = eina_list_append(wd->subs, si);
702 _request_sizing_eval(wd);
706 * Insert child to layout box part at a given position.
708 * Once the object is inserted, its lifetime will be bound to the
709 * layout, whenever the layout dies the child will be deleted
710 * automatically. One should use elm_layout_box_remove() to make this
711 * layout forget about the object.
713 * @param obj the layout object
714 * @param part the box part to insert.
715 * @param child the child object to insert into box.
716 * @param pos the numeric position >=0 to insert the child.
721 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
723 ELM_CHECK_WIDTYPE(obj, widtype);
724 Widget_Data *wd = elm_widget_data_get(obj);
728 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
729 WRN("child %p could not be inserted at %u to box part '%s'",
732 elm_widget_sub_object_add(obj, child);
733 evas_object_event_callback_add
734 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
736 si = ELM_NEW(Subinfo);
737 si->type = BOX_INSERT_AT;
738 si->part = eina_stringshare_add(part);
741 wd->subs = eina_list_append(wd->subs, si);
742 _request_sizing_eval(wd);
746 _sub_box_remove(Widget_Data *wd, Subinfo *si)
750 if (si->type == BOX_INSERT_BEFORE)
751 evas_object_event_callback_del_full
752 ((Evas_Object *)si->p.box.reference,
753 EVAS_CALLBACK_DEL, _box_reference_del, si);
755 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
756 edje_object_part_box_remove(wd->lay, si->part, child);
757 elm_widget_sub_object_del(wd->obj, child);
762 _sub_table_remove(Widget_Data *wd, Subinfo *si)
766 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
767 edje_object_part_table_unpack(wd->lay, si->part, child);
768 elm_widget_sub_object_del(wd->obj, child);
773 _sub_box_is(const Subinfo *si)
779 case BOX_INSERT_BEFORE:
788 * Remove a child of the given part box.
790 * The object will be removed from the box part and its lifetime will
791 * not be handled by the layout anymore. This is equivalent to
792 * elm_layout_content_unset() for box.
794 * @param obj The layout object
795 * @param part The box part name to remove child.
796 * @param child The object to remove from box.
797 * @return The object that was being used, or NULL if not found.
802 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
804 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
805 Widget_Data *wd = elm_widget_data_get(obj);
809 if (!wd) return NULL;
811 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
812 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
813 EINA_LIST_FOREACH(wd->subs, l, si)
815 if (!_sub_box_is(si)) continue;
816 if ((si->obj == child) && (!strcmp(si->part, part)))
817 return _sub_box_remove(wd, si);
823 * Remove all child of the given part box.
825 * The objects will be removed from the box part and their lifetime will
826 * not be handled by the layout anymore. This is equivalent to
827 * elm_layout_content_unset() for all box children.
829 * @param obj The layout object
830 * @param part The box part name to remove child.
831 * @param clear If EINA_TRUE, then all objects will be deleted as
832 * well, otherwise they will just be removed and will be
833 * dangling on the canvas.
838 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
840 ELM_CHECK_WIDTYPE(obj, widtype);
841 Widget_Data *wd = elm_widget_data_get(obj);
846 EINA_SAFETY_ON_NULL_RETURN(part);
848 lst = eina_list_clone(wd->subs);
849 EINA_LIST_FREE(lst, si)
851 if (!_sub_box_is(si)) continue;
852 if (!strcmp(si->part, part))
854 Evas_Object *child = _sub_box_remove(wd, si);
855 if ((clear) && (child)) evas_object_del(child);
858 /* eventually something may not be added with layout, del them as well */
859 edje_object_part_box_remove_all(wd->lay, part, clear);
863 * Insert child to layout table part.
865 * Once the object is inserted, its lifetime will be bound to the
866 * layout, whenever the layout dies the child will be deleted
867 * automatically. One should use elm_layout_box_remove() to make this
868 * layout forget about the object.
870 * @param obj the layout object
871 * @param part the box part to pack child.
872 * @param child the child object to pack into table.
873 * @param reference another reference object to insert before in box.
878 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)
880 ELM_CHECK_WIDTYPE(obj, widtype);
881 Widget_Data *wd = elm_widget_data_get(obj);
885 if (!edje_object_part_table_pack
886 (wd->lay, part, child, col, row, colspan, rowspan))
887 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
888 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
890 elm_widget_sub_object_add(obj, child);
891 evas_object_event_callback_add
892 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
894 si = ELM_NEW(Subinfo);
895 si->type = TABLE_PACK;
896 si->part = eina_stringshare_add(part);
898 si->p.table.col = col;
899 si->p.table.row = row;
900 si->p.table.colspan = colspan;
901 si->p.table.rowspan = rowspan;
902 wd->subs = eina_list_append(wd->subs, si);
903 _request_sizing_eval(wd);
907 * Unpack (remove) a child of the given part table.
909 * The object will be unpacked from the table part and its lifetime
910 * will not be handled by the layout anymore. This is equivalent to
911 * elm_layout_content_unset() for table.
913 * @param obj The layout object
914 * @param part The table part name to remove child.
915 * @param child The object to remove from table.
916 * @return The object that was being used, or NULL if not found.
921 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
923 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
924 Widget_Data *wd = elm_widget_data_get(obj);
928 if (!wd) return NULL;
930 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
931 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
932 EINA_LIST_FOREACH(wd->subs, l, si)
934 if (si->type != TABLE_PACK) continue;
935 if ((si->obj == child) && (!strcmp(si->part, part)))
936 return _sub_table_remove(wd, si);
942 * Remove all child of the given part table.
944 * The objects will be removed from the table part and their lifetime will
945 * not be handled by the layout anymore. This is equivalent to
946 * elm_layout_content_unset() for all table children.
948 * @param obj The layout object
949 * @param part The table part name to remove child.
950 * @param clear If EINA_TRUE, then all objects will be deleted as
951 * well, otherwise they will just be removed and will be
952 * dangling on the canvas.
957 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
959 ELM_CHECK_WIDTYPE(obj, widtype);
960 Widget_Data *wd = elm_widget_data_get(obj);
965 EINA_SAFETY_ON_NULL_RETURN(part);
967 lst = eina_list_clone(wd->subs);
968 EINA_LIST_FREE(lst, si)
970 if (si->type != TABLE_PACK) continue;
971 if (!strcmp(si->part, part))
973 Evas_Object *child = _sub_table_remove(wd, si);
974 if ((clear) && (child)) evas_object_del(child);
977 /* eventually something may not be added with layout, del them as well */
978 edje_object_part_table_clear(wd->lay, part, clear);
982 * Get the edje layout
984 * @param obj The layout object
986 * This returns the edje object. It is not expected to be used to then swallow
987 * objects via edje_object_part_swallow() for example. Use
988 * elm_layout_content_set() instead so child object handling and sizing is
989 * done properly. This is more intended for setting text, emitting signals,
990 * hooking to signal callbacks etc.
992 * @return A Evas_Object with the edje layout settings loaded
993 * with function elm_layout_file_set
998 elm_layout_edje_get(const Evas_Object *obj)
1000 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1001 Widget_Data *wd = elm_widget_data_get(obj);
1002 if (!wd) return NULL;
1009 * Manually forms a sizing re-evaluation when contents changed state so that
1010 * minimum size might have changed and needs re-evaluation. Also note that
1011 * a standard signal of "size,eval" "elm" emitted by the edje object will
1012 * cause this to happen too
1014 * @param obj The layout object
1019 elm_layout_sizing_eval(Evas_Object *obj)
1021 ELM_CHECK_WIDTYPE(obj, widtype);
1022 Widget_Data *wd = elm_widget_data_get(obj);
1023 EINA_SAFETY_ON_NULL_RETURN(wd);
1024 _request_sizing_eval(wd);
1028 * Sets a specific cursor for an edje part.
1030 * @param obj The layout object.
1031 * @param part_name a part from loaded edje group.
1032 * @param cursor cursor name to use, see Elementary_Cursor.h
1034 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1035 * part not exists or it has "mouse_events: 0".
1040 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1042 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1043 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1044 Widget_Data *wd = elm_widget_data_get(obj);
1045 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1046 Evas_Object *part_obj;
1049 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1052 const char *group, *file;
1053 edje_object_file_get(wd->lay, &file, &group);
1054 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1055 part_name, group, file, cursor);
1058 if (evas_object_pass_events_get(part_obj))
1060 const char *group, *file;
1061 edje_object_file_get(wd->lay, &file, &group);
1062 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1063 "Cannot set cursor '%s'",
1064 part_name, group, file, cursor);
1068 pc = _parts_cursors_find(wd, part_name);
1069 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1072 pc = calloc(1, sizeof(*pc));
1073 pc->part = eina_stringshare_add(part_name);
1074 pc->cursor = eina_stringshare_add(cursor);
1078 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1083 * Get the cursor to be shown when mouse is over an edje part
1085 * @param obj The layout object.
1086 * @param part_name a part from loaded edje group.
1087 * @return the cursor name.
1092 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1094 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1095 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1096 Widget_Data *wd = elm_widget_data_get(obj);
1097 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1098 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1099 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1100 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1101 return elm_object_cursor_get(pc->obj);
1105 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1107 * @param obj The layout object.
1108 * @param part_name a part from loaded edje group, that had a cursor set
1109 * with elm_layout_part_cursor_set().
1114 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1116 ELM_CHECK_WIDTYPE(obj, widtype);
1117 EINA_SAFETY_ON_NULL_RETURN(part_name);
1118 Widget_Data *wd = elm_widget_data_get(obj);
1119 EINA_SAFETY_ON_NULL_RETURN(wd);
1123 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1125 if (!strcmp(part_name, pc->part))
1127 if (pc->obj) elm_object_cursor_unset(pc->obj);
1128 _part_cursor_free(pc);
1129 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1136 * Sets a specific cursor style for an edje part.
1138 * @param obj The layout object.
1139 * @param part_name a part from loaded edje group.
1140 * @param style the theme style to use (default, transparent, ...)
1142 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1143 * part not exists or it did not had a cursor set.
1148 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1150 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1151 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1152 Widget_Data *wd = elm_widget_data_get(obj);
1153 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1154 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1155 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1156 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1158 eina_stringshare_replace(&pc->style, style);
1159 elm_object_cursor_style_set(pc->obj, pc->style);
1164 * Gets a specific cursor style for an edje part.
1166 * @param obj The layout object.
1167 * @param part_name a part from loaded edje group.
1169 * @return the theme style in use, defaults to "default". If the
1170 * object does not have a cursor set, then NULL is returned.
1175 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1177 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1178 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1179 Widget_Data *wd = elm_widget_data_get(obj);
1180 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1181 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1182 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1183 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1184 return elm_object_cursor_style_get(pc->obj);
1188 * Sets if the cursor set should be searched on the theme or should use
1189 * the provided by the engine, only.
1191 * @note before you set if should look on theme you should define a
1192 * cursor with elm_layout_part_cursor_set(). By default it will only
1193 * look for cursors provided by the engine.
1195 * @param obj The layout object.
1196 * @param part_name a part from loaded edje group.
1197 * @param engine_only if cursors should be just provided by the engine
1198 * or should also search on widget's theme as well
1200 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1201 * part not exists or it did not had a cursor set.
1206 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1208 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1209 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1210 Widget_Data *wd = elm_widget_data_get(obj);
1211 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1212 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1213 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1214 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1216 pc->engine_only = !!engine_only;
1217 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1222 * Gets a specific cursor engine_only for an edje part.
1224 * @param obj The layout object.
1225 * @param part_name a part from loaded edje group.
1227 * @return whenever the cursor is just provided by engine or also from theme.
1232 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1234 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1235 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1236 Widget_Data *wd = elm_widget_data_get(obj);
1237 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1238 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1239 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1240 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1241 return elm_object_cursor_engine_only_get(pc->obj);