2 * @defgroup SegmentControl SegmentControl
5 * @image html img/widget/segment_control/preview-00.png
6 * @image latex img/widget/segment_control/preview-00.eps width=\textwidth
8 * @image html img/segment_control.png
9 * @image latex img/segment_control.eps width=\textwidth
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.
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.
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.
26 * Available styles for it:
29 * Here is an example on its usage:
30 * @li @ref segment_control_example
34 * @addtogroup SegmentControl
39 * Add a new segment control widget to the given parent Elementary
42 * @param parent The parent object.
43 * @return a new segment control widget handle or @c NULL, on errors.
45 * This function inserts a new segment control widget on the canvas.
47 * @ingroup SegmentControl
49 EAPI Evas_Object *elm_segment_control_add(Evas_Object *parent);
52 * Append a new item to the segment control object.
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.
62 * A new item will be created and appended to the segment control, i.e., will
63 * be set as @b last item.
65 * If it should be inserted at another position,
66 * elm_segment_control_item_insert_at() should be used instead.
68 * Items created with this function can be deleted with function
69 * elm_segment_control_item_del() or elm_segment_control_item_del_at().
71 * @note @p label set to @c NULL is different from empty string "".
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
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);
87 * @see elm_segment_control_item_insert_at()
88 * @see elm_segment_control_item_del()
90 * @ingroup SegmentControl
92 EAPI Elm_Object_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label);
95 * Insert a new item to the segment control object at specified position.
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.
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().
110 * Items created with this function can be deleted with function
111 * elm_segment_control_item_del() or elm_segment_control_item_del_at().
113 * @note @p label set to @c NULL is different from empty string "".
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.
119 * @see elm_segment_control_item_add()
120 * @see elm_segment_control_item_count_get()
121 * @see elm_segment_control_item_del()
123 * @ingroup SegmentControl
125 EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
128 * Remove a segment control item from its parent, deleting it.
130 * @param it The item to be removed.
132 * Items can be added with elm_segment_control_item_add() or
133 * elm_segment_control_item_insert_at().
135 * @ingroup SegmentControl
137 EAPI void elm_segment_control_item_del(Elm_Object_Item *it);
140 * Remove a segment control item at given index from its parent,
143 * @param obj The segment control object.
144 * @param index The position of the segment control item to be deleted.
146 * Items can be added with elm_segment_control_item_add() or
147 * elm_segment_control_item_insert_at().
149 * @ingroup SegmentControl
151 EAPI void elm_segment_control_item_del_at(Evas_Object *obj, int index);
154 * Get the Segment items count from segment control.
156 * @param obj The segment control object.
157 * @return Segment items count.
159 * It will just return the number of items added to segment control @p obj.
161 * @ingroup SegmentControl
163 EAPI int elm_segment_control_item_count_get(const Evas_Object *obj);
166 * Get the item placed at specified index.
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.
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().
177 * @ingroup SegmentControl
179 EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int index);
182 * Get the label of item.
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.
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.
193 * @see elm_segment_control_item_label_set() for more details.
194 * @see elm_segment_control_item_add()
196 * @ingroup SegmentControl
198 EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
201 * Set the label of item.
203 * @param it The item of segment control.
204 * @param text The label of item.
206 * The label to be displayed by the item.
207 * Label will be at right of the icon (if set).
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.
213 * @see elm_segment_control_item_label_get()
214 * @see elm_segment_control_item_add()
216 * @ingroup SegmentControl
218 EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
221 * Get the icon associated to the item.
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.
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.
232 * @see elm_segment_control_item_add()
233 * @see elm_segment_control_item_icon_set()
235 * @ingroup SegmentControl
237 EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
240 * Set the icon associated to the item.
242 * @param it The segment control item.
243 * @param icon The icon object to associate with @p it.
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().
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.
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.
257 * @see elm_segment_control_item_add()
258 * @see elm_segment_control_item_icon_get()
260 * @ingroup SegmentControl
262 EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
265 * Get the index of an item.
267 * @param it The segment control item.
268 * @return The position of item in segment control widget.
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().
275 * @ingroup SegmentControl
277 EAPI int elm_segment_control_item_index_get(const Elm_Object_Item *it);
280 * Get the base object of the item.
282 * @param it The segment control item.
283 * @return The base object associated with @p it.
285 * Base object is the @c Evas_Object that represents that item.
287 * @ingroup SegmentControl
289 EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Object_Item *it);
292 * Get the selected item.
294 * @param obj The segment control object.
295 * @return The selected item or @c NULL if none of segment items is
298 * The selected item can be unselected with function
299 * elm_segment_control_item_selected_set().
301 * The selected item always will be highlighted on segment control.
303 * @ingroup SegmentControl
305 EAPI Elm_Object_Item *elm_segment_control_item_selected_get(const Evas_Object *obj);
308 * Set the selected state of an item.
310 * @param it The segment control item
311 * @param select The selected state
313 * This sets the selected state of the given item @p it.
314 * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
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().
320 * The selected item always will be highlighted on segment control.
322 * @see elm_segment_control_item_selected_get()
324 * @ingroup SegmentControl
326 EAPI void elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);