Merge "[NUI] Setting since_tizen 3/4 on Tizen.NUI API" into rel/api_4
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / CircleGenList.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.ComponentModel;
19 using System.Diagnostics;
20
21 namespace ElmSharp.Wearable
22 {
23     /// <summary>
24     /// The Circle GenList Selector is a widget to display and handle genlist items by rotary event
25     /// Inherits <see cref="GenList"/>
26     /// </summary>
27     /// <since_tizen> preview </since_tizen>
28     public class CircleGenList : GenList, IRotaryActionWidget
29     {
30         IntPtr _circleHandle;
31         CircleSurface _surface;
32
33         /// <summary>
34         /// Creates and initializes a new instance of the Circle GenList class
35         /// </summary>
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()
40         {
41             Debug.Assert(parent == null || surface == null || parent.IsRealized);
42             _surface = surface;
43             Realize(parent);
44         }
45
46         /// <summary>
47         /// Creates and initializes a new instance of the Circle GenList class.
48         /// </summary>
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))
54         {
55             ((IRotaryActionWidget)this).Activate();
56         }
57
58         /// <summary>
59         /// Gets the handle for Circle Widget.
60         /// </summary>
61         /// <since_tizen> preview </since_tizen>
62         public virtual IntPtr CircleHandle => _circleHandle;
63
64         /// <summary>
65         /// Gets the handle for Circle Surface used in this widget
66         /// </summary>
67         /// <since_tizen> preview </since_tizen>
68         public virtual CircleSurface CircleSurface => _surface;
69
70         /// <summary>
71         /// Sets or gets disabled state of this widget.
72         /// </summary>
73         /// <since_tizen> preview </since_tizen>
74         [Obsolete("Use IsEnabled")]
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public bool Disabled
77         {
78             get => !IsEnabled;
79             set => IsEnabled = !value;
80         }
81
82         /// <summary>
83         /// Sets or gets the state of the widget, which might be enabled or disabled.
84         /// </summary>
85         /// <since_tizen> preview </since_tizen>
86         public override bool IsEnabled
87         {
88             get
89             {
90                 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
91             }
92             set
93             {
94                 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
95             }
96         }
97
98         /// <summary>
99         /// Sets or gets the color of the scroll background
100         /// </summary>
101         /// <since_tizen> preview </since_tizen>
102         public Color VerticalScrollBackgroundColor
103         {
104             get
105             {
106                 int r, g, b, a;
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);
109             }
110             set
111             {
112                 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
113             }
114         }
115
116         /// <summary>
117         /// Sets or gets the line width of the scroll background
118         /// </summary>
119         /// <since_tizen> preview </since_tizen>
120         public int VerticalScrollBackgroundLineWidth
121         {
122             get
123             {
124                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
125             }
126             set
127             {
128                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
129             }
130         }
131
132         /// <summary>
133         /// Sets or gets the redius of the scroll background
134         /// </summary>
135         /// <since_tizen> preview </since_tizen>
136         public double VerticalScrollBackgroundRadius
137         {
138             get
139             {
140                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
141             }
142             set
143             {
144                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
145             }
146         }
147
148         /// <summary>
149         /// Sets or gets the color of the scroll bar
150         /// </summary>
151         /// <since_tizen> preview </since_tizen>
152         public Color VerticalScrollBarColor
153         {
154             get
155             {
156                 int r, g, b, a;
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);
159             }
160             set
161             {
162                 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
163             }
164         }
165
166         /// <summary>
167         /// Sets or gets the line width of the scroll bar
168         /// </summary>
169         /// <since_tizen> preview </since_tizen>
170         public int VerticalScrollBarLineWidth
171         {
172             get
173             {
174                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
175             }
176             set
177             {
178                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
179             }
180         }
181
182         /// <summary>
183         /// Sets or gets the redius of the scroll bar
184         /// </summary>
185         /// <since_tizen> preview </since_tizen>
186         public double VerticalScrollBarRadius
187         {
188             get
189             {
190                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
191             }
192             set
193             {
194                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
195             }
196         }
197
198         /// <summary>
199         /// Sets or gets the policy if the scroll bar is visible
200         /// </summary>
201         /// <remarks>
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.
204         /// </remarks>
205         /// <since_tizen> preview </since_tizen>
206         public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
207         {
208             get
209             {
210                 int policy;
211                 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
212                 return (ScrollBarVisiblePolicy)policy;
213             }
214             set
215             {
216                 int h;
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);
219             }
220         }
221
222         /// <summary>
223         /// Creates a widget handle.
224         /// </summary>
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)
229         {
230             var handle = base.CreateHandle(parent);
231             _circleHandle = Interop.Eext.eext_circle_object_genlist_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);
232
233             return handle;
234         }
235     }
236 }