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.Diagnostics;
20 namespace ElmSharp.Wearable
23 /// Circle scroller provides scrollbar with circular movement and is scrolled by rotary event.
25 public class CircleScroller : Scroller, IRotaryActionWidget
28 CircleSurface _surface;
31 /// Creates and initializes a new instance of the CircleScroller class.
33 /// <param name="parent">The <see cref="EvasObject"/> to which the new CircleScroller will be attached as a child.</param>
34 /// <param name="surface">The surface for drawing circle features for this widget.</param>
35 public CircleScroller(EvasObject parent, CircleSurface surface) : base()
37 Debug.Assert(parent == null || surface == null || parent.IsRealized);
43 /// Gets the handle for Circle Widget.
45 public virtual IntPtr CircleHandle => _circleHandle;
48 /// Gets the handle for Circle Surface used in this widget
50 public virtual CircleSurface CircleSurface => _surface;
53 /// Sets or gets the state of the widget, which might be enabled or disabled.
55 public override bool IsEnabled
59 return !Interop.Eext.eext_circle_object_disabled_get(Handle);
63 Interop.Eext.eext_circle_object_disabled_set(Handle, !value);
68 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
71 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
72 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
74 public override ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
79 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, out policy, IntPtr.Zero);
80 return (ScrollBarVisiblePolicy)policy;
84 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
85 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)value, (int)v);
90 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
93 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
94 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
96 public override ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
101 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
102 return (ScrollBarVisiblePolicy)policy;
106 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
107 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)h, (int)value);
112 /// Sets or gets color of the vertical scroll bar.
114 public Color VerticalScrollBarColor
122 Interop.Eext.eext_circle_object_color_get(CircleHandle, out r, out g, out b, out a);
123 return Color.FromRgba(r, g, b, a);
127 Interop.Eext.eext_circle_object_color_set(CircleHandle, value.R, value.G, value.B, value.A);
132 /// Sets or gets color of the horizontal scroll bar.
134 public Color HorizontalScrollBarColor
142 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bar", out r, out g, out b, out a);
143 return Color.FromRgba(r, g, b, a);
147 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bar", value.R, value.G, value.B, value.A);
152 /// Sets or gets color of the vertical scroll background.
154 public Color VerticalScrollBackgroundColor
162 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
163 return Color.FromRgba(r, g, b, a);
167 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
172 /// Sets or gets color of the horizontal scroll background.
174 public Color HorizontalScrollBackgroundColor
182 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bg", out r, out g, out b, out a);
183 return Color.FromRgba(r, g, b, a);
187 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bg", value.R, value.G, value.B, value.A);
192 /// Sets or gets line width of the vertical scroll bar.
194 public int VerticalScrollBarLineWidth
198 return Interop.Eext.eext_circle_object_line_width_get(CircleHandle);
202 Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value);
207 /// Sets or gets line width of the horizontal scroll bar.
209 public int HorizontalScrollBarLineWidth
213 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bar");
217 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bar", value);
222 /// Sets or gets line width of the vertical scroll background.
224 public int VerticalScrollBackgroundLineWidth
228 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
232 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
237 /// Sets or gets line width of the horizontal scroll background.
239 public int HorizontalScrollBackgroundLineWidth
243 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bg");
247 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bg", value);
252 /// Sets or gets radius of the vertical scroll bar.
254 public double VerticalScrollBarRadius
258 return Interop.Eext.eext_circle_object_radius_get(CircleHandle);
262 Interop.Eext.eext_circle_object_radius_set(CircleHandle, value);
267 /// Sets or gets radius of the horizontal scroll bar.
269 public double HorizontalScrollBarRadius
273 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bar");
277 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bar", value);
282 /// Sets or gets radius of the vertical scroll background.
284 public double VerticalScrollBackgroundRadius
288 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
292 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
297 /// Sets or gets radius of the horizontal scroll background.
299 public double HorizontalScrollBackgroundRadius
303 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bg");
307 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bg", value);
312 /// Creates a widget handle.
314 /// <param name="parent">Parent EvasObject</param>
315 /// <returns>Handle IntPtr</returns>
316 protected override IntPtr CreateHandle(EvasObject parent)
318 IntPtr handle = base.CreateHandle(parent);
319 _circleHandle = Interop.Eext.eext_circle_object_scroller_add(RealHandle == IntPtr.Zero ? Handle : RealHandle, CircleSurface.Handle);