38d17e014567280d0d960aa8a58435b699cfa25c
[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 content parts of the diskselector 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  * Supported elm_object_item common APIs.
28  * @li elm_object_item_part_text_set
29  * @li elm_object_item_part_text_get
30  * @li elm_object_item_part_content_set
31  * @li elm_object_item_part_content_get
32  *
33  * List of examples:
34  * @li @ref diskselector_example_01
35  * @li @ref diskselector_example_02
36  */
37
38 /**
39  * @addtogroup Diskselector
40  * @{
41  */
42
43 /**
44  * Add a new diskselector widget to the given parent Elementary
45  * (container) object.
46  *
47  * @param parent The parent object.
48  * @return a new diskselector widget handle or @c NULL, on errors.
49  *
50  * This function inserts a new diskselector widget on the canvas.
51  *
52  * @ingroup Diskselector
53  */
54 EAPI Evas_Object           *elm_diskselector_add(Evas_Object *parent);
55
56 /**
57  * Enable or disable round mode.
58  *
59  * @param obj The diskselector object.
60  * @param rnd @c EINA_TRUE to enable round mode or @c EINA_FALSE to
61  * disable it.
62  *
63  * Disabled by default. If round mode is enabled the items list will
64  * work like a circle list, so when the user reaches the last item,
65  * the first one will popup.
66  *
67  * @see elm_diskselector_round_get()
68  *
69  * @ingroup Diskselector
70  */
71 EAPI void                   elm_diskselector_round_set(Evas_Object *obj, Eina_Bool rnd);
72
73 /**
74  * Get a value whether round mode is enabled or not.
75  *
76  * @see elm_diskselector_round_set() for details.
77  *
78  * @param obj The diskselector object.
79  * @return @c EINA_TRUE means round mode is enabled. @c EINA_FALSE indicates
80  * it's disabled. If @p obj is @c NULL, @c EINA_FALSE is returned.
81  *
82  * @ingroup Diskselector
83  */
84 EAPI Eina_Bool              elm_diskselector_round_get(const Evas_Object *obj);
85
86 /**
87  * Get the side labels max length.
88  *
89  * @see elm_diskselector_side_label_length_set() for details.
90  *
91  * @param obj The diskselector object.
92  * @return The max length defined for side labels, or 0 if not a valid
93  * diskselector.
94  *
95  * @ingroup Diskselector
96  */
97 EAPI int                    elm_diskselector_side_label_length_get(const Evas_Object *obj);
98
99 /**
100  * Set the side labels max length.
101  *
102  * @param obj The diskselector object.
103  * @param len The max length defined for side labels.
104  *
105  * Length is the number of characters of items' label that will be
106  * visible when it's set on side positions. It will just crop
107  * the string after defined size. E.g.:
108  *
109  * An item with label "January" would be displayed on side position as
110  * "Jan" if max length is set to 3, or "Janu", if this property
111  * is set to 4.
112  *
113  * When it's selected, the entire label will be displayed, except for
114  * width restrictions. In this case label will be cropped and "..."
115  * will be concatenated.
116  *
117  * Default side label max length is 3.
118  *
119  * This property will be applied over all items, included before or
120  * later this function call.
121  *
122  * @ingroup Diskselector
123  */
124 EAPI void                   elm_diskselector_side_label_length_set(Evas_Object *obj, int len);
125
126 /**
127  * Set the number of items to be displayed.
128  *
129  * @param obj The diskselector object.
130  * @param num The number of items the diskselector will display.
131  *
132  * Default value is 3, and also it's the minimum. If @p num is less
133  * than 3, it will be set to 3.
134  *
135  * Also, it can be set on theme, using data item @c display_item_num
136  * on group "elm/diskselector/item/X", where X is style set.
137  * E.g.:
138  *
139  * group { name: "elm/diskselector/item/X";
140  * data {
141  *     item: "display_item_num" "5";
142  *     }
143  *
144  * @ingroup Diskselector
145  */
146 EAPI void                   elm_diskselector_display_item_num_set(Evas_Object *obj, int num);
147
148 /**
149  * Get the number of items in the diskselector object.
150  *
151  * @param obj The diskselector object.
152  *
153  * @ingroup Diskselector
154  */
155 EAPI int                   elm_diskselector_display_item_num_get(const Evas_Object *obj);
156
157 /**
158  * Set bouncing behaviour when the scrolled content reaches an edge.
159  *
160  * Tell the internal scroller object whether it should bounce or not
161  * when it reaches the respective edges for each axis.
162  *
163  * @param obj The diskselector object.
164  * @param h_bounce Whether to bounce or not in the horizontal axis.
165  * @param v_bounce Whether to bounce or not in the vertical axis.
166  *
167  * @see elm_scroller_bounce_set()
168  *
169  * @ingroup Diskselector
170  */
171 EAPI void                   elm_diskselector_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
172
173 /**
174  * Get the bouncing behaviour of the internal scroller.
175  *
176  * Get whether the internal scroller should bounce when the edge of each
177  * axis is reached scrolling.
178  *
179  * @param obj The diskselector object.
180  * @param h_bounce Pointer to store the bounce state of the horizontal
181  * axis.
182  * @param v_bounce Pointer to store the bounce state of the vertical
183  * axis.
184  *
185  * @see elm_scroller_bounce_get()
186  * @see elm_diskselector_bounce_set()
187  *
188  * @ingroup Diskselector
189  */
190 EAPI void                   elm_diskselector_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
191
192 /**
193  * Get the scrollbar policy.
194  *
195  * @see elm_diskselector_scroller_policy_get() for details.
196  *
197  * @param obj The diskselector object.
198  * @param policy_h Pointer to store horizontal scrollbar policy.
199  * @param policy_v Pointer to store vertical scrollbar policy.
200  *
201  * @ingroup Diskselector
202  */
203 EAPI void                   elm_diskselector_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v);
204
205 /**
206  * Set the scrollbar policy.
207  *
208  * @param obj The diskselector object.
209  * @param policy_h Horizontal scrollbar policy.
210  * @param policy_v Vertical scrollbar policy.
211  *
212  * This sets the scrollbar visibility policy for the given scroller.
213  * #ELM_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it
214  * is needed, and otherwise kept hidden. #ELM_SCROLLER_POLICY_ON turns
215  * it on all the time, and #ELM_SCROLLER_POLICY_OFF always keeps it off.
216  * This applies respectively for the horizontal and vertical scrollbars.
217  *
218  * The both are disabled by default, i.e., are set to
219  * #ELM_SCROLLER_POLICY_OFF.
220  *
221  * @ingroup Diskselector
222  */
223 EAPI void                   elm_diskselector_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v);
224
225 /**
226  * Remove all diskselector's items.
227  *
228  * @param obj The diskselector object.
229  *
230  * @see elm_object_item_del()
231  * @see elm_diskselector_item_append()
232  *
233  * @ingroup Diskselector
234  */
235 EAPI void                   elm_diskselector_clear(Evas_Object *obj);
236
237 /**
238  * Get a list of all the diskselector items.
239  *
240  * @param obj The diskselector object.
241  * @return An @c Eina_List of diskselector items, #Elm_Object_Item,
242  * or @c NULL on failure.
243  *
244  * @see elm_diskselector_item_append()
245  * @see elm_object_item_del()
246  * @see elm_diskselector_clear()
247  *
248  * @ingroup Diskselector
249  */
250 EAPI const Eina_List       *elm_diskselector_items_get(const Evas_Object *obj);
251
252 /**
253  * Appends a new item to the diskselector object.
254  *
255  * @param obj The diskselector object.
256  * @param label The label of the diskselector item.
257  * @param icon The icon object to use at left side of the item. An
258  * icon can be any Evas object, but usually it is an icon created
259  * with elm_icon_add().
260  * @param func The function to call when the item is selected.
261  * @param data The data to associate with the item for related callbacks.
262  *
263  * @return The created item or @c NULL upon failure.
264  *
265  * A new item will be created and appended to the diskselector, i.e., will
266  * be set as last item. Also, if there is no selected item, it will
267  * be selected. This will always happens for the first appended item.
268  *
269  * If no icon is set, label will be centered on item position, otherwise
270  * the icon will be placed at left of the label, that will be shifted
271  * to the right.
272  *
273  * Items created with this method can be deleted with
274  * elm_object_item_del().
275  *
276  * Associated @p data can be properly freed when item is deleted if a
277  * callback function is set with elm_object_item_del_cb_set().
278  *
279  * If a function is passed as argument, it will be called every time this item
280  * is selected, i.e., the user stops the diskselector with this
281  * item on center position. If such function isn't needed, just passing
282  * @c NULL as @p func is enough. The same should be done for @p data.
283  *
284  * Simple example (with no function callback or data associated):
285  * @code
286  * disk = elm_diskselector_add(win);
287  * ic = elm_icon_add(win);
288  * elm_icon_file_set(ic, "path/to/image", NULL);
289  * elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
290  * elm_diskselector_item_append(disk, "label", ic, NULL, NULL);
291  * @endcode
292  *
293  * @see elm_object_item_del()
294  * @see elm_diskselector_clear()
295  * @see elm_icon_add()
296  *
297  * @ingroup Diskselector
298  */
299 EAPI Elm_Object_Item *elm_diskselector_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data);
300
301 /**
302  * Get the selected item.
303  *
304  * @param obj The diskselector object.
305  * @return The selected diskselector item.
306  *
307  * The selected item can be unselected with function
308  * elm_diskselector_item_selected_set(), and the first item of
309  * diskselector will be selected.
310  *
311  * The selected item always will be centered on diskselector, with
312  * full label displayed, i.e., max length set to side labels won't
313  * apply on the selected item. More details on
314  * elm_diskselector_side_label_length_set().
315  *
316  * @ingroup Diskselector
317  */
318 EAPI Elm_Object_Item *elm_diskselector_selected_item_get(const Evas_Object *obj);
319
320 /**
321  * Set the selected state of an item.
322  *
323  * @param it The diskselector item
324  * @param selected The selected state
325  *
326  * This sets the selected state of the given item @p it.
327  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
328  *
329  * If a new item is selected the previously selected will be unselected.
330  * Previously selected item can be get with function
331  * elm_diskselector_selected_item_get().
332  *
333  * If the item @p it is unselected, the first item of diskselector will
334  * be selected.
335  *
336  * Selected items will be visible on center position of diskselector.
337  * So if it was on another position before selected, or was invisible,
338  * diskselector will animate items until the selected item reaches center
339  * position.
340  *
341  * @see elm_diskselector_item_selected_get()
342  * @see elm_diskselector_selected_item_get()
343  *
344  * @ingroup Diskselector
345  */
346 EAPI void                   elm_diskselector_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
347
348 /*
349  * Get whether the @p item is selected or not.
350  *
351  * @param it The diskselector item.
352  * @return @c EINA_TRUE means item is selected. @c EINA_FALSE indicates
353  * it's not. If @p obj is @c NULL, @c EINA_FALSE is returned.
354  *
355  * @see elm_diskselector_selected_item_set() for details.
356  * @see elm_diskselector_item_selected_get()
357  *
358  * @ingroup Diskselector
359  */
360 EAPI Eina_Bool              elm_diskselector_item_selected_get(const Elm_Object_Item *it);
361
362 /**
363  * Get the first item of the diskselector.
364  *
365  * @param obj The diskselector object.
366  * @return The first item, or @c NULL if none.
367  *
368  * The list of items follows append order. So it will return the first
369  * item appended to the widget that wasn't deleted.
370  *
371  * @see elm_diskselector_item_append()
372  * @see elm_diskselector_items_get()
373  *
374  * @ingroup Diskselector
375  */
376 EAPI Elm_Object_Item *elm_diskselector_first_item_get(const Evas_Object *obj);
377
378 /**
379  * Get the last item of the diskselector.
380  *
381  * @param obj The diskselector object.
382  * @return The last item, or @c NULL if none.
383  *
384  * The list of items follows append order. So it will return last first
385  * item appended to the widget that wasn't deleted.
386  *
387  * @see elm_diskselector_item_append()
388  * @see elm_diskselector_items_get()
389  *
390  * @ingroup Diskselector
391  */
392 EAPI Elm_Object_Item *elm_diskselector_last_item_get(const Evas_Object *obj);
393
394 /**
395  * Get the item before @p item in diskselector.
396  *
397  * @param it The diskselector item.
398  * @return The item before @p item, or @c NULL if none or on failure.
399  *
400  * The list of items follows append order. So it will return item appended
401  * just before @p item and that wasn't deleted.
402  *
403  * If it is the first item, @c NULL will be returned.
404  * First item can be get by elm_diskselector_first_item_get().
405  *
406  * @see elm_diskselector_item_append()
407  * @see elm_diskselector_items_get()
408  *
409  * @ingroup Diskselector
410  */
411 EAPI Elm_Object_Item *elm_diskselector_item_prev_get(const Elm_Object_Item *it);
412
413 /**
414  * Get the item after @p item in diskselector.
415  *
416  * @param it The diskselector item.
417  * @return The item after @p item, or @c NULL if none or on failure.
418  *
419  * The list of items follows append order. So it will return item appended
420  * just after @p item and that wasn't deleted.
421  *
422  * If it is the last item, @c NULL will be returned.
423  * Last item can be get by elm_diskselector_last_item_get().
424  *
425  * @see elm_diskselector_item_append()
426  * @see elm_diskselector_items_get()
427  *
428  * @ingroup Diskselector
429  */
430 EAPI Elm_Object_Item *elm_diskselector_item_next_get(const Elm_Object_Item *it);
431
432 /**
433  * @}
434  */
435