[NUI] Remove duplicate getCPtr from BaseHandle subclasses (#3545)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / Wheel.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.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// The wheel event structure is used to store a wheel rolling, it facilitates processing of the wheel rolling and passing to other libraries like Toolkit.<br />
24     /// There is a key modifier which relates to keys like Alt, Shift, and Ctrl functions are supplied to check if they have been pressed when the wheel is being rolled.<br />
25     /// We support a mouse device and there may be another custom device that support the wheel event. The device type is specified as \e type.<br />
26     /// The mouse wheel event can be sent to the specific actor but the custom wheel event will be sent to the window.<br />
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public class Wheel : BaseHandle
30     {
31
32         /// <summary>
33         /// The default constructor.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public Wheel() : this(Interop.Wheel.New(0, 0, 0u, Vector2.getCPtr(new Vector2(0.0f, 0.0f)), 0, 0u), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// The constructor.
43         /// </summary>
44         /// <param name="type">The type of the wheel event.</param>
45         /// <param name="direction">The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).</param>
46         /// <param name="modifiers">Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).</param>
47         /// <param name="point">The coordinates of the cursor relative to the top-left of the screen.</param>
48         /// <param name="z">The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).</param>
49         /// <param name="timeStamp">The time the wheel is being rolled.</param>
50         /// <since_tizen> 3 </since_tizen>
51         public Wheel(Wheel.WheelType type, int direction, uint modifiers, Vector2 point, int z, uint timeStamp) : this(Interop.Wheel.New((int)type, direction, modifiers, Vector2.getCPtr(point), z, timeStamp), true)
52         {
53             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54         }
55
56         internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
57         {
58         }
59
60         /// <summary>
61         /// The type of the wheel event.
62         /// </summary>
63         /// <since_tizen> 3 </since_tizen>
64         public enum WheelType
65         {
66             /// <summary>
67             /// Mouse wheel event.
68             /// </summary>
69             /// <since_tizen> 3 </since_tizen>
70             MouseWheel,
71
72             /// <summary>
73             /// Custom wheel event.
74             /// </summary>
75             /// <since_tizen> 3 </since_tizen>
76             CustomWheel
77         }
78
79         /// <summary>
80         /// The type of the wheel event.
81         /// </summary>
82         /// <since_tizen> 3 </since_tizen>
83         public Wheel.WheelType Type
84         {
85             get
86             {
87                 return type;
88             }
89         }
90
91         /// <summary>
92         /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         public int Direction
96         {
97             get
98             {
99                 return direction;
100             }
101         }
102
103         /// <summary>
104         /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         public uint Modifiers
108         {
109             get
110             {
111                 return modifiers;
112             }
113         }
114
115         /// <summary>
116         /// The coordinates of the cursor relative to the top-left of the screen.
117         /// </summary>
118         /// <since_tizen> 3 </since_tizen>
119         public Vector2 Point
120         {
121             get
122             {
123                 return point;
124             }
125         }
126
127         /// <summary>
128         /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
129         /// </summary>
130         /// <since_tizen> 3 </since_tizen>
131         public int Z
132         {
133             get
134             {
135                 return z;
136             }
137         }
138
139         /// <summary>
140         /// The time the wheel is being rolled.
141         /// </summary>
142         /// <since_tizen> 3 </since_tizen>
143         public uint TimeStamp
144         {
145             get
146             {
147                 return timeStamp;
148             }
149         }
150
151         private Wheel.WheelType type
152         {
153             get
154             {
155                 Wheel.WheelType ret = (Wheel.WheelType)Interop.Wheel.TypeGet(SwigCPtr);
156                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157                 return ret;
158             }
159         }
160
161         private int direction
162         {
163             get
164             {
165                 int ret = Interop.Wheel.DirectionGet(SwigCPtr);
166                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167                 return ret;
168             }
169         }
170
171         private uint modifiers
172         {
173             get
174             {
175                 uint ret = Interop.Wheel.ModifiersGet(SwigCPtr);
176                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177                 return ret;
178             }
179         }
180
181         private Vector2 point
182         {
183             get
184             {
185                 global::System.IntPtr cPtr = Interop.Wheel.PointGet(SwigCPtr);
186                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
187                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188                 return ret;
189             }
190         }
191
192         private int z
193         {
194             get
195             {
196                 int ret = Interop.Wheel.DeltaGet(SwigCPtr);
197                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198                 return ret;
199             }
200         }
201
202         private uint timeStamp
203         {
204             get
205             {
206                 uint ret = Interop.Wheel.TimeStampGet(SwigCPtr);
207                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208                 return ret;
209             }
210         }
211
212
213         /// <summary>
214         /// Checks to see if the Shift key modifier has been supplied.
215         /// </summary>
216         /// <returns>True if Shift modifier.</returns>
217         /// <since_tizen> 3 </since_tizen>
218         public bool IsShiftModifier()
219         {
220             bool ret = Interop.Wheel.IsShiftModifier(SwigCPtr);
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222             return ret;
223         }
224
225         /// <summary>
226         /// Checks to see if Ctrl (control) key modifier has been supplied.
227         /// </summary>
228         /// <returns>True if Ctrl modifier.</returns>
229         /// <since_tizen> 3 </since_tizen>
230         public bool IsCtrlModifier()
231         {
232             bool ret = Interop.Wheel.IsCtrlModifier(SwigCPtr);
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             return ret;
235         }
236
237         /// <summary>
238         /// Checks to see if Alt key modifier has been supplied.
239         /// </summary>
240         /// <returns>True if Alt modifier.</returns>
241         /// <since_tizen> 3 </since_tizen>
242         public bool IsAltModifier()
243         {
244             bool ret = Interop.Wheel.IsAltModifier(SwigCPtr);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246             return ret;
247         }
248
249         internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
250         {
251             Wheel ret = new Wheel(cPtr, false);
252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253             return ret;
254         }
255
256         /// This will not be public opened.
257         [EditorBrowsable(EditorBrowsableState.Never)]
258         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
259         {
260             Interop.Wheel.DeleteWheel(swigCPtr);
261         }
262     }
263 }