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.
18 using System.ComponentModel;
19 using System.Diagnostics;
21 namespace ElmSharp.Wearable
25 /// The Circle Spinner is a widget to display and handle the spinner value by the Rotary event.
26 /// Inherits <see cref="Spinner"/>.
28 /// <since_tizen> preview </since_tizen>
29 public class CircleSpinner : Spinner, IRotaryActionWidget
32 double _angleRatio = -1.0;
33 CircleSurface _surface;
36 /// Creates and initializes a new instance of the Circle Spinner class.
38 /// <param name="parent">The parent of the new Circle Spinner instance.</param>
39 /// <param name="surface">The surface for drawing circle features for this widget.</param>
40 /// <since_tizen> preview </since_tizen>
41 public CircleSpinner(EvasObject parent, CircleSurface surface) : base()
43 Debug.Assert(parent == null || surface == null || parent.IsRealized);
49 /// Creates and initializes a new instance of the Circle Spinner class.
51 /// <param name="parent">The parent of the new Circle Spinner instance.</param>
52 /// <since_tizen> preview </since_tizen>
53 [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public CircleSpinner(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
57 ((IRotaryActionWidget)this).Activate();
61 /// Gets the handle for Circle widget.
63 /// <since_tizen> preview </since_tizen>
64 public virtual IntPtr CircleHandle => _circleHandle;
67 /// Gets the handle for the circle surface used in this widget.
69 /// <since_tizen> preview </since_tizen>
70 public virtual CircleSurface CircleSurface => _surface;
73 /// Sets or gets the circle spinner angle per each spinner value.
75 /// <since_tizen> preview </since_tizen>
76 [Obsolete("Use Step")]
77 [EditorBrowsable(EditorBrowsableState.Never)]
78 public double AngleRatio
84 if(Maximum == Minimum)
90 return 360/(Maximum - Minimum);
100 if (_angleRatio == value) return;
104 Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
110 /// Sets or gets the disabled state of this widget.
112 /// <since_tizen> preview </since_tizen>
113 [Obsolete("Use IsEnabled")]
114 [EditorBrowsable(EditorBrowsableState.Never)]
118 set => IsEnabled = !value;
122 /// Sets or gets the state of the widget, which might be enabled or disabled.
124 /// <since_tizen> preview </since_tizen>
125 public override bool IsEnabled
129 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
133 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
138 /// Sets or gets the line width of the marker.
140 /// <since_tizen> preview </since_tizen>
141 public int MarkerLineWidth
145 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
149 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
154 /// Sets or gets the color of the marker.
156 /// <since_tizen> preview </since_tizen>
157 public Color MarkerColor
162 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
163 return new Color(r, g, b, a);
167 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
172 /// Sets or gets the radius at which the center of the marker lies.
174 /// <since_tizen> preview </since_tizen>
175 public double MarkerRadius
179 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
183 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
188 /// Creates a widget handle.
190 /// <param name="parent">Parent EvasObject.</param>
191 /// <returns>Handle IntPtr.</returns>
192 /// <since_tizen> preview </since_tizen>
193 protected override IntPtr CreateHandle(EvasObject parent)
195 IntPtr handle = base.CreateHandle(parent);
196 _circleHandle = Interop.Eext.eext_circle_object_spinner_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);