30aae794653e261949befea193e93c452abbb184
[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.ComponentModel;
19 using System.Diagnostics;
20
21 namespace ElmSharp.Wearable
22 {
23     /// <summary>
24     /// The Circle DateTime Selector is a widget to display and handle datetime value by the Rotary event.
25     /// Inherits <see cref="DateTimeSelector"/>.
26     /// </summary>
27     /// <since_tizen> preview </since_tizen>
28     public class CircleDateTimeSelector : DateTimeSelector, IRotaryActionWidget
29     {
30         IntPtr _circleHandle;
31         CircleSurface _surface;
32
33         /// <summary>
34         /// Creates and initializes a new instance of the Circle DateTime class.
35         /// </summary>
36         /// <param name="parent">The parent of the new Circle DateTime instance.</param>
37         /// <param name="surface">The surface for drawing circle features for this widget.</param>
38         /// <since_tizen> preview </since_tizen>
39         public CircleDateTimeSelector(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 DateTimeSelector class.
48         /// </summary>
49         /// <param name="parent">The parent of the new Circle DateTimeSelector 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 CircleDateTimeSelector(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
54         {
55             ((IRotaryActionWidget)this).Activate();
56         }
57
58         /// <summary>
59         /// Gets the handle for the Circle widget.
60         /// </summary>
61         /// <since_tizen> preview </since_tizen>
62         public virtual IntPtr CircleHandle => _circleHandle;
63
64         /// <summary>
65         /// Gets the handle for the 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 the 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 marker.
100         /// </summary>
101         /// <since_tizen> preview </since_tizen>
102         public Color MarkerColor
103         {
104             get
105             {
106                 int r, g, b, a;
107                 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", 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, "default", value.R, value.G, value.B, value.A);
113             }
114         }
115
116         /// <summary>
117         /// Sets or gets the line width of the marker.
118         /// </summary>
119         /// <since_tizen> preview </since_tizen>
120         public int MarkerLineWidth
121         {
122             get
123             {
124                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
125             }
126             set
127             {
128                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
129             }
130         }
131
132         /// <summary>
133         /// Sets or gets the radius at which the center of the marker lies.
134         /// </summary>
135         /// <since_tizen> preview </since_tizen>
136         public double MarkerRadius
137         {
138             get
139             {
140                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
141             }
142             set
143             {
144                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
145             }
146         }
147
148         /// <summary>
149         /// Creates a widget handle.
150         /// </summary>
151         /// <param name="parent">Parent EvasObject.</param>
152         /// <returns>Handle IntPtr.</returns>
153         /// <since_tizen> preview </since_tizen>
154         protected override IntPtr CreateHandle(EvasObject parent)
155         {
156             var handle = base.CreateHandle(parent);
157
158             _circleHandle = Interop.Eext.eext_circle_object_datetime_add(RealHandle == IntPtr.Zero ? handle : RealHandle , CircleSurface.Handle);
159
160             return handle;
161         }
162     }
163 }