27c8cee4a5c39d3a67c62d2ce39ac138b701cce6
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Wheel.cs
1 /*
2  * Copyright(c) 2019 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
18 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// 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 />
22     /// 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 />
23     /// 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 />
24     /// The mouse wheel event can be sent to the specific actor but the custom wheel event will be sent to the window.<br />
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class Wheel : Disposable
28     {
29         /// <summary>
30         /// swigCMemOwn.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         protected bool swigCMemOwn;
34
35         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36
37         /// <summary>
38         /// The default constructor.
39         /// </summary>
40         /// <since_tizen> 3 </since_tizen>
41         public Wheel() : this(Interop.Wheel.new_Wheel__SWIG_0(), true)
42         {
43             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44         }
45
46         /// <summary>
47         /// The constructor.
48         /// </summary>
49         /// <param name="type">The type of the wheel event.</param>
50         /// <param name="direction">The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).</param>
51         /// <param name="modifiers">Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).</param>
52         /// <param name="point">The coordinates of the cursor relative to the top-left of the screen.</param>
53         /// <param name="z">The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).</param>
54         /// <param name="timeStamp">The time the wheel is being rolled.</param>
55         /// <since_tizen> 3 </since_tizen>
56         public Wheel(Wheel.WheelType type, int direction, uint modifiers, Vector2 point, int z, uint timeStamp) : this(Interop.Wheel.new_Wheel__SWIG_1((int)type, direction, modifiers, Vector2.getCPtr(point), z, timeStamp), true)
57         {
58             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59         }
60
61         internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn)
62         {
63             swigCMemOwn = cMemoryOwn;
64             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
65         }
66
67         /// <summary>
68         /// The type of the wheel event.
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         public enum WheelType
72         {
73             /// <summary>
74             /// Mouse wheel event.
75             /// </summary>
76             /// <since_tizen> 3 </since_tizen>
77             MouseWheel,
78
79             /// <summary>
80             /// Custom wheel event.
81             /// </summary>
82             /// <since_tizen> 3 </since_tizen>
83             CustomWheel
84         }
85
86         /// <summary>
87         /// The type of the wheel event.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public Wheel.WheelType Type
91         {
92             get
93             {
94                 return type;
95             }
96         }
97
98         /// <summary>
99         /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
100         /// </summary>
101         /// <since_tizen> 3 </since_tizen>
102         public int Direction
103         {
104             get
105             {
106                 return direction;
107             }
108         }
109
110         /// <summary>
111         /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
112         /// </summary>
113         /// <since_tizen> 3 </since_tizen>
114         public uint Modifiers
115         {
116             get
117             {
118                 return modifiers;
119             }
120         }
121
122         /// <summary>
123         /// The coordinates of the cursor relative to the top-left of the screen.
124         /// </summary>
125         /// <since_tizen> 3 </since_tizen>
126         public Vector2 Point
127         {
128             get
129             {
130                 return point;
131             }
132         }
133
134         /// <summary>
135         /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
136         /// </summary>
137         /// <since_tizen> 3 </since_tizen>
138         public int Z
139         {
140             get
141             {
142                 return z;
143             }
144         }
145
146         /// <summary>
147         /// The time the wheel is being rolled.
148         /// </summary>
149         /// <since_tizen> 3 </since_tizen>
150         public uint TimeStamp
151         {
152             get
153             {
154                 return timeStamp;
155             }
156         }
157
158         private Wheel.WheelType type
159         {
160             set
161             {
162                 Interop.Wheel.Wheel_type_set(swigCPtr, (int)value);
163                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164             }
165             get
166             {
167                 Wheel.WheelType ret = (Wheel.WheelType)Interop.Wheel.Wheel_type_get(swigCPtr);
168                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169                 return ret;
170             }
171         }
172
173         private int direction
174         {
175             set
176             {
177                 Interop.Wheel.Wheel_direction_set(swigCPtr, value);
178                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179             }
180             get
181             {
182                 int ret = Interop.Wheel.Wheel_direction_get(swigCPtr);
183                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184                 return ret;
185             }
186         }
187
188         private uint modifiers
189         {
190             set
191             {
192                 Interop.Wheel.Wheel_modifiers_set(swigCPtr, value);
193                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194             }
195             get
196             {
197                 uint ret = Interop.Wheel.Wheel_modifiers_get(swigCPtr);
198                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199                 return ret;
200             }
201         }
202
203         private Vector2 point
204         {
205             set
206             {
207                 Interop.Wheel.Wheel_point_set(swigCPtr, Vector2.getCPtr(value));
208                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209             }
210             get
211             {
212                 global::System.IntPtr cPtr = Interop.Wheel.Wheel_point_get(swigCPtr);
213                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
214                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215                 return ret;
216             }
217         }
218
219         private int z
220         {
221             set
222             {
223                 Interop.Wheel.Wheel_z_set(swigCPtr, value);
224                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             }
226             get
227             {
228                 int ret = Interop.Wheel.Wheel_z_get(swigCPtr);
229                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230                 return ret;
231             }
232         }
233
234         private uint timeStamp
235         {
236             set
237             {
238                 Interop.Wheel.Wheel_timeStamp_set(swigCPtr, value);
239                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             }
241             get
242             {
243                 uint ret = Interop.Wheel.Wheel_timeStamp_get(swigCPtr);
244                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245                 return ret;
246             }
247         }
248
249
250         /// <summary>
251         /// Checks to see if the Shift key modifier has been supplied.
252         /// </summary>
253         /// <returns>True if Shift modifier.</returns>
254         /// <since_tizen> 3 </since_tizen>
255         public bool IsShiftModifier()
256         {
257             bool ret = Interop.Wheel.Wheel_IsShiftModifier(swigCPtr);
258             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259             return ret;
260         }
261
262         /// <summary>
263         /// Checks to see if Ctrl (control) key modifier has been supplied.
264         /// </summary>
265         /// <returns>True if Ctrl modifier.</returns>
266         /// <since_tizen> 3 </since_tizen>
267         public bool IsCtrlModifier()
268         {
269             bool ret = Interop.Wheel.Wheel_IsCtrlModifier(swigCPtr);
270             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271             return ret;
272         }
273
274         /// <summary>
275         /// Checks to see if Alt key modifier has been supplied.
276         /// </summary>
277         /// <returns>True if Alt modifier.</returns>
278         /// <since_tizen> 3 </since_tizen>
279         public bool IsAltModifier()
280         {
281             bool ret = Interop.Wheel.Wheel_IsAltModifier(swigCPtr);
282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283             return ret;
284         }
285
286         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Wheel obj)
287         {
288             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
289         }
290
291         internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
292         {
293             Wheel ret = new Wheel(cPtr, false);
294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295             return ret;
296         }
297
298         /// <summary>
299         /// Dispose.
300         /// </summary>
301         /// <param name="type">The type dispose, it could be from user, or called by DisposeQueue.</param>
302         /// <since_tizen> 3 </since_tizen>
303         protected override void Dispose(DisposeTypes type)
304         {
305             if (disposed)
306             {
307                 return;
308             }
309
310             //Release your own unmanaged resources here.
311             //You should not access any managed member here except static instance.
312             //because the execution order of Finalizes is non-deterministic.
313
314             if (swigCPtr.Handle != global::System.IntPtr.Zero)
315             {
316                 if (swigCMemOwn)
317                 {
318                     swigCMemOwn = false;
319                     Interop.Wheel.delete_Wheel(swigCPtr);
320                 }
321                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
322             }
323             base.Dispose(type);
324         }
325     }
326 }