2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 /// The Spinner is a widget that increases or decreases the numeric values using arrow buttons, or edit values directly.
23 /// Inherits <see cref="Layout"/>.
25 /// <since_tizen> preview </since_tizen>
26 public class Spinner : Layout
28 double _minimum = 0.0;
29 double _maximum = 100.0;
32 SmartEvent _delayedChanged;
35 /// Creates and initializes a new instance of the Spinner class.
37 /// <param name="parent">The parent of new Spinner instance</param>
38 /// <since_tizen> preview </since_tizen>
39 public Spinner(EvasObject parent) : base(parent)
41 if (Elementary.GetProfile() == "tv")
48 /// Creates and initializes a new instance of the Layout class.
50 /// <since_tizen> preview </since_tizen>
51 protected Spinner() : base()
56 /// ValueChanged will be triggered whenever the spinner value is changed.
58 /// <since_tizen> preview </since_tizen>
59 public event EventHandler ValueChanged;
62 /// DelayedValueChanged will be triggered after a short time when the value is changed.
64 /// <since_tizen> preview </since_tizen>
65 public event EventHandler DelayedValueChanged;
68 /// Sets or gets the label format of the spinner.
70 /// <since_tizen> preview </since_tizen>
71 public string LabelFormat
75 return Interop.Elementary.elm_spinner_label_format_get(RealHandle);
79 Interop.Elementary.elm_spinner_label_format_set(RealHandle, value);
84 /// Sets or gets the minimum value for the spinner.
86 /// <since_tizen> preview </since_tizen>
96 Interop.Elementary.elm_spinner_min_max_set(RealHandle, _minimum, _maximum);
101 /// Sets or gets the maximum value for the spinner.
103 /// <since_tizen> preview </since_tizen>
104 public double Maximum
113 Interop.Elementary.elm_spinner_min_max_set(RealHandle, _minimum, _maximum);
118 /// Sets or gets the step that is used to increment or decrement the spinner value.
120 /// <since_tizen> preview </since_tizen>
125 return Interop.Elementary.elm_spinner_step_get(RealHandle);
129 Interop.Elementary.elm_spinner_step_set(RealHandle, value);
134 /// Sets or gets the value displayed by the spinner.
136 /// <since_tizen> preview </since_tizen>
141 return Interop.Elementary.elm_spinner_value_get(RealHandle);
145 Interop.Elementary.elm_spinner_value_set(RealHandle, value);
150 /// Sets or gets the interval on time updates for a user mouse button to hold on the spinner widgets' arrows.
152 /// <since_tizen> preview </since_tizen>
153 public double Interval
157 return Interop.Elementary.elm_spinner_interval_get(RealHandle);
161 Interop.Elementary.elm_spinner_interval_set(RealHandle, value);
166 /// Sets or gets the base for rounding.
168 /// <since_tizen> preview </since_tizen>
169 public double RoundBase
173 return Interop.Elementary.elm_spinner_base_get(RealHandle);
177 Interop.Elementary.elm_spinner_base_set(RealHandle, value);
182 /// Sets or gets the round value for rounding.
184 /// <since_tizen> preview </since_tizen>
185 public int RoundValue
189 return Interop.Elementary.elm_spinner_round_get(RealHandle);
193 Interop.Elementary.elm_spinner_round_set(RealHandle, value);
198 /// Sets or gets the wrap of a given spinner widget.
201 /// If wrap is disabled when the user tries to increment the value, but the displayed value plus step value is bigger than the maximum value, then the new value will be the maximum value.
202 /// If wrap is enabled when the user tries to increment the value, but the displayed value plus step value is bigger than the maximum value, then the new value will be the minimum value.
203 /// By default, it's disabled.
205 /// <since_tizen> preview </since_tizen>
206 public bool IsWrapEnabled
210 return Interop.Elementary.elm_spinner_wrap_get(RealHandle);
214 Interop.Elementary.elm_spinner_wrap_set(RealHandle, value);
219 /// Sets or gets whether the spinner can be directly edited by the user or not.
221 /// <remarks>By default, it is enabled.</remarks>
222 /// <since_tizen> preview </since_tizen>
223 public bool IsEditable
227 return Interop.Elementary.elm_spinner_editable_get(RealHandle);
231 Interop.Elementary.elm_spinner_editable_set(RealHandle, value);
236 /// Sets a special string to display in the place of the numerical value.
238 /// <param name="value">The numerical value to be replaced</param>
239 /// <param name="label">The label to be used</param>
240 /// <since_tizen> preview </since_tizen>
241 public void AddSpecialValue(double value, string label)
243 Interop.Elementary.elm_spinner_special_value_add(RealHandle, value, label);
247 /// Removes a previously added special value. After this, the spinner will display the value itself instead of a label.
249 /// <param name="value">The replaced numerical value.</param>
250 /// <since_tizen> preview </since_tizen>
251 public void RemoveSpecialValue(double value)
253 Interop.Elementary.elm_spinner_special_value_del(RealHandle, value);
257 /// Gets the special string display in the place of the numerical value.
259 /// <param name="value">The replaced numerical value.</param>
260 /// <returns>The value of the spinner, which replaced the numerical value with a special string.</returns>
261 /// <since_tizen> preview </since_tizen>
262 public string GetSpecialValue(double value)
264 return Interop.Elementary.elm_spinner_special_value_get(RealHandle, value);
268 /// The callback of the Realized event.
270 /// <since_tizen> preview </since_tizen>
271 protected override void OnRealized()
274 _changed = new SmartEvent(this, this.RealHandle, "changed");
275 _changed.On += (s, e) => ValueChanged?.Invoke(this, EventArgs.Empty);
277 _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed");
278 _delayedChanged.On += (s, e) => DelayedValueChanged?.Invoke(this, EventArgs.Empty);
282 /// Creates a widget handle.
284 /// <param name="parent">Parent EvasObject.</param>
285 /// <returns>Handle IntPtr.</returns>
286 /// <since_tizen> preview </since_tizen>
287 protected override IntPtr CreateHandle(EvasObject parent)
289 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
290 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
292 RealHandle = Interop.Elementary.elm_spinner_add(handle);
293 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);