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
24 /// The Circle GenList Selector is a widget to display and handle genlist items by rotary event
25 /// Inherits <see cref="GenList"/>
27 /// <since_tizen> preview </since_tizen>
28 public class CircleGenList : GenList, IRotaryActionWidget
31 CircleSurface _surface;
34 /// Creates and initializes a new instance of the Circle GenList class
36 /// <param name="parent">The parent of new Circle GenList instance</param>
37 /// <param name="surface">The surface for drawing circle features for this widget.</param>
38 /// <since_tizen> preview </since_tizen>
39 public CircleGenList(EvasObject parent, CircleSurface surface) : base()
41 Debug.Assert(parent == null || surface == null || parent.IsRealized);
47 /// Creates and initializes a new instance of the Circle GenList class.
49 /// <param name="parent">The parent of new Circle CircleGenList instance</param>
50 /// <since_tizen> preview </since_tizen>
51 [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
52 [EditorBrowsable(EditorBrowsableState.Never)]
53 public CircleGenList(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
55 ((IRotaryActionWidget)this).Activate();
59 /// Gets the handle for Circle Widget.
61 /// <since_tizen> preview </since_tizen>
62 public virtual IntPtr CircleHandle => _circleHandle;
65 /// Gets the handle for Circle Surface used in this widget
67 /// <since_tizen> preview </since_tizen>
68 public virtual CircleSurface CircleSurface => _surface;
71 /// Sets or gets disabled state of this widget.
73 /// <since_tizen> preview </since_tizen>
74 [Obsolete("Use IsEnabled")]
75 [EditorBrowsable(EditorBrowsableState.Never)]
79 set => IsEnabled = !value;
83 /// Sets or gets the state of the widget, which might be enabled or disabled.
85 /// <since_tizen> preview </since_tizen>
86 public override bool IsEnabled
90 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
94 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
99 /// Sets or gets the color of the scroll background
101 /// <since_tizen> preview </since_tizen>
102 public Color VerticalScrollBackgroundColor
107 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
108 return new Color(r, g, b, a);
112 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
117 /// Sets or gets the line width of the scroll background
119 /// <since_tizen> preview </since_tizen>
120 public int VerticalScrollBackgroundLineWidth
124 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
128 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
133 /// Sets or gets the redius of the scroll background
135 /// <since_tizen> preview </since_tizen>
136 public double VerticalScrollBackgroundRadius
140 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
144 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
149 /// Sets or gets the color of the scroll bar
151 /// <since_tizen> preview </since_tizen>
152 public Color VerticalScrollBarColor
157 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
158 return new Color(r, g, b, a);
162 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
167 /// Sets or gets the line width of the scroll bar
169 /// <since_tizen> preview </since_tizen>
170 public int VerticalScrollBarLineWidth
174 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
178 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
183 /// Sets or gets the redius of the scroll bar
185 /// <since_tizen> preview </since_tizen>
186 public double VerticalScrollBarRadius
190 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
194 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
199 /// Sets or gets the policy if the scroll bar is visible
202 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
203 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
205 /// <since_tizen> preview </since_tizen>
206 public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
211 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
212 return (ScrollBarVisiblePolicy)policy;
217 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, out h, IntPtr.Zero);
218 Interop.Eext.eext_circle_object_genlist_scroller_policy_set(CircleHandle, (int)h, (int)value);
223 /// Creates a widget handle.
225 /// <param name="parent">Parent EvasObject</param>
226 /// <returns>Handle IntPtr</returns>
227 /// <since_tizen> preview </since_tizen>
228 protected override IntPtr CreateHandle(EvasObject parent)
230 var handle = base.CreateHandle(parent);
231 _circleHandle = Interop.Eext.eext_circle_object_genlist_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);