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