Merge "elementary/index - merged with opensource for page control"
[framework/uifw/elementary.git] / src / lib / elm_index.h
1 /**
2  * @defgroup Index Index
3  *
4  * @image html img/widget/index/preview-00.png
5  * @image latex img/widget/index/preview-00.eps
6  *
7  * An index widget gives you an index for fast access to whichever
8  * group of other UI items one might have. It's a list of text
9  * items (usually letters, for alphabetically ordered access).
10  *
11  * Index widgets are by default hidden and just appear when the
12  * user clicks over it's reserved area in the canvas. In its
13  * default theme, it's an area one @ref Fingers "finger" wide on
14  * the right side of the index widget's container.
15  *
16  * When items on the index are selected, smart callbacks get
17  * called, so that its user can make other container objects to
18  * show a given area or child object depending on the index item
19  * selected. You'd probably be using an index together with @ref
20  * List "lists", @ref Genlist "generic lists" or @ref Gengrid
21  * "general grids".
22  *
23  * Smart events one  can add callbacks for are:
24  * - @c "changed" - When the selected index item changes. @c
25  *      event_info is the selected item's data pointer.
26  * - @c "delay,changed" - When the selected index item changes, but
27  *      after a small idling period. @c event_info is the selected
28  *      item's data pointer.
29  * - @c "selected" - When the user releases a mouse button and
30  *      selects an item. @c event_info is the selected item's data
31  *      pointer.
32  * - @c "level,up" - when the user moves a finger from the first
33  *      level to the second level
34  * - @c "level,down" - when the user moves a finger from the second
35  *      level to the first level
36  *
37  * The @c "delay,changed" event is so that it'll wait a small time
38  * before actually reporting those events and, moreover, just the
39  * last event happening on those time frames will actually be
40  * reported.
41  *
42  * Here are some examples on its usage:
43  * @li @ref index_example_01
44  * @li @ref index_example_02
45  */
46
47 /**
48  * @addtogroup Index
49  * @{
50  */
51 /**
52  * Add a new index widget to the given parent Elementary
53  * (container) object
54  *
55  * @param parent The parent object
56  * @return a new index widget handle or @c NULL, on errors
57  *
58  * This function inserts a new index widget on the canvas.
59  *
60  * @ingroup Index
61  */
62 EAPI Evas_Object          *elm_index_add(Evas_Object *parent);
63
64 /**
65  * Enable or disable auto hiding feature for a given index widget.
66  *
67  * @param obj The index object
68  * @param disabled @c EINA_TRUE to disable auto hiding, @c EINA_FALSE to enable
69  *
70  * @see elm_index_autohide_disabled_get()
71  *
72  * @ingroup Index
73  */
74 EAPI void                  elm_index_autohide_disabled_set(Evas_Object *obj, Eina_Bool disabled);
75 EAPI void                  elm_index_active_set(Evas_Object *obj, Eina_Bool active);
76
77 /**
78  * Get whether auto hiding feature is enabled or not for a given index widget.
79  *
80  * @param obj The index object
81  * @return @c EINA_TRUE, if auto hiding is disabled, @c EINA_FALSE otherwise
82  *
83  * @see elm_index_active_set() for more details
84  *
85  * @ingroup Index
86  */
87 EAPI Eina_Bool             elm_index_autohide_disabled_get(const Evas_Object *obj);
88 EAPI Eina_Bool             elm_index_active_get(const Evas_Object *obj);
89
90 /**
91  * Set the items level for a given index widget.
92  *
93  * @param obj The index object.
94  * @param level @c 0 or @c 1, the currently implemented levels.
95  *
96  * @see elm_index_item_level_get()
97  *
98  * @ingroup Index
99  */
100 EAPI void                  elm_index_item_level_set(Evas_Object *obj, int level);
101
102 /**
103  * Get the items level set for a given index widget.
104  *
105  * @param obj The index object.
106  * @return @c 0 or @c 1, which are the levels @p obj might be at.
107  *
108  * @see elm_index_item_level_set() for more information
109  *
110  * @ingroup Index
111  */
112 EAPI int                   elm_index_item_level_get(const Evas_Object *obj);
113
114 /**
115  * Set the selected state of an item.
116  *
117  * @param it The index item
118  * @param selected The selected state
119  *
120  * This sets the selected state of the given item @p it.
121  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
122  *
123  * If a new item is selected the previously selected will be unselected.
124  * Previously selected item can be get with function
125  * elm_index_selected_item_get().
126  *
127  * Selected items will be highlighted.
128  *
129  * @see elm_index_item_selected_get()
130  * @see elm_index_selected_item_get()
131  *
132  * @ingroup Index
133  */
134 EAPI void                  elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
135
136 /**
137  * Returns the last selected item, for a given index widget.
138  *
139  * @param obj The index object.
140  * @return The last item @b selected on @p obj (or @c NULL, on errors).
141  *
142  * @ingroup Index
143  */
144 EAPI Elm_Object_Item      *elm_index_selected_item_get(const Evas_Object *obj, int level);
145 EAPI Elm_Object_Item      *elm_index_item_selected_get(const Evas_Object *obj, int level);
146
147 /**
148  * Append a new item on a given index widget.
149  *
150  * @param obj The index object.
151  * @param letter Letter under which the item should be indexed
152  * @param func The function to call when the item is selected.
153  * @param data The item data to set for the index's item
154  * @return A handle to the item added or @c NULL, on errors 
155  *
156  * Despite the most common usage of the @p letter argument is for
157  * single char strings, one could use arbitrary strings as index
158  * entries.
159  *
160  * @c item will be the pointer returned back on @c "changed", @c
161  * "delay,changed" and @c "selected" smart events.
162  *
163  * @ingroup Index
164  */
165 EAPI Elm_Object_Item      *elm_index_item_append(Evas_Object *obj, const char *letter, const void *data);
166
167 /**
168  * Prepend a new item on a given index widget.
169  *
170  * @param obj The index object.
171  * @param letter Letter under which the item should be indexed
172  * @param func The function to call when the item is selected.
173  * @param data The item data to set for the index's item
174  * @return A handle to the item added or @c NULL, on errors 
175  *
176  * Despite the most common usage of the @p letter argument is for
177  * single char strings, one could use arbitrary strings as index
178  * entries.
179  *
180  * @c item will be the pointer returned back on @c "changed", @c
181  * "delay,changed" and @c "selected" smart events.
182  *
183  * @ingroup Index
184  */
185 EAPI Elm_Object_Item      *elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *data);
186
187 /**
188  * Insert a new item into the index object after item @p after.
189  *
190  * @param obj The index object.
191  * @param after The index item to insert after.
192  * @param letter Letter under which the item should be indexed
193  * @param func The function to call when the item is clicked.
194  * @param data The item data to set for the index's item
195  * @return A handle to the item added or @c NULL, on errors 
196  *
197  * Despite the most common usage of the @p letter argument is for
198  * single char strings, one could use arbitrary strings as index
199  * entries.
200  *
201  * @c item will be the pointer returned back on @c "changed", @c
202  * "delay,changed" and @c "selected" smart events.
203  *
204  * @note If @p relative is @c NULL this function will behave as
205  * elm_index_item_append().
206  *
207  * @ingroup Index
208  */
209 EAPI Elm_Object_Item      *elm_index_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data);
210 EAPI Elm_Object_Item      *elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *data, const Elm_Object_Item *relative);
211
212 /**
213  * Insert a new item into the index object before item @p before.
214  *
215  * @param obj The index object.
216  * @param before The index item to insert after.
217  * @param letter Letter under which the item should be indexed
218  * @param func The function to call when the item is clicked.
219  * @param data The item data to set for the index's item
220  * @return A handle to the item added or @c NULL, on errors 
221  *
222  * Despite the most common usage of the @p letter argument is for
223  * single char strings, one could use arbitrary strings as index
224  * entries.
225  *
226  * @c item will be the pointer returned back on @c "changed", @c
227  * "delay,changed" and @c "selected" smart events.
228  *
229  * @note If @p relative is @c NULL this function will behave as
230  * elm_index_item_prepend().
231  *
232  * @ingroup Index
233  */
234 EAPI Elm_Object_Item      *elm_index_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data);
235 EAPI Elm_Object_Item      *elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *data, const Elm_Object_Item *relative);
236
237 /**
238  * Insert a new item into the given index widget, using @p cmp_func
239  * function to sort items (by item handles).
240  *
241  * @param obj The index object.
242  * @param letter Letter under which the item should be indexed
243  * @param func The function to call when the item is clicked.
244  * @param data The item data to set for the index's item
245  * @param cmp_func The comparing function to be used to sort index
246  * items <b>by #index item handles</b>
247  * @param cmp_data_func A @b fallback function to be called for the
248  * sorting of index items <b>by item data</b>). It will be used
249  * when @p cmp_func returns @c 0 (equality), which means an index
250  * item with provided item data already exists. To decide which
251  * data item should be pointed to by the index item in question, @p
252  * cmp_data_func will be used. If @p cmp_data_func returns a
253  * non-negative value, the previous index item data will be
254  * replaced by the given @p item pointer. If the previous data need
255  * to be freed, it should be done by the @p cmp_data_func function,
256  * because all references to it will be lost. If this function is
257  * not provided (@c NULL is given), index items will be @b
258  * duplicated, if @p cmp_func returns @c 0.
259  * @return A handle to the item added or @c NULL, on errors 
260  *
261  * Despite the most common usage of the @p letter argument is for
262  * single char strings, one could use arbitrary strings as index
263  * entries.
264  *
265  * @c item will be the pointer returned back on @c "changed", @c
266  * "delay,changed" and @c "selected" smart events.
267  *
268  * @ingroup Index
269  */
270 EAPI Elm_Object_Item     *elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func);
271
272 /**
273  * Find a given index widget's item, <b>using item data</b>.
274  *
275  * @param obj The index object
276  * @param data The item data pointed to by the desired index item
277  * @return The index item handle, if found, or @c NULL otherwise
278  *
279  * @ingroup Index
280  */
281 EAPI Elm_Object_Item      *elm_index_item_find(Evas_Object *obj, const void *data);
282
283 /**
284  * Removes @b all items from a given index widget.
285  *
286  * @param obj The index object.
287  *
288  * If deletion callbacks are set, via elm_object_item_del_cb_set(),
289  * that callback function will be called for each item in @p obj.
290  *
291  * @ingroup Index
292  */
293 EAPI void                  elm_index_item_clear(Evas_Object *obj);
294
295 /**
296  * Go to a given items level on a index widget
297  *
298  * @param obj The index object
299  * @param level The index level (one of @c 0 or @c 1)
300  *
301  * @ingroup Index
302  */
303 EAPI void                  elm_index_level_go(Evas_Object *obj, int level);
304 EAPI void                  elm_index_item_go(Evas_Object *obj, int level);
305
306 /**
307  * Get the letter (string) set on a given index widget item.
308  *
309  * @param item The index item handle
310  * @return The letter string set on @p it
311  *
312  * @ingroup Index
313  */
314 EAPI const char           *elm_index_item_letter_get(const Elm_Object_Item *item);
315
316 /**
317  * Set the indicator as to be disabled.
318  *
319  * @param obj The index object
320  * @param disabled  @c EINA_TRUE to disable it, @c EINA_FALSE to enable it
321  *
322  * In Index widget, Indicator notes popup text, which shows a letter has been selecting.
323  *
324  * @see elm_index_indicator_disabled_get()
325  *
326  * @ingroup Index
327  */
328 EAPI void                 elm_index_indicator_disabled_set(Evas_Object *obj, Eina_Bool disabled);
329
330 /**
331  * Get the value of indicator's disabled status.
332  *
333  * @param obj The index object
334  * @return EINA_TRUE if the indicator is disabled.
335  *
336  * @see elm_index_indicator_disabled_set()
337  *
338  * @ingroup Index
339  */
340 EAPI Eina_Bool            elm_index_indicator_disabled_get(const Evas_Object *obj);
341
342 /**
343  * Enable or disable horizontal mode on the index object
344  *
345  * @param obj The index object.
346  * @param horizontal @c EINA_TRUE to enable horizontal or @c EINA_FALSE to
347  * disable it, i.e., to enable vertical mode. it's an area one @ref Fingers
348  * "finger" wide on the bottom side of the index widget's container.
349  *
350  * @note Vertical mode is set by default.
351  *
352  * On horizontal mode items are displayed on index from left to right,
353  * instead of from top to bottom. Also, the index will scroll horizontally.
354  *
355  * @see elm_index_horizontal_get()
356  *
357  * @ingroup Index
358  */
359 EAPI void                      elm_index_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
360
361 /**
362  * Get a value whether horizontal mode is enabled or not.
363  *
364  * @param obj The index object.
365  * @return @c EINA_TRUE means horizontal mode selection is enabled.
366  * @c EINA_FALSE indicates it's disabled. If @p obj is @c NULL,
367  * @c EINA_FALSE is returned.
368  *
369  * @see elm_index_horizontal_set() for details.
370  *
371  * @ingroup Index
372  */
373 EAPI Eina_Bool                 elm_index_horizontal_get(const Evas_Object *obj);
374
375 /**
376  * @}
377  */