50f3e372d5fdd87afa402bc54be68d25b68e522d
[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  * Default contents parts of the segment control items that you can use for are:
30  * @li "icon" - An icon in a segment control item
31  *
32  * Default text parts of the segment control items that you can use for are:
33  * @li "default" - Title label in a segment control item
34  *
35  * Supported elm_object common APIs.
36  * @li elm_object_disabled_set
37  * @li elm_object_disabled_get
38  *
39  * Supported elm_object_item common APIs.
40  * @li elm_object_item_part_text_set
41  * @li elm_object_item_part_text_get
42  * @li elm_object_item_part_content_set
43  * @li elm_object_item_part_content_get
44  * 
45  * Here is an example on its usage:
46  * @li @ref segment_control_example
47  *
48  */
49
50 /**
51  * @addtogroup SegmentControl
52  * @{
53  */
54
55 /**
56  * Add a new segment control widget to the given parent Elementary
57  * (container) object.
58  *
59  * @param parent The parent object.
60  * @return a new segment control widget handle or @c NULL, on errors.
61  *
62  * This function inserts a new segment control widget on the canvas.
63  *
64  * @ingroup SegmentControl
65  */
66 EAPI Evas_Object      *elm_segment_control_add(Evas_Object *parent);
67
68 /**
69  * Append a new item to the segment control object.
70  *
71  * @param obj The segment control object.
72  * @param icon The icon object to use for the left side of the item. An
73  * icon can be any Evas object, but usually it is an icon created
74  * with elm_icon_add().
75  * @param label The label of the item.
76  *        Note that, NULL is different from empty string "".
77  * @return The created item or @c NULL upon failure.
78  *
79  * A new item will be created and appended to the segment control, i.e., will
80  * be set as @b last item.
81  *
82  * If it should be inserted at another position,
83  * elm_segment_control_item_insert_at() should be used instead.
84  *
85  * Items created with this function can be deleted with function
86  * elm_segment_control_item_del() or elm_segment_control_item_del_at().
87  *
88  * @note @p label set to @c NULL is different from empty string "".
89  * If an item
90  * only has icon, it will be displayed bigger and centered. If it has
91  * icon and label, even that an empty string, icon will be smaller and
92  * positioned at left.
93  *
94  * Simple example:
95  * @code
96  * sc = elm_segment_control_add(win);
97  * ic = elm_icon_add(win);
98  * elm_icon_file_set(ic, "path/to/image", NULL);
99  * elm_icon_scale_set(ic, EINA_TRUE, EINA_TRUE);
100  * elm_segment_control_item_add(sc, ic, "label");
101  * evas_object_show(sc);
102  * @endcode
103  *
104  * @see elm_segment_control_item_insert_at()
105  * @see elm_segment_control_item_del()
106  *
107  * @ingroup SegmentControl
108  */
109 EAPI Elm_Object_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label);
110
111 /**
112  * Insert a new item to the segment control object at specified position.
113  *
114  * @param obj The segment control object.
115  * @param icon The icon object to use for the left side of the item. An
116  * icon can be any Evas object, but usually it is an icon created
117  * with elm_icon_add().
118  * @param label The label of the item.
119  * @param index Item position. Value should be between 0 and items count.
120  * @return The created item or @c NULL upon failure.
121
122  * Index values must be between @c 0, when item will be prepended to
123  * segment control, and items count, that can be get with
124  * elm_segment_control_item_count_get(), case when item will be appended
125  * to segment control, just like elm_segment_control_item_add().
126  *
127  * Items created with this function can be deleted with function
128  * elm_segment_control_item_del() or elm_segment_control_item_del_at().
129  *
130  * @note @p label set to @c NULL is different from empty string "".
131  * If an item
132  * only has icon, it will be displayed bigger and centered. If it has
133  * icon and label, even that an empty string, icon will be smaller and
134  * positioned at left.
135  *
136  * @see elm_segment_control_item_add()
137  * @see elm_segment_control_item_count_get()
138  * @see elm_segment_control_item_del()
139  *
140  * @ingroup SegmentControl
141  */
142 EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
143
144 /**
145  * Remove a segment control item from its parent, deleting it.
146  *
147  * @param it The item to be removed.
148  *
149  * Items can be added with elm_segment_control_item_add() or
150  * elm_segment_control_item_insert_at().
151  *
152  * @ingroup SegmentControl
153  */
154 EAPI void              elm_segment_control_item_del(Elm_Object_Item *it);
155
156 /**
157  * Remove a segment control item at given index from its parent,
158  * deleting it.
159  *
160  * @param obj The segment control object.
161  * @param index The position of the segment control item to be deleted.
162  *
163  * Items can be added with elm_segment_control_item_add() or
164  * elm_segment_control_item_insert_at().
165  *
166  * @ingroup SegmentControl
167  */
168 EAPI void              elm_segment_control_item_del_at(Evas_Object *obj, int index);
169
170 /**
171  * Get the Segment items count from segment control.
172  *
173  * @param obj The segment control object.
174  * @return Segment items count.
175  *
176  * It will just return the number of items added to segment control @p obj.
177  *
178  * @ingroup SegmentControl
179  */
180 EAPI int               elm_segment_control_item_count_get(const Evas_Object *obj);
181
182 /**
183  * Get the item placed at specified index.
184  *
185  * @param obj The segment control object.
186  * @param index The index of the segment item.
187  * @return The segment control item or @c NULL on failure.
188  *
189  * Index is the position of an item in segment control widget. Its
190  * range is from @c 0 to <tt> count - 1 </tt>.
191  * Count is the number of items, that can be get with
192  * elm_segment_control_item_count_get().
193  *
194  * @ingroup SegmentControl
195  */
196 EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int index);
197
198 /**
199  * Get the label of item.
200  *
201  * @param obj The segment control object.
202  * @param index The index of the segment item.
203  * @return The label of the item at @p index.
204  *
205  * The return value is a pointer to the label associated to the item when
206  * it was created, with function elm_segment_control_item_add(), or later
207  * with function elm_segment_control_item_label_set. If no label
208  * was passed as argument, it will return @c NULL.
209  *
210  * @see elm_segment_control_item_label_set() for more details.
211  * @see elm_segment_control_item_add()
212  *
213  * @ingroup SegmentControl
214  */
215 EAPI const char       *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
216
217 /**
218  * Get the icon associated to the item.
219  *
220  * @param obj The segment control object.
221  * @param index The index of the segment item.
222  * @return The left side icon associated to the item at @p index.
223  *
224  * The return value is a pointer to the icon associated to the item when
225  * it was created, with function elm_segment_control_item_add(), or later
226  * with function elm_segment_control_item_icon_set(). If no icon
227  * was passed as argument, it will return @c NULL.
228  *
229  * @see elm_segment_control_item_add()
230  * @see elm_segment_control_item_icon_set()
231  *
232  * @ingroup SegmentControl
233  */
234 EAPI Evas_Object      *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
235
236 /**
237  * Get the index of an item.
238  *
239  * @param it The segment control item.
240  * @return The position of item in segment control widget.
241  *
242  * Index is the position of an item in segment control widget. Its
243  * range is from @c 0 to <tt> count - 1 </tt>.
244  * Count is the number of items, that can be get with
245  * elm_segment_control_item_count_get().
246  *
247  * @ingroup SegmentControl
248  */
249 EAPI int               elm_segment_control_item_index_get(const Elm_Object_Item *it);
250
251 /**
252  * Get the base object of the item.
253  *
254  * @param it The segment control item.
255  * @return The base object associated with @p it.
256  *
257  * Base object is the @c Evas_Object that represents that item.
258  *
259  * @ingroup SegmentControl
260  */
261 EAPI Evas_Object      *elm_segment_control_item_object_get(const Elm_Object_Item *it);
262
263 /**
264  * Get the selected item.
265  *
266  * @param obj The segment control object.
267  * @return The selected item or @c NULL if none of segment items is
268  * selected.
269  *
270  * The selected item can be unselected with function
271  * elm_segment_control_item_selected_set().
272  *
273  * The selected item always will be highlighted on segment control.
274  *
275  * @ingroup SegmentControl
276  */
277 EAPI Elm_Object_Item *elm_segment_control_item_selected_get(const Evas_Object *obj);
278
279 /**
280  * Set the selected state of an item.
281  *
282  * @param it The segment control item
283  * @param select The selected state
284  *
285  * This sets the selected state of the given item @p it.
286  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
287  *
288  * If a new item is selected the previosly selected will be unselected.
289  * Previoulsy selected item can be get with function
290  * elm_segment_control_item_selected_get().
291  *
292  * The selected item always will be highlighted on segment control.
293  *
294  * @see elm_segment_control_item_selected_get()
295  *
296  * @ingroup SegmentControl
297  */
298 EAPI void              elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);
299
300 /**
301  * @}
302  */