Release 4.0.0-preview1-00285
[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
19 namespace ElmSharp.Wearable
20 {
21     /// <summary>
22     /// The Circle GenList Selector is a widget to display and handle genlist items by rotary event
23     /// Inherits <see cref="GenList"/>
24     /// </summary>
25     public class CircleGenList : GenList
26     {
27         IntPtr circleHandle;
28
29         /// <summary>
30         /// Creates and initializes a new instance of the Circle GenList class
31         /// </summary>
32         /// <param name="parent">The parent of new Circle GenList instance</param>
33         public CircleGenList(EvasObject parent) : base(parent) { }
34
35         /// <summary>
36         /// Sets or gets the disabled state of the Circle GenList Selector
37         /// </summary>
38         public bool Disabled
39         {
40             get
41             {
42                 return Interop.Eext.eext_circle_object_disabled_get(circleHandle);
43             }
44             set
45             {
46                 Interop.Eext.eext_circle_object_disabled_set(circleHandle, value);
47             }
48         }
49
50         /// <summary>
51         /// Sets or gets the color of the scroll background
52         /// </summary>
53         public Color VerticalScrollBackgroundColor
54         {
55             get
56             {
57                 int r, g, b, a;
58                 Interop.Eext.eext_circle_object_item_color_get(circleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
59                 return new Color(r, g, b, a);
60             }
61             set
62             {
63                 Interop.Eext.eext_circle_object_item_color_set(circleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
64             }
65         }
66
67         /// <summary>
68         /// Sets or gets the line width of the scroll background
69         /// </summary>
70         public int VerticalScrollBackgroundLineWidth
71         {
72             get
73             {
74                 return Interop.Eext.eext_circle_object_item_line_width_get(circleHandle, "vertical,scroll,bg");
75             }
76             set
77             {
78                 Interop.Eext.eext_circle_object_item_line_width_set(circleHandle, "vertical,scroll,bg", value);
79             }
80         }
81
82         /// <summary>
83         /// Sets or gets the redius of the scroll background
84         /// </summary>
85         public double VerticalScrollBackgroundRadius
86         {
87             get
88             {
89                 return Interop.Eext.eext_circle_object_item_radius_get(circleHandle, "vertical,scroll,bg");
90             }
91             set
92             {
93                 Interop.Eext.eext_circle_object_item_radius_set(circleHandle, "vertical,scroll,bg", value);
94             }
95         }
96
97         /// <summary>
98         /// Sets or gets the color of the scroll bar
99         /// </summary>
100         public Color VerticalScrollBarColor
101         {
102             get
103             {
104                 int r, g, b, a;
105                 Interop.Eext.eext_circle_object_item_color_get(circleHandle, "default", out r, out g, out b, out a);
106                 return new Color(r, g, b, a);
107             }
108             set
109             {
110                 Interop.Eext.eext_circle_object_item_color_set(circleHandle, "default", value.R, value.G, value.B, value.A);
111             }
112         }
113
114         /// <summary>
115         /// Sets or gets the line width of the scroll bar
116         /// </summary>
117         public int VerticalScrollBarLineWidth
118         {
119             get
120             {
121                 return Interop.Eext.eext_circle_object_item_line_width_get(circleHandle, "default");
122             }
123             set
124             {
125                 Interop.Eext.eext_circle_object_item_line_width_set(circleHandle, "default", value);
126             }
127         }
128
129         /// <summary>
130         /// Sets or gets the redius of the scroll bar
131         /// </summary>
132         public double VerticalScrollBarRadius
133         {
134             get
135             {
136                 return Interop.Eext.eext_circle_object_item_radius_get(circleHandle, "default");
137             }
138             set
139             {
140                 Interop.Eext.eext_circle_object_item_radius_set(circleHandle, "default", value);
141             }
142         }
143
144         /// <summary>
145         /// Sets or gets the policy if the scroll bar is visible
146         /// </summary>
147         /// <remarks>
148         /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
149         /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
150         /// </remarks>
151         public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
152         {
153             get
154             {
155                 int policy;
156                 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(circleHandle, IntPtr.Zero, out policy);
157                 return (ScrollBarVisiblePolicy)policy;
158             }
159             set
160             {
161                 int h;
162                 Interop.Eext.eext_circle_object_genlist_scroller_policy_get(circleHandle, out h, IntPtr.Zero);
163                 Interop.Eext.eext_circle_object_genlist_scroller_policy_set(circleHandle, (int)h, (int)value);
164             }
165         }
166
167         /// <summary>
168         /// Creates a widget handle.
169         /// </summary>
170         /// <param name="parent">Parent EvasObject</param>
171         /// <returns>Handle IntPtr</returns>
172         protected override IntPtr CreateHandle(EvasObject parent)
173         {
174             var handle = base.CreateHandle(parent);
175
176             IntPtr surface = IntPtr.Zero;
177
178             if (parent is Conformant)
179             {
180                 surface = Interop.Eext.eext_circle_surface_conformant_add(parent);
181             }
182             else if (parent is Naviframe)
183             {
184                 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
185             }
186             else if (parent is Layout)
187             {
188                 surface = Interop.Eext.eext_circle_surface_layout_add(parent);
189             }
190
191             circleHandle = Interop.Eext.eext_circle_object_genlist_add(RealHandle, surface);
192             if (surface == IntPtr.Zero)
193             {
194                 EvasObject p = parent;
195                 while(!(p is Window))
196                 {
197                     p = p.Parent;
198                 }
199                 var w = (p as Window).ScreenSize.Width;
200                 var h = (p as Window).ScreenSize.Height;
201                 Interop.Evas.evas_object_resize(circleHandle, w, h);
202             }
203
204             Interop.Eext.eext_rotary_object_event_activated_set(circleHandle, true);
205
206             return handle;
207         }
208     }
209 }