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.
19 namespace ElmSharp.Wearable
22 /// Circle scroller provides scrollbar with circular movement and is scrolled by rotary event.
24 public class CircleScroller : Scroller
26 private IntPtr _circleHandle;
29 /// Creates and initializes a new instance of the CircleScroller class.
31 /// <param name="parent">The <see cref="EvasObject"/> to which the new CircleScroller will be attached as a child.</param>
32 public CircleScroller(EvasObject parent) : base(parent)
37 /// Sets or gets disabled state of the circle scroller object.
43 return Interop.Eext.eext_circle_object_disabled_get(_circleHandle); ;
47 Interop.Eext.eext_circle_object_disabled_set(_circleHandle, value);
52 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
55 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
56 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
58 public override ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
63 Interop.Eext.eext_circle_object_scroller_policy_get(_circleHandle, out policy, IntPtr.Zero);
64 return (ScrollBarVisiblePolicy)policy;
68 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
69 Interop.Eext.eext_circle_object_scroller_policy_set(_circleHandle, (int)value, (int)v);
74 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
77 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
78 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
80 public override ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
85 Interop.Eext.eext_circle_object_scroller_policy_get(_circleHandle, IntPtr.Zero, out policy);
86 return (ScrollBarVisiblePolicy)policy;
90 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
91 Interop.Eext.eext_circle_object_scroller_policy_set(_circleHandle, (int)h, (int)value);
96 /// Sets or gets color of the vertical scroll bar.
98 public Color VerticalScrollBarColor
106 Interop.Eext.eext_circle_object_color_get(_circleHandle, out r, out g, out b, out a);
107 return Color.FromRgba(r, g, b, a);
111 Interop.Eext.eext_circle_object_color_set(_circleHandle, value.R, value.G, value.B, value.A);
116 /// Sets or gets color of the horizontal scroll bar.
118 public Color HorizontalScrollBarColor
126 Interop.Eext.eext_circle_object_item_color_get(_circleHandle, "horizontal,scroll,bar", out r, out g, out b, out a);
127 return Color.FromRgba(r, g, b, a);
131 Interop.Eext.eext_circle_object_item_color_set(_circleHandle, "horizontal,scroll,bar", value.R, value.G, value.B, value.A);
136 /// Sets or gets color of the vertical scroll background.
138 public Color VerticalScrollBackgroundColor
146 Interop.Eext.eext_circle_object_item_color_get(_circleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
147 return Color.FromRgba(r, g, b, a);
151 Interop.Eext.eext_circle_object_item_color_set(_circleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
156 /// Sets or gets color of the horizontal scroll background.
158 public Color HorizontalScrollBackgroundColor
166 Interop.Eext.eext_circle_object_item_color_get(_circleHandle, "horizontal,scroll,bg", out r, out g, out b, out a);
167 return Color.FromRgba(r, g, b, a);
171 Interop.Eext.eext_circle_object_item_color_set(_circleHandle, "horizontal,scroll,bg", value.R, value.G, value.B, value.A);
176 /// Sets or gets line width of the vertical scroll bar.
178 public int VerticalScrollBarLineWidth
182 return Interop.Eext.eext_circle_object_line_width_get(_circleHandle); ;
186 Interop.Eext.eext_circle_object_line_width_set(_circleHandle, value);
191 /// Sets or gets line width of the horizontal scroll bar.
193 public int HorizontalScrollBarLineWidth
197 return Interop.Eext.eext_circle_object_item_line_width_get(_circleHandle, "horizontal,scroll,bar");
201 Interop.Eext.eext_circle_object_item_line_width_set(_circleHandle, "horizontal,scroll,bar", value);
206 /// Sets or gets line width of the vertical scroll background.
208 public int VerticalScrollBackgroundLineWidth
212 return Interop.Eext.eext_circle_object_item_line_width_get(_circleHandle, "vertical,scroll,bg");
216 Interop.Eext.eext_circle_object_item_line_width_set(_circleHandle, "vertical,scroll,bg", value);
221 /// Sets or gets line width of the horizontal scroll background.
223 public int HorizontalScrollBackgroundLineWidth
227 return Interop.Eext.eext_circle_object_item_line_width_get(_circleHandle, "horizontal,scroll,bg");
231 Interop.Eext.eext_circle_object_item_line_width_set(_circleHandle, "horizontal,scroll,bg", value);
236 /// Sets or gets radius of the vertical scroll bar.
238 public double VerticalScrollBarRadius
242 return Interop.Eext.eext_circle_object_radius_get(_circleHandle); ;
246 Interop.Eext.eext_circle_object_radius_set(_circleHandle, value);
251 /// Sets or gets radius of the horizontal scroll bar.
253 public double HorizontalScrollBarRadius
257 return Interop.Eext.eext_circle_object_item_radius_get(_circleHandle, "horizontal,scroll,bar"); ;
261 Interop.Eext.eext_circle_object_item_radius_set(_circleHandle, "horizontal,scroll,bar", value);
266 /// Sets or gets radius of the vertical scroll background.
268 public double VerticalScrollBackgroundRadius
272 return Interop.Eext.eext_circle_object_item_radius_get(_circleHandle, "vertical,scroll,bg"); ;
276 Interop.Eext.eext_circle_object_item_radius_set(_circleHandle, "vertical,scroll,bg", value);
281 /// Sets or gets radius of the horizontal scroll background.
283 public double HorizontalScrollBackgroundRadius
287 return Interop.Eext.eext_circle_object_item_radius_get(_circleHandle, "horizontal,scroll,bg"); ;
291 Interop.Eext.eext_circle_object_item_radius_set(_circleHandle, "horizontal,scroll,bg", value);
295 protected override IntPtr CreateHandle(EvasObject parent)
297 IntPtr handle = base.CreateHandle(parent);
298 IntPtr surface = IntPtr.Zero;
299 if (parent is Conformant)
301 surface = Interop.Eext.eext_circle_surface_conformant_add(parent);
303 else if (parent is Layout)
305 surface = Interop.Eext.eext_circle_surface_layout_add(parent);
307 else if (parent is Naviframe)
309 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
312 _circleHandle = Interop.Eext.eext_circle_object_scroller_add(RealHandle, surface);
313 if (surface == IntPtr.Zero)
315 EvasObject p = parent;
316 while (!(p is Window))
320 var w = (p as Window).ScreenSize.Width;
321 var h = (p as Window).ScreenSize.Height;
322 Interop.Evas.evas_object_resize(_circleHandle, w, h);
324 Interop.Eext.eext_rotary_object_event_activated_set(_circleHandle, true);