elementary - Added 1 more API elm_object_item_del_cb_set()
[framework/uifw/elementary.git] / src / lib / elm_diskselector.h
1 /**
2  * @defgroup Diskselector Diskselector
3  * @ingroup Elementary
4  *
5  * @image html img/widget/diskselector/preview-00.png
6  * @image latex img/widget/diskselector/preview-00.eps
7  *
8  * A diskselector is a kind of list widget. It scrolls horizontally,
9  * and can contain label and icon objects. Three items are displayed
10  * with the selected one in the middle.
11  *
12  * It can act like a circular list with round mode and labels can be
13  * reduced for a defined length for side items.
14  *
15  * Smart callbacks one can listen to:
16  * - "selected" - when item is selected, i.e. scroller stops.
17  *
18  * Available styles for it:
19  * - @c "default"
20  *
21  * Default contents parts of the diskseletor items that you can use for are:
22  * @li "icon" - An icon in the diskselector item
23  *
24  * Default text parts of the diskselector items that you can use for are:
25  * @li "default" - Label of the diskselector item
26  * 
27  * List of examples:
28  * @li @ref diskselector_example_01
29  * @li @ref diskselector_example_02
30  */
31
32 /**
33  * @addtogroup Diskselector
34  * @{
35  */
36
37 /**
38  * Add a new diskselector widget to the given parent Elementary
39  * (container) object.
40  *
41  * @param parent The parent object.
42  * @return a new diskselector widget handle or @c NULL, on errors.
43  *
44  * This function inserts a new diskselector widget on the canvas.
45  *
46  * @ingroup Diskselector
47  */
48 EAPI Evas_Object           *elm_diskselector_add(Evas_Object *parent);
49
50 /**
51  * Enable or disable round mode.
52  *
53  * @param obj The diskselector object.
54  * @param round @c EINA_TRUE to enable round mode or @c EINA_FALSE to
55  * disable it.
56  *
57  * Disabled by default. If round mode is enabled the items list will
58  * work like a circle list, so when the user reaches the last item,
59  * the first one will popup.
60  *
61  * @see elm_diskselector_round_get()
62  *
63  * @ingroup Diskselector
64  */
65 EAPI void                   elm_diskselector_round_set(Evas_Object *obj, Eina_Bool round);
66
67 /**
68  * Get a value whether round mode is enabled or not.
69  *
70  * @see elm_diskselector_round_set() for details.
71  *
72  * @param obj The diskselector object.
73  * @return @c EINA_TRUE means round mode is enabled. @c EINA_FALSE indicates
74  * it's disabled. If @p obj is @c NULL, @c EINA_FALSE is returned.
75  *
76  * @ingroup Diskselector
77  */
78 EAPI Eina_Bool              elm_diskselector_round_get(const Evas_Object *obj);
79
80 /**
81  * Get the side labels max length.
82  *
83  * @see elm_diskselector_side_label_length_set() for details.
84  *
85  * @param obj The diskselector object.
86  * @return The max length defined for side labels, or 0 if not a valid
87  * diskselector.
88  *
89  * @ingroup Diskselector
90  */
91 EAPI int                    elm_diskselector_side_label_length_get(const Evas_Object *obj);
92
93 /**
94  * Set the side labels max length.
95  *
96  * @param obj The diskselector object.
97  * @param len The max length defined for side labels.
98  *
99  * Length is the number of characters of items' label that will be
100  * visible when it's set on side positions. It will just crop
101  * the string after defined size. E.g.:
102  *
103  * An item with label "January" would be displayed on side position as
104  * "Jan" if max length is set to 3, or "Janu", if this property
105  * is set to 4.
106  *
107  * When it's selected, the entire label will be displayed, except for
108  * width restrictions. In this case label will be cropped and "..."
109  * will be concatenated.
110  *
111  * Default side label max length is 3.
112  *
113  * This property will be applyed over all items, included before or
114  * later this function call.
115  *
116  * @ingroup Diskselector
117  */
118 EAPI void                   elm_diskselector_side_label_length_set(Evas_Object *obj, int len);
119
120 /**
121  * Set the number of items to be displayed.
122  *
123  * @param obj The diskselector object.
124  * @param num The number of items the diskselector will display.
125  *
126  * Default value is 3, and also it's the minimun. If @p num is less
127  * than 3, it will be set to 3.
128  *
129  * Also, it can be set on theme, using data item @c display_item_num
130  * on group "elm/diskselector/item/X", where X is style set.
131  * E.g.:
132  *
133  * group { name: "elm/diskselector/item/X";
134  * data {
135  *     item: "display_item_num" "5";
136  *     }
137  *
138  * @ingroup Diskselector
139  */
140 EAPI void                   elm_diskselector_display_item_num_set(Evas_Object *obj, int num);
141
142 /**
143  * Get the number of items in the diskselector object.
144  *
145  * @param obj The diskselector object.
146  *
147  * @ingroup Diskselector
148  */
149 EAPI int                   elm_diskselector_display_item_num_get(const Evas_Object *obj);
150
151 /**
152  * Set bouncing behaviour when the scrolled content reaches an edge.
153  *
154  * Tell the internal scroller object whether it should bounce or not
155  * when it reaches the respective edges for each axis.
156  *
157  * @param obj The diskselector object.
158  * @param h_bounce Whether to bounce or not in the horizontal axis.
159  * @param v_bounce Whether to bounce or not in the vertical axis.
160  *
161  * @see elm_scroller_bounce_set()
162  *
163  * @ingroup Diskselector
164  */
165 EAPI void                   elm_diskselector_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
166
167 /**
168  * Get the bouncing behaviour of the internal scroller.
169  *
170  * Get whether the internal scroller should bounce when the edge of each
171  * axis is reached scrolling.
172  *
173  * @param obj The diskselector object.
174  * @param h_bounce Pointer where to store the bounce state of the horizontal
175  * axis.
176  * @param v_bounce Pointer where to store the bounce state of the vertical
177  * axis.
178  *
179  * @see elm_scroller_bounce_get()
180  * @see elm_diskselector_bounce_set()
181  *
182  * @ingroup Diskselector
183  */
184 EAPI void                   elm_diskselector_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
185
186 /**
187  * Get the scrollbar policy.
188  *
189  * @see elm_diskselector_scroller_policy_get() for details.
190  *
191  * @param obj The diskselector object.
192  * @param policy_h Pointer where to store horizontal scrollbar policy.
193  * @param policy_v Pointer where to store vertical scrollbar policy.
194  *
195  * @ingroup Diskselector
196  */
197 EAPI void                   elm_diskselector_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v);
198
199 /**
200  * Set the scrollbar policy.
201  *
202  * @param obj The diskselector object.
203  * @param policy_h Horizontal scrollbar policy.
204  * @param policy_v Vertical scrollbar policy.
205  *
206  * This sets the scrollbar visibility policy for the given scroller.
207  * #ELM_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it
208  * is needed, and otherwise kept hidden. #ELM_SCROLLER_POLICY_ON turns
209  * it on all the time, and #ELM_SCROLLER_POLICY_OFF always keeps it off.
210  * This applies respectively for the horizontal and vertical scrollbars.
211  *
212  * The both are disabled by default, i.e., are set to
213  * #ELM_SCROLLER_POLICY_OFF.
214  *
215  * @ingroup Diskselector
216  */
217 EAPI void                   elm_diskselector_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v);
218
219 /**
220  * Remove all diskselector's items.
221  *
222  * @param obj The diskselector object.
223  *
224  * @see elm_diskselector_item_del()
225  * @see elm_diskselector_item_append()
226  *
227  * @ingroup Diskselector
228  */
229 EAPI void                   elm_diskselector_clear(Evas_Object *obj);
230
231 /**
232  * Get a list of all the diskselector items.
233  *
234  * @param obj The diskselector object.
235  * @return An @c Eina_List of diskselector items, #Elm_Object_Item,
236  * or @c NULL on failure.
237  *
238  * @see elm_diskselector_item_append()
239  * @see elm_diskselector_item_del()
240  * @see elm_diskselector_clear()
241  *
242  * @ingroup Diskselector
243  */
244 EAPI const Eina_List       *elm_diskselector_items_get(const Evas_Object *obj);
245
246 /**
247  * Appends a new item to the diskselector object.
248  *
249  * @param obj The diskselector object.
250  * @param label The label of the diskselector item.
251  * @param icon The icon object to use at left side of the item. An
252  * icon can be any Evas object, but usually it is an icon created
253  * with elm_icon_add().
254  * @param func The function to call when the item is selected.
255  * @param data The data to associate with the item for related callbacks.
256  *
257  * @return The created item or @c NULL upon failure.
258  *
259  * A new item will be created and appended to the diskselector, i.e., will
260  * be set as last item. Also, if there is no selected item, it will
261  * be selected. This will always happens for the first appended item.
262  *
263  * If no icon is set, label will be centered on item position, otherwise
264  * the icon will be placed at left of the label, that will be shifted
265  * to the right.
266  *
267  * Items created with this method can be deleted with
268  * elm_diskselector_item_del().
269  *
270  * Associated @p data can be properly freed when item is deleted if a
271  * callback function is set with elm_object_item_del_cb_set().
272  *
273  * If a function is passed as argument, it will be called everytime this item
274  * is selected, i.e., the user stops the diskselector with this
275  * item on center position. If such function isn't needed, just passing
276  * @c NULL as @p func is enough. The same should be done for @p data.
277  *
278  * Simple example (with no function callback or data associated):
279  * @code
280  * disk = elm_diskselector_add(win);
281  * ic = elm_icon_add(win);
282  * elm_icon_file_set(ic, "path/to/image", NULL);
283  * elm_icon_scale_set(ic, EINA_TRUE, EINA_TRUE);
284  * elm_diskselector_item_append(disk, "label", ic, NULL, NULL);
285  * @endcode
286  *
287  * @see elm_diskselector_item_del()
288  * @see elm_diskselector_clear()
289  * @see elm_icon_add()
290  *
291  * @ingroup Diskselector
292  */
293 EAPI Elm_Object_Item *elm_diskselector_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data);
294
295
296 /**
297  * Delete them item from the diskselector.
298  *
299  * @param it The item of diskselector to be deleted.
300  *
301  * If deleting all diskselector items is required, elm_diskselector_clear()
302  * should be used instead of getting items list and deleting each one.
303  *
304  * @see elm_diskselector_clear()
305  * @see elm_diskselector_item_append()
306  *
307  * @ingroup Diskselector
308  */
309 EAPI void                   elm_diskselector_item_del(Elm_Object_Item *it);
310
311 /**
312  * Get the selected item.
313  *
314  * @param obj The diskselector object.
315  * @return The selected diskselector item.
316  *
317  * The selected item can be unselected with function
318  * elm_diskselector_item_selected_set(), and the first item of
319  * diskselector will be selected.
320  *
321  * The selected item always will be centered on diskselector, with
322  * full label displayed, i.e., max lenght set to side labels won't
323  * apply on the selected item. More details on
324  * elm_diskselector_side_label_length_set().
325  *
326  * @ingroup Diskselector
327  */
328 EAPI Elm_Object_Item *elm_diskselector_selected_item_get(const Evas_Object *obj);
329
330 /**
331  * Set the selected state of an item.
332  *
333  * @param it The diskselector item
334  * @param selected The selected state
335  *
336  * This sets the selected state of the given item @p it.
337  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
338  *
339  * If a new item is selected the previosly selected will be unselected.
340  * Previoulsy selected item can be get with function
341  * elm_diskselector_selected_item_get().
342  *
343  * If the item @p it is unselected, the first item of diskselector will
344  * be selected.
345  *
346  * Selected items will be visible on center position of diskselector.
347  * So if it was on another position before selected, or was invisible,
348  * diskselector will animate items until the selected item reaches center
349  * position.
350  *
351  * @see elm_diskselector_item_selected_get()
352  * @see elm_diskselector_selected_item_get()
353  *
354  * @ingroup Diskselector
355  */
356 EAPI void                   elm_diskselector_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
357
358 /*
359  * Get whether the @p item is selected or not.
360  *
361  * @param it The diskselector item.
362  * @return @c EINA_TRUE means item is selected. @c EINA_FALSE indicates
363  * it's not. If @p obj is @c NULL, @c EINA_FALSE is returned.
364  *
365  * @see elm_diskselector_selected_item_set() for details.
366  * @see elm_diskselector_item_selected_get()
367  *
368  * @ingroup Diskselector
369  */
370 EAPI Eina_Bool              elm_diskselector_item_selected_get(const Elm_Object_Item *it);
371
372 /**
373  * Get the first item of the diskselector.
374  *
375  * @param obj The diskselector object.
376  * @return The first item, or @c NULL if none.
377  *
378  * The list of items follows append order. So it will return the first
379  * item appended to the widget that wasn't deleted.
380  *
381  * @see elm_diskselector_item_append()
382  * @see elm_diskselector_items_get()
383  *
384  * @ingroup Diskselector
385  */
386 EAPI Elm_Object_Item *elm_diskselector_first_item_get(const Evas_Object *obj);
387
388 /**
389  * Get the last item of the diskselector.
390  *
391  * @param obj The diskselector object.
392  * @return The last item, or @c NULL if none.
393  *
394  * The list of items follows append order. So it will return last first
395  * item appended to the widget that wasn't deleted.
396  *
397  * @see elm_diskselector_item_append()
398  * @see elm_diskselector_items_get()
399  *
400  * @ingroup Diskselector
401  */
402 EAPI Elm_Object_Item *elm_diskselector_last_item_get(const Evas_Object *obj);
403
404 /**
405  * Get the item before @p item in diskselector.
406  *
407  * @param it The diskselector item.
408  * @return The item before @p item, or @c NULL if none or on failure.
409  *
410  * The list of items follows append order. So it will return item appended
411  * just before @p item and that wasn't deleted.
412  *
413  * If it is the first item, @c NULL will be returned.
414  * First item can be get by elm_diskselector_first_item_get().
415  *
416  * @see elm_diskselector_item_append()
417  * @see elm_diskselector_items_get()
418  *
419  * @ingroup Diskselector
420  */
421 EAPI Elm_Object_Item *elm_diskselector_item_prev_get(const Elm_Object_Item *it);
422
423 /**
424  * Get the item after @p item in diskselector.
425  *
426  * @param it The diskselector item.
427  * @return The item after @p item, or @c NULL if none or on failure.
428  *
429  * The list of items follows append order. So it will return item appended
430  * just after @p item and that wasn't deleted.
431  *
432  * If it is the last item, @c NULL will be returned.
433  * Last item can be get by elm_diskselector_last_item_get().
434  *
435  * @see elm_diskselector_item_append()
436  * @see elm_diskselector_items_get()
437  *
438  * @ingroup Diskselector
439  */
440 EAPI Elm_Object_Item *elm_diskselector_item_next_get(const Elm_Object_Item *it);
441
442 /**
443  * Set the text to be shown in the diskselector item.
444  *
445  * @param it Target item
446  * @param text The text to set in the content
447  *
448  * Setup the text as tooltip to object. The item can have only one tooltip,
449  * so any previous tooltip data is removed.
450  *
451  * @see elm_object_tooltip_text_set() for more details.
452  *
453  * @ingroup Diskselector
454  */
455 EAPI void                   elm_diskselector_item_tooltip_text_set(Elm_Object_Item *it, const char *text);
456
457 /**
458  * Set the content to be shown in the tooltip item.
459  *
460  * Setup the tooltip to item. The item can have only one tooltip,
461  * so any previous tooltip data is removed. @p func(with @p data) will
462  * be called every time that need show the tooltip and it should
463  * return a valid Evas_Object. This object is then managed fully by
464  * tooltip system and is deleted when the tooltip is gone.
465  *
466  * @param it the diskselector item being attached a tooltip.
467  * @param func the function used to create the tooltip contents.
468  * @param data what to provide to @a func as callback data/context.
469  * @param del_cb called when data is not needed anymore, either when
470  *        another callback replaces @p func, the tooltip is unset with
471  *        elm_diskselector_item_tooltip_unset() or the owner @a item
472  *        dies. This callback receives as the first parameter the
473  *        given @a data, and @c event_info is the item.
474  *
475  * @see elm_object_tooltip_content_cb_set() for more details.
476  *
477  * @ingroup Diskselector
478  */
479 EAPI void                   elm_diskselector_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb);
480
481 /**
482  * Unset tooltip from item.
483  *
484  * @param it diskselector item to remove previously set tooltip.
485  *
486  * Remove tooltip from item. The callback provided as del_cb to
487  * elm_diskselector_item_tooltip_content_cb_set() will be called to notify
488  * it is not used anymore.
489  *
490  * @see elm_object_tooltip_unset() for more details.
491  * @see elm_diskselector_item_tooltip_content_cb_set()
492  *
493  * @ingroup Diskselector
494  */
495 EAPI void                   elm_diskselector_item_tooltip_unset(Elm_Object_Item *it);
496
497 /**
498  * Sets a different style for this item tooltip.
499  *
500  * @note before you set a style you should define a tooltip with
501  *       elm_diskselector_item_tooltip_content_cb_set() or
502  *       elm_diskselector_item_tooltip_text_set()
503  *
504  * @param it diskselector item with tooltip already set.
505  * @param style the theme style to use (default, transparent, ...)
506  *
507  * @see elm_object_tooltip_style_set() for more details.
508  *
509  * @ingroup Diskselector
510  */
511 EAPI void                   elm_diskselector_item_tooltip_style_set(Elm_Object_Item *it, const char *style);
512
513 /**
514  * Get the style for this item tooltip.
515  *
516  * @param it diskselector item with tooltip already set.
517  * @return style the theme style in use, defaults to "default". If the
518  *         object does not have a tooltip set, then NULL is returned.
519  *
520  * @see elm_object_tooltip_style_get() for more details.
521  * @see elm_diskselector_item_tooltip_style_set()
522  *
523  * @ingroup Diskselector
524  */
525 EAPI const char            *elm_diskselector_item_tooltip_style_get(const Elm_Object_Item *it);
526
527 /**
528  * Set the cursor to be shown when mouse is over the diskselector item
529  *
530  * @param it Target item
531  * @param cursor the cursor name to be used.
532  *
533  * @see elm_object_cursor_set() for more details.
534  *
535  * @ingroup Diskselector
536  */
537 EAPI void                   elm_diskselector_item_cursor_set(Elm_Object_Item *it, const char *cursor);
538
539 /**
540  * Get the cursor to be shown when mouse is over the diskselector item
541  *
542  * @param it diskselector item with cursor already set.
543  * @return the cursor name.
544  *
545  * @see elm_object_cursor_get() for more details.
546  * @see elm_diskselector_cursor_set()
547  *
548  * @ingroup Diskselector
549  */
550 EAPI const char            *elm_diskselector_item_cursor_get(const Elm_Object_Item *it);
551
552 /**
553  * Unset the cursor to be shown when mouse is over the diskselector item
554  *
555  * @param it Target item
556  *
557  * @see elm_object_cursor_unset() for more details.
558  * @see elm_diskselector_cursor_set()
559  *
560  * @ingroup Diskselector
561  */
562 EAPI void                   elm_diskselector_item_cursor_unset(Elm_Object_Item *it);
563
564 /**
565  * Sets a different style for this item cursor.
566  *
567  * @note before you set a style you should define a cursor with
568  *       elm_diskselector_item_cursor_set()
569  *
570  * @param it diskselector item with cursor already set.
571  * @param style the theme style to use (default, transparent, ...)
572  *
573  * @see elm_object_cursor_style_set() for more details.
574  *
575  * @ingroup Diskselector
576  */
577 EAPI void                   elm_diskselector_item_cursor_style_set(Elm_Object_Item *it, const char *style);
578
579 /**
580  * Get the style for this item cursor.
581  *
582  * @param it diskselector item with cursor already set.
583  * @return style the theme style in use, defaults to "default". If the
584  *         object does not have a cursor set, then @c NULL is returned.
585  *
586  * @see elm_object_cursor_style_get() for more details.
587  * @see elm_diskselector_item_cursor_style_set()
588  *
589  * @ingroup Diskselector
590  */
591 EAPI const char            *elm_diskselector_item_cursor_style_get(const Elm_Object_Item *it);
592
593
594 /**
595  * Set if the cursor set should be searched on the theme or should use
596  * the provided by the engine, only.
597  *
598  * @note before you set if should look on theme you should define a cursor
599  * with elm_diskselector_item_cursor_set().
600  * By default it will only look for cursors provided by the engine.
601  *
602  * @param it widget item with cursor already set.
603  * @param engine_only boolean to define if cursors set with
604  * elm_diskselector_item_cursor_set() should be searched only
605  * between cursors provided by the engine or searched on widget's
606  * theme as well.
607  *
608  * @see elm_object_cursor_engine_only_set() for more details.
609  *
610  * @ingroup Diskselector
611  */
612 EAPI void                   elm_diskselector_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only);
613
614 /**
615  * Get the cursor engine only usage for this item cursor.
616  *
617  * @param it widget item with cursor already set.
618  * @return engine_only boolean to define it cursors should be looked only
619  * between the provided by the engine or searched on widget's theme as well.
620  * If the item does not have a cursor set, then @c EINA_FALSE is returned.
621  *
622  * @see elm_object_cursor_engine_only_get() for more details.
623  * @see elm_diskselector_item_cursor_engine_only_set()
624  *
625  * @ingroup Diskselector
626  */
627 EAPI Eina_Bool              elm_diskselector_item_cursor_engine_only_get(const Elm_Object_Item *it);
628
629 /**
630  * @}
631  */
632