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