[NUI] Remove duplicate getCPtr from BaseHandle subclasses (#3545)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / Hover.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
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 Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Hover events are a collection of points at a specific moment in time.<br />
25     /// When a multi-event occurs, each point represents the points that are currently being
26     /// hovered or the points where a hover has stopped.<br />
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public class Hover : BaseHandle
30     {
31
32         /// <summary>
33         /// The default constructor.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public Hover() : this(Interop.Hover.New(0u), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// The constructor.
43         /// </summary>
44         /// <param name="time">The time the event occurred.</param>
45         internal Hover(uint time) : this(Interop.Hover.New(time), true)
46         {
47             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48         }
49
50         internal Hover(Hover other) : this(Interop.Hover.NewHover(Hover.getCPtr(other)), true)
51         {
52             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53         }
54
55         internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
56         {
57         }
58
59         /// <summary>
60         /// The time (in ms) that the hover event occurred.
61         /// </summary>
62         /// <since_tizen> 3 </since_tizen>
63         public uint Time
64         {
65             get
66             {
67                 uint ret = Interop.Hover.GetTime(SwigCPtr);
68                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
69                 return ret;
70             }
71         }
72
73         /// <summary>
74         /// Returns the ID of the device used for the point specified.<br />
75         /// Each point has a unique device ID which specifies the device used for that
76         /// point. This is returned by this method.<br />
77         /// If a point is greater than GetPointCount(), then this method will return -1.<br />
78         /// </summary>
79         /// <param name="point">The point required.</param>
80         /// <returns>The device ID of this point.</returns>
81         /// <since_tizen> 3 </since_tizen>
82         public int GetDeviceId(uint point)
83         {
84             int ret = Interop.Hover.GetDeviceId(SwigCPtr, point);
85             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         /// <summary>
90         /// Retrieves the state of the point specified.<br />
91         /// If a point is greater than GetPointCount(), then this method will return PointState.Finished.<br />
92         /// </summary>
93         /// <param name="point">The point required.</param>
94         /// <returns>The state of the point specified.</returns>
95         /// <since_tizen> 3 </since_tizen>
96         public PointStateType GetState(uint point)
97         {
98             PointStateType ret = (PointStateType)Interop.Hover.GetState(SwigCPtr, point);
99             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100             return ret;
101         }
102
103         /// <summary>
104         /// Retrieves the view that was underneath the point specified.<br />
105         /// If a point is greater than GetPointCount(), then this method will return an empty handle.<br />
106         /// </summary>
107         /// <param name="point">The point required.</param>
108         /// <returns>The view that was underneath the point specified.</returns>
109         /// <since_tizen> 3 </since_tizen>
110         public View GetHitView(uint point)
111         {
112             global::System.IntPtr cPtr = Interop.Hover.GetHitActor(SwigCPtr, point);
113             View ret = this.GetInstanceSafely<View>(cPtr);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115             return ret;
116         }
117
118         /// <summary>
119         /// Retrieves the coordinates relative to the top-left of the hit-view at the point specified.
120         /// </summary>
121         /// <param name="point">The point required.</param>
122         /// <returns>The coordinates relative to the top-left of the hit-view of the point specified.</returns>
123         /// <since_tizen> 3 </since_tizen>
124         public Vector2 GetLocalPosition(uint point)
125         {
126             Vector2 ret = new Vector2(Interop.Hover.GetLocalPosition(SwigCPtr, point), false);
127             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             return ret;
129         }
130
131         /// <summary>
132         /// Retrieves the coordinates relative to the top-left of the screen of the point specified.
133         /// </summary>
134         /// <param name="point">The point required.</param>
135         /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
136         /// <since_tizen> 3 </since_tizen>
137         public Vector2 GetScreenPosition(uint point)
138         {
139             Vector2 ret = new Vector2(Interop.Hover.GetScreenPosition(SwigCPtr, point), false);
140             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141             return ret;
142         }
143
144         /// <summary>
145         /// Returns the total number of points.
146         /// </summary>
147         /// <returns>Total number of points.</returns>
148         /// <since_tizen> 3 </since_tizen>
149         public uint GetPointCount()
150         {
151             uint ret = Interop.Hover.GetPointCount(SwigCPtr);
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153             return ret;
154         }
155
156         internal static Hover GetHoverFromPtr(global::System.IntPtr cPtr)
157         {
158             Hover ret = new Hover(cPtr, false);
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             return ret;
161         }
162
163         /// This will not be public opened.
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
166         {
167             Interop.Hover.DeleteHover(swigCPtr);
168         }
169     }
170 }