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 public class CircleGenList : GenList, IRotaryActionWidget
30 CircleSurface _surface;
33 /// Creates and initializes a new instance of the Circle GenList class
35 /// <param name="parent">The parent of new Circle GenList instance</param>
36 /// <param name="surface">The surface for drawing circle features for this widget.</param>
37 public CircleGenList(EvasObject parent, CircleSurface surface) : base()
39 Debug.Assert(parent == null || surface == null || parent.IsRealized);
45 /// Creates and initializes a new instance of the Circle GenList class.
47 /// <param name="parent">The parent of new Circle CircleGenList instance</param>
48 [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public CircleGenList(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
52 ((IRotaryActionWidget)this).Activate();
56 /// Gets the handle for Circle Widget.
58 public virtual IntPtr CircleHandle => _circleHandle;
61 /// Gets the handle for Circle Surface used in this widget
63 public virtual CircleSurface CircleSurface => _surface;
66 /// Sets or gets disabled state of this widget.
68 [Obsolete("Use IsEnabled")]
69 [EditorBrowsable(EditorBrowsableState.Never)]
73 set => IsEnabled = !value;
77 /// Sets or gets the state of the widget, which might be enabled or disabled.
79 public override bool IsEnabled
83 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
87 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
92 /// Sets or gets the color of the scroll background
94 public Color VerticalScrollBackgroundColor
99 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
100 return new Color(r, g, b, a);
104 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
109 /// Sets or gets the line width of the scroll background
111 public int VerticalScrollBackgroundLineWidth
115 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
119 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
124 /// Sets or gets the redius of the scroll background
126 public double VerticalScrollBackgroundRadius
130 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
134 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
139 /// Sets or gets the color of the scroll bar
141 public Color VerticalScrollBarColor
146 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
147 return new Color(r, g, b, a);
151 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
156 /// Sets or gets the line width of the scroll bar
158 public int VerticalScrollBarLineWidth
162 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
166 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
171 /// Sets or gets the redius of the scroll bar
173 public double VerticalScrollBarRadius
177 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
181 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
186 /// Sets or gets the policy if the scroll bar is visible
189 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
190 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
192 public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
197 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
198 return (ScrollBarVisiblePolicy)policy;
203 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, out h, IntPtr.Zero);
204 Interop.Eext.eext_circle_object_genlist_scroller_policy_set(CircleHandle, (int)h, (int)value);
209 /// Creates a widget handle.
211 /// <param name="parent">Parent EvasObject</param>
212 /// <returns>Handle IntPtr</returns>
213 protected override IntPtr CreateHandle(EvasObject parent)
215 var handle = base.CreateHandle(parent);
216 _circleHandle = Interop.Eext.eext_circle_object_genlist_add(RealHandle == IntPtr.Zero ? Handle : RealHandle, CircleSurface.Handle);