ff97d0e45bf2c1b5c2d4d44e349c6a1ee5420fb6
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / CircleProgressBar.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
24     /// <summary>
25     /// The Circle ProgressBar is a widget for visually representing the progress status of a given job/task with the circular design.
26     /// </summary>
27     /// <since_tizen> preview </since_tizen>
28     public class CircleProgressBar : Widget, ICircleWidget
29     {
30         CircleSurface _surface;
31
32         /// <summary>
33         /// Creates and initializes a new instance of the Circle Progressbar class.
34         /// </summary>
35         /// <param name="parent">The parent of new Circle Progressbar instance</param>
36         /// <param name="surface">The surface for drawing circle features for this widget.</param>
37         /// <since_tizen> preview </since_tizen>
38         public CircleProgressBar(EvasObject parent, CircleSurface surface) : base()
39         {
40             Debug.Assert(parent == null || surface == null || parent.IsRealized);
41             _surface = surface;
42             Realize(parent);
43         }
44
45         /// <summary>
46         /// Creates and initializes a new instance of the Circle Progressbar class.
47         /// </summary>
48         /// <param name="parent">The parent of new Circle Progressbar instance</param>
49         /// <since_tizen> preview </since_tizen>
50         [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public CircleProgressBar(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
53         {
54         }
55
56         /// <summary>
57         /// Gets the handle for Circle Widget.
58         /// </summary>
59         /// <since_tizen> preview </since_tizen>
60         public virtual IntPtr CircleHandle => Handle;
61
62         /// <summary>
63         /// Gets the handle for Circle Surface used in this widget
64         /// </summary>
65         /// <since_tizen> preview </since_tizen>
66         public virtual CircleSurface CircleSurface => _surface;
67
68         /// <summary>
69         /// Sets or gets disabled state of this widget.
70         /// </summary>
71         /// <since_tizen> preview </since_tizen>
72         [Obsolete("Use IsEnabled")]
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public bool Disabled
75         {
76             get => !IsEnabled;
77             set => IsEnabled = !value;
78         }
79
80         /// <summary>
81         /// Sets or gets the state of the widget, which might be enabled or disabled.
82         /// </summary>
83         /// <since_tizen> preview </since_tizen>
84         public override bool IsEnabled
85         {
86             get
87             {
88                 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
89             }
90             set
91             {
92                 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
93             }
94         }
95
96         /// <summary>
97         /// Sets or gets the value of ProgressBar.
98         /// </summary>
99         /// <since_tizen> preview </since_tizen>
100         public double Value
101         {
102             get
103             {
104                 return Interop.Eext.eext_circle_object_value_get(CircleHandle);
105             }
106             set
107             {
108                 Interop.Eext.eext_circle_object_value_set(CircleHandle, value);
109             }
110         }
111
112         /// <summary>
113         /// Sets or gets the maximum value of ProgressBar.
114         /// </summary>
115         /// <since_tizen> preview </since_tizen>
116         public double Maximum
117         {
118             get
119             {
120                 double max = 0;
121                 double min = 0;
122                 Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max);
123                 return max;
124             }
125             set
126             {
127                 double min = Minimum;
128                 Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, min, value);
129             }
130         }
131
132         /// <summary>
133         /// Sets or gets the minimum value of ProgressBar.
134         /// </summary>
135         /// <since_tizen> preview </since_tizen>
136         public double Minimum
137         {
138             get
139             {
140                 double max = 0;
141                 double min = 0;
142                 Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max);
143                 return min;
144             }
145             set
146             {
147                 double max = Maximum;
148                 Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, value, max);
149             }
150         }
151
152         /// <summary>
153         /// Sets or gets the angle value of ProgressBar.
154         /// </summary>
155         /// <since_tizen> preview </since_tizen>
156         public double BarAngle
157         {
158             get
159             {
160                 return Interop.Eext.eext_circle_object_angle_get(CircleHandle);
161             }
162             set
163             {
164                 Interop.Eext.eext_circle_object_angle_set(CircleHandle, value);
165             }
166         }
167
168         /// <summary>
169         /// Sets or gets the angle value of Background ProgressBar.
170         /// </summary>
171         /// <since_tizen> preview </since_tizen>
172         public double BackgroundAngle
173         {
174             get
175             {
176                 return Interop.Eext.eext_circle_object_item_angle_get(CircleHandle, "bg");
177             }
178             set
179             {
180                 Interop.Eext.eext_circle_object_item_angle_set(CircleHandle, "bg", value);
181             }
182         }
183
184         /// <summary>
185         /// Sets or gets the angle offset value of ProgressBar.
186         /// </summary>
187         /// <since_tizen> preview </since_tizen>
188         public double BarAngleOffset
189         {
190             get
191             {
192                 return Interop.Eext.eext_circle_object_angle_offset_get(CircleHandle);
193             }
194             set
195             {
196                 Interop.Eext.eext_circle_object_angle_offset_set(CircleHandle, value);
197             }
198         }
199
200         /// <summary>
201         /// Sets or gets the angle offset value of Background ProgressBar.
202         /// </summary>
203         /// <since_tizen> preview </since_tizen>
204         public double BackgroundAngleOffset
205         {
206             get
207             {
208                 return Interop.Eext.eext_circle_object_item_angle_offset_get(CircleHandle, "bg");
209             }
210             set
211             {
212                 Interop.Eext.eext_circle_object_item_angle_offset_set(CircleHandle, "bg", value);
213             }
214         }
215
216         /// <summary>
217         /// Sets or gets the maximum angle value of ProgressBar.
218         /// </summary>
219         /// <since_tizen> preview </since_tizen>
220         public double BarAngleMaximum
221         {
222             get
223             {
224                 double max = 0;
225                 double min = 0;
226                 Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max);
227                 return max;
228             }
229             set
230             {
231                 double min = BarAngleMinimum;
232                 Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, min, value);
233             }
234         }
235
236         /// <summary>
237         /// Sets or gets the minimum angle value of ProgressBar.
238         /// </summary>
239         /// <since_tizen> preview </since_tizen>
240         public double BarAngleMinimum
241         {
242             get
243             {
244                 double max = 0;
245                 double min = 0;
246                 Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max);
247                 return min;
248             }
249             set
250             {
251                 double max = BarAngleMaximum;
252                 Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, value, max);
253             }
254         }
255
256         /// <summary>
257         /// Sets or gets color of ProgressBar.
258         /// </summary>
259         /// <since_tizen> preview </since_tizen>
260         public Color BarColor
261         {
262             get
263             {
264                 int r = 0;
265                 int g = 0;
266                 int b = 0;
267                 int a = 0;
268                 Interop.Eext.eext_circle_object_color_get(CircleHandle, out r, out g, out b, out a);
269                 return Color.FromRgba(r, g, b, a);
270             }
271             set
272             {
273                 Interop.Eext.eext_circle_object_color_set(CircleHandle, value.R, value.G, value.B, value.A);
274             }
275         }
276
277         /// <summary>
278         /// Sets or gets color of Background ProgressBar.
279         /// </summary>
280         /// <since_tizen> preview </since_tizen>
281         public override Color BackgroundColor
282         {
283             get
284             {
285                 int r = 0;
286                 int g = 0;
287                 int b = 0;
288                 int a = 0;
289                 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "bg", out r, out g, out b, out a);
290                 return Color.FromRgba(r, g, b, a);
291             }
292             set
293             {
294                 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "bg", value.R, value.G, value.B, value.A);
295             }
296         }
297
298         /// <summary>
299         /// Sets or gets line width of ProgressBar.
300         /// </summary>
301         /// <since_tizen> preview </since_tizen>
302         public int BarLineWidth
303         {
304             get
305             {
306                 return Interop.Eext.eext_circle_object_line_width_get(CircleHandle);
307             }
308             set
309             {
310                 Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value);
311             }
312         }
313
314         /// <summary>
315         /// Sets or gets line width of Background ProgressBar.
316         /// </summary>
317         /// <since_tizen> preview </since_tizen>
318         public int BackgroundLineWidth
319         {
320             get
321             {
322                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "bg");
323             }
324             set
325             {
326                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "bg", value);
327             }
328         }
329
330         /// <summary>
331         /// Sets or gets radius of ProgressBar.
332         /// </summary>
333         /// <since_tizen> preview </since_tizen>
334         public double BarRadius
335         {
336             get
337             {
338                 return Interop.Eext.eext_circle_object_radius_get(CircleHandle);
339             }
340             set
341             {
342                 Interop.Eext.eext_circle_object_radius_set(CircleHandle, value);
343             }
344         }
345
346         /// <summary>
347         /// Sets or gets radius of Background ProgressBar.
348         /// </summary>
349         /// <since_tizen> preview </since_tizen>
350         public double BackgroundRadius
351         {
352             get
353             {
354                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "bg");
355             }
356             set
357             {
358                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "bg", value);
359             }
360         }
361
362         /// <summary>
363         /// Creates a widget handle.
364         /// </summary>
365         /// <param name="parent">Parent EvasObject</param>
366         /// <returns>Handle IntPtr</returns>
367         /// <since_tizen> preview </since_tizen>
368         protected override IntPtr CreateHandle(EvasObject parent)
369         {
370             return Interop.Eext.eext_circle_object_progressbar_add(parent, CircleSurface.Handle);
371         }
372     }
373 }