2 * @defgroup SegmentControl SegmentControl
5 * @image html segment_control_inheritance_tree.png
6 * @image latex segment_control_inheritance_tree.eps
8 * @image html img/widget/segment_control/preview-00.png
9 * @image latex img/widget/segment_control/preview-00.eps width=\textwidth
11 * @image html img/segment_control.png
12 * @image latex img/segment_control.eps width=\textwidth
14 * Segment control widget is a horizontal control made of multiple segment
15 * items, each segment item functioning similar to discrete two state button.
16 * A segment control groups the items together and provides compact
17 * single button with multiple equal size segments.
19 * Segment item size is determined by base widget
20 * size and the number of items added.
21 * Only one segment item can be at selected state. A segment item can display
22 * combination of Text and any Evas_Object like Images or other widget.
24 * This widget inherits from the @ref Layout one, so that all the
25 * functions acting on it also work for segment control objects.
27 * This widget emits the following signals, besides the ones sent from
29 * - @c "changed" - When the user clicks on a segment item which is not
30 * previously selected and get selected. The event_info parameter is the
31 * segment item pointer.
33 * Available styles for it:
36 * Default content parts of the segment control items that you can use for are:
37 * @li "icon" - An icon in a segment control item
39 * Default text parts of the segment control items that you can use for are:
40 * @li "default" - Title label in a segment control item
42 * Supported elm_object common APIs.
43 * @li elm_object_disabled_set
44 * @li elm_object_disabled_get
46 * Supported elm_object_item common APIs.
47 * @li @ref elm_object_item_part_text_set
48 * @li @ref elm_object_item_part_text_get
49 * @li @ref elm_object_item_part_content_set
50 * @li @ref elm_object_item_part_content_get
52 * Here is an example on its usage:
53 * @li @ref segment_control_example
58 * @addtogroup SegmentControl
63 * Add a new segment control widget to the given parent Elementary
66 * @param parent The parent object.
67 * @return a new segment control widget handle or @c NULL, on errors.
69 * This function inserts a new segment control widget on the canvas.
71 * @ingroup SegmentControl
73 EAPI Evas_Object *elm_segment_control_add(Evas_Object *parent);
76 * Append a new item to the segment control object.
78 * @param obj The segment control object.
79 * @param icon The icon object to use for the left side of the item. An
80 * icon can be any Evas object, but usually it is an icon created
81 * with elm_icon_add().
82 * @param label The label of the item.
83 * Note that, NULL is different from empty string "".
84 * @return The created item or @c NULL upon failure.
86 * A new item will be created and appended to the segment control, i.e., will
87 * be set as @b last item.
89 * If it should be inserted at another position,
90 * elm_segment_control_item_insert_at() should be used instead.
92 * Items created with this function can be deleted with function
93 * elm_object_item_del() or elm_object_item_del_at().
95 * @note @p label set to @c NULL is different from empty string "".
97 * only has icon, it will be displayed bigger and centered. If it has
98 * icon and label, even that an empty string, icon will be smaller and
103 * sc = elm_segment_control_add(win);
104 * ic = elm_icon_add(win);
105 * elm_image_file_set(ic, "path/to/image", NULL);
106 * elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
107 * elm_segment_control_item_add(sc, ic, "label");
108 * evas_object_show(sc);
111 * @see elm_segment_control_item_insert_at()
112 * @see elm_object_item_del()
114 * @ingroup SegmentControl
116 EAPI Elm_Object_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label);
119 * Insert a new item to the segment control object at specified position.
121 * @param obj The segment control object.
122 * @param icon The icon object to use for the left side of the item. An
123 * icon can be any Evas object, but usually it is an icon created
124 * with elm_icon_add().
125 * @param label The label of the item.
126 * @param index Item position. Value should be between 0 and items count.
127 * @return The created item or @c NULL upon failure.
129 * Index values must be between @c 0, when item will be prepended to
130 * segment control, and items count, that can be get with
131 * elm_segment_control_item_count_get(), case when item will be appended
132 * to segment control, just like elm_segment_control_item_add().
134 * Items created with this function can be deleted with function
135 * elm_object_item_del() or elm_segment_control_item_del_at().
137 * @note @p label set to @c NULL is different from empty string "".
139 * only has icon, it will be displayed bigger and centered. If it has
140 * icon and label, even that an empty string, icon will be smaller and
141 * positioned at left.
143 * @see elm_segment_control_item_add()
144 * @see elm_segment_control_item_count_get()
145 * @see elm_object_item_del()
147 * @ingroup SegmentControl
149 EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
152 * Remove a segment control item at given index from its parent,
155 * @param obj The segment control object.
156 * @param index The position of the segment control item to be deleted.
158 * Items can be added with elm_segment_control_item_add() or
159 * elm_segment_control_item_insert_at().
161 * @ingroup SegmentControl
163 EAPI void elm_segment_control_item_del_at(Evas_Object *obj, int index);
166 * Get the Segment items count from segment control.
168 * @param obj The segment control object.
169 * @return Segment items count.
171 * It will just return the number of items added to segment control @p obj.
173 * @ingroup SegmentControl
175 EAPI int elm_segment_control_item_count_get(const Evas_Object *obj);
178 * Get the item placed at specified index.
180 * @param obj The segment control object.
181 * @param index The index of the segment item.
182 * @return The segment control item or @c NULL on failure.
184 * Index is the position of an item in segment control widget. Its
185 * range is from @c 0 to <tt> count - 1 </tt>.
186 * Count is the number of items, that can be get with
187 * elm_segment_control_item_count_get().
189 * @ingroup SegmentControl
191 EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int index);
194 * Get the label of item.
196 * @param obj The segment control object.
197 * @param index The index of the segment item.
198 * @return The label of the item at @p index.
200 * The return value is a pointer to the label associated to the item when
201 * it was created, with function elm_segment_control_item_add(), or later
202 * with function elm_object_item_text_set. If no label
203 * was passed as argument, it will return @c NULL.
205 * @see elm_object_item_text_set() for more details.
206 * @see elm_segment_control_item_add()
208 * @ingroup SegmentControl
210 EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
213 * Get the icon associated to the item.
215 * @param obj The segment control object.
216 * @param index The index of the segment item.
217 * @return The left side icon associated to the item at @p index.
219 * The return value is a pointer to the icon associated to the item when
220 * it was created, with function elm_segment_control_item_add(), or later
221 * with function elm_object_item_part_content_set(). If no icon
222 * was passed as argument, it will return @c NULL.
224 * @see elm_segment_control_item_add()
225 * @see elm_object_item_part_content_set()
227 * @ingroup SegmentControl
229 EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
232 * Get the index of an item.
234 * @param it The segment control item.
235 * @return The position of item in segment control widget.
237 * Index is the position of an item in segment control widget. Its
238 * range is from @c 0 to <tt> count - 1 </tt>.
239 * Count is the number of items, that can be get with
240 * elm_segment_control_item_count_get().
242 * @ingroup SegmentControl
244 EAPI int elm_segment_control_item_index_get(const Elm_Object_Item *it);
247 * Get the base object of the item.
249 * @param it The segment control item.
250 * @return The base object associated with @p it.
252 * Base object is the @c Evas_Object that represents that item.
254 * @ingroup SegmentControl
256 EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Object_Item *it);
259 * Get the selected item.
261 * @param obj The segment control object.
262 * @return The selected item or @c NULL if none of segment items is
265 * The selected item can be unselected with function
266 * elm_segment_control_item_selected_set().
268 * The selected item always will be highlighted on segment control.
270 * @ingroup SegmentControl
272 EAPI Elm_Object_Item *elm_segment_control_item_selected_get(const Evas_Object *obj);
275 * Set the selected state of an item.
277 * @param it The segment control item
278 * @param select The selected state
280 * This sets the selected state of the given item @p it.
281 * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
283 * If a new item is selected the previously selected will be unselected.
284 * Selected item can be got with function
285 * elm_segment_control_item_selected_get().
287 * The selected item always will be highlighted on segment control.
289 * @see elm_segment_control_item_selected_get()
291 * @ingroup SegmentControl
293 EAPI void elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);