Release 4.0.0-preview1-00051
[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
19 namespace ElmSharp.Wearable
20 {
21     /// <summary>
22     /// The Circle DateTime Selector is a widget to display and handle datetime value by rotary event
23     /// Inherits <see cref="DateTimeSelector"/>
24     /// </summary>
25     public class CircleDateTimeSelector : DateTimeSelector
26     {
27         IntPtr circleHandle;
28
29         /// <summary>
30         /// Creates and initializes a new instance of the Circle DateTime class
31         /// </summary>
32         /// <param name="parent">The parent of new Circle DateTime instance</param>
33         public CircleDateTimeSelector(EvasObject parent) : base(parent) { }
34
35         /// <summary>
36         /// Sets or gets the disabled state of the Circle DateTime 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 marker
52         /// </summary>
53         public Color MarkerColor
54         {
55             get
56             {
57                 int r, g, b, a;
58                 Interop.Eext.eext_circle_object_item_color_get(circleHandle, "default", 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, "default", value.R, value.G, value.B, value.A);
64             }
65         }
66
67         /// <summary>
68         /// Sets or gets the line width of the marker
69         /// </summary>
70         public int MarkerLineWidth
71         {
72             get
73             {
74                 return Interop.Eext.eext_circle_object_item_line_width_get(circleHandle, "default");
75             }
76             set
77             {
78                 Interop.Eext.eext_circle_object_item_line_width_set(circleHandle, "default", value);
79             }
80         }
81
82         /// <summary>
83         /// Sets or gets the radius at which the center of the marker lies
84         /// </summary>
85         public double MarkerRadius
86         {
87             get
88             {
89                 return Interop.Eext.eext_circle_object_item_radius_get(circleHandle, "default");
90             }
91             set
92             {
93                 Interop.Eext.eext_circle_object_item_radius_set(circleHandle, "default", value);
94             }
95         }
96
97         protected override IntPtr CreateHandle(EvasObject parent)
98         {
99             var handle = base.CreateHandle(parent);
100
101             IntPtr surface = IntPtr.Zero;
102
103             if (parent is Conformant)
104             {
105                 surface = Interop.Eext.eext_circle_surface_conformant_add(parent);
106             }
107             else if (parent is Naviframe)
108             {
109                 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
110             }
111             else if (parent is Layout)
112             {
113                 surface = Interop.Eext.eext_circle_surface_layout_add(parent);
114             }
115
116             circleHandle = Interop.Eext.eext_circle_object_datetime_add(RealHandle, surface);
117             if (surface == IntPtr.Zero)
118             {
119                 EvasObject p = parent;
120                 while (!(p is Window))
121                 {
122                     p = p.Parent;
123                 }
124                 var w = (p as Window).ScreenSize.Width;
125                 var h = (p as Window).ScreenSize.Height;
126                 Interop.Evas.evas_object_resize(circleHandle, w, h);
127             }
128
129             Interop.Eext.eext_rotary_object_event_activated_set(circleHandle, true);
130
131             return handle;
132         }
133     }
134 }