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 spinner value by 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 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 new Circle CircleSpinner 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 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 public double AngleRatio
85 Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
90 /// Sets or gets disabled state of this widget.
92 /// <since_tizen> preview </since_tizen>
93 [Obsolete("Use IsEnabled")]
94 [EditorBrowsable(EditorBrowsableState.Never)]
98 set => IsEnabled = !value;
102 /// Sets or gets the state of the widget, which might be enabled or disabled.
104 /// <since_tizen> preview </since_tizen>
105 public override bool IsEnabled
109 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
113 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
118 /// Sets or gets the line width of the marker
120 /// <since_tizen> preview </since_tizen>
121 public int MarkerLineWidth
125 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
129 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
134 /// Sets or gets the color of the marker
136 /// <since_tizen> preview </since_tizen>
137 public Color MarkerColor
142 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
143 return new Color(r, g, b, a);
147 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
152 /// Sets or gets the radius at which the center of the marker lies
154 /// <since_tizen> preview </since_tizen>
155 public double MarkerRadius
159 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
163 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
168 /// Creates a widget handle.
170 /// <param name="parent">Parent EvasObject</param>
171 /// <returns>Handle IntPtr</returns>
172 /// <since_tizen> preview </since_tizen>
173 protected override IntPtr CreateHandle(EvasObject parent)
175 IntPtr handle = base.CreateHandle(parent);
176 _circleHandle = Interop.Eext.eext_circle_object_spinner_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);