Release 4.0.0-preview1-00337
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / CircleDatetimeSelector.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.Diagnostics;
19
20 namespace ElmSharp.Wearable
21 {
22     /// <summary>
23     /// The Circle DateTime Selector is a widget to display and handle datetime value by rotary event
24     /// Inherits <see cref="DateTimeSelector"/>
25     /// </summary>
26     public class CircleDateTimeSelector : DateTimeSelector, IRotaryActionWidget
27     {
28         IntPtr _circleHandle;
29         CircleSurface _surface;
30
31         /// <summary>
32         /// Creates and initializes a new instance of the Circle DateTime class
33         /// </summary>
34         /// <param name="parent">The parent of new Circle DateTime instance</param>
35         /// <param name="surface">The surface for drawing circle features for this widget.</param>
36         public CircleDateTimeSelector(EvasObject parent, CircleSurface surface) : base()
37         {
38             Debug.Assert(parent == null || surface == null || parent.IsRealized);
39             _surface = surface;
40             Realize(parent);
41         }
42
43         /// <summary>
44         /// Gets the handle for Circle Widget.
45         /// </summary>
46         public virtual IntPtr CircleHandle => _circleHandle;
47
48         /// <summary>
49         /// Gets the handle for Circle Surface used in this widget
50         /// </summary>
51         public virtual CircleSurface CircleSurface => _surface;
52
53         /// <summary>
54         /// Sets or gets the state of the widget, which might be enabled or disabled.
55         /// </summary>
56         public override bool IsEnabled
57         {
58             get
59             {
60                 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
61             }
62             set
63             {
64                 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
65             }
66         }
67
68         /// <summary>
69         /// Sets or gets the color of the marker
70         /// </summary>
71         public Color MarkerColor
72         {
73             get
74             {
75                 int r, g, b, a;
76                 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
77                 return new Color(r, g, b, a);
78             }
79             set
80             {
81                 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
82             }
83         }
84
85         /// <summary>
86         /// Sets or gets the line width of the marker
87         /// </summary>
88         public int MarkerLineWidth
89         {
90             get
91             {
92                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
93             }
94             set
95             {
96                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
97             }
98         }
99
100         /// <summary>
101         /// Sets or gets the radius at which the center of the marker lies
102         /// </summary>
103         public double MarkerRadius
104         {
105             get
106             {
107                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
108             }
109             set
110             {
111                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
112             }
113         }
114
115         /// <summary>
116         /// Creates a widget handle.
117         /// </summary>
118         /// <param name="parent">Parent EvasObject</param>
119         /// <returns>Handle IntPtr</returns>
120         protected override IntPtr CreateHandle(EvasObject parent)
121         {
122             var handle = base.CreateHandle(parent);
123
124             _circleHandle = Interop.Eext.eext_circle_object_datetime_add(RealHandle == IntPtr.Zero ? Handle : RealHandle , CircleSurface.Handle);
125
126             return handle;
127         }
128     }
129 }