elm genlist: Fixed a bug with decorate all mode + tree effect. Delete tree effect...
[framework/uifw/elementary.git] / src / lib / elm_layout.h
1 /**
2  * @defgroup Layout Layout
3  * @ingroup Elementary
4  *
5  * @image html img/widget/layout/preview-00.png
6  * @image latex img/widget/layout/preview-00.eps width=\textwidth
7  *
8  * @image html img/layout-predefined.png
9  * @image latex img/layout-predefined.eps width=\textwidth
10  *
11  * This is a container widget that takes a standard Edje design file and
12  * wraps it very thinly in a widget.
13  *
14  * An Edje design (theme) file has a very wide range of possibilities to
15  * describe the behavior of elements added to the Layout. Check out the Edje
16  * documentation and the EDC reference to get more information about what can
17  * be done with Edje.
18  *
19  * Just like @ref List, @ref Box, and other container widgets, any
20  * object added to the Layout will become its child, meaning that it will be
21  * deleted if the Layout is deleted, move if the Layout is moved, and so on.
22  *
23  * The Layout widget can contain as many Contents, Boxes or Tables as
24  * described in its theme file. For instance, objects can be added to
25  * different Tables by specifying the respective Table part names. The same
26  * is valid for Content and Box.
27  *
28  * The objects added as child of the Layout will behave as described in the
29  * part description where they were added. There are 3 possible types of
30  * parts where a child can be added:
31  *
32  * @section secContent Content (SWALLOW part)
33  *
34  * Only one object can be added to the @c SWALLOW part (but you still can
35  * have many @c SWALLOW parts and one object on each of them). Use the @c
36  * elm_object_content_set/get/unset functions to set, retrieve and unset
37  * objects as content of the @c SWALLOW. After being set to this part, the
38  * object size, position, visibility, clipping and other description
39  * properties will be totally controlled by the description of the given part
40  * (inside the Edje theme file).
41  *
42  * One can use @c evas_object_size_hint_* functions on the child to have some
43  * kind of control over its behavior, but the resulting behavior will still
44  * depend heavily on the @c SWALLOW part description.
45  *
46  * The Edje theme also can change the part description, based on signals or
47  * scripts running inside the theme. This change can also be animated. All of
48  * this will affect the child object set as content accordingly. The object
49  * size will be changed if the part size is changed, it will animate move if
50  * the part is moving, and so on.
51  *
52  * The following picture demonstrates a Layout widget with a child object
53  * added to its @c SWALLOW:
54  *
55  * @image html layout_swallow.png
56  * @image latex layout_swallow.eps width=\textwidth
57  *
58  * @section secBox Box (BOX part)
59  *
60  * An Edje @c BOX part is very similar to the Elementary @ref Box widget. It
61  * allows one to add objects to the box and have them distributed along its
62  * area, accordingly to the specified @a layout property (now by @a layout we
63  * mean the chosen layouting design of the Box, not the Layout widget
64  * itself).
65  *
66  * A similar effect for having a box with its position, size and other things
67  * controlled by the Layout theme would be to create an Elementary @ref Box
68  * widget and add it as a Content in the @c SWALLOW part.
69  *
70  * The main difference of using the Layout Box is that its behavior, the box
71  * properties like layouting format, padding, align, etc. will be all
72  * controlled by the theme. This means, for example, that a signal could be
73  * sent to the Layout theme (with elm_object_signal_emit()) and the theme
74  * handled the signal by changing the box padding, or align, or both. Using
75  * the Elementary @ref Box widget is not necessarily harder or easier, it
76  * just depends on the circumstances and requirements.
77  *
78  * The Layout Box can be used through the @c elm_layout_box_* set of
79  * functions.
80  *
81  * The following picture demonstrates a Layout widget with many child objects
82  * added to its @c BOX part:
83  *
84  * @image html layout_box.png
85  * @image latex layout_box.eps width=\textwidth
86  *
87  * @section secTable Table (TABLE part)
88  *
89  * Just like the @ref secBox, the Layout Table is very similar to the
90  * Elementary @ref Table widget. It allows one to add objects to the Table
91  * specifying the row and column where the object should be added, and any
92  * column or row span if necessary.
93  *
94  * Again, we could have this design by adding a @ref Table widget to the @c
95  * SWALLOW part using elm_object_part_content_set(). The same difference happens
96  * here when choosing to use the Layout Table (a @c TABLE part) instead of
97  * the @ref Table plus @c SWALLOW part. It's just a matter of convenience.
98  *
99  * The Layout Table can be used through the @c elm_layout_table_* set of
100  * functions.
101  *
102  * The following picture demonstrates a Layout widget with many child objects
103  * added to its @c TABLE part:
104  *
105  * @image html layout_table.png
106  * @image latex layout_table.eps width=\textwidth
107  *
108  * @section secPredef Predefined Layouts
109  *
110  * Another interesting thing about the Layout widget is that it offers some
111  * predefined themes that come with the default Elementary theme. These
112  * themes can be set by the call elm_layout_theme_set(), and provide some
113  * basic functionality depending on the theme used.
114  *
115  * Most of them already send some signals, some already provide a toolbar or
116  * back and next buttons.
117  *
118  * These are available predefined theme layouts. All of them have class = @c
119  * layout, group = @c application, and style = one of the following options:
120  *
121  * @li @c toolbar-content - application with toolbar and main content area
122  * @li @c toolbar-content-back - application with toolbar and main content
123  * area with a back button and title area
124  * @li @c toolbar-content-back-next - application with toolbar and main
125  * content area with a back and next buttons and title area
126  * @li @c content-back - application with a main content area with a back
127  * button and title area
128  * @li @c content-back-next - application with a main content area with a
129  * back and next buttons and title area
130  * @li @c toolbar-vbox - application with toolbar and main content area as a
131  * vertical box
132  * @li @c toolbar-table - application with toolbar and main content area as a
133  * table
134  *
135  * Supported elm_object common APIs.
136  * @li @ref elm_object_signal_emit
137  * @li @ref elm_object_signal_callback_add
138  * @li @ref elm_object_signal_callback_del
139  * @li @ref elm_object_part_text_set
140  * @li @ref elm_object_part_text_get
141  * @li @ref elm_object_part_content_set
142  * @li @ref elm_object_part_content_get
143  * @li @ref elm_object_part_content_unset
144  *
145  * @section secExamples Examples
146  *
147  * Some examples of the Layout widget can be found here:
148  * @li @ref layout_example_01
149  * @li @ref layout_example_02
150  * @li @ref layout_example_03
151  * @li @ref layout_example_edc
152  *
153  */
154
155 /**
156  * Add a new layout to the parent
157  *
158  * @param parent The parent object
159  * @return The new object or NULL if it cannot be created
160  *
161  * @see elm_layout_file_set()
162  * @see elm_layout_theme_set()
163  *
164  * @ingroup Layout
165  */
166 EAPI Evas_Object                 *elm_layout_add(Evas_Object *parent);
167
168 /**
169  * Set the file that will be used as layout
170  *
171  * @param obj The layout object
172  * @param file The path to file (edj) that will be used as layout
173  * @param group The group that the layout belongs in edje file
174  *
175  * @return (1 = success, 0 = error)
176  *
177  * @ingroup Layout
178  */
179 EAPI Eina_Bool                    elm_layout_file_set(Evas_Object *obj, const char *file, const char *group);
180
181 /**
182  * Set the edje group from the elementary theme that will be used as layout
183  *
184  * @param obj The layout object
185  * @param clas the class of the group
186  * @param group the group
187  * @param style the style to used
188  *
189  * @return (1 = success, 0 = error)
190  *
191  * @ingroup Layout
192  */
193 EAPI Eina_Bool                    elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style);
194
195 /**
196  * Append child to layout box part.
197  *
198  * @param obj the layout object
199  * @param part the box part to which the object will be appended.
200  * @param child the child object to append to box.
201  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
202  *
203  * Once the object is appended, it will become child of the layout. Its
204  * lifetime will be bound to the layout, whenever the layout dies the child
205  * will be deleted automatically. One should use elm_layout_box_remove() to
206  * make this layout forget about the object.
207  *
208  * @see elm_layout_box_prepend()
209  * @see elm_layout_box_insert_before()
210  * @see elm_layout_box_insert_at()
211  * @see elm_layout_box_remove()
212  *
213  * @ingroup Layout
214  */
215 EAPI Eina_Bool                    elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child);
216
217 /**
218  * Prepend child to layout box part.
219  *
220  * @param obj the layout object
221  * @param part the box part to prepend.
222  * @param child the child object to prepend to box.
223  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
224  *
225  * Once the object is prepended, it will become child of the layout. Its
226  * lifetime will be bound to the layout, whenever the layout dies the child
227  * will be deleted automatically. One should use elm_layout_box_remove() to
228  * make this layout forget about the object.
229  *
230  * @see elm_layout_box_append()
231  * @see elm_layout_box_insert_before()
232  * @see elm_layout_box_insert_at()
233  * @see elm_layout_box_remove()
234  *
235  * @ingroup Layout
236  */
237 EAPI Eina_Bool                    elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child);
238
239 /**
240  * Insert child to layout box part before a reference object.
241  *
242  * @param obj the layout object
243  * @param part the box part to insert.
244  * @param child the child object to insert into box.
245  * @param reference another reference object to insert before in box.
246  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
247  *
248  * Once the object is inserted, it will become child of the layout. Its
249  * lifetime will be bound to the layout, whenever the layout dies the child
250  * will be deleted automatically. One should use elm_layout_box_remove() to
251  * make this layout forget about the object.
252  *
253  * @see elm_layout_box_append()
254  * @see elm_layout_box_prepend()
255  * @see elm_layout_box_insert_before()
256  * @see elm_layout_box_remove()
257  *
258  * @ingroup Layout
259  */
260 EAPI Eina_Bool                    elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference);
261
262 /**
263  * Insert child to layout box part at a given position.
264  *
265  * @param obj the layout object
266  * @param part the box part to insert.
267  * @param child the child object to insert into box.
268  * @param pos the numeric position >=0 to insert the child.
269  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
270  *
271  * Once the object is inserted, it will become child of the layout. Its
272  * lifetime will be bound to the layout, whenever the layout dies the child
273  * will be deleted automatically. One should use elm_layout_box_remove() to
274  * make this layout forget about the object.
275  *
276  * @see elm_layout_box_append()
277  * @see elm_layout_box_prepend()
278  * @see elm_layout_box_insert_before()
279  * @see elm_layout_box_remove()
280  *
281  * @ingroup Layout
282  */
283 EAPI Eina_Bool                    elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos);
284
285 /**
286  * Remove a child of the given part box.
287  *
288  * @param obj The layout object
289  * @param part The box part name to remove child.
290  * @param child The object to remove from box.
291  * @return The object that was being used, or NULL if not found.
292  *
293  * The object will be removed from the box part and its lifetime will
294  * not be handled by the layout anymore. This is equivalent to
295  * elm_object_part_content_unset() for box.
296  *
297  * @see elm_layout_box_append()
298  * @see elm_layout_box_remove_all()
299  *
300  * @ingroup Layout
301  */
302 EAPI Evas_Object                 *elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child);
303
304 /**
305  * Remove all children of the given part box.
306  *
307  * @param obj The layout object
308  * @param part The box part name to remove child.
309  * @param clear If EINA_TRUE, then all objects will be deleted as
310  *        well, otherwise they will just be removed and will be
311  *        dangling on the canvas.
312  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
313  *
314  * The objects will be removed from the box part and their lifetime will
315  * not be handled by the layout anymore. This is equivalent to
316  * elm_layout_box_remove() for all box children.
317  *
318  * @see elm_layout_box_append()
319  * @see elm_layout_box_remove()
320  *
321  * @ingroup Layout
322  */
323 EAPI Eina_Bool                    elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear);
324
325 /**
326  * Insert child to layout table part.
327  *
328  * @param obj the layout object
329  * @param part the box part to pack child.
330  * @param child_obj the child object to pack into table.
331  * @param col the column to which the child should be added. (>= 0)
332  * @param row the row to which the child should be added. (>= 0)
333  * @param colspan how many columns should be used to store this object. (>=
334  *        1)
335  * @param rowspan how many rows should be used to store this object. (>= 1)
336  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
337  *
338  * Once the object is inserted, it will become child of the table. Its
339  * lifetime will be bound to the layout, and whenever the layout dies the
340  * child will be deleted automatically. One should use
341  * elm_layout_table_remove() to make this layout forget about the object.
342  *
343  * If @p colspan or @p rowspan are bigger than 1, that object will occupy
344  * more space than a single cell. For instance, the following code:
345  * @code
346  * elm_layout_table_pack(layout, "table_part", child, 0, 1, 3, 1);
347  * @endcode
348  *
349  * Would result in an object being added like the following picture:
350  *
351  * @image html layout_colspan.png
352  * @image latex layout_colspan.eps width=\textwidth
353  *
354  * @see elm_layout_table_unpack()
355  * @see elm_layout_table_clear()
356  *
357  * @ingroup Layout
358  */
359 EAPI Eina_Bool                    elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan);
360
361 /**
362  * Unpack (remove) a child of the given part table.
363  *
364  * @param obj The layout object
365  * @param part The table part name to remove child.
366  * @param child_obj The object to remove from table.
367  * @return The object that was being used, or NULL if not found.
368  *
369  * The object will be unpacked from the table part and its lifetime
370  * will not be handled by the layout anymore. This is equivalent to
371  * elm_object_part_content_unset() for table.
372  *
373  * @see elm_layout_table_pack()
374  * @see elm_layout_table_clear()
375  *
376  * @ingroup Layout
377  */
378 EAPI Evas_Object                 *elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj);
379
380 /**
381  * Remove all the child objects of the given part table.
382  *
383  * @param obj The layout object
384  * @param part The table part name to remove child.
385  * @param clear If EINA_TRUE, then all objects will be deleted as
386  *        well, otherwise they will just be removed and will be
387  *        dangling on the canvas.
388  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
389  *
390  * The objects will be removed from the table part and their lifetime will
391  * not be handled by the layout anymore. This is equivalent to
392  * elm_layout_table_unpack() for all table children.
393  *
394  * @see elm_layout_table_pack()
395  * @see elm_layout_table_unpack()
396  *
397  * @ingroup Layout
398  */
399 EAPI Eina_Bool                    elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear);
400
401 /**
402  * Get the edje layout
403  *
404  * @param obj The layout object
405  *
406  * @return A Evas_Object with the edje layout settings loaded
407  * with function elm_layout_file_set
408  *
409  * This returns the edje object. It is not expected to be used to then
410  * swallow objects via edje_object_part_swallow() for example. Use
411  * elm_object_part_content_set() instead so child object handling and sizing is
412  * done properly.
413  *
414  * @note This function should only be used if you really need to call some
415  * low level Edje function on this edje object. All the common stuff (setting
416  * text, emitting signals, hooking callbacks to signals, etc.) can be done
417  * with proper elementary functions.
418  *
419  * @see elm_object_signal_callback_add()
420  * @see elm_object_signal_emit()
421  * @see elm_object_part_text_set()
422  * @see elm_object_part_content_set()
423  * @see elm_layout_box_append()
424  * @see elm_layout_table_pack()
425  * @see elm_layout_data_get()
426  *
427  * @ingroup Layout
428  */
429 EAPI Evas_Object                 *elm_layout_edje_get(const Evas_Object *obj);
430
431 /**
432  * Get the edje data from the given layout
433  *
434  * @param obj The layout object
435  * @param key The data key
436  *
437  * @return The edje data string
438  *
439  * This function fetches data specified inside the edje theme of this layout.
440  * This function return NULL if data is not found.
441  *
442  * In EDC this comes from a data block within the group block that @p
443  * obj was loaded from. E.g.
444  *
445  * @code
446  * collections {
447  *   group {
448  *     name: "a_group";
449  *     data {
450  *       item: "key1" "value1";
451  *       item: "key2" "value2";
452  *     }
453  *   }
454  * }
455  * @endcode
456  *
457  * @ingroup Layout
458  */
459 EAPI const char                  *elm_layout_data_get(const Evas_Object *obj, const char *key);
460
461 /**
462  * Eval sizing
463  *
464  * @param obj The layout object
465  *
466  * Manually forces a sizing re-evaluation. This is useful when the minimum
467  * size required by the edje theme of this layout has changed. The change on
468  * the minimum size required by the edje theme is not immediately reported to
469  * the elementary layout, so one needs to call this function in order to tell
470  * the widget (layout) that it needs to reevaluate its own size.
471  *
472  * The minimum size of the theme is calculated based on minimum size of
473  * parts, the size of elements inside containers like box and table, etc. All
474  * of this can change due to state changes, and that's when this function
475  * should be called.
476  *
477  * Also note that a standard signal of "size,eval" "elm" emitted from the
478  * edje object will cause this to happen too.
479  *
480  * @ingroup Layout
481  */
482 EAPI void                         elm_layout_sizing_eval(Evas_Object *obj);
483
484 /**
485  * Sets a specific cursor for an edje part.
486  *
487  * @param obj The layout object.
488  * @param part_name a part from loaded edje group.
489  * @param cursor cursor name to use, see Elementary_Cursor.h
490  *
491  * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
492  *         part not exists or it has "mouse_events: 0".
493  *
494  * @ingroup Layout
495  */
496 EAPI Eina_Bool                    elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor);
497
498 /**
499  * Get the cursor to be shown when mouse is over an edje part
500  *
501  * @param obj The layout object.
502  * @param part_name a part from loaded edje group.
503  * @return the cursor name.
504  *
505  * @ingroup Layout
506  */
507 EAPI const char                  *elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name);
508
509 /**
510  * Unsets a cursor previously set with elm_layout_part_cursor_set().
511  *
512  * @param obj The layout object.
513  * @param part_name a part from loaded edje group, that had a cursor set
514  *        with elm_layout_part_cursor_set().
515  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
516  *
517  * @ingroup Layout
518  */
519 EAPI Eina_Bool                    elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name);
520
521 /**
522  * Sets a specific cursor style for an edje part.
523  *
524  * @param obj The layout object.
525  * @param part_name a part from loaded edje group.
526  * @param style the theme style to use (default, transparent, ...)
527  *
528  * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
529  *         part not exists or it did not had a cursor set.
530  *
531  * @ingroup Layout
532  */
533 EAPI Eina_Bool                    elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style);
534
535 /**
536  * Gets a specific cursor style for an edje part.
537  *
538  * @param obj The layout object.
539  * @param part_name a part from loaded edje group.
540  *
541  * @return the theme style in use, defaults to "default". If the
542  *         object does not have a cursor set, then NULL is returned.
543  *
544  * @ingroup Layout
545  */
546 EAPI const char                  *elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name);
547
548 /**
549  * Sets if the cursor set should be searched on the theme or should use
550  * the provided by the engine, only.
551  *
552  * @note before you set if should look on theme you should define a
553  * cursor with elm_layout_part_cursor_set(). By default it will only
554  * look for cursors provided by the engine.
555  *
556  * @param obj The layout object.
557  * @param part_name a part from loaded edje group.
558  * @param engine_only if cursors should be just provided by the engine (EINA_TRUE)
559  *        or should also search on widget's theme as well (EINA_FALSE)
560  *
561  * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
562  *         part not exists or it did not had a cursor set.
563  *
564  * @ingroup Layout
565  */
566 EAPI Eina_Bool                    elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only);
567
568 /**
569  * Gets a specific cursor engine_only for an edje part.
570  *
571  * @param obj The layout object.
572  * @param part_name a part from loaded edje group.
573  *
574  * @return whenever the cursor is just provided by engine or also from theme.
575  *
576  * @ingroup Layout
577  */
578 EAPI Eina_Bool                    elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name);
579
580 /**
581  * @def elm_layout_icon_set
582  * Convenience macro to set the icon object in a layout that follows the
583  * Elementary naming convention for its parts.
584  *
585  * @ingroup Layout
586  */
587 #define elm_layout_icon_set(_ly, _obj)                                 \
588   do {                                                                 \
589        const char *sig;                                                \
590        elm_object_part_content_set((_ly), "elm.swallow.icon", (_obj)); \
591        if ((_obj)) sig = "elm,state,icon,visible";                     \
592        else sig = "elm,state,icon,hidden";                             \
593        elm_object_signal_emit((_ly), sig, "elm");                      \
594     } while (0)
595
596 /**
597  * @def elm_layout_icon_get
598  * Convenience macro to get the icon object from a layout that follows the
599  * Elementary naming convention for its parts.
600  *
601  * @ingroup Layout
602  */
603 #define elm_layout_icon_get(_ly) \
604   elm_object_part_content_get((_ly), "elm.swallow.icon")
605
606 /**
607  * @def elm_layout_end_set
608  * Convenience macro to set the end object in a layout that follows the
609  * Elementary naming convention for its parts.
610  *
611  * @ingroup Layout
612  */
613 #define elm_layout_end_set(_ly, _obj)                                 \
614   do {                                                                \
615        const char *sig;                                               \
616        elm_object_part_content_set((_ly), "elm.swallow.end", (_obj)); \
617        if ((_obj)) sig = "elm,state,end,visible";                     \
618        else sig = "elm,state,end,hidden";                             \
619        elm_object_signal_emit((_ly), sig, "elm");                     \
620     } while (0)
621
622 /**
623  * @def elm_layout_end_get
624  * Convenience macro to get the end object in a layout that follows the
625  * Elementary naming convention for its parts.
626  *
627  * @ingroup Layout
628  */
629 #define elm_layout_end_get(_ly) \
630   elm_object_part_content_get((_ly), "elm.swallow.end")
631
632 /* smart callbacks called:
633  * "theme,changed" - when elm theme is changed.
634  */
635
636 /**
637  * @}
638  */