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