2 * @defgroup Spinner Spinner
5 * @image html img/widget/spinner/preview-00.png
6 * @image latex img/widget/spinner/preview-00.eps
8 * A spinner is a widget which allows the user to increase or decrease
9 * numeric values using arrow buttons, or edit values directly, clicking
10 * over it and typing the new value.
12 * By default the spinner will not wrap and has a label
13 * of "%.0f" (just showing the integer value of the double).
15 * A spinner has a label that is formatted with floating
16 * point values and thus accepts a printf-style format string, like
19 * It also allows specific values to be replaced by pre-defined labels.
21 * Smart callbacks one can register to:
23 * - "changed" - Whenever the spinner value is changed.
24 * - "delay,changed" - A short time after the value is changed by the user.
25 * This will be called only when the user stops dragging for a very short
26 * period or when they release their finger/mouse, so it avoids possibly
27 * expensive reactions to the value change.
29 * Available styles for it:
31 * - @c "vertical": up/down buttons at the right side and text left aligned.
33 * Supported elm_object common APIs.
34 * @li elm_object_signal_emit
35 * @li elm_object_signal_callback_add
36 * @li elm_object_signal_callback_del
37 * @li elm_object_disabled_set
38 * @li elm_object_disabled_get
40 * Here is an example on its usage:
41 * @ref spinner_example
50 * Add a new spinner widget to the given parent Elementary
53 * @param parent The parent object.
54 * @return a new spinner widget handle or @c NULL, on errors.
56 * This function inserts a new spinner widget on the canvas.
61 EAPI Evas_Object *elm_spinner_add(Evas_Object *parent);
64 * Set the format string of the displayed label.
66 * @param obj The spinner object.
67 * @param fmt The format string for the label display.
69 * If @c NULL, this sets the format to "%.0f". If not it sets the format
70 * string for the label text. The label text is provided a floating point
71 * value, so the label text can display up to 1 floating point value.
72 * Note that this is optional.
74 * Use a format string such as "%1.2f meters" for example, and it will
75 * display values like: "3.14 meters" for a value equal to 3.14159.
79 * @see elm_spinner_label_format_get()
83 EAPI void elm_spinner_label_format_set(Evas_Object *obj, const char *fmt);
86 * Get the label format of the spinner.
88 * @param obj The spinner object.
89 * @return The text label format string in UTF-8.
91 * @see elm_spinner_label_format_set() for details.
95 EAPI const char *elm_spinner_label_format_get(const Evas_Object *obj);
98 * Set the minimum and maximum values for the spinner.
100 * @param obj The spinner object.
101 * @param min The minimum value.
102 * @param max The maximum value.
104 * Define the allowed range of values to be selected by the user.
106 * If actual value is less than @p min, it will be updated to @p min. If it
107 * is bigger then @p max, will be updated to @p max. Actual value can be
108 * get with elm_spinner_value_get().
110 * By default, min is equal to 0, and max is equal to 100.
112 * @warning Maximum must be greater than minimum.
114 * @see elm_spinner_min_max_get()
118 EAPI void elm_spinner_min_max_set(Evas_Object *obj, double min, double max);
121 * Get the minimum and maximum values of the spinner.
123 * @param obj The spinner object.
124 * @param min Pointer to store the minimum value.
125 * @param max Pointer to store the maximum value.
127 * @note If only one value is needed, the other pointer can be passed
130 * @see elm_spinner_min_max_set() for details.
134 EAPI void elm_spinner_min_max_get(const Evas_Object *obj, double *min, double *max);
137 * Set the step used to increment or decrement the spinner value.
139 * @param obj The spinner object.
140 * @param step The step value.
142 * This value will be incremented or decremented to the displayed value.
143 * It will be incremented while the user keep right or top arrow pressed,
144 * and will be decremented while the user keep left or bottom arrow pressed.
146 * The interval to increment / decrement can be set with
147 * elm_spinner_interval_set().
149 * By default step value is equal to 1.
151 * @see elm_spinner_step_get()
155 EAPI void elm_spinner_step_set(Evas_Object *obj, double step);
158 * Get the step used to increment or decrement the spinner value.
160 * @param obj The spinner object.
161 * @return The step value.
163 * @see elm_spinner_step_get() for more details.
167 EAPI double elm_spinner_step_get(const Evas_Object *obj);
170 * Set the value the spinner displays.
172 * @param obj The spinner object.
173 * @param val The value to be displayed.
175 * Value will be presented on the label following format specified with
176 * elm_spinner_format_set().
178 * @warning The value must to be between min and max values. This values
179 * are set by elm_spinner_min_max_set().
181 * @see elm_spinner_value_get().
182 * @see elm_spinner_format_set().
183 * @see elm_spinner_min_max_set().
187 EAPI void elm_spinner_value_set(Evas_Object *obj, double val);
190 * Get the value displayed by the spinner.
192 * @param obj The spinner object.
193 * @return The value displayed.
195 * @see elm_spinner_value_set() for details.
199 EAPI double elm_spinner_value_get(const Evas_Object *obj);
202 * Set whether the spinner should wrap when it reaches its
203 * minimum or maximum value.
205 * @param obj The spinner object.
206 * @param wrap @c EINA_TRUE to enable wrap or @c EINA_FALSE to
209 * Disabled by default. If disabled, when the user tries to increment the
211 * but displayed value plus step value is bigger than maximum value,
213 * won't allow it. The same happens when the user tries to decrement it,
214 * but the value less step is less than minimum value.
216 * When wrap is enabled, in such situations it will allow these changes,
217 * but will get the value that would be less than minimum and subtracts
218 * from maximum. Or add the value that would be more than maximum to
224 * @li step value = 20
225 * @li displayed value = 20
227 * When the user decrement value (using left or bottom arrow), it will
228 * displays @c 40, because max - (min - (displayed - step)) is
229 * @c 50 - (@c 10 - (@c 20 - @c 20)) = @c 40.
231 * @see elm_spinner_wrap_get().
235 EAPI void elm_spinner_wrap_set(Evas_Object *obj, Eina_Bool wrap);
238 * Get whether the spinner should wrap when it reaches its
239 * minimum or maximum value.
241 * @param obj The spinner object
242 * @return @c EINA_TRUE means wrap is enabled. @c EINA_FALSE indicates
243 * it's disabled. If @p obj is @c NULL, @c EINA_FALSE is returned.
245 * @see elm_spinner_wrap_set() for details.
249 EAPI Eina_Bool elm_spinner_wrap_get(const Evas_Object *obj);
252 * Set whether the spinner can be directly edited by the user or not.
254 * @param obj The spinner object.
255 * @param editable @c EINA_TRUE to allow users to edit it or @c EINA_FALSE to
256 * don't allow users to edit it directly.
258 * Spinner objects can have edition @b disabled, in which state they will
259 * be changed only by arrows.
260 * Useful for contexts
261 * where you don't want your users to interact with it writing the value.
263 * when using special values, the user can see real value instead
264 * of special label on edition.
266 * It's enabled by default.
268 * @see elm_spinner_editable_get()
272 EAPI void elm_spinner_editable_set(Evas_Object *obj, Eina_Bool editable);
275 * Get whether the spinner can be directly edited by the user or not.
277 * @param obj The spinner object.
278 * @return @c EINA_TRUE means edition is enabled. @c EINA_FALSE indicates
279 * it's disabled. If @p obj is @c NULL, @c EINA_FALSE is returned.
281 * @see elm_spinner_editable_set() for details.
285 EAPI Eina_Bool elm_spinner_editable_get(const Evas_Object *obj);
288 * Set a special string to display in the place of the numerical value.
290 * @param obj The spinner object.
291 * @param value The value to be replaced.
292 * @param label The label to be used.
294 * It's useful for cases when a user should select an item that is
295 * better indicated by a label than a value. For example, weekdays or months.
299 * sp = elm_spinner_add(win);
300 * elm_spinner_min_max_set(sp, 1, 3);
301 * elm_spinner_special_value_add(sp, 1, "January");
302 * elm_spinner_special_value_add(sp, 2, "February");
303 * elm_spinner_special_value_add(sp, 3, "March");
304 * evas_object_show(sp);
309 EAPI void elm_spinner_special_value_add(Evas_Object *obj, double value, const char *label);
312 * Set the interval on time updates for an user mouse button hold
313 * on spinner widgets' arrows.
315 * @param obj The spinner object.
316 * @param interval The (first) interval value in seconds.
318 * This interval value is @b decreased while the user holds the
319 * mouse pointer either incrementing or decrementing spinner's value.
321 * This helps the user to get to a given value distant from the
322 * current one easier/faster, as it will start to change quicker and
323 * quicker on mouse button holds.
325 * The calculation for the next change interval value, starting from
326 * the one set with this call, is the previous interval divided by
327 * @c 1.05, so it decreases a little bit.
329 * The default starting interval value for automatic changes is
332 * @see elm_spinner_interval_get()
336 EAPI void elm_spinner_interval_set(Evas_Object *obj, double interval);
339 * Get the interval on time updates for an user mouse button hold
340 * on spinner widgets' arrows.
342 * @param obj The spinner object.
343 * @return The (first) interval value, in seconds, set on it.
345 * @see elm_spinner_interval_set() for more details.
349 EAPI double elm_spinner_interval_get(const Evas_Object *obj);
352 * Set the base for rounding
354 * @param obj The spinner object
355 * @param base The base value
357 * Rounding works as follows:
359 * rounded_val = base + (double)(((value - base) / round) * round)
361 * Where rounded_val, value and base are doubles, and round is an integer.
363 * This means that things will be rounded to increments (or decrements) of
364 * "round" starting from value @p base. The default base for rounding is 0.
366 * Example: round = 3, base = 2
367 * Values: 3, 6, 9, 12, 15, ...
369 * Example: round = 2, base = 5.5
370 * Values: 5.5, 7.5, 9.5, 11.5, ...
372 * @see elm_spinner_round_get()
373 * @see elm_spinner_base_get() too.
377 EAPI void elm_spinner_base_set(Evas_Object *obj, double base);
380 * Get the base for rounding
382 * @param obj The spinner object
383 * @return The base rounding value
385 * This returns the base for rounding.
387 * @see elm_spinner_round_set() too.
388 * @see elm_spinner_base_set() too.
392 EAPI double elm_spinner_base_get(const Evas_Object *obj);
395 * Set the round value for rounding
397 * @param obj The spinner object
398 * @param rnd The rounding value
400 * Sets the rounding value used for value rounding in the spinner.
402 * @see elm_spinner_round_get()
403 * @see elm_spinner_base_set()
407 EAPI void elm_spinner_round_set(Evas_Object *obj, int rnd);
410 * Get the round value for rounding
412 * @param obj The spinner object
413 * @return The rounding value
415 * This returns the round value for rounding.
417 * @see elm_spinner_round_set() too.
418 * @see elm_spinner_base_set() too.
422 EAPI int elm_spinner_round_get(const Evas_Object *obj);