elementary/segment_control - Elm_Segment_Item -> Elm_Object_Item
[framework/uifw/elementary.git] / src / lib / elm_segment_control.h
1 /**
2  * @defgroup SegmentControl SegmentControl
3  * @ingroup Elementary
4  *
5  * @image html img/widget/segment_control/preview-00.png
6  * @image latex img/widget/segment_control/preview-00.eps width=\textwidth
7  *
8  * @image html img/segment_control.png
9  * @image latex img/segment_control.eps width=\textwidth
10  *
11  * Segment control widget is a horizontal control made of multiple segment
12  * items, each segment item functioning similar to discrete two state button.
13  * A segment control groups the items together and provides compact
14  * single button with multiple equal size segments.
15  *
16  * Segment item size is determined by base widget
17  * size and the number of items added.
18  * Only one segment item can be at selected state. A segment item can display
19  * combination of Text and any Evas_Object like Images or other widget.
20  *
21  * Smart callbacks one can listen to:
22  * - "changed" - When the user clicks on a segment item which is not
23  *   previously selected and get selected. The event_info parameter is the
24  *   segment item pointer.
25  *
26  * Available styles for it:
27  * - @c "default"
28  *
29  * Here is an example on its usage:
30  * @li @ref segment_control_example
31  */
32
33 /**
34  * @addtogroup SegmentControl
35  * @{
36  */
37
38 /**
39  * Add a new segment control widget to the given parent Elementary
40  * (container) object.
41  *
42  * @param parent The parent object.
43  * @return a new segment control widget handle or @c NULL, on errors.
44  *
45  * This function inserts a new segment control widget on the canvas.
46  *
47  * @ingroup SegmentControl
48  */
49 EAPI Evas_Object      *elm_segment_control_add(Evas_Object *parent);
50
51 /**
52  * Append a new item to the segment control object.
53  *
54  * @param obj The segment control object.
55  * @param icon The icon object to use for the left side of the item. An
56  * icon can be any Evas object, but usually it is an icon created
57  * with elm_icon_add().
58  * @param label The label of the item.
59  *        Note that, NULL is different from empty string "".
60  * @return The created item or @c NULL upon failure.
61  *
62  * A new item will be created and appended to the segment control, i.e., will
63  * be set as @b last item.
64  *
65  * If it should be inserted at another position,
66  * elm_segment_control_item_insert_at() should be used instead.
67  *
68  * Items created with this function can be deleted with function
69  * elm_segment_control_item_del() or elm_segment_control_item_del_at().
70  *
71  * @note @p label set to @c NULL is different from empty string "".
72  * If an item
73  * only has icon, it will be displayed bigger and centered. If it has
74  * icon and label, even that an empty string, icon will be smaller and
75  * positioned at left.
76  *
77  * Simple example:
78  * @code
79  * sc = elm_segment_control_add(win);
80  * ic = elm_icon_add(win);
81  * elm_icon_file_set(ic, "path/to/image", NULL);
82  * elm_icon_scale_set(ic, EINA_TRUE, EINA_TRUE);
83  * elm_segment_control_item_add(sc, ic, "label");
84  * evas_object_show(sc);
85  * @endcode
86  *
87  * @see elm_segment_control_item_insert_at()
88  * @see elm_segment_control_item_del()
89  *
90  * @ingroup SegmentControl
91  */
92 EAPI Elm_Object_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label);
93
94 /**
95  * Insert a new item to the segment control object at specified position.
96  *
97  * @param obj The segment control object.
98  * @param icon The icon object to use for the left side of the item. An
99  * icon can be any Evas object, but usually it is an icon created
100  * with elm_icon_add().
101  * @param label The label of the item.
102  * @param index Item position. Value should be between 0 and items count.
103  * @return The created item or @c NULL upon failure.
104
105  * Index values must be between @c 0, when item will be prepended to
106  * segment control, and items count, that can be get with
107  * elm_segment_control_item_count_get(), case when item will be appended
108  * to segment control, just like elm_segment_control_item_add().
109  *
110  * Items created with this function can be deleted with function
111  * elm_segment_control_item_del() or elm_segment_control_item_del_at().
112  *
113  * @note @p label set to @c NULL is different from empty string "".
114  * If an item
115  * only has icon, it will be displayed bigger and centered. If it has
116  * icon and label, even that an empty string, icon will be smaller and
117  * positioned at left.
118  *
119  * @see elm_segment_control_item_add()
120  * @see elm_segment_control_item_count_get()
121  * @see elm_segment_control_item_del()
122  *
123  * @ingroup SegmentControl
124  */
125 EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
126
127 /**
128  * Remove a segment control item from its parent, deleting it.
129  *
130  * @param it The item to be removed.
131  *
132  * Items can be added with elm_segment_control_item_add() or
133  * elm_segment_control_item_insert_at().
134  *
135  * @ingroup SegmentControl
136  */
137 EAPI void              elm_segment_control_item_del(Elm_Object_Item *it);
138
139 /**
140  * Remove a segment control item at given index from its parent,
141  * deleting it.
142  *
143  * @param obj The segment control object.
144  * @param index The position of the segment control item to be deleted.
145  *
146  * Items can be added with elm_segment_control_item_add() or
147  * elm_segment_control_item_insert_at().
148  *
149  * @ingroup SegmentControl
150  */
151 EAPI void              elm_segment_control_item_del_at(Evas_Object *obj, int index);
152
153 /**
154  * Get the Segment items count from segment control.
155  *
156  * @param obj The segment control object.
157  * @return Segment items count.
158  *
159  * It will just return the number of items added to segment control @p obj.
160  *
161  * @ingroup SegmentControl
162  */
163 EAPI int               elm_segment_control_item_count_get(const Evas_Object *obj);
164
165 /**
166  * Get the item placed at specified index.
167  *
168  * @param obj The segment control object.
169  * @param index The index of the segment item.
170  * @return The segment control item or @c NULL on failure.
171  *
172  * Index is the position of an item in segment control widget. Its
173  * range is from @c 0 to <tt> count - 1 </tt>.
174  * Count is the number of items, that can be get with
175  * elm_segment_control_item_count_get().
176  *
177  * @ingroup SegmentControl
178  */
179 EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int index);
180
181 /**
182  * Get the label of item.
183  *
184  * @param obj The segment control object.
185  * @param index The index of the segment item.
186  * @return The label of the item at @p index.
187  *
188  * The return value is a pointer to the label associated to the item when
189  * it was created, with function elm_segment_control_item_add(), or later
190  * with function elm_segment_control_item_label_set. If no label
191  * was passed as argument, it will return @c NULL.
192  *
193  * @see elm_segment_control_item_label_set() for more details.
194  * @see elm_segment_control_item_add()
195  *
196  * @ingroup SegmentControl
197  */
198 EAPI const char       *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
199
200 /**
201  * Set the label of item.
202  *
203  * @param it The item of segment control.
204  * @param text The label of item.
205  *
206  * The label to be displayed by the item.
207  * Label will be at right of the icon (if set).
208  *
209  * If a label was passed as argument on item creation, with function
210  * elm_control_segment_item_add(), it will be already
211  * displayed by the item.
212  *
213  * @see elm_segment_control_item_label_get()
214  * @see elm_segment_control_item_add()
215  *
216  * @ingroup SegmentControl
217  */
218 EAPI void              elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
219
220 /**
221  * Get the icon associated to the item.
222  *
223  * @param obj The segment control object.
224  * @param index The index of the segment item.
225  * @return The left side icon associated to the item at @p index.
226  *
227  * The return value is a pointer to the icon associated to the item when
228  * it was created, with function elm_segment_control_item_add(), or later
229  * with function elm_segment_control_item_icon_set(). If no icon
230  * was passed as argument, it will return @c NULL.
231  *
232  * @see elm_segment_control_item_add()
233  * @see elm_segment_control_item_icon_set()
234  *
235  * @ingroup SegmentControl
236  */
237 EAPI Evas_Object      *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
238
239 /**
240  * Set the icon associated to the item.
241  *
242  * @param it The segment control item.
243  * @param icon The icon object to associate with @p it.
244  *
245  * The icon object to use at left side of the item. An
246  * icon can be any Evas object, but usually it is an icon created
247  * with elm_icon_add().
248  *
249  * Once the icon object is set, a previously set one will be deleted.
250  * @warning Setting the same icon for two items will cause the icon to
251  * dissapear from the first item.
252  *
253  * If an icon was passed as argument on item creation, with function
254  * elm_segment_control_item_add(), it will be already
255  * associated to the item.
256  *
257  * @see elm_segment_control_item_add()
258  * @see elm_segment_control_item_icon_get()
259  *
260  * @ingroup SegmentControl
261  */
262 EAPI void              elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
263
264 /**
265  * Get the index of an item.
266  *
267  * @param it The segment control item.
268  * @return The position of item in segment control widget.
269  *
270  * Index is the position of an item in segment control widget. Its
271  * range is from @c 0 to <tt> count - 1 </tt>.
272  * Count is the number of items, that can be get with
273  * elm_segment_control_item_count_get().
274  *
275  * @ingroup SegmentControl
276  */
277 EAPI int               elm_segment_control_item_index_get(const Elm_Object_Item *it);
278
279 /**
280  * Get the base object of the item.
281  *
282  * @param it The segment control item.
283  * @return The base object associated with @p it.
284  *
285  * Base object is the @c Evas_Object that represents that item.
286  *
287  * @ingroup SegmentControl
288  */
289 EAPI Evas_Object      *elm_segment_control_item_object_get(const Elm_Object_Item *it);
290
291 /**
292  * Get the selected item.
293  *
294  * @param obj The segment control object.
295  * @return The selected item or @c NULL if none of segment items is
296  * selected.
297  *
298  * The selected item can be unselected with function
299  * elm_segment_control_item_selected_set().
300  *
301  * The selected item always will be highlighted on segment control.
302  *
303  * @ingroup SegmentControl
304  */
305 EAPI Elm_Object_Item *elm_segment_control_item_selected_get(const Evas_Object *obj);
306
307 /**
308  * Set the selected state of an item.
309  *
310  * @param it The segment control item
311  * @param select The selected state
312  *
313  * This sets the selected state of the given item @p it.
314  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
315  *
316  * If a new item is selected the previosly selected will be unselected.
317  * Previoulsy selected item can be get with function
318  * elm_segment_control_item_selected_get().
319  *
320  * The selected item always will be highlighted on segment control.
321  *
322  * @see elm_segment_control_item_selected_get()
323  *
324  * @ingroup SegmentControl
325  */
326 EAPI void              elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);
327
328 /**
329  * @}
330  */