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 /// Circle scroller provides scrollbar with circular movement and is scrolled by rotary event.
26 public class CircleScroller : Scroller, IRotaryActionWidget
29 CircleSurface _surface;
32 /// Creates and initializes a new instance of the CircleScroller class.
34 /// <param name="parent">The <see cref="EvasObject"/> to which the new CircleScroller will be attached as a child.</param>
35 /// <param name="surface">The surface for drawing circle features for this widget.</param>
36 public CircleScroller(EvasObject parent, CircleSurface surface) : base()
38 Debug.Assert(parent == null || surface == null || parent.IsRealized);
44 /// Creates and initializes a new instance of the Circle Scroller class.
46 /// <param name="parent">The parent of new Circle CircleScroller instance</param>
47 [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
48 [EditorBrowsable(EditorBrowsableState.Never)]
49 public CircleScroller(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
51 ((IRotaryActionWidget)this).Activate();
55 /// Gets the handle for Circle Widget.
57 public virtual IntPtr CircleHandle => _circleHandle;
60 /// Gets the handle for Circle Surface used in this widget
62 public virtual CircleSurface CircleSurface => _surface;
65 /// Sets or gets disabled state of this widget.
67 [Obsolete("Use IsEnabled")]
68 [EditorBrowsable(EditorBrowsableState.Never)]
72 set => IsEnabled = !value;
76 /// Sets or gets the state of the widget, which might be enabled or disabled.
78 public override bool IsEnabled
82 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
86 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
91 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
94 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
95 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
97 public override ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
102 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, out policy, IntPtr.Zero);
103 return (ScrollBarVisiblePolicy)policy;
107 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
108 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)value, (int)v);
113 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
116 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
117 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
119 public override ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
124 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
125 return (ScrollBarVisiblePolicy)policy;
129 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
130 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)h, (int)value);
135 /// Sets or gets color of the vertical scroll bar.
137 public Color VerticalScrollBarColor
145 Interop.Eext.eext_circle_object_color_get(CircleHandle, out r, out g, out b, out a);
146 return Color.FromRgba(r, g, b, a);
150 Interop.Eext.eext_circle_object_color_set(CircleHandle, value.R, value.G, value.B, value.A);
155 /// Sets or gets color of the horizontal scroll bar.
157 public Color HorizontalScrollBarColor
165 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bar", out r, out g, out b, out a);
166 return Color.FromRgba(r, g, b, a);
170 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bar", value.R, value.G, value.B, value.A);
175 /// Sets or gets color of the vertical scroll background.
177 public Color VerticalScrollBackgroundColor
185 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
186 return Color.FromRgba(r, g, b, a);
190 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
195 /// Sets or gets color of the horizontal scroll background.
197 public Color HorizontalScrollBackgroundColor
205 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bg", out r, out g, out b, out a);
206 return Color.FromRgba(r, g, b, a);
210 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bg", value.R, value.G, value.B, value.A);
215 /// Sets or gets line width of the vertical scroll bar.
217 public int VerticalScrollBarLineWidth
221 return Interop.Eext.eext_circle_object_line_width_get(CircleHandle);
225 Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value);
230 /// Sets or gets line width of the horizontal scroll bar.
232 public int HorizontalScrollBarLineWidth
236 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bar");
240 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bar", value);
245 /// Sets or gets line width of the vertical scroll background.
247 public int VerticalScrollBackgroundLineWidth
251 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
255 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
260 /// Sets or gets line width of the horizontal scroll background.
262 public int HorizontalScrollBackgroundLineWidth
266 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bg");
270 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bg", value);
275 /// Sets or gets radius of the vertical scroll bar.
277 public double VerticalScrollBarRadius
281 return Interop.Eext.eext_circle_object_radius_get(CircleHandle);
285 Interop.Eext.eext_circle_object_radius_set(CircleHandle, value);
290 /// Sets or gets radius of the horizontal scroll bar.
292 public double HorizontalScrollBarRadius
296 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bar");
300 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bar", value);
305 /// Sets or gets radius of the vertical scroll background.
307 public double VerticalScrollBackgroundRadius
311 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
315 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
320 /// Sets or gets radius of the horizontal scroll background.
322 public double HorizontalScrollBackgroundRadius
326 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bg");
330 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bg", value);
335 /// Creates a widget handle.
337 /// <param name="parent">Parent EvasObject</param>
338 /// <returns>Handle IntPtr</returns>
339 protected override IntPtr CreateHandle(EvasObject parent)
341 IntPtr handle = base.CreateHandle(parent);
342 _circleHandle = Interop.Eext.eext_circle_object_scroller_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);