[Elmsharp.Wearable]add remarks of marker properties (#729)
[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         /// <remarks>
102         /// MarkerColor is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner.
103         /// </remarks>
104         /// <since_tizen> preview </since_tizen>
105         public Color MarkerColor
106         {
107             get
108             {
109                 int r, g, b, a;
110                 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
111                 return new Color(r, g, b, a);
112             }
113             set
114             {
115                 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
116             }
117         }
118
119         /// <summary>
120         /// Sets or gets the line width of the marker.
121         /// </summary>
122         /// <remarks>
123         /// MarkerLineWidth is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner.
124         /// </remarks>
125         /// <since_tizen> preview </since_tizen>
126         public int MarkerLineWidth
127         {
128             get
129             {
130                 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
131             }
132             set
133             {
134                 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
135             }
136         }
137
138         /// <summary>
139         /// Sets or gets the radius at which the center of the marker lies.
140         /// </summary>
141         /// <remarks>
142         /// MarkerRadius is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner.
143         /// </remarks>
144         /// <since_tizen> preview </since_tizen>
145         public double MarkerRadius
146         {
147             get
148             {
149                 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
150             }
151             set
152             {
153                 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
154             }
155         }
156
157         /// <summary>
158         /// Creates a widget handle.
159         /// </summary>
160         /// <param name="parent">Parent EvasObject.</param>
161         /// <returns>Handle IntPtr.</returns>
162         /// <since_tizen> preview </since_tizen>
163         protected override IntPtr CreateHandle(EvasObject parent)
164         {
165             var handle = base.CreateHandle(parent);
166
167             _circleHandle = Interop.Eext.eext_circle_object_datetime_add(RealHandle == IntPtr.Zero ? handle : RealHandle , CircleSurface.Handle);
168
169             return handle;
170         }
171     }
172 }